From 1335fb888f2f570c3830929197537265063e1e5a Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Mon, 22 May 2006 10:47:33 +0000 Subject: [PATCH] Fixed crash bug in DSound closing procedure git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@470 74dad513-b988-da41-8d7b-12977e46ad98 --- pjmedia/src/pjmedia/dsound.c | 48 +++++++++++++++++------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/pjmedia/src/pjmedia/dsound.c b/pjmedia/src/pjmedia/dsound.c index 36db101d9..9e1d7a554 100644 --- a/pjmedia/src/pjmedia/dsound.c +++ b/pjmedia/src/pjmedia/dsound.c @@ -882,6 +882,23 @@ PJ_DEF(pj_status_t) pjmedia_snd_stream_close(pjmedia_snd_stream *stream) pjmedia_snd_stream_stop(stream); + 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) { + IDirectSoundNotify_Release( stream->play_strm.lpDsNotify ); + stream->play_strm.lpDsNotify = NULL; + } + + if (stream->play_strm.hEvent) { + CloseHandle(stream->play_strm.hEvent); + stream->play_strm.hEvent = NULL; + } + if (stream->play_strm.ds.play.lpDsBuffer) { IDirectSoundBuffer_Release( stream->play_strm.ds.play.lpDsBuffer ); stream->play_strm.ds.play.lpDsBuffer = NULL; @@ -892,18 +909,16 @@ PJ_DEF(pj_status_t) pjmedia_snd_stream_close(pjmedia_snd_stream *stream) stream->play_strm.ds.play.lpDs = NULL; } - if (stream->play_strm.lpDsNotify) { - //No need? - //IDirectSoundNotify_Release( stream->play_strm.lpDsNotify ); - stream->play_strm.lpDsNotify = NULL; + if (stream->rec_strm.lpDsNotify) { + IDirectSoundNotify_Release( stream->rec_strm.lpDsNotify ); + stream->rec_strm.lpDsNotify = NULL; } - if (stream->play_strm.hEvent) { - CloseHandle(stream->play_strm.hEvent); - stream->play_strm.hEvent = NULL; + if (stream->rec_strm.hEvent) { + CloseHandle(stream->rec_strm.hEvent); + stream->rec_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; @@ -914,23 +929,6 @@ PJ_DEF(pj_status_t) pjmedia_snd_stream_close(pjmedia_snd_stream *stream) stream->rec_strm.ds.capture.lpDs = NULL; } - if (stream->rec_strm.lpDsNotify) { - //No need? - //IDirectSoundNotify_Release( stream->rec_strm.lpDsNotify ); - stream->rec_strm.lpDsNotify = NULL; - } - - if (stream->rec_strm.hEvent) { - CloseHandle(stream->rec_strm.hEvent); - 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; - } pj_pool_release(stream->pool);