Changeset 766 for pjproject


Ignore:
Timestamp:
Oct 12, 2006 4:00:02 PM (18 years ago)
Author:
bennylp
Message:

Fixed bugs in pasound.c again, this time it is suspected that two input/output streams will be called by different threads, while pasound.c only expect it to be called by the same thread [thanks Norman Franke]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/pasound.c

    r762 r766  
    6464    pj_bool_t            quit_flag; 
    6565 
    66     pj_bool_t            thread_exited; 
    67     pj_bool_t            thread_initialized; 
    68     pj_thread_desc       thread_desc; 
    69     pj_thread_t         *thread; 
     66    pj_bool_t            rec_thread_exited; 
     67    pj_bool_t            rec_thread_initialized; 
     68    pj_thread_desc       rec_thread_desc; 
     69    pj_thread_t         *rec_thread; 
     70 
     71    pj_bool_t            play_thread_exited; 
     72    pj_bool_t            play_thread_initialized; 
     73    pj_thread_desc       play_thread_desc; 
     74    pj_thread_t         *play_thread; 
    7075}; 
    7176 
     
    9095        return paContinue; 
    9196 
    92     if (stream->thread_initialized == 0) { 
    93         status = pj_thread_register("pa_rec", stream->thread_desc,  
    94                                     &stream->thread); 
    95         stream->thread_initialized = 1; 
     97    if (stream->rec_thread_initialized == 0) { 
     98        status = pj_thread_register("pa_rec", stream->rec_thread_desc,  
     99                                    &stream->rec_thread); 
     100        stream->rec_thread_initialized = 1; 
    96101        PJ_LOG(5,(THIS_FILE, "Recorder thread started")); 
    97102    } 
     
    113118 
    114119on_break: 
    115     stream->thread_exited = 1; 
     120    stream->rec_thread_exited = 1; 
    116121    return paAbort; 
    117122} 
     
    138143        return paContinue; 
    139144 
    140     if (stream->thread_initialized == 0) { 
    141         status = pj_thread_register("portaudio", stream->thread_desc, 
    142                                     &stream->thread); 
    143         stream->thread_initialized = 1; 
     145    if (stream->play_thread_initialized == 0) { 
     146        status = pj_thread_register("portaudio", stream->play_thread_desc, 
     147                                    &stream->play_thread); 
     148        stream->play_thread_initialized = 1; 
    144149        PJ_LOG(5,(THIS_FILE, "Player thread started")); 
    145150    } 
     
    159164 
    160165on_break: 
    161     stream->thread_exited = 1; 
     166    stream->play_thread_exited = 1; 
    162167    return paAbort; 
    163168} 
     
    744749 
    745750    stream->quit_flag = 1; 
    746     for (i=0; !stream->thread_exited && i<100; ++i) 
     751    for (i=0; !stream->rec_thread_exited && i<100; ++i) 
     752        pj_thread_sleep(10); 
     753    for (i=0; !stream->play_thread_exited && i<100; ++i) 
    747754        pj_thread_sleep(10); 
    748755 
     
    770777 
    771778    stream->quit_flag = 1; 
    772     for (i=0; !stream->thread_exited && i<100; ++i) { 
     779    for (i=0; !stream->rec_thread_exited && i<100; ++i) { 
     780        pj_thread_sleep(1); 
     781    } 
     782    for (i=0; !stream->play_thread_exited && i<100; ++i) { 
    773783        pj_thread_sleep(1); 
    774784    } 
Note: See TracChangeset for help on using the changeset viewer.