diff options
author | deva <deva> | 2005-10-04 21:39:53 +0000 |
---|---|---|
committer | deva <deva> | 2005-10-04 21:39:53 +0000 |
commit | 111b16802de661228ef414eb6ec7484e2fa186ed (patch) | |
tree | d6d1ce9e8b857371414f33ff460266258c462275 /src/multiplexer.cc | |
parent | 9640339f2e9dc126406f6b6f8a091b924898b4f5 (diff) |
*** empty log message ***
Diffstat (limited to 'src/multiplexer.cc')
-rw-r--r-- | src/multiplexer.cc | 52 |
1 files changed, 12 insertions, 40 deletions
diff --git a/src/multiplexer.cc b/src/multiplexer.cc index d2aecfc..0b54bf8 100644 --- a/src/multiplexer.cc +++ b/src/multiplexer.cc @@ -68,37 +68,27 @@ static double picture_rate_index[16] = { RESERVED, RESERVED, RESERVED, RESERVED, RESERVED, RESERVED, RESERVED }; */ - Multiplexer::Multiplexer(File *f, Info *i, volatile bool *r, - FramePriorityQueue *v_q, pthread_mutex_t *v_m, sem_t *v_s, - FramePriorityQueue *a_q, pthread_mutex_t *a_m, sem_t *a_s) + ThreadSafeQueuePriority *video_q, + ThreadSafeQueuePriority *audio_q) { running = r; file = f; info = i; - queue[TYPE_VIDEO] = v_q; - queue[TYPE_AUDIO] = a_q; - - sem[TYPE_VIDEO] = v_s; - sem[TYPE_AUDIO] = a_s; - - mutex[TYPE_VIDEO] = v_m; - mutex[TYPE_AUDIO] = a_m; - frame[TYPE_VIDEO] = NULL; - frame[TYPE_AUDIO] = NULL; + written[TYPE_VIDEO] = 0.0; - frame_number[TYPE_VIDEO] = 0; - frame_number[TYPE_AUDIO] = 0; + frame[TYPE_AUDIO] = NULL; + written[TYPE_AUDIO] = 0.0; - write_system_header = 0; write_audio_packet = 0; + write_system_header = 0; audio_header_read = false; - written[TYPE_VIDEO] = 0.0; - written[TYPE_AUDIO] = 0.0; + queue[TYPE_VIDEO] = video_q; + queue[TYPE_AUDIO] = audio_q; SCR = 3904;//0x40010003LL;//0x1E80; @@ -111,29 +101,11 @@ Multiplexer::~Multiplexer() Frame *Multiplexer::getFrame(StreamType type) { - Frame *tmpframe; - Frame *frame = NULL; - - sem_wait(sem[type]); - - while( frame == NULL ) { - // Lock output mutex - pthread_mutex_lock( mutex[type] ); - tmpframe = queue[type]->top(); - - if(tmpframe && tmpframe->number == frame_number[type] ) { - queue[type]->pop(); - frame = tmpframe; - frame_number[type]++; - read[type] = 0; - } - - pthread_mutex_unlock( mutex[type] ); - // Unlock output mutex + info->info("Get %s Frame", type==TYPE_AUDIO?"Audio\0":"Video\0"); + + read[type] = 0; - sleep_0_2_frame(); - } - return frame; + return queue[type]->pop(); } int Multiplexer::read_stream(char *buf, unsigned int size, StreamType type) |