Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linux-dvb] Re: Help on use of DMX_OUT_TAP (II)
I am not convinced that the poll method is better. When I switched from
GCC 2.95 to GCC 3.2 I found that dvbtune stopped being able to read PSI
tables. This code:
struct pollfd ufd;
** SNIP **
fd_pat = open(demuxdev[card],O_RDWR|O_NONBLOCK)
** SNIP **
ufd.fd=fd_pat;
ufd.events=POLLPRI;
if (poll(&ufd,1,2000) < 0) {
fprintf(stderr,"TIMEOUT reading from fd_pat\n");
close(fd_pat);
return;
}
if (read(fd_pat,buf,3)==3) {
** SNIP **
} else {
fprintf(stderr,"Nothing to read from fd_pat\n");
}
Always returns "Nothing to read from fd_pat" when compiled on my system
with GCC 3.2 but the binary compiled with GCC 2.95 works perfectly on
the same system. The error returned was always "Resource temporarily
unavailable". I found the following code, inspired by scan that came
with the DVB drivers, works with both versions of GCC, although I can
see it is less elegant.
time_t now = time(0);
n = -1;
while( n < 0 && time(0) < now + 10 ){
if (read(fd_pat,buf,3)==3) {
** SNIP **
close(fd_pat);
return;
}
}
close(fd_pat);
fprintf(stderr,"Nothing to read from fd_pat\n");
I have no real explanation why one should work and the other not.
-----Original Message-----
From: linux-dvb-bounce@linuxtv.org [mailto:linux-dvb-bounce@linuxtv.org]
On Behalf Of jng_junk@greenmail.demon.co.uk
Sent: 02 June 2003 18:58
To: linux-dvb@linuxtv.org
Subject: [linux-dvb] Re: Help on use of DMX_OUT_TAP (II)
On Mon, 2 Jun 2003, Johannes Stezenbach wrote:
> jng_junk@greenmail.demon.co.uk wrote:
> ...
> > if (type == DMX_PES_AUDIO) flags |= O_NONBLOCK;
> ...
> > while (1) {
> > int bytes;
> >
> > /* Video. */
> > bytes = read(video_fd, buf, sizeof(buf));
> > if (bytes < 0) {
> > fprintf(stderr, "Errno %d: ", errno);
> > perror("video_fd read");
> > } else {
> > fprintf(stderr, "Read %d bytes from video_fd.\n", bytes);
> > }
> >
> > /* Audio. */
> > bytes = read(audio_fd, buf, sizeof(buf));
> > if (bytes < 0) {
> > if (errno != EAGAIN) {
> > fprintf(stderr, "Errno %d: ", errno);
> > perror("audio_fd read");
> > }
> > } else {
> > fprintf(stderr, "Read %d bytes from audio_fd.\n", bytes);
> > }
> > }
>
> This can't work. You must use select() or poll() to wait for
> data to arrive, then read() from the file descriptor which is ready.
Thanks for the advice. I'll give this a try, but I'm not sure if it'll
make any difference. I made the audio stream non-blocking, and since it
is
a much lower data rate than the video stream, I think it should work.
But
I agree select() it a neater way of doing it.
I'll let you know,
James.
--
Info:
To unsubscribe send a mail to ecartis@linuxtv.org with "unsubscribe
linux-dvb" as subject.
--
Info:
To unsubscribe send a mail to ecartis@linuxtv.org with "unsubscribe linux-dvb" as subject.
Home |
Main Index |
Thread Index