Mailing List Archive

IOError: [Errno 16] Device or resource busy
With ivtv 0.10.6, I get the error "IOError: [Errno 16] Device or resource
busy" when setting the input (v4l2-ctl -i, ioctl). With ivtv 0.10.5 it did
work. That is, with 0.10.6 it is not possible to change the input from tuner
to e.g. composite or svideo while the device is open. Is this a know issue?
Is it solved in a later version? Note that 0.10.6 is the current default in
Gentoo.

theHog

_______________________________________________
ivtv-devel mailing list
ivtv-devel@ivtvdriver.org
http://ivtvdriver.org/mailman/listinfo/ivtv-devel
Re: IOError: [Errno 16] Device or resource busy [ In reply to ]
On Wednesday 21 November 2007 02:57:32 TheHog wrote:
> With ivtv 0.10.6, I get the error "IOError: [Errno 16] Device or
> resource busy" when setting the input (v4l2-ctl -i, ioctl). With ivtv
> 0.10.5 it did work. That is, with 0.10.6 it is not possible to change
> the input from tuner to e.g. composite or svideo while the device is
> open. Is this a know issue? Is it solved in a later version? Note
> that 0.10.6 is the current default in Gentoo.

No, this is a feature: changing inputs like that could cause a corrupt
MPEG stream so I changed the driver to prevent people from switching to
another input when a capture is in progress.

Regards,

Hans

_______________________________________________
ivtv-devel mailing list
ivtv-devel@ivtvdriver.org
http://ivtvdriver.org/mailman/listinfo/ivtv-devel
Re: IOError: [Errno 16] Device or resource busy [ In reply to ]
----- Oorspronkelijk bericht -----
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Discussion list for development of the IVTV driver
<ivtv-devel@ivtvdriver.org>
Date: 21-Nov-2007 09:28
Subject: Re: [ivtv-devel] IOError: [Errno 16] Device or resource busy

> On Wednesday 21 November 2007 02:57:32 TheHog wrote:
> > With ivtv 0.10.6, I get the error "IOError: [Errno 16] Device or
> > resource busy" when setting the input (v4l2-ctl -i, ioctl). With ivtv
> > 0.10.5 it did work. That is, with 0.10.6 it is not possible to change
> > the input from tuner to e.g. composite or svideo while the device is
> > open. Is this a know issue? Is it solved in a later version? Note
> > that 0.10.6 is the current default in Gentoo.
>
> No, this is a feature: changing inputs like that could cause a corrupt
> MPEG stream so I changed the driver to prevent people from switching to
> another input when a capture is in progress.
>

OK, understandable but an annoying 'feature'. In Freevo (www.freevo.org) we
have a TV channel list that includes different inputs. I.e. composite and
s-video inputs are in the same list as tuner channels. The user can 'zap'
through the channel list: BBC 1, Composite, S-Video, BBC 2, ... without
stopping the player (xine in this case). I'll now have to find a way to
re-enable this functionality. Restarting the player is not an option, that
takes too long.

Regards,

Richard.


_______________________________________________
ivtv-devel mailing list
ivtv-devel@ivtvdriver.org
http://ivtvdriver.org/mailman/listinfo/ivtv-devel
Re: IOError: [Errno 16] Device or resource busy [ In reply to ]
From: Hans Verkuil <hverkuil@xs4all.nl>
Date: 21-Nov-2007 09:28
> On Wednesday 21 November 2007 02:57:32 TheHog wrote:
> > With ivtv 0.10.6, I get the error "IOError: [Errno 16] Device or
> > resource busy" when setting the input (v4l2-ctl -i, ioctl). With ivtv
> > 0.10.5 it did work. That is, with 0.10.6 it is not possible to change
> > the input from tuner to e.g. composite or svideo while the device is
> > open. Is this a know issue? Is it solved in a later version? Note
> > that 0.10.6 is the current default in Gentoo.
>
> No, this is a feature: changing inputs like that could cause a corrupt
> MPEG stream so I changed the driver to prevent people from switching to
> another input when a capture is in progress.
>

What exaclty causes the bad packets in the MPEG stream? Is it the PVR
firmware or ivtv? I found some code in xine's input_pvr plugin that copes
with corrupted streams: it does an close/open on the device to obtain a valid
stream again. That's probably why Freevo users didn't encounter the issue.

Do you plan to re-enable the functionality to switch inputs while a capture
is in progress in the future?

--theHog

