[FFmpeg-devel] [PATCH] lavf: AVFMT_HAS_NONBLOCK flag for (de)muxers
Ivo
ivop
Thu Nov 26 21:56:08 CET 2009
On Thursday 26 November 2009, 21:10:35, Luca Abeni wrote:
> On Thu, 2009-11-26 at 18:08 +0100, Ivo wrote:
> > On Thursday 26 November 2009, 18:06:33, Ivo wrote:
> > > This patch...
>
> [...]
>
> > while((res = snd_pcm_writei(s->h, buf, size / s->frame_size)) < 0)
> > { - if (res == -EAGAIN) {
> > + if (res == -EAGAIN && s1->flags & AVFMT_FLAG_NONBLOCK) {
> >
> > return AVERROR(EAGAIN);
> > }
>
> Are you sure about this hunk? I would not expect alsa to return -EAGAIN
> if the non-blocking flag has not been set previously...
I checked the Alsa API docs and -EGAIN isn't a valid return value in any
case:
[snd_pcm_writei()] Returns: a positive number of frames actually written
otherwise a negative error code
[negative] Return values: -EBADFD, -EPIPE, -ESTRPIPE
So, basically, the code is incorrect. Hopefully, alsa supports a way to
check whether writing x frames will block, so we can return EAGAIN in that
case, otherwise I think a non-blocking alsa muxer is not possible. I'll
look into it.
> Also, I think you said that the OSS driver is not honouring the NONBLOCK
> flag... (or am I misremembering?). If this is the case, I suspect that
> simply adding AVFMT_HAS_NONBLOCK to the oss_demuxer flags is not enough.
> Or am I missing something?
I have checked the code and the OSS demuxer returns an empty packet
(pkt->size=0; pkt->pts=av_gettime();) if it's in non-blocking mode. In
blocking mode, it actually does the same if the select() times out.
The OSS muxer always blocks, hence I did not add the flag there.
Regards,
--Ivo
More information about the ffmpeg-devel
mailing list