[mythtv] no more live tv
David Engel
dlengel at attbi.com
Fri May 9 15:02:32 EDT 2003
On Thu, May 01, 2003 at 06:22:56PM -0400, Isaac Richards wrote:
> On Thursday 01 May 2003 01:48 am, David Engel wrote:
> > On Wed, Apr 30, 2003 at 05:22:57PM -0500, David Engel wrote:
> > > First, mythtv behaves differently when watching live TV than it does
> > > when watching a recorded program when it, or another program, is being
> > > recorded. Perhaps mythtv should attempt the open without blocking so
> > > an error message could be printed out instead of just hanging.
> > >
> > > Second, since mythtv now supports capture cards that don't need an
> > > audio device for input, it should probably allow for no audio device
> > > to be configured. If this was the case, the problematic open wouldn't
> > > even be attempted.
> >
> > P.S. I'm willing to generate patches for these or any other solutions
> > you would find acceptable.
>
> Either would be fine, if you're willing to have a go at it.
OK, here it is. CVS was down before I went out of town so I couldn't
send this until now.
Since blocking on audio opens seems to be a common problem for
newbies, I changed all of them to non-blocking so an error message is
always printed. In those cases where the device is kept open, the
O_NONBLOCK flag is cleared with fcntl so no other semantics are
changed except the open. Doing this fixes one potential, albeit
unlikely, race condition in NuppelVideoPlayer.cpp.
David
--
David Engel
dlengel at attbi.com
Index: libs/libmythtv/NuppelVideoPlayer.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/NuppelVideoPlayer.cpp,v
retrieving revision 1.187
diff -u -r1.187 NuppelVideoPlayer.cpp
--- libs/libmythtv/NuppelVideoPlayer.cpp 29 Apr 2003 04:46:48 -0000 1.187
+++ libs/libmythtv/NuppelVideoPlayer.cpp 9 May 2003 18:49:12 -0000
@@ -348,10 +348,7 @@
return;
}
- close(audiofd);
- audiofd = -1;
-
- audiofd = open(audiodevice.ascii(), O_WRONLY);
+ fcntl(audiofd, F_SETFL, fcntl(audiofd, F_GETFL) & ~O_NONBLOCK);
if (ioctl(audiofd, SNDCTL_DSP_SAMPLESIZE, &audio_bits) < 0 ||
ioctl(audiofd, SNDCTL_DSP_CHANNELS, &audio_channels) < 0 ||
Index: libs/libmythtv/NuppelVideoRecorder.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp,v
retrieving revision 1.108
diff -u -r1.108 NuppelVideoRecorder.cpp
--- libs/libmythtv/NuppelVideoRecorder.cpp 29 Apr 2003 04:46:48 -0000 1.108
+++ libs/libmythtv/NuppelVideoRecorder.cpp 9 May 2003 18:49:12 -0000
@@ -464,11 +464,14 @@
if (!skipdevice)
{
- if (-1 == (afd = open(audiodevice.ascii(), O_RDONLY)))
+ if (-1 == (afd = open(audiodevice.ascii(), O_RDONLY | O_NONBLOCK)))
{
cerr << "Cannot open DSP '" << audiodevice << "', dying.\n";
+ perror("open");
return 1;
}
+
+ fcntl(afd, F_SETFL, fcntl(afd, F_GETFL) & ~O_NONBLOCK);
//ioctl(afd, SNDCTL_DSP_RESET, 0);
@@ -1569,11 +1572,14 @@
act_audio_sample = 0;
- if (-1 == (afd = open(audiodevice.ascii(), O_RDONLY)))
+ if (-1 == (afd = open(audiodevice.ascii(), O_RDONLY | O_NONBLOCK)))
{
cerr << "Cannot open DSP '" << audiodevice << "', exiting";
+ perror("open");
return;
}
+
+ fcntl(afd, F_SETFL, fcntl(afd, F_GETFL) & ~O_NONBLOCK);
//ioctl(afd, SNDCTL_DSP_RESET, 0);
Index: libs/libmythtv/videosource.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/videosource.h,v
retrieving revision 1.36
diff -u -r1.36 videosource.h
--- libs/libmythtv/videosource.h 26 Apr 2003 03:35:39 -0000 1.36
+++ libs/libmythtv/videosource.h 9 May 2003 18:49:13 -0000
@@ -294,6 +294,7 @@
fillSelectionsFromDir(dev);
dev.setPath("/dev/sound");
fillSelectionsFromDir(dev);
+ addSelection("(None)", "/dev/null");
};
};
Index: programs/mythbackend/mainserver.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/mainserver.cpp,v
retrieving revision 1.51
diff -u -r1.51 mainserver.cpp
--- programs/mythbackend/mainserver.cpp 7 May 2003 19:35:12 -0000 1.51
+++ programs/mythbackend/mainserver.cpp 9 May 2003 18:49:13 -0000
@@ -404,7 +404,7 @@
if (audiodevice.right(4) == audiooutputdevice.right(4)) //they match
{
- int dsp_fd = open(audiodevice, O_RDWR);
+ int dsp_fd = open(audiodevice, O_RDWR | O_NONBLOCK);
if (dsp_fd != -1)
{
dsp_status = ioctl(dsp_fd, SNDCTL_DSP_GETCAPS,
@@ -425,9 +425,12 @@
close(dsp_fd);
}
else
+ {
cerr << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")
<< " Could not open audio device: "
<< audiodevice << endl;
+ perror("open");
+ }
}
}
}
More information about the mythtv-dev
mailing list