From 552360cfe801ffecc71d2cc585b7d2026897510e Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Tue, 25 Mar 2008 17:05:59 +0000 Subject: Ticket #516: Assertion in sound device when headset is plugged/unplugged in MacOS X (thanks Alexei Kuznetsov) git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1893 74dad513-b988-da41-8d7b-12977e46ad98 --- pjmedia/src/pjmedia/pasound.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'pjmedia/src') diff --git a/pjmedia/src/pjmedia/pasound.c b/pjmedia/src/pjmedia/pasound.c index 78f4778c..e355749f 100644 --- a/pjmedia/src/pjmedia/pasound.c +++ b/pjmedia/src/pjmedia/pasound.c @@ -69,12 +69,12 @@ struct pjmedia_snd_stream pj_bool_t quit_flag; pj_bool_t rec_thread_exited; - pj_bool_t rec_thread_initialized; + //pj_bool_t rec_thread_initialized; pj_thread_desc rec_thread_desc; pj_thread_t *rec_thread; pj_bool_t play_thread_exited; - pj_bool_t play_thread_initialized; + //pj_bool_t play_thread_initialized; pj_thread_desc play_thread_desc; pj_thread_t *play_thread; }; @@ -101,10 +101,13 @@ static int PaRecorderCallback(const void *input, if (input == NULL) return paContinue; - if (stream->rec_thread_initialized == 0) { + // Sometime the thread, where this callback called from, is changed + // (e.g: in MacOS this happens when plugging/unplugging headphone) + // if (stream->rec_thread_initialized == 0) { + if (!pj_thread_is_registered()) { status = pj_thread_register("pa_rec", stream->rec_thread_desc, &stream->rec_thread); - stream->rec_thread_initialized = 1; + //stream->rec_thread_initialized = 1; PJ_LOG(5,(THIS_FILE, "Recorder thread started")); } @@ -151,10 +154,13 @@ static int PaPlayerCallback( const void *input, if (output == NULL) return paContinue; - if (stream->play_thread_initialized == 0) { + // Sometime the thread, where this callback called from, is changed + // (e.g: in MacOS this happens when plugging/unplugging headphone) + // if (stream->play_thread_initialized == 0) { + if (!pj_thread_is_registered()) { status = pj_thread_register("portaudio", stream->play_thread_desc, &stream->play_thread); - stream->play_thread_initialized = 1; + //stream->play_thread_initialized = 1; PJ_LOG(5,(THIS_FILE, "Player thread started")); } -- cgit v1.2.3