_______________________________________________
ivtv-devel mailing list
ivtv-devel@ivtvdriver.org
http://ivtvdriver.org/mailman/listinfo/ivtv-devel
Re: IOError: [Errno 16] Device or resource busy [ In reply to ]
On Wednesday 28 November 2007 13:09:45 TheHog wrote:
> From: Hans Verkuil <hverkuil@xs4all.nl>
> Date: 21-Nov-2007 09:28
>
> > On Wednesday 21 November 2007 02:57:32 TheHog wrote:
> > > With ivtv 0.10.6, I get the error "IOError: [Errno 16] Device or
> > > resource busy" when setting the input (v4l2-ctl -i, ioctl). With
> > > ivtv 0.10.5 it did work. That is, with 0.10.6 it is not possible
> > > to change the input from tuner to e.g. composite or svideo while
> > > the device is open. Is this a know issue? Is it solved in a later
> > > version? Note that 0.10.6 is the current default in Gentoo.
> >
> > No, this is a feature: changing inputs like that could cause a
> > corrupt MPEG stream so I changed the driver to prevent people from
> > switching to another input when a capture is in progress.
>
> What exaclty causes the bad packets in the MPEG stream? Is it the PVR
> firmware or ivtv?

It's really the hardware: changing the input will mean changing the
settings of the digitizer chip (saa7115 or cx2584x). This means that
the cx23416 can receive a bad frame from the digitizer which means that
the MPEG stream also gets corrupted.

> I found some code in xine's input_pvr plugin that
> copes with corrupted streams: it does an close/open on the device to
> obtain a valid stream again. That's probably why Freevo users didn't
> encounter the issue.
>
> Do you plan to re-enable the functionality to switch inputs while a
> capture is in progress in the future?

I have no plans, unless someone can figure out how to safely change
inputs. There might be some magic incantation, but experience has shown
that it is quite tricky to get it working under all circumstances.

Regards,

Hans

_______________________________________________
ivtv-devel mailing list
ivtv-devel@ivtvdriver.org
http://ivtvdriver.org/mailman/listinfo/ivtv-devel
Re: IOError: [Errno 16] Device or resource busy [ In reply to ]
From: Hans Verkuil <hverkuil@xs4all.nl>

> On Wednesday 28 November 2007 13:09:45 TheHog wrote:
> > From: Hans Verkuil <hverkuil@xs4all.nl>
> > Date: 21-Nov-2007 09:28
> >
> > > On Wednesday 21 November 2007 02:57:32 TheHog wrote:
> > > > With ivtv 0.10.6, I get the error "IOError: [Errno 16] Device or
> > > > resource busy" when setting the input (v4l2-ctl -i, ioctl). With
> > > > ivtv 0.10.5 it did work. That is, with 0.10.6 it is not possible
> > > > to change the input from tuner to e.g. composite or svideo while
> > > > the device is open. Is this a know issue? Is it solved in a later
> > > > version? Note that 0.10.6 is the current default in Gentoo.
> > >
> > > No, this is a feature: changing inputs like that could cause a
> > > corrupt MPEG stream so I changed the driver to prevent people from
> > > switching to another input when a capture is in progress.
> >
> > What exaclty causes the bad packets in the MPEG stream? Is it the PVR
> > firmware or ivtv?
>
> It's really the hardware: changing the input will mean changing the
> settings of the digitizer chip (saa7115 or cx2584x). This means that
> the cx23416 can receive a bad frame from the digitizer which means that
> the MPEG stream also gets corrupted.
>
> > I found some code in xine's input_pvr plugin that
> > copes with corrupted streams: it does an close/open on the device to
> > obtain a valid stream again. That's probably why Freevo users didn't
> > encounter the issue.
> >
> > Do you plan to re-enable the functionality to switch inputs while a
> > capture is in progress in the future?
>
> I have no plans, unless someone can figure out how to safely change
> inputs. There might be some magic incantation, but experience has shown
> that it is quite tricky to get it working under all circumstances.
>

OK, I understand. I presume it is not possible to detect that situation in
the ivtv driver and discard the frame since it has already been encoded into
the stream? Instead, is it possible to put the digitizer chip "on hold"
(maybe causing the cx23416 to insert black frames into the stream)? That way,
clients of ivtv can issue a "hold - change input - continue" sequence without
closing and re-opening the video device?

Richard.


