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)



Hi,

James Green wrote:
> 
> Thanks for the clue, I managed to find the problem as well. I fixed it, 
> but then I found another bug as well. I fixed it by doing the 
> following in dmxdev.c:dvb_dmxdev_buffer_read():
> 
> while (todo>0) {
>   if (non_blocking && (src->pwrite==src->pread))
>   return (count-todo) ? (count-todo) : -EWOULDBLOCK;
>   
> >>  if ((!non_blocking) && ((count - todo) > 0)  && (src->pwrite==src->pread))
> >>     return (count-todo);
>   
>   if (wait_event_interruptible(src->queue,
> 			       (src->pread!=src->pwrite) ||
> 			       (src->error))<0)
>   return count-todo;
> 
> My new code is indented with ">>". I don't know if this is a very good fix
> though? From memory, I think the proper thing to do is to wait for a
> certain amount of data to be available. The threshold can be specified
> with an ioctl(), but defaults to some sensible value (half the buffer 
> size?).

I think the real fix would be to drop the while-loop completely
(just return whatever data is in the buffer), and only block if
the buffer is empty.

But I don't want to commit this, because there might be software
that depends on the current read() behaviour. The current read()
also has the advantage that there are less read() calls necessary
because the buffer you pass to read() is always completely filled.
With correct Posix semantics the worst case would be that each read()
would return one TS packet's payload only.

A better solution would be to have an API which allows one to queue
a number of userspace buffers, and get notified when a buffer is
completely filled. But that's stuff for a future API.


> But when I did this fix I found that I still got overflow errors. I 
> instrumented the code a lot and found that the read routine couldn't keep 
> up with the write routine. The buffer size was the default, 8192 bytes. 
> This doesn't seem large enough on my PC, ie. it gets filled too quickly 
> before the read routine can get in. However, my PC is pretty quick, and it 
> is only 2% loaded, so I think the buffer default size needs increasing. 
> 16KB was enough for me, but if somebody has a slower PC they might need 
> bigger. Is there any problem with making the default bigger. It's pretty 
> useless at the moment.

I think the default is fine. You can use DMX_SET_BUFFER_SIZE to increase
it if you need to.


Regards,
Johannes


-- 
Info:
To unsubscribe send a mail to ecartis@linuxtv.org with "unsubscribe linux-dvb" as subject.



Home | Main Index | Thread Index