From da5c5e15a3b22dd387afb8945a208336f9342a3e Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Mon, 22 May 2006 10:47:33 +0000 Subject: Fixed crash bug in DSound closing procedure git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@470 74dad513-b988-da41-8d7b-12977e46ad98 --- pjmedia/src/pjmedia/dsound.c | 46 +++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/pjmedia/src/pjmedia/dsound.c b/pjmedia/src/pjmedia/dsound.c index 36db101d..9e1d7a55 100644 --- a/pjmedia/src/pjmedia/dsound.c +++ b/pjmedia/src/pjmedia/dsound.c @@ -882,19 +882,15 @@ PJ_DEF(pj_status_t) pjmedia_snd_stream_close(pjmedia_snd_stream *stream) pjmedia_snd_stream_stop(stream); - if (stream->play_strm.ds.play.lpDsBuffer) { - IDirectSoundBuffer_Release( stream->play_strm.ds.play.lpDsBuffer ); - stream->play_strm.ds.play.lpDsBuffer = NULL; - } - - if (stream->play_strm.ds.play.lpDs) { - IDirectSound_Release( stream->play_strm.ds.play.lpDs ); - stream->play_strm.ds.play.lpDs = NULL; + if (stream->thread) { + stream->thread_quit_flag = 1; + pj_thread_join(stream->thread); + pj_thread_destroy(stream->thread); + stream->thread = NULL; } if (stream->play_strm.lpDsNotify) { - //No need? - //IDirectSoundNotify_Release( stream->play_strm.lpDsNotify ); + IDirectSoundNotify_Release( stream->play_strm.lpDsNotify ); stream->play_strm.lpDsNotify = NULL; } @@ -903,20 +899,18 @@ PJ_DEF(pj_status_t) pjmedia_snd_stream_close(pjmedia_snd_stream *stream) stream->play_strm.hEvent = NULL; } - - if (stream->rec_strm.ds.capture.lpDsBuffer) { - IDirectSoundCaptureBuffer_Release( stream->rec_strm.ds.capture.lpDsBuffer ); - stream->rec_strm.ds.capture.lpDsBuffer = NULL; + if (stream->play_strm.ds.play.lpDsBuffer) { + IDirectSoundBuffer_Release( stream->play_strm.ds.play.lpDsBuffer ); + stream->play_strm.ds.play.lpDsBuffer = NULL; } - if (stream->rec_strm.ds.capture.lpDs) { - IDirectSoundCapture_Release( stream->rec_strm.ds.capture.lpDs ); - stream->rec_strm.ds.capture.lpDs = NULL; + if (stream->play_strm.ds.play.lpDs) { + IDirectSound_Release( stream->play_strm.ds.play.lpDs ); + stream->play_strm.ds.play.lpDs = NULL; } if (stream->rec_strm.lpDsNotify) { - //No need? - //IDirectSoundNotify_Release( stream->rec_strm.lpDsNotify ); + IDirectSoundNotify_Release( stream->rec_strm.lpDsNotify ); stream->rec_strm.lpDsNotify = NULL; } @@ -925,13 +919,17 @@ PJ_DEF(pj_status_t) pjmedia_snd_stream_close(pjmedia_snd_stream *stream) stream->rec_strm.hEvent = NULL; } - if (stream->thread) { - stream->thread_quit_flag = 1; - pj_thread_join(stream->thread); - pj_thread_destroy(stream->thread); - stream->thread = NULL; + if (stream->rec_strm.ds.capture.lpDsBuffer) { + IDirectSoundCaptureBuffer_Release( stream->rec_strm.ds.capture.lpDsBuffer ); + stream->rec_strm.ds.capture.lpDsBuffer = NULL; + } + + if (stream->rec_strm.ds.capture.lpDs) { + IDirectSoundCapture_Release( stream->rec_strm.ds.capture.lpDs ); + stream->rec_strm.ds.capture.lpDs = NULL; } + pj_pool_release(stream->pool); return PJ_SUCCESS; -- cgit v1.2.3