From 2b4519e34d86182d5cd8048c3521b61bd1628543 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Thu, 3 Mar 2016 02:14:18 +0000 Subject: [PATCH] Fplay: fixed broken rewind in software decoder mode git-svn-id: svn://kolibrios.org@6301 a494cfbc-eb01-0410-851d-a64ba20cac60 --- contrib/media/fplay/audio.c | 9 +++------ contrib/media/fplay/fplay.c | 8 ++++---- contrib/media/fplay/fplay.h | 13 +++++++------ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/contrib/media/fplay/audio.c b/contrib/media/fplay/audio.c index 02ea46d6df..c098befbae 100644 --- a/contrib/media/fplay/audio.c +++ b/contrib/media/fplay/audio.c @@ -25,12 +25,11 @@ volatile enum player_state sound_state; static SNDBUF hBuff; -static int snd_format; int sample_rate; static uint32_t samples_written = 0; -int init_audio(int format) +int init_audio(vst_t* vst) { int err; int version =-1; @@ -49,9 +48,7 @@ int init_audio(int format) goto exit_whith_error; } - snd_format = format; - - create_thread(audio_thread, 0, 163840); + create_thread(audio_thread, vst, 32768); return 1; @@ -252,7 +249,7 @@ int audio_thread(void *param) char *errstr; int active; - if((err = CreateBuffer(snd_format|PCM_RING,0, &hBuff)) != 0) + if((err = CreateBuffer(vst->snd_format|PCM_RING,0, &hBuff)) != 0) { errstr = "Cannot create sound buffer\n\r"; goto exit_whith_error; diff --git a/contrib/media/fplay/fplay.c b/contrib/media/fplay/fplay.c index 4d0c256a62..3ee93e1c78 100644 --- a/contrib/media/fplay/fplay.c +++ b/contrib/media/fplay/fplay.c @@ -151,9 +151,9 @@ int main( int argc, char *argv[]) sample_rate = vst.aCtx->sample_rate; - fmt = test_wav(&whdr); + vst.snd_format = test_wav(&whdr); - if( init_audio(fmt) ) + if( init_audio(&vst) ) { decoder_buffer = (uint8_t*)av_mallocz(192000*2+64); if( decoder_buffer != NULL ) @@ -347,7 +347,7 @@ void decoder(vst_t* vst) rewind_pos, INT64_MAX, 0); decoder_state = STOP; - break; + continue; case REWIND: while(sound_state != STOP) @@ -376,7 +376,7 @@ void decoder(vst_t* vst) (double)rewind_pos / AV_TIME_BASE); } decoder_state = PREPARE; - break; + continue; } }; }; diff --git a/contrib/media/fplay/fplay.h b/contrib/media/fplay/fplay.h index 95c18e4a39..0c55d82873 100644 --- a/contrib/media/fplay/fplay.h +++ b/contrib/media/fplay/fplay.h @@ -152,12 +152,13 @@ struct vstate struct list_head output_list; struct decoder *decoder; + int snd_format; volatile int frames_count; - int has_sound:1; - int audio_timer_valid:1; - int blit_bitmap:1; /* hardware RGBA blitter */ - int blit_texture:1; /* hardware RGBA blit and scale */ - int blit_planar:1; /* hardbare YUV blit and scale */ + unsigned int has_sound:1; + unsigned int audio_timer_valid:1; + unsigned int blit_bitmap:1; /* hardware RGBA blitter */ + unsigned int blit_texture:1; /* hardware RGBA blit and scale */ + unsigned int blit_planar:1; /* hardbare YUV blit and scale */ }; @@ -177,7 +178,7 @@ void render_draw_client(render_t *render); int fplay_init_context(vst_t *vst); -int init_audio(int format); +int init_audio(vst_t* vst); int audio_thread(void *param); void set_audio_volume(int left, int right);