Mercurial > repos > blastem
diff mediaplayer.c @ 2305:6aca1734d573
Merge
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 15 Mar 2023 19:28:11 -0700 |
parents | 0343f0d5add0 |
children | 97f164d1f0f6 |
line wrap: on
line diff
--- a/mediaplayer.c Wed Mar 15 18:50:24 2023 -0700 +++ b/mediaplayer.c Wed Mar 15 19:28:11 2023 -0700 @@ -443,7 +443,16 @@ void flac_frame(media_player *player) { - render_sleep_ms(15); + for (uint32_t remaining_samples = player->flac->sample_rate / 60; remaining_samples > 0; remaining_samples--) + { + int16_t samples[2]; + if (flac_get_sample(player->flac, samples, 2)) { + render_put_stereo_sample(player->audio, samples[0], samples[1]); + } else { + player->state = STATE_PAUSED; + return; + } + } } void vgm_init(media_player *player, uint32_t opts) @@ -571,6 +580,14 @@ free(player->wave); } +static void flac_player_init(media_player *player) +{ + player->flac = flac_file_from_buffer(player->media->buffer, player->media->size); + if (player->flac) { + player->audio = render_audio_source("Audio File", player->flac->sample_rate, 1, 2); + } +} + static void resume_player(system_header *system) { media_player *player = (media_player *)system; @@ -594,10 +611,15 @@ } break; case STATE_PAUSED: +#ifndef IS_LIB render_sleep_ms(15); +#endif break; } + //TODO: Fix this for libretro build properly +#ifndef IS_LIB render_update_display(); +#endif } } @@ -689,6 +711,9 @@ case AUDIO_WAVE: wave_player_init(player); break; + case AUDIO_FLAC: + flac_player_init(player); + break; } return player;