[FFmpeg-devel] [PATCH v2 1/3] Refactor close_slaves function in tee muxer

Nicolas George george at nsup.org
Thu Mar 24 09:34:53 CET 2016


Le quintidi 5 germinal, an CCXXIV, Jan Sebechlebsky a écrit :
> Closing single slave operation is pulled out into separate
> function close_slave(TeeSlave*).
> Both close_slave and close_slaves function are moved before
> open_slave function.
> 
> Signed-off-by: Jan Sebechlebsky <sebechlebskyjan at gmail.com>
> ---
>  libavformat/tee.c | 59 +++++++++++++++++++++++++++++++------------------------
>  1 file changed, 33 insertions(+), 26 deletions(-)
> 
> diff --git a/libavformat/tee.c b/libavformat/tee.c
> index 1390705..09551b3 100644
> --- a/libavformat/tee.c
> +++ b/libavformat/tee.c
> @@ -135,6 +135,39 @@ end:
>      return ret;
>  }
>  

> +static void close_slave(TeeSlave* tee_slave)
> +{
> +    AVFormatContext * avf;

Please keep style consistent: spaces between type and pointer, not between
pointer and identifier.

(There is a good reason for that: compare the intuitive meaning of
"int* a, b;" and "int *a, b;".)

> +    unsigned i;
> +
> +    avf = tee_slave->avf;
> +    for (i=0; i < avf->nb_streams; ++i) {
> +        AVBitStreamFilterContext *bsf_next, *bsf = tee_slave->bsfs[i];
> +        while (bsf) {
> +            bsf_next = bsf->next;
> +            av_bitstream_filter_close(bsf);
> +            bsf = bsf_next;
> +        }
> +    }
> +    av_freep(&tee_slave->stream_map);
> +    av_freep(&tee_slave->bsfs);
> +
> +    ff_format_io_close(avf,&avf->pb);
> +    avformat_free_context(avf);
> +    tee_slave->avf = NULL;
> +}
> +
> +static void close_slaves(AVFormatContext *avf)
> +{
> +    TeeContext *tee = avf->priv_data;
> +    unsigned i;
> +
> +    for (i = 0; i < tee->nb_slaves; i++) {

> +        if (tee->slaves[i].is_alive)

The is_alive field does not exist for now, you add it in a following patch.
When reworking patches like that, you should run at least one build (and
preferably one full fate FATE) on the tree after each commit.

> +            close_slave(&tee->slaves[i]);
> +    }
> +}
> +
>  static int open_slave(AVFormatContext *avf, char *slave, TeeSlave *tee_slave)
>  {
>      int i, ret;
> @@ -311,32 +344,6 @@ end:
>      return ret;
>  }
>  
> -static void close_slaves(AVFormatContext *avf)
> -{
> -    TeeContext *tee = avf->priv_data;
> -    AVFormatContext *avf2;
> -    unsigned i, j;
> -
> -    for (i = 0; i < tee->nb_slaves; i++) {
> -        avf2 = tee->slaves[i].avf;
> -
> -        for (j = 0; j < avf2->nb_streams; j++) {
> -            AVBitStreamFilterContext *bsf_next, *bsf = tee->slaves[i].bsfs[j];
> -            while (bsf) {
> -                bsf_next = bsf->next;
> -                av_bitstream_filter_close(bsf);
> -                bsf = bsf_next;
> -            }
> -        }
> -        av_freep(&tee->slaves[i].stream_map);
> -        av_freep(&tee->slaves[i].bsfs);
> -
> -        ff_format_io_close(avf2, &avf2->pb);
> -        avformat_free_context(avf2);
> -        tee->slaves[i].avf = NULL;
> -    }
> -}
> -
>  static void log_slave(TeeSlave *slave, void *log_ctx, int log_level)
>  {
>      int i;

No principle objection from me.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160324/40250b9e/attachment.sig>


More information about the ffmpeg-devel mailing list