diff options
author | Thomas Roos <thomas.roos@industronic.de> | 2015-12-11 13:23:13 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-12-11 13:42:04 +0300 |
commit | 4d72fd98842f519c2ec3c0352642b159ffc6ca57 (patch) | |
tree | 9ad4f5fbef1c4873376fa7d2eb2f1384212f6917 /sys/directsound/gstdirectsoundsink.c | |
parent | e731fe4af5e988be2f4ad9b1a8170a0c05525614 (diff) |
directsoundsink: Check the return value of GetStatus() too to decide if there was an error
If GetStatus() fails, the status itself won't be very meaningful but we also
have to look at its return value. This fixes blocking pipelines when removing
sound devices or during other errors, where we wouldn't notice the error and
then wait forever.
https://bugzilla.gnome.org/show_bug.cgi?id=734098
Diffstat (limited to 'sys/directsound/gstdirectsoundsink.c')
-rw-r--r-- | sys/directsound/gstdirectsoundsink.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/sys/directsound/gstdirectsoundsink.c b/sys/directsound/gstdirectsoundsink.c index 39cb0921f..5a4e35624 100644 --- a/sys/directsound/gstdirectsoundsink.c +++ b/sys/directsound/gstdirectsoundsink.c @@ -589,8 +589,8 @@ static gint gst_directsound_sink_write (GstAudioSink * asink, gpointer data, guint length) { GstDirectSoundSink *dsoundsink; - DWORD dwStatus; - HRESULT hRes; + DWORD dwStatus = 0; + HRESULT hRes, hRes2; LPVOID pLockedBuffer1 = NULL, pLockedBuffer2 = NULL; DWORD dwSizeBuffer1, dwSizeBuffer2; DWORD dwCurrentPlayCursor; @@ -603,10 +603,10 @@ gst_directsound_sink_write (GstAudioSink * asink, gpointer data, guint length) hRes = IDirectSoundBuffer_GetStatus (dsoundsink->pDSBSecondary, &dwStatus); /* get current play cursor position */ - hRes = IDirectSoundBuffer_GetCurrentPosition (dsoundsink->pDSBSecondary, + hRes2 = IDirectSoundBuffer_GetCurrentPosition (dsoundsink->pDSBSecondary, &dwCurrentPlayCursor, NULL); - if (SUCCEEDED (hRes) && (dwStatus & DSBSTATUS_PLAYING)) { + if (SUCCEEDED (hRes) && SUCCEEDED (hRes2) && (dwStatus & DSBSTATUS_PLAYING)) { DWORD dwFreeBufferSize; calculate_freesize: @@ -624,14 +624,19 @@ gst_directsound_sink_write (GstAudioSink * asink, gpointer data, guint length) hRes = IDirectSoundBuffer_GetCurrentPosition (dsoundsink->pDSBSecondary, &dwCurrentPlayCursor, NULL); - hRes = + hRes2 = IDirectSoundBuffer_GetStatus (dsoundsink->pDSBSecondary, &dwStatus); - if (SUCCEEDED (hRes) && (dwStatus & DSBSTATUS_PLAYING)) + if (SUCCEEDED (hRes) && SUCCEEDED (hRes2) + && (dwStatus & DSBSTATUS_PLAYING)) goto calculate_freesize; else { dsoundsink->first_buffer_after_reset = FALSE; GST_DSOUND_UNLOCK (dsoundsink); - return 0; + GST_ELEMENT_ERROR (dsoundsink, RESOURCE, OPEN_WRITE, + ("gst_directsound_sink_write: IDirectSoundBuffer_GetStatus %s, IDirectSoundBuffer_GetCurrentPosition: %s, dwStatus: %lu", + DXGetErrorString9 (hRes2), DXGetErrorString9 (hRes), dwStatus), + (NULL)); + return -1; } } } @@ -690,7 +695,7 @@ gst_directsound_sink_delay (GstAudioSink * asink) /* get current buffer status */ hRes = IDirectSoundBuffer_GetStatus (dsoundsink->pDSBSecondary, &dwStatus); - if (dwStatus & DSBSTATUS_PLAYING) { + if (SUCCEEDED (hRes) && (dwStatus & DSBSTATUS_PLAYING)) { /*evaluate the number of samples in queue in the circular buffer */ hRes = IDirectSoundBuffer_GetCurrentPosition (dsoundsink->pDSBSecondary, &dwCurrentPlayCursor, NULL); |