Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: dmx_stop blocks unexpectedly



Edwin Mulder wrote:
> 
> I have a section filter configured like this:
> 
> thread_A:
>    open ("/dev/dvb/adapter0/demux0", O_RDWR)) < 0
> 
>    filter[0] = 0x02; // TID for PMT
>    mask[0] = 0xff;
>    filter[3] = static_cast<U8>(mPmtSectionVersion << 1);
>    mask[3] = 0x3e;
>    mode[3] = 0x3e;
>    flags |= (LDMX_CHECK_CRC | LDMX_ONESHOT)
> 
>    ioctl(mFd, DMX_SET_FILTER, &parm)
>    ioctl(mFd, DMX_START)
>    read(mFd, pBuffer, count)   --> blocks because there is no change in 
> version of section; so far so good
> 
> If client wants to stop the filter, it executes
> thread_B:
>    ioctl(mFd, DMX_STOP)
> 
> Now I observe that thread_B, DMX_STOP blocks. Is this behaviour okay? I 
> can't find anything about this in the documentation. I expected a 
> non-blocking DMX_STOP and thread_A returning from read().
> Replacing the ioct(DMX_STOP) by close(FileDescriptorSectionFilter) does not 
> work either; thread_A is still blocking.
> 
> How should the the API work???

That is a good question.

However, with the current implementation this is not supported.
read() and DMX_STOP modify the same filter state and are thus
protected from each other by a mutex. However, it would be
feasible to drop the mutex in read() when it waits for data.

But I suspect you would run into more locking problems when
two threads work on the same file descriptor...

We usually use non-blocking mode and an event loop.

Johannes


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



Home | Main Index | Thread Index