diff options
author | Mohamed Naufal <naufal22@gmail.com> | 2011-10-07 17:21:09 +0530 |
---|---|---|
committer | Mohamed Naufal <naufal22@gmail.com> | 2011-10-07 18:32:36 +0530 |
commit | 295f13953dc57be8c2ad7e41f6254d0a036582a8 (patch) | |
tree | 243364bd250fbedea219175edd37ebab27d57bd9 | |
parent | 23ea48f2f7caebbaac19a6a4d8c931c06e9bd2df (diff) | |
download | ffmpeg-295f13953dc57be8c2ad7e41f6254d0a036582a8.tar.gz |
libstagefright: limit the output queue size
-rw-r--r-- | libavcodec/libstagefright.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/libavcodec/libstagefright.cpp b/libavcodec/libstagefright.cpp index 7f3b785211..1f8bdc4d59 100644 --- a/libavcodec/libstagefright.cpp +++ b/libavcodec/libstagefright.cpp @@ -174,7 +174,15 @@ void* decode_thread(void *arg) decode_done = 1; } } - pthread_mutex_lock(&s->out_mutex); + while (true) { + pthread_mutex_lock(&s->out_mutex); + if (s->out_queue->size() >= 10) { + pthread_mutex_unlock(&s->out_mutex); + usleep(10000); + continue; + } + break; + } s->out_queue->push_back(frame); pthread_mutex_unlock(&s->out_mutex); } while (!decode_done && !s->stop_decode); @@ -435,6 +443,17 @@ static av_cold int Stagefright_close(AVCodecContext *avctx) if (!s->thread_exited) { s->stop_decode = 1; + // Make sure decode_thread() doesn't get stuck + pthread_mutex_lock(&s->out_mutex); + while (!s->out_queue->empty()) { + frame = *s->out_queue->begin(); + s->out_queue->erase(s->out_queue->begin()); + if (frame->size) + frame->mbuffer->release(); + av_freep(&frame); + } + pthread_mutex_unlock(&s->out_mutex); + // Feed a dummy frame prior to signalling EOF. // This is required to terminate the decoder(OMX.SEC) // when only one frame is read during stream info detection. |