diff options
author | Tuomas Virtanen <katajakasa@gmail.com> | 2018-06-28 01:21:02 +0300 |
---|---|---|
committer | Tuomas Virtanen <katajakasa@gmail.com> | 2018-06-28 01:21:02 +0300 |
commit | 233661a4f70a39f4f237e4faea2ab76b87bad817 (patch) | |
tree | b1199f607c7a93b176a7e42f364251907dbed5eb /examples | |
parent | 7c30236604aaf7337db00a973e3568880bef8a1b (diff) |
More cleanup and documentation
Diffstat (limited to 'examples')
-rw-r--r-- | examples/example_complex.c | 14 | ||||
-rw-r--r-- | examples/example_custom.c | 8 | ||||
-rw-r--r-- | examples/example_simple.c | 8 |
3 files changed, 19 insertions, 11 deletions
diff --git a/examples/example_complex.c b/examples/example_complex.c index ac136ac..ada613a 100644 --- a/examples/example_complex.c +++ b/examples/example_complex.c @@ -72,7 +72,6 @@ int main(int argc, char *argv[]) { // Audio playback SDL_AudioSpec wanted_spec, audio_spec; SDL_AudioDeviceID audio_dev; - char audiobuf[AUDIOBUFFER_SIZE]; // Get filename to open if(argc != 2) { @@ -228,18 +227,25 @@ int main(int argc, char *argv[]) { // Start playback Kit_PlayerPlay(player); - // Get movie area size + // Playback temporary data buffers + char audiobuf[AUDIOBUFFER_SIZE]; + SDL_Rect sources[ATLAS_MAX]; + SDL_Rect targets[ATLAS_MAX]; int mouse_x = 0; int mouse_y = 0; int size_w = 0; int size_h = 0; int screen_w = 0; int screen_h = 0; + bool fullscreen = false; + + // Get movie area size SDL_GetWindowSize(window, &screen_w, &screen_h); find_viewport_size(screen_w, screen_h, pinfo.video.output.width, pinfo.video.output.height, &size_w, &size_h); SDL_RenderSetLogicalSize(renderer, size_w, size_h); Kit_SetPlayerScreenSize(player, size_w, size_h); - bool fullscreen = false; + + // Run until playback is stopped while(run) { if(Kit_GetPlayerState(player) == KIT_STOPPED) { run = false; @@ -344,8 +350,6 @@ int main(int argc, char *argv[]) { // Refresh subtitle texture atlas and render subtitle frames from it // For subtitles, use screen size instead of video size for best quality - SDL_Rect sources[ATLAS_MAX]; - SDL_Rect targets[ATLAS_MAX]; int got = Kit_GetPlayerSubtitleData(player, subtitle_tex, sources, targets, ATLAS_MAX); for(int i = 0; i < got; i++) { SDL_RenderCopy(renderer, subtitle_tex, &sources[i], &targets[i]); diff --git a/examples/example_custom.c b/examples/example_custom.c index 507efb1..1d33b0e 100644 --- a/examples/example_custom.c +++ b/examples/example_custom.c @@ -40,7 +40,6 @@ int main(int argc, char *argv[]) { Kit_Player *player = NULL; SDL_AudioSpec wanted_spec, audio_spec; SDL_AudioDeviceID audio_dev; - char audiobuf[AUDIOBUFFER_SIZE]; // Get filename to open if(argc != 2) { @@ -153,6 +152,11 @@ int main(int argc, char *argv[]) { // Start playback Kit_PlayerPlay(player); + // Playback temporary data buffers + char audiobuf[AUDIOBUFFER_SIZE]; + SDL_Rect sources[ATLAS_MAX]; + SDL_Rect targets[ATLAS_MAX]; + // Get movie area size SDL_RenderSetLogicalSize(renderer, pinfo.video.output.width, pinfo.video.output.height); while(run) { @@ -203,8 +207,6 @@ int main(int argc, char *argv[]) { // Refresh subtitle texture atlas and render subtitle frames from it // For subtitles, use screen size instead of video size for best quality - SDL_Rect sources[ATLAS_MAX]; - SDL_Rect targets[ATLAS_MAX]; int got = Kit_GetPlayerSubtitleData(player, subtitle_tex, sources, targets, ATLAS_MAX); for(int i = 0; i < got; i++) { SDL_RenderCopy(renderer, subtitle_tex, &sources[i], &targets[i]); diff --git a/examples/example_simple.c b/examples/example_simple.c index d3b7146..2569fab 100644 --- a/examples/example_simple.c +++ b/examples/example_simple.c @@ -23,7 +23,6 @@ int main(int argc, char *argv[]) { Kit_Player *player = NULL; SDL_AudioSpec wanted_spec, audio_spec; SDL_AudioDeviceID audio_dev; - char audiobuf[AUDIOBUFFER_SIZE]; // Get filename to open if(argc != 2) { @@ -130,6 +129,11 @@ int main(int argc, char *argv[]) { // Start playback Kit_PlayerPlay(player); + // Playback temporary data buffers + char audiobuf[AUDIOBUFFER_SIZE]; + SDL_Rect sources[ATLAS_MAX]; + SDL_Rect targets[ATLAS_MAX]; + // Get movie area size SDL_RenderSetLogicalSize(renderer, pinfo.video.output.width, pinfo.video.output.height); while(run) { @@ -180,8 +184,6 @@ int main(int argc, char *argv[]) { // Refresh subtitle texture atlas and render subtitle frames from it // For subtitles, use screen size instead of video size for best quality - SDL_Rect sources[ATLAS_MAX]; - SDL_Rect targets[ATLAS_MAX]; int got = Kit_GetPlayerSubtitleData(player, subtitle_tex, sources, targets, ATLAS_MAX); for(int i = 0; i < got; i++) { SDL_RenderCopy(renderer, subtitle_tex, &sources[i], &targets[i]); |