Fixed crash bug in DSound closing procedure

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@470 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
Benny Prijono 2006-05-22 10:47:33 +00:00
parent 6a61c22b35
commit 1335fb888f
1 changed files with 23 additions and 25 deletions

View File

@ -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);