[FFmpeg-devel] [PATCH 1/2] ffmpeg: don't reconfigure terminal if we're not taking input from stdin

Nicolas George george at nsup.org
Sat Sep 10 13:11:27 EEST 2016


Le quintidi 25 fructidor, an CCXXIV, Rodger Combs a écrit :
> ---
>  ffmpeg.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/ffmpeg.c b/ffmpeg.c
> index d858407..08a7a3d 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -366,7 +366,7 @@ static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
>  void term_init(void)
>  {
>  #if HAVE_TERMIOS_H
> -    if(!run_as_daemon){
> +    if (!run_as_daemon && stdin_interaction) {
>          struct termios tty;
>          if (tcgetattr (0, &tty) == 0) {
>              oldtty = tty;
> @@ -4328,13 +4328,13 @@ int main(int argc, char **argv)
>  
>      show_banner(argc, argv, options);
>  

> -    term_init();
> -
>      /* parse options and open all input/output files */
>      ret = ffmpeg_parse_options(argc, argv);
>      if (ret < 0)
>          exit_program(1);
>  
> +    term_init();
> +

I am really sorry: in my last mail, I made a mistake. For my excuses, the
function names are misleading: term_init() does not only init the term, it
also sets the signal handlers; and ffmpeg_parse_options() does not only
parse the options, it also open the files.

That means that, unlike what I wrote, moving term_init() below
ffmpeg_parse_options() will change the behaviour: opening the files will
happen without signal handlers.

Still, initing the term after really parsing the options instead of
out-of-order parsing is better. In particular, regular parsing will set
stdin_interaction to 0 when stdin is used as input, this would not be taken
into account with out-of-order parsing.

I think the best solution would be to split signal initing from term_init()
into a separate signals_init(): then keep the call to signals_init() at the
current place of term_init() and the actual call to term_init() where you
moved it.

>      if (nb_output_files <= 0 && nb_input_files == 0) {
>          show_usage();
>          av_log(NULL, AV_LOG_WARNING, "Use -h to get full help or, even better, run 'man %s'\n", program_name);

Sorry for the wasted time.

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/20160910/7eb3cf93/attachment.sig>


More information about the ffmpeg-devel mailing list