summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pjmedia/src/pjmedia/pasound.c18
1 files changed, 12 insertions, 6 deletions
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"));
}