History

player: add audio render

lieff committed 8 years ago

Commit 53cb2a11 parent 29f6dca6 files · +133 −8Browse files

Showing the changes to player/player.cpp (1 of 6 files). Show all

Unified · Split

player/player.cpp+13−5
@@ -10,6 +10,8 @@ · 9 unmodified lines
1010 #include <OpenGL/gl3.h>
1111 #endif
1212 #include "FreeSans.h"
13+#include "audio_sdl.h"
14+#include "decode.h"
1315
1416 #define STB_IMAGE_IMPLEMENTATION
1517 #include "stb_image.h"
@@ -32,10 +34,11 @@ · 16 unmodified lines
3234 #ifdef USE_GLES3
3335 static PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
3436 #endif
35−void *_ctx;
36−GLFWwindow *_mainWindow;
37−std::map<std::string, int> _previews;
38−std::vector<std::string> _playlist;
37+static void *_ctx;
38+static GLFWwindow *_mainWindow;
39+static std::map<std::string, int> _previews;
40+static std::vector<std::string> _playlist;
41+static void *_render;
3942
4043 static int load_image(const stbi_uc *data, int len)
4144 {
@@ -156,7 +159,7 @@ static void tick() · 114 unmodified lines
156159 if (nk_button_label(ctx, "Play") && _selected < (int)_playlist.size())
157160 {
158161 _play_state = 1;
159− //play();
162+ preload_mp3(&_dec, _playlist[_selected].c_str());
160163 }
161164 } else
162165 {
@@ -196,10 +199,15 @@ static void tick() · 33 unmodified lines
196199
197200 int main(int argc, char *argv[])
198201 {
202+ InitializeCriticalSection(&_dec.mp3_lock);
203+ sdl_audio_init(&_render, 44100, 2, 0, 0);
199204 init();
205+ for (int i = 1; i < argc; i++)
206+ _playlist.push_back(argv[i]);
200207 while (!glfwWindowShouldClose(_mainWindow))
201208 {
202209 tick();
203210 }
204211 close();
212+ sdl_audio_release(_render);
205213 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t