[vlc-devel] Re: vlc & hauppauge pvr350
Daniel Lawson
daniel at wand.net.nz
Mon Aug 23 23:40:07 CEST 2004
Gildas Bazin wrote:
>
>The actual code in the plugin is this one:
>
> while( !( i_ret = select( p_sys->i_fd + 1, &fds,
> NULL, NULL, &timeout) ) )
>
>
My bad here. Shouldn't post to mailing lists at midnight. Probably
shouldn't attempt to debug someone elses code at midnight either
> {
> FD_ZERO( &fds );
> FD_SET( p_sys->i_fd, &fds );
> timeout.tv_sec = 0;
> timeout.tv_usec = 500000;
>
> if( p_input->b_die || p_input->b_error )
> return 0;
> }
>
>And this will spin on the select until it returns something different from
>0! In other words, until it reads some data (or an error happens).
>
>I don't see anything wrong with that.
>
>If you have problems with the PVR input, you should first give a go to the
>--cr-average=10000 option.
>
>
That option makes no difference.
I've strace()d the program, and it spins on the above select() waiting
for input. IE, it *always* times out. This is reading from a device that
*always* has input available - I can cat /dev/video0 to a file and will
always be able to read from it. Yet the code as it stood spins on
select(), and never gets out of the while loop.
I've also added debugging output within the loop, which gets executed
every .5 seconds (select() timeout), and debugging output outside the
loop, which never gets executed.
while( !( i_ret = select( p_sys->i_fd + 1, &fds,
NULL, NULL, &timeout ) ) )
{
printf("in while loop\n");
FD_ZERO( &fds );
FD_SET( p_sys->i_fd, &fds );
timeout.tv_sec = 0;
timeout.tv_usec = 500000;
if( p_input->b_die || p_input->b_error )
return 0;
}
printf("out of while loop\n");
---------
./vlc
pvr:/dev/video0:norm=pal:size=720x576:bitrate=2000000:maxbitrate=3000000
--sout udp:10.1.18.163 --cr-average=10000
VLC media player 0.7.2 Bond
Remote control interface initialized, `h' for help
[00000174] main input: playlist item
`pvr:/dev/video0:norm=pal:size=720x576:bitrate=2000000:maxbitrate=3000000'
in while loop
in while loop
in while loop
in while loop
in while loop
in while loop
in while loop
in while loop
in while loop
in while loop
in while loop
in while loop
in while loop
in while loop
in while loop
in while loop
in while loop
in while loop
in while loop
in while loop
signal 2 received, terminating vlc - do it again in case it gets stuck
in while loop
strace output:
-----------------
child_stack=0x42effb48,
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID|CLONE_DETACHED,
parent_tidptr=0x42effbf8, {entry_number:6, base_addr:0x42effbb0,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
limit_in_pages:1, seg_not_present:0, useable:1},
child_tidptr=0x42effbf8) = 6284
[pid 6282] gettimeofday({1093295949, 747684}, NULL) = 0
[pid 6282] gettimeofday( <unfinished ...>
[pid 6284] futex(0x8450f0c, FUTEX_WAIT, 0, NULL <unfinished ...>
[pid 6282] <... gettimeofday resumed> {1093295949, 748685}, NULL) = 0
[pid 6282] open("/dev/video0", O_RDWR|O_LARGEFILE) = 4
[pid 6282] ioctl(4, VIDIOC_S_STD, 0x8453ccc) = 0
[pid 6282] ioctl(4, VIDIOC_G_FMT or VT_SENDSIG, 0x41d7e800) = 0
[pid 6282] ioctl(4, VIDIOC_S_FMT or VT_RELDISP <unfinished ...>
card has finished initialising here.
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6282] <... ioctl resumed> , 0x41d7e800) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6282] ioctl(4, 0xffee7703, 0x41d7e790) = 0
[pid 6282] ioctl(4, 0xffee7704, 0x41d7e790) = 0
[pid 6282] select(5, [4], NULL, NULL, {0, 500000} <unfinished ...>
This select() is the one we want (fd of /dev/video0 is 4, as from the
ioctl()s above), the others are for the other threads.
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6282] <... select resumed> ) = 0 (Timeout)
[pid 6282] write(1, "in while loop\n", 14in while loop
) = 14
[pid 6282] select(5, [4], NULL, NULL, {0, 500000} <unfinished ...>
pid 6282, select times out, we write out our debugging code from within
the while loop, and then
select() again.
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
[pid 6279] <... select resumed> ) = 0 (Timeout)
[pid 6279] select(1, [0], NULL, NULL, {0, 50000} <unfinished ...>
[pid 6280] <... nanosleep resumed> NULL) = 0
[pid 6280] nanosleep({0, 50000000}, <unfinished ...>
[pid 6283] <... nanosleep resumed> NULL) = 0
[pid 6283] nanosleep({0, 50000000}, <unfinished ...>
[pid 6281] <... nanosleep resumed> NULL) = 0
[pid 6281] nanosleep({0, 50000000}, <unfinished ...>
Process 6280 detached
Process 6281 detached
Process 6282 detached
Process 6283 detached
Process 6284 detached
--------------
So, yes, your codepath is correct. As I said, don't debug someone elses
code at midnight.
Select() returns 0, hence a timeout. However, it *shouldn't*. There
should always be data available to read off this card. Do we even need
to select() off this device?
Daniel
--
Daniel Lawson
WAND Group, Computer Science Department
University of Waikato
email: daniel at wand.net.nz phone: +64 7 838 4136
--
This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html
If you are in trouble, please contact <postmaster at videolan.org>
More information about the vlc-devel
mailing list