[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-video
Subject:    Re: [video4linux] using select()
From:       Bill Dirks <dirks () rendition ! com>
Date:       1998-07-28 18:29:26
[Download RAW message or body]

Alan Cox wrote:
> > Yes. Read() should not block, so the data should already be ready for
> > copy to the user buffer passed to read(). In my experience, a DMA card
> > will DMA to a temp buffer and copy to the user buffer (you can't DMA to
> > a user buffer anyway). And a non-DMA card will capture to on-board
> > memory, and copy straight from there to the user buffer in read().
> 
> read() needs to block if you dont have O_NDELAY set. But it will block
> until the frame arrives so thats no different.

What I was saying was that if select() returns, then a (blocking) call
to read() will not actually block that time because it doesn't need to
because it is known that data is ready. The purpose of select() is to
avoid blocking on the read(), and it accomplishes that.

I see what you're saying, though. If select returns and the app waits "a
long time" before calling read(), read() may be designed not to give the
app such an old frame, and so block waiting for a fresh one. Yes, I
agree.

> > while doing read() or stream captures, it could screw up select().
> 
> select() tells you where there is data ready. It doesnt guarantee the
> data didnt vanish before you got to it. Not a problem

Even better: Since data written to the screen is not captured by the
app, select() doesn't apply. Select() tells the app data is ready for it
to read. There are two ways the app reads data, read() and from the
streaming buffers. That means, if streaming is active, select() returns
when there are a non-zero number of filled streaming buffers, and when
streaming is not active, it returns when data is ready to be read().

Bill.
------------
To unsubscribe from this list send mail to majordomo@phunk.org with the
line "unsubscribe video4linux" without the quotes in the body of the
message.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic