Ticket #516: ticket516.patch

File ticket516.patch, 1.8 KB (added by nanang, 11 years ago)

Changed the way registering audio callback thread

  • pjmedia/src/pjmedia/pasound.c

     
    6969    pj_bool_t            quit_flag; 
    7070 
    7171    pj_bool_t            rec_thread_exited; 
    72     pj_bool_t            rec_thread_initialized; 
     72    //pj_bool_t          rec_thread_initialized; 
    7373    pj_thread_desc       rec_thread_desc; 
    7474    pj_thread_t         *rec_thread; 
    7575 
    7676    pj_bool_t            play_thread_exited; 
    77     pj_bool_t            play_thread_initialized; 
     77    //pj_bool_t          play_thread_initialized; 
    7878    pj_thread_desc       play_thread_desc; 
    7979    pj_thread_t         *play_thread; 
    8080}; 
     
    101101    if (input == NULL) 
    102102        return paContinue; 
    103103 
    104     if (stream->rec_thread_initialized == 0) { 
     104    // Sometime the thread, where this callback called from, is changed 
     105    // (e.g: in MacOS this happens when plugging/unplugging headphone) 
     106    // if (stream->rec_thread_initialized == 0) { 
     107    if (!pj_thread_is_registered()) { 
    105108        status = pj_thread_register("pa_rec", stream->rec_thread_desc,  
    106109                                    &stream->rec_thread); 
    107         stream->rec_thread_initialized = 1; 
     110        //stream->rec_thread_initialized = 1; 
    108111        PJ_LOG(5,(THIS_FILE, "Recorder thread started")); 
    109112    } 
    110113 
     
    151154    if (output == NULL) 
    152155        return paContinue; 
    153156 
    154     if (stream->play_thread_initialized == 0) { 
     157    // Sometime the thread, where this callback called from, is changed 
     158    // (e.g: in MacOS this happens when plugging/unplugging headphone) 
     159    // if (stream->play_thread_initialized == 0) { 
     160    if (!pj_thread_is_registered()) { 
    155161        status = pj_thread_register("portaudio", stream->play_thread_desc, 
    156162                                    &stream->play_thread); 
    157         stream->play_thread_initialized = 1; 
     163        //stream->play_thread_initialized = 1; 
    158164        PJ_LOG(5,(THIS_FILE, "Player thread started")); 
    159165    } 
    160166