[FFmpeg-devel] Windows deprecated stdin reading method

Peter dravorek at googlemail.com
Sun Mar 8 00:22:37 CET 2015

>It checks if there is data in the buffer. The point is to do a non-blocking read on stdin.

I don't know how else to do that for stdin. Using WaitForSingleObject with
generic functions like read() from io.h or ReadFile doesn't work since
WaitForSingleObject will trigger on mouse and windows events, so calling those
functions can result in blocking (even if I wait for an actual keyboard event).

Or is that code specifically there to deal with everything that is not a
console and what I actually need to do there is somehow typecheck that
GetStdHandle did not return a console and only then call one of the generic
read functions? (and let the kbhit and getch that come afterwards handle the

2015-03-07 23:38 GMT+01:00 Reimar Döffinger <Reimar.Doeffinger at gmx.de>:
> On 07.03.2015, at 16:51, Peter <dravorek at googlemail.com> wrote:
>> The issue is this patch
>> https://github.com/FFmpeg/FFmpeg/commit/ca4d71b149ebe32aeaf617ffccf362624b9aafb1
>> which uses a member of the FILE struct which is not available in the
>> new C runtime (it's now just a struct with a void*).
>> I do not quite know the semantics of the stdin->_cnt > 0 check.
> It checks if there is data in the buffer. The point is to do a non-blocking read on stdin.
>> So I tried a few approaches, like using the deprecated function that is called
>> after the #ifdef block anyway:
>> https://github.com/Bigpet/FFmpeg/commit/b167e17e6f8839e1b4ce0edad2708ff4237e4aec
>> (I'm kind of worried about this since using "read(0, &ch, 1);" instead
>> of "getch" with that if
>> condition actually blocks in some cases, so it's not 100% equivalent)
>> Or trying to understand what the non-deprecated Win32 API calls would look like:
>> https://github.com/Bigpet/FFmpeg/commit/8d9cae13f389ab7dddc736ecac3feb01843ca094
> I don't think that's generic enough, you can't know what kind of thing stdin is, so using any non-generic function on it might break things...
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

More information about the ffmpeg-devel mailing list