Message ID | alpine.LNX.2.20.1706281459451.26976@scil.sinp.msu.ru |
---|---|
State | New |
Headers | show |
On Wed, Jun 28, 2017 at 03:02:42PM +0300, ffmpeg@a.legko.ru wrote: > > subject: when input sample stops, input thread stops too (withous > restart), thus, breaking the streaming and loop mode does not affect > this. touches only multistream (multiprog) mode, when threads are > used. > > ffmpeg.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > 0884edd00a6d3466d157519a0d48763545f44087 0001-add-support-for-samples-looping-threaded-mode-thread.patch > From d8310311a3c1a1828eacd4b45b31f9a723b5ee2b Mon Sep 17 00:00:00 2001 > From: root <ffmpeg@scil.sinp.msu.ru> Missing name (unless you do not want to have your name in the Author field) > Date: Wed, 28 Jun 2017 14:53:40 +0300 > Subject: [PATCH 1/3] add support for samples looping (threaded mode; thread > stops after decoding input) > > --- > ffmpeg.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/ffmpeg.c b/ffmpeg.c > index a783e6e..2866754 100644 > --- a/ffmpeg.c > +++ b/ffmpeg.c > @@ -4013,6 +4013,29 @@ static void free_input_threads(void) > } > } > > +static int init_input_thread(int i) > +{ > + int ret; > + > + if (nb_input_files == 1) > + return 0; > + > + InputFile *f = input_files[i]; mixing declaration and statment > + if (f->ctx->pb ? !f->ctx->pb->seekable : > + strcmp(f->ctx->iformat->name, "lavfi")) > + f->non_blocking = 1; > + ret = av_thread_message_queue_alloc(&f->in_thread_queue, > + f->thread_queue_size, sizeof(AVPacket)); > + if (ret < 0) > + return ret; > + if ((ret = pthread_create(&f->thread, NULL, input_thread, f))) { > + av_log(NULL, AV_LOG_ERROR, "pthread_create failed: %s. Try to increase `ulimit -v` or decrease `ulimit -s`.\n", strerror(ret)); > + av_thread_message_queue_free(&f->in_thread_queue); > + return AVERROR(ret); > + } > +return 0; the indention is inconsistent > +} > + > static int init_input_threads(void) > { > int i, ret; > @@ -4191,9 +4214,13 @@ static int process_input(int file_index) > ifile->eagain = 1; > return ret; > } > + > if (ret < 0 && ifile->loop) { > if ((ret = seek_to_start(ifile, is)) < 0) > return ret; > +#if HAVE_PTHREADS > + init_input_thread(file_index); The function returns an error code which is never used > +#endif > ret = get_input_packet(ifile, &pkt); > if (ret == AVERROR(EAGAIN)) { > ifile->eagain = 1; > -- > 2.7.4 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
On Wed, Jun 28, 2017 at 15:02:42 +0300, ffmpeg@a.legko.ru wrote: In addition to what Michael wrote: > + if (nb_input_files == 1) > + return 0; Indentation is not only inconsistent, but also wrong. Your first level is four spaces, your second level is seven, should be eight. Please get hold of an editor which assists you with this. > + if (f->ctx->pb ? !f->ctx->pb->seekable : > + strcmp(f->ctx->iformat->name, "lavfi")) I (personally) find reading a ternary operator expression inside an if() clause very confusing. > return ret; > } > + > if (ret < 0 && ifile->loop) { Please don't add arbitrary extra empty lines to the code. Moritz
diff --git a/ffmpeg.c b/ffmpeg.c index a783e6e..2866754 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -4013,6 +4013,29 @@ static void free_input_threads(void) } } +static int init_input_thread(int i) +{ + int ret; + + if (nb_input_files == 1) + return 0; + + InputFile *f = input_files[i]; + if (f->ctx->pb ? !f->ctx->pb->seekable : + strcmp(f->ctx->iformat->name, "lavfi")) + f->non_blocking = 1; + ret = av_thread_message_queue_alloc(&f->in_thread_queue, + f->thread_queue_size, sizeof(AVPacket)); + if (ret < 0) + return ret; + if ((ret = pthread_create(&f->thread, NULL, input_thread, f))) { + av_log(NULL, AV_LOG_ERROR, "pthread_create failed: %s. Try to increase `ulimit -v` or decrease `ulimit -s`.\n", strerror(ret)); + av_thread_message_queue_free(&f->in_thread_queue); + return AVERROR(ret); + } +return 0; +} + static int init_input_threads(void) { int i, ret; @@ -4191,9 +4214,13 @@ static int process_input(int file_index) ifile->eagain = 1; return ret; } + if (ret < 0 && ifile->loop) { if ((ret = seek_to_start(ifile, is)) < 0) return ret; +#if HAVE_PTHREADS + init_input_thread(file_index); +#endif ret = get_input_packet(ifile, &pkt); if (ret == AVERROR(EAGAIN)) { ifile->eagain = 1;
subject: when input sample stops, input thread stops too (withous restart), thus, breaking the streaming and loop mode does not affect this. touches only multistream (multiprog) mode, when threads are used. From d8310311a3c1a1828eacd4b45b31f9a723b5ee2b Mon Sep 17 00:00:00 2001 From: root <ffmpeg@scil.sinp.msu.ru> Date: Wed, 28 Jun 2017 14:53:40 +0300 Subject: [PATCH 1/3] add support for samples looping (threaded mode; thread stops after decoding input) --- ffmpeg.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) -- 2.7.4