[mythtv] lirc blocks reading from /dev/video
Matt Zimmerman
mdz at debian.org
Sun Mar 23 14:34:39 EST 2003
On Sun, Mar 23, 2003 at 12:57:50PM -0600, Geoffrey Hausheer wrote:
> When using live-tv, everything worked fine. As soon as I tried to record
> anything, mythbackend would get messed up with a message like:
>
> Changing from None to RecordingOnly
> Can't open video device: /dev/video0
> open video:: Device or resource busy
> VIDIOCSAUDIO: Bad file descriptor
>
> Changing chennels within live-tv works fine.
> I finally figured out that it was because of my channel changing script:
I have a patch for this, but have not had a chance to test it yet. Let me
know if it fixes things for you.
--
- mdz
-------------- next part --------------
Index: libs/libmythtv/channel.cpp
===================================================================
RCS file: /var/lib/cvs/MC/libs/libmythtv/channel.cpp,v
retrieving revision 1.32
diff -u -r1.32 channel.cpp
--- libs/libmythtv/channel.cpp 21 Mar 2003 02:50:26 -0000 1.32
+++ libs/libmythtv/channel.cpp 23 Mar 2003 19:33:37 -0000
@@ -5,6 +5,7 @@
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/wait.h>
#include <linux/videodev.h>
#include "channel.h"
#include "frequencies.h"
@@ -628,7 +629,31 @@
.arg(channum);
cout << "External channel change: " << command << endl;
- system(command.ascii());
+ pid_t child = fork();
+ if (child < 0)
+ {
+ perror("fork");
+ }
+ else if (child == 0)
+ {
+ for(int i = 3; i < sysconf(_SC_OPEN_MAX) - 1; ++i)
+ close(i);
+ execl("/bin/sh", "sh", "-c", command.ascii());
+ perror("exec");
+ exit(1);
+ }
+ else
+ {
+ int status;
+ if (waitpid(child, &status, 0) < 0)
+ perror("waitpid");
+ if (status != 0)
+ {
+ cerr << "External channel change command exited with status "
+ << status << endl;
+ return false;
+ }
+ }
return true;
}
More information about the mythtv-dev
mailing list