[FFmpeg-devel] [PATCH] Add option to disable termios.h usage
Måns Rullgård
mans
Thu Mar 10 16:59:47 CET 2011
Takis Issaris <t4k1s at yahoo.com> writes:
> Hi M?ns,
>
> ----- Original Message ----
>> From: M?ns Rullg?rd <mans at mansr.com>
>> Sent: Mon, March 7, 2011 1:15:18 PM
>> > The attached patch adds an ffmpeg commandline option to allow one to disable
>>
>> > ffmpeg using tcgetattr and tcsetattr to modify terminal parameters.
>> >...
>> > In the end, the attributes do not get restored correctly, forcing me to use
>
>> > "reset" or "stty sane".
>>
>> I find the messing with terminal settings highly annoying in general. I
>> suggest we remove it entirely and use only ctrl-c to interrupt, at least
>> on systems where signals work properly.
>
> Something similar to the attached patch?
>
> Met vriendelijke groeten,
> Takis
>
>
> From fb6503b350a5422ed4b0a73eba89222df3d28129 Mon Sep 17 00:00:00 2001
> From: Panagiotis H.M. Issaris <takis at issaris.org>
> Date: Thu, 10 Mar 2011 16:07:52 +0100
> Subject: [PATCH] Do no modify terminal parameters using termios.h.
>
> Get rid of ffmpeg's usage of tcgetattr and tcsetattr to modify terminal
> parameters. Rely on ctrl-c to stop ffmpeg instead of pressing 'q'. On systems
> having conio.h, keep the old behavior.
>
> The issue is the following:
> 1. Start one instance of ffmpeg (process A).
> 2. Process A stores the current attributes, which it would restore at the end of
> its execution.
> 3. Process A modifies the terminals parameters.
> 4. Start a second instance of ffmpeg (process B) on the same terminal, which
> also stores the already modified attributes, which it would also restore at the
> end of its execution.
> 5. Process A ends first and correctly restores the correct terminals attributes.
> 6. Process B ends and restores the terminals attributes which had already been
> modified by process A.
>
> In the end, the attributes do not get restored correctly, forcing one to use
> "reset" or "stty sane".
There's another simpler scenario that's equally annoying too:
1. Start ffmpeg.
2. ffmpeg crashes.
3. Terminal is messed up.
> @@ -2490,7 +2438,11 @@ static int transcode(AVFormatContext **output_files,
> }
>
> if (!using_stdin && verbose >= 0) {
> +#if HAVE_CONIO_H
> fprintf(stderr, "Press [q] to stop encoding\n");
> +#else
> + fprintf(stderr, "Press ctrl-c to stop encoding\n");
> +#endif
> url_set_interrupt_cb(decode_interrupt_cb);
> }
I'm always a bit averse to ifdefs but I suppose it has to go somewhere.
Patch looks good.
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list