c - Failing to read frames from stream after interrupt -


i'm using ffmpeg read , decode network video stream. have read/decode stuff happening on dedicated thread. occasionally, join on thread. this, i've tried specifying interrupt callback , flags indicate reads should non-blocking. have of basics working, i'm running issue av_read_frame after interrupt. here's basic structure:

void read() {     avpacket pkt;      while (shouldread)     {         if (av_read_frame(formatctx, &pkt)         {             // succesfully read frame         }         else         {             // failed read frame         }     } }  int interrupt_cb(void* param) {     return shouldinterrupt; }  void initialize()  {     formatctx = avformat_alloc_context();     formatctx->flags |= avfmt_flag_nonblock;     formatctx->flags |= avio_flag_nonblock;     formatctx->interrupt_callback.callback = interrupt_cb;      // ...other initialization stuff (e.g. avformat_open_input, etc.) } 

after initialization, looks fine - happily chug along reading frames. however, if ever try interrupt setting shouldinterrupt true, subsequent av_read_frame calls fail. also, interrupt callback never gets called again. digging code bit, see formatctx->packet_buffer empty. given that, makes sense reads fail. how resume reading after interrupt then? i'd rather not have tear down resume reading , decoding.

update: discovered there's avio_flag_nonblock flag well. tried didn't seem help.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -