[vlc-commits] directsound: fix drain
Thomas Guillem
git at videolan.org
Tue Mar 12 15:32:42 CET 2019
vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Mar 11 16:02:53 2019 +0100| [9ee7cfa08097bab36b53491ef424d6f2ff1f9210] | committer: Thomas Guillem
directsound: fix drain
Use the same drain emulation than mmdevice.h
This fixes draining with directsound output + directsound stream (Windows XP +
Vista).
(cherry picked from commit 25ba4f58177382f90f31ad64eb8b584c895d5a92)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=9ee7cfa08097bab36b53491ef424d6f2ff1f9210
---
modules/audio_output/directsound.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/modules/audio_output/directsound.c b/modules/audio_output/directsound.c
index 534c9952e2..4aa9d28d53 100644
--- a/modules/audio_output/directsound.c
+++ b/modules/audio_output/directsound.c
@@ -140,7 +140,7 @@ struct aout_sys_t
} volume;
};
-static HRESULT Flush( aout_stream_sys_t *sys, bool drain);
+static HRESULT Flush( aout_stream_sys_t *sys );
static HRESULT TimeGet( aout_stream_sys_t *sys, mtime_t *delay )
{
DWORD read, status;
@@ -171,7 +171,7 @@ static HRESULT TimeGet( aout_stream_sys_t *sys, mtime_t *delay )
if( sys->i_data < 0 )
/* underrun */
- Flush(sys, false);
+ Flush(sys);
*delay = ( sys->i_data / sys->i_bytes_per_sample ) * CLOCK_FREQ / sys->i_rate;
@@ -339,10 +339,10 @@ static void OutputPause( audio_output_t *aout, bool pause, mtime_t date )
(void) date;
}
-static HRESULT Flush( aout_stream_sys_t *sys, bool drain)
+static HRESULT Flush( aout_stream_sys_t *sys )
{
HRESULT ret = IDirectSoundBuffer_Stop( sys->p_dsbuffer );
- if( ret == DS_OK && !drain )
+ if( ret == DS_OK )
{
vlc_mutex_lock(&sys->lock);
sys->i_data = 0;
@@ -356,13 +356,21 @@ static HRESULT Flush( aout_stream_sys_t *sys, bool drain)
static HRESULT StreamFlush( aout_stream_t *s )
{
- return Flush( s->sys, false );
+ return Flush( s->sys );
}
static void OutputFlush( audio_output_t *aout, bool drain )
{
- aout_stream_sys_t *sys = &aout->sys->s;
- Flush( sys, drain );
+ aout_sys_t *sys = aout->sys;
+ if (drain)
+ { /* Loosy drain emulation */
+ mtime_t delay;
+
+ if (OutputTimeGet(aout, &delay) == 0 && delay <= INT64_C(5000000))
+ Sleep((delay / (CLOCK_FREQ / 1000)) + 1);
+ }
+ else
+ Flush( &sys->s );
}
/**
More information about the vlc-commits
mailing list