Changeset 1149:cf7498bdfad5 in mediastreamer2
- Timestamp:
- Sep 13, 2010 11:26:33 PM (3 years ago)
- Branch:
- default
- File:
-
- 1 edited
-
src/msandroid.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/msandroid.cpp
r1120 r1149 29 29 static void sound_read_setup(MSFilter *f); 30 30 31 static void set_high_prio(void){ 32 struct sched_param param; 33 int result=0; 34 memset(¶m,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, ¶m))) { 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 } 31 43 /* 32 44 mediastreamer2 sound card functions … … 179 191 jmethodID record_id=0; 180 192 193 set_high_prio(); 181 194 182 195 jint result = d->jvm->AttachCurrentThread(&jni_env,NULL); … … 428 441 class msandroid_sound_write_data : public msandroid_sound_data{ 429 442 public: 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){ 431 444 bufferizer = ms_bufferizer_new(); 432 445 ms_cond_init(&cond,0); … … 445 458 int write_chunk_size; 446 459 unsigned int writtenBytes; 460 unsigned long last_sample_date; 461 bool sleeping; 447 462 unsigned int getWriteBuffSize() { 448 463 return buff_size; … … 460 475 461 476 jint result; 477 set_high_prio(); 462 478 int buff_size = d->getWriteBuffSize(); 463 479 result = d->jvm->AttachCurrentThread(&jni_env,NULL); … … 506 522 } 507 523 } 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 } 509 529 ms_mutex_unlock(&d->mutex); 510 530 } … … 665 685 ms_mutex_lock(&d->mutex); 666 686 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; 668 690 ms_mutex_unlock(&d->mutex); 669 691 }else freemsg(m); … … 703 725 ms_andsnd_jvm=jvm; 704 726 } 727 728 705 729
Note: See TracChangeset
for help on using the changeset viewer.
