Changeset 1149:cf7498bdfad5 in mediastreamer2


Ignore:
Timestamp:
Sep 13, 2010 11:26:33 PM (3 years ago)
Author:
Jehan Monnier <jehan.monnier@…>
Branch:
default
Message:

reduce amount of pthread signal (just in case)
set player/recorder threads to high prio

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/msandroid.cpp

    r1120 r1149  
    2929static void sound_read_setup(MSFilter *f); 
    3030 
     31static void set_high_prio(void){ 
     32        struct sched_param param; 
     33        int result=0; 
     34        memset(&param,0,sizeof(param)); 
     35        int policy=SCHED_OTHER; 
     36        param.sched_priority=sched_get_priority_max(policy); 
     37        if((result=pthread_setschedparam(pthread_self(),policy, &param))) { 
     38                ms_warning("Set sched param failed with error code(%i)\n",result); 
     39        } else { 
     40                ms_message("msandroid thread priority set to max"); 
     41        } 
     42} 
    3143/* 
    3244 mediastreamer2 sound card functions 
     
    179191        jmethodID record_id=0; 
    180192 
     193        set_high_prio(); 
    181194 
    182195        jint result = d->jvm->AttachCurrentThread(&jni_env,NULL); 
     
    428441class msandroid_sound_write_data : public msandroid_sound_data{ 
    429442public: 
    430         msandroid_sound_write_data() :audio_track_class(0),audio_track(0),write_chunk_size(0),writtenBytes(0){ 
     443        msandroid_sound_write_data() :audio_track_class(0),audio_track(0),write_chunk_size(0),writtenBytes(0),last_sample_date(0){ 
    431444                bufferizer = ms_bufferizer_new(); 
    432445                ms_cond_init(&cond,0); 
     
    445458        int                     write_chunk_size; 
    446459        unsigned int    writtenBytes; 
     460        unsigned long   last_sample_date; 
     461        bool sleeping; 
    447462        unsigned int getWriteBuffSize() { 
    448463                return buff_size; 
     
    460475 
    461476        jint result; 
     477        set_high_prio(); 
    462478        int buff_size = d->getWriteBuffSize(); 
    463479        result = d->jvm->AttachCurrentThread(&jni_env,NULL); 
     
    506522                        } 
    507523                } 
    508                 if (d->started) ms_cond_wait(&d->cond,&d->mutex); 
     524                if (d->started) { 
     525                        d->sleeping=true; 
     526                        ms_cond_wait(&d->cond,&d->mutex); 
     527                        d->sleeping=false; 
     528                } 
    509529                ms_mutex_unlock(&d->mutex); 
    510530        } 
     
    665685                        ms_mutex_lock(&d->mutex); 
    666686                        ms_bufferizer_put(d->bufferizer,m); 
    667                         ms_cond_signal(&d->cond); 
     687                        if (d->sleeping) 
     688                                ms_cond_signal(&d->cond); 
     689                        d->last_sample_date=f->ticker->time; 
    668690                        ms_mutex_unlock(&d->mutex); 
    669691                }else freemsg(m); 
     
    703725        ms_andsnd_jvm=jvm; 
    704726} 
     727 
     728 
    705729         
Note: See TracChangeset for help on using the changeset viewer.