From d0b129971a934bf499c478ea52fcd6051713ae19 Mon Sep 17 00:00:00 2001 From: "Diogo Franco (Kovensky)" Date: Fri, 19 Jul 2013 13:06:14 -0300 Subject: ao_wasapi0: Don't starve the WASAPI thread on seeks Seeking calls thread_reset, but doesn't call thread_play. thread_reset would disable WASAPI events, but they would never get re-enabled unless the user paused and then unpaused. Keep track of whether the stream is paused or not (there already was a field for that, but it was apparently unused), and if it's not paused, call thread_play after thread_reset. Fixes mpv freezing after seeks. --- audio/out/ao_wasapi0.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'audio') diff --git a/audio/out/ao_wasapi0.c b/audio/out/ao_wasapi0.c index 6a3bfc943c..11303ddde1 100644 --- a/audio/out/ao_wasapi0.c +++ b/audio/out/ao_wasapi0.c @@ -430,15 +430,10 @@ exit_label: static void thread_pause(wasapi0_state *state) { + state->is_playing = 0; IAudioClient_Stop(state->pAudioClient); } -static void thread_reset(wasapi0_state *state) -{ - IAudioClient_Stop(state->pAudioClient); - IAudioClient_Reset(state->pAudioClient); -} - /* force_feed - feed in even if available data is smaller than required buffer, to clear the buffer */ static void thread_feed(wasapi0_state *state,int force_feed) { @@ -477,10 +472,20 @@ exit_label: static void thread_play(wasapi0_state *state) { thread_feed(state, 0); + state->is_playing = 1; IAudioClient_Start(state->pAudioClient); return; } +static void thread_reset(wasapi0_state *state) +{ + IAudioClient_Stop(state->pAudioClient); + IAudioClient_Reset(state->pAudioClient); + if (state->is_playing) { + thread_play(state); + } +} + static void thread_getVol(wasapi0_state *state) { IAudioEndpointVolume_GetMasterVolumeLevelScalar(state->pEndpointVolume, -- cgit v1.2.3