_______________________________________________
ivtv-devel mailing list
ivtv-devel@ivtvdriver.org
http://ivtvdriver.org/mailman/listinfo/ivtv-devel
Re: IOError: [Errno 16] Device or resource busy [ In reply to ]
On Thursday 29 November 2007 20:16:51 TheHog wrote:
> From: Hans Verkuil <hverkuil@xs4all.nl>
>
> > On Wednesday 28 November 2007 13:09:45 TheHog wrote:
> > > From: Hans Verkuil <hverkuil@xs4all.nl>
> > > Date: 21-Nov-2007 09:28
> > >
> > > > On Wednesday 21 November 2007 02:57:32 TheHog wrote:
> > > > > With ivtv 0.10.6, I get the error "IOError: [Errno 16] Device
> > > > > or resource busy" when setting the input (v4l2-ctl -i,
> > > > > ioctl). With ivtv 0.10.5 it did work. That is, with 0.10.6 it
> > > > > is not possible to change the input from tuner to e.g.
> > > > > composite or svideo while the device is open. Is this a know
> > > > > issue? Is it solved in a later version? Note that 0.10.6 is
> > > > > the current default in Gentoo.
> > > >
> > > > No, this is a feature: changing inputs like that could cause a
> > > > corrupt MPEG stream so I changed the driver to prevent people
> > > > from switching to another input when a capture is in progress.
> > >
> > > What exaclty causes the bad packets in the MPEG stream? Is it the
> > > PVR firmware or ivtv?
> >
> > It's really the hardware: changing the input will mean changing the
> > settings of the digitizer chip (saa7115 or cx2584x). This means
> > that the cx23416 can receive a bad frame from the digitizer which
> > means that the MPEG stream also gets corrupted.
> >
> > > I found some code in xine's input_pvr plugin that
> > > copes with corrupted streams: it does an close/open on the device
> > > to obtain a valid stream again. That's probably why Freevo users
> > > didn't encounter the issue.
> > >
> > > Do you plan to re-enable the functionality to switch inputs while
> > > a capture is in progress in the future?
> >
> > I have no plans, unless someone can figure out how to safely change
> > inputs. There might be some magic incantation, but experience has
> > shown that it is quite tricky to get it working under all
> > circumstances.
>
> OK, I understand. I presume it is not possible to detect that
> situation in the ivtv driver and discard the frame since it has
> already been encoded into the stream? Instead, is it possible to put
> the digitizer chip "on hold" (maybe causing the cx23416 to insert
> black frames into the stream)? That way, clients of ivtv can issue a
> "hold - change input - continue" sequence without closing and
> re-opening the video device?

It might be possible to use some workaround like that to make it work.
The problem is with the cx23416 part where the documentation on what to
do in a situation like this is for all practical purposes non-existant.
So the only way to fix this is to simply experiment a lot. I'm not
going to do that myself (too many other tasks), but I'm perfectly
willing to give pointers if you want to take this on.

Regards,

Hans

_______________________________________________
ivtv-devel mailing list
ivtv-devel@ivtvdriver.org
http://ivtvdriver.org/mailman/listinfo/ivtv-devel
Re: IOError: [Errno 16] Device or resource busy [ In reply to ]
From: Hans Verkuil <hverkuil@xs4all.nl>
> On Thursday 29 November 2007 20:16:51 TheHog wrote:
> > From: Hans Verkuil <hverkuil@xs4all.nl>
> >
> > > On Wednesday 28 November 2007 13:09:45 TheHog wrote:
> > > > From: Hans Verkuil <hverkuil@xs4all.nl>
> > > > Date: 21-Nov-2007 09:28
> > > >
> > > > > On Wednesday 21 November 2007 02:57:32 TheHog wrote:
> > > > > > With ivtv 0.10.6, I get the error "IOError: [Errno 16] Device
> > > > > > or resource busy" when setting the input (v4l2-ctl -i,
> > > > > > ioctl). With ivtv 0.10.5 it did work. That is, with 0.10.6 it
> > > > > > is not possible to change the input from tuner to e.g.
> > > > > > composite or svideo while the device is open. Is this a know
> > > > > > issue? Is it solved in a later version? Note that 0.10.6 is
> > > > > > the current default in Gentoo.
> > > > >
> > > > > No, this is a feature: changing inputs like that could cause a
> > > > > corrupt MPEG stream so I changed the driver to prevent people
> > > > > from switching to another input when a capture is in progress.
> > > >
> > > > What exaclty causes the bad packets in the MPEG stream? Is it the
> > > > PVR firmware or ivtv?
> > >
> > > It's really the hardware: changing the input will mean changing the
> > > settings of the digitizer chip (saa7115 or cx2584x). This means
> > > that the cx23416 can receive a bad frame from the digitizer which
> > > means that the MPEG stream also gets corrupted.
> > >
> > > > I found some code in xine's input_pvr plugin that
> > > > copes with corrupted streams: it does an close/open on the device
> > > > to obtain a valid stream again. That's probably why Freevo users
> > > > didn't encounter the issue.
> > > >
> > > > Do you plan to re-enable the functionality to switch inputs while
> > > > a capture is in progress in the future?
> > >
> > > I have no plans, unless someone can figure out how to safely change
> > > inputs. There might be some magic incantation, but experience has
> > > shown that it is quite tricky to get it working under all
> > > circumstances.
> >
> > OK, I understand. I presume it is not possible to detect that
> > situation in the ivtv driver and discard the frame since it has
> > already been encoded into the stream? Instead, is it possible to put
> > the digitizer chip "on hold" (maybe causing the cx23416 to insert
> > black frames into the stream)? That way, clients of ivtv can issue a
> > "hold - change input - continue" sequence without closing and
> > re-opening the video device?
>
> It might be possible to use some workaround like that to make it work.
> The problem is with the cx23416 part where the documentation on what to
> do in a situation like this is for all practical purposes non-existant.
> So the only way to fix this is to simply experiment a lot. I'm not
> going to do that myself (too many other tasks), but I'm perfectly
> willing to give pointers if you want to take this on.
>

OK, I'll give a try after my current work with xine has been done.

Cheers,
Richard.


_______________________________________________
ivtv-devel mailing list
ivtv-devel@ivtvdriver.org
http://ivtvdriver.org/mailman/listinfo/ivtv-devel
Re: IOError: [Errno 16] Device or resource busy [ In reply to ]
the problem is not the cx23416, but the cx23415.

I never had problems with my PVR250 (cx23416) changing channels or inputs. But
the PVR350 (cx23415) had freezes and a flickering problem (see
http://www.gossamer-threads.com/lists/ivtv/devel/32970)

Hans fixed the freezing problems, with the result that now we must stop the
encoder when changing inputs or switching between TV/radio while on tuner
input.

My first solution for the pvrinput-plugin (vdr) was to stop the encoder only
when it was necessary. For switching between TV channels I used the faster
pause/resume or the let the encoder run. I also tested black video during
channel switches, using CX2341X_ENC_MUTE_VIDEO (like it is done during radio
captures).

After a lot of tests I found out that the only reliable solution against
flickering with cx23415 is to stop the encoder before every channel switch
and restart it after tuning is done. With the current ivtv driver in v4l-dvb
hg stopping and starting the encoder works very fast. It also makes channels
switching smoother, because we don`t see the tuning interferences.

With the 1.x driver I let the application do the following:
-delete the read thread
-call V4L2_ENC_CMD_STOP
-change inputs and/or tune
-call V4L2_ENC_CMD_START
-create a new read thread

with ivtv 0.10 it is a bit more tricky, because the stop/start ioctls
(VIDIOC_STREAMON/OFF) doesn`t work properly according to Hans.
-delete the read thread
-close device
-reopen device
-change inputs and/or tune
-create a new read thread
The encoder will stop and start automatically

_______________________________________________
ivtv-devel mailing list
ivtv-devel@ivtvdriver.org
http://ivtvdriver.org/mailman/listinfo/ivtv-devel
Re: IOError: [Errno 16] Device or resource busy [ In reply to ]
Martin Dauskardt wrote:
> the problem is not the cx23416, but the cx23415.
>
> I never had problems with my PVR250 (cx23416) changing channels or inputs. But
> the PVR350 (cx23415) had freezes and a flickering problem (see
> http://www.gossamer-threads.com/lists/ivtv/devel/32970)
>
> Hans fixed the freezing problems, with the result that now we must stop the
> encoder when changing inputs or switching between TV/radio while on tuner
> input.
>
> My first solution for the pvrinput-plugin (vdr) was to stop the encoder only
> when it was necessary. For switching between TV channels I used the faster
> pause/resume or the let the encoder run. I also tested black video during
> channel switches, using CX2341X_ENC_MUTE_VIDEO (like it is done during radio
> captures).
>
> After a lot of tests I found out that the only reliable solution against
> flickering with cx23415 is to stop the encoder before every channel switch
> and restart it after tuning is done. With the current ivtv driver in v4l-dvb
> hg stopping and starting the encoder works very fast. It also makes channels
> switching smoother, because we don`t see the tuning interferences.
>
> With the 1.x driver I let the application do the following:
> -delete the read thread
> -call V4L2_ENC_CMD_STOP
> -change inputs and/or tune
> -call V4L2_ENC_CMD_START
> -create a new read thread
>
> with ivtv 0.10 it is a bit more tricky, because the stop/start ioctls
> (VIDIOC_STREAMON/OFF) doesn`t work properly according to Hans.
> -delete the read thread
> -close device
> -reopen device
> -change inputs and/or tune
> -create a new read thread
> The encoder will stop and start automatically
>
I used the close/reopen approach and implemented it into xine-lib's
input_pvr plugin. It seems to work fine with the 0.10 release of ivtv
(and my PVR-250). I submitted a patch to the xine maintainers.

Thanks for the info!

Richard.


_______________________________________________
ivtv-devel mailing list
ivtv-devel@ivtvdriver.org
http://ivtvdriver.org/mailman/listinfo/ivtv-devel