Changeset 2426 for pjproject/trunk
- Timestamp:
- Jan 20, 2009 6:05:58 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/pasound.c
r2394 r2426 73 73 74 74 pj_bool_t rec_thread_exited; 75 //pj_bool_t rec_thread_initialized;75 pj_bool_t rec_thread_initialized; 76 76 pj_thread_desc rec_thread_desc; 77 77 pj_thread_t *rec_thread; 78 78 79 79 pj_bool_t play_thread_exited; 80 //pj_bool_t play_thread_initialized;80 pj_bool_t play_thread_initialized; 81 81 pj_thread_desc play_thread_desc; 82 82 pj_thread_t *play_thread; … … 119 119 return paContinue; 120 120 121 // Sometime the thread, where this callback called from, is changed 122 // (e.g: in MacOS this happens when plugging/unplugging headphone) 123 // if (stream->rec_thread_initialized == 0) { 124 if (!pj_thread_is_registered()) { 121 /* Known cases of callback's thread: 122 * - The thread may be changed in the middle of a session, e.g: in MacOS 123 * it happens when plugging/unplugging headphone. 124 * - The same thread may be reused in consecutive sessions. The first 125 * session will leave TLS set, but release the TLS data address, 126 * so the second session must re-register the callback's thread. 127 */ 128 if (stream->rec_thread_initialized == 0 || !pj_thread_is_registered()) 129 { 125 130 status = pj_thread_register("pa_rec", stream->rec_thread_desc, 126 131 &stream->rec_thread); 127 //stream->rec_thread_initialized = 1;132 stream->rec_thread_initialized = 1; 128 133 PJ_LOG(5,(THIS_FILE, "Recorder thread started")); 129 134 } … … 215 220 return paContinue; 216 221 217 // Sometime the thread, where this callback called from, is changed 218 // (e.g: in MacOS this happens when plugging/unplugging headphone) 219 // if (stream->play_thread_initialized == 0) { 220 if (!pj_thread_is_registered()) { 222 /* Known cases of callback's thread: 223 * - The thread may be changed in the middle of a session, e.g: in MacOS 224 * it happens when plugging/unplugging headphone. 225 * - The same thread may be reused in consecutive sessions. The first 226 * session will leave TLS set, but release the TLS data address, 227 * so the second session must re-register the callback's thread. 228 */ 229 if (stream->play_thread_initialized == 0 || !pj_thread_is_registered()) 230 { 221 231 status = pj_thread_register("portaudio", stream->play_thread_desc, 222 232 &stream->play_thread); 223 //stream->play_thread_initialized = 1;233 stream->play_thread_initialized = 1; 224 234 PJ_LOG(5,(THIS_FILE, "Player thread started")); 225 235 } … … 954 964 err = Pa_StopStream(stream->rec_strm); 955 965 966 stream->play_thread_initialized = 0; 967 stream->rec_thread_initialized = 0; 968 956 969 PJ_LOG(5,(THIS_FILE, "Done, status=%d", err)); 957 970
Note: See TracChangeset
for help on using the changeset viewer.