Showing the changes to player/player.cpp (1 of 6 files). Show all
Unified · Split
| @@ -10,6 +10,8 @@ · 9 unmodified lines | ||
| 10 | 10 | #include <OpenGL/gl3.h> |
| 11 | 11 | #endif |
| 12 | 12 | #include "FreeSans.h" |
| 13 | +#include "audio_sdl.h" | |
| 14 | +#include "decode.h" | |
| 13 | 15 | |
| 14 | 16 | #define STB_IMAGE_IMPLEMENTATION |
| 15 | 17 | #include "stb_image.h" |
| @@ -32,10 +34,11 @@ · 16 unmodified lines | ||
| 32 | 34 | #ifdef USE_GLES3 |
| 33 | 35 | static PFNGLGENERATEMIPMAPPROC glGenerateMipmap; |
| 34 | 36 | #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; | |
| 39 | 42 | |
| 40 | 43 | static int load_image(const stbi_uc *data, int len) |
| 41 | 44 | { |
| @@ -156,7 +159,7 @@ static void tick() · 114 unmodified lines | ||
| 156 | 159 | if (nk_button_label(ctx, "Play") && _selected < (int)_playlist.size()) |
| 157 | 160 | { |
| 158 | 161 | _play_state = 1; |
| 159 | − //play(); | |
| 162 | + preload_mp3(&_dec, _playlist[_selected].c_str()); | |
| 160 | 163 | } |
| 161 | 164 | } else |
| 162 | 165 | { |
| @@ -196,10 +199,15 @@ static void tick() · 33 unmodified lines | ||
| 196 | 199 | |
| 197 | 200 | int main(int argc, char *argv[]) |
| 198 | 201 | { |
| 202 | + InitializeCriticalSection(&_dec.mp3_lock); | |
| 203 | + sdl_audio_init(&_render, 44100, 2, 0, 0); | |
| 199 | 204 | init(); |
| 205 | + for (int i = 1; i < argc; i++) | |
| 206 | + _playlist.push_back(argv[i]); | |
| 200 | 207 | while (!glfwWindowShouldClose(_mainWindow)) |
| 201 | 208 | { |
| 202 | 209 | tick(); |
| 203 | 210 | } |
| 204 | 211 | close(); |
| 212 | + sdl_audio_release(_render); | |
| 205 | 213 | } |