<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1170" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I have been tracing the channel change code to
track down a pause during channel change, and I have got stuck. Can anyone
help with some ideas on where to look please.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Basically the motivation is to see if I can't
speedup channel change time. What I'm finding is that when tracing through
tv_play.cpp in ChangeChannel the lines:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>
activenvp->Pause(false);<BR>
activerbuffer->WaitForPause();<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Are taking up to 600ms+ to complete. This is
using a DVB card as the input source. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>At first I thought I had it sussed with the
following:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>---
NuppelVideoPlayer.cpp 23 Nov 2003 05:44:16
-0000 1.297<BR>+++
NuppelVideoPlayer.cpp 23 Nov 2003 18:42:59
-0000<BR>@@ -1518,7 +1528,7
@@<BR>
else<BR>
{<BR>
//printf("startplaying waiting for
unpause\n");<BR>-
usleep(500);<BR>+
usleep(100);<BR>
continue;<BR>
}<BR> }<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>However, this merely pushes the wait time into the
ringbuffer->WaitForPause(); So first of all, why usleep(500) anyway?
And also, does anyone have any ideas on how to trace where this second call is
spending all it's time?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Here's what I checked: The play loop in dvbrecorder
appears to be very responsive, it only seems to be reading a single ts frame at
a time. In the "if (paused)" section of the play loop there is no
significant time delay pausing the recorder thread. Also I can't spot any
significant delays pausing the decoder thread, it seems to be decoding a single
frame each time round the play loop, so it should be pretty responsive? So
what the heck is it doing for 600ms?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I think this would be a useful speedup if this
pausing delay could be worked out. If anyone wants to time this for
themselves try the following:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>--- tv_play.cpp 23 Nov 2003 01:15:30
-0000 1.122<BR>+++ tv_play.cpp 23 Nov 2003
18:43:04 -0000<BR>@@ -1669,6 +1669,8 @@</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> void TV::ChangeChannel(int
direction)<BR> {<BR>+ QTime
qtm;qtm.start();<BR>+ cout << "Starting Channel
Change\r\n";<BR> bool muted = false;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> if (volumeControl
&& !volumeControl->GetMute() && activenvp == nvp)<BR>@@
-1684,20 +1686,28 @@<BR> paused
= false;<BR> }</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>+ cout << "Before Pause:"
<< qtm.elapsed() << "\r\n";<BR>
activenvp->Pause(false);<BR>+ cout << "Pause Issued:"
<< qtm.elapsed() << "\r\n";<BR> // all we
care about is the ringbuffer being paused, here..<BR>
activerbuffer->WaitForPause();<BR>+ cout << "Paused:"
<< qtm.elapsed() << "\r\n";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> // Save the current
channel if this is the first time<BR> if
(channame_vector.size() == 0 && activenvp ==
nvp)<BR>
AddPreviousChannel();</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>
activerecorder->Pause();<BR>+ cout << "Active
Recorder Paused:" << qtm.elapsed() <<
"\r\n";<BR>
activerbuffer->Reset();<BR>+ cout << "Buffer
reset:" << qtm.elapsed() <<
"\r\n";<BR>
activerecorder->ChangeChannel(direction);<BR>+ cout
<< "Active Recorder Channel Changed:" << qtm.elapsed() <<
"\r\n";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>
activenvp->ResetPlaying();<BR>+ cout << "Reset
Playing:" << qtm.elapsed() << "\r\n";<BR>
activenvp->Unpause(false);<BR>+ cout << "Un Paused:"
<< qtm.elapsed() << "\r\n";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> if (activenvp ==
nvp)<BR> {<BR></FONT></DIV>
<DIV><FONT face=Arial size=2> </DIV></FONT>
<DIV><FONT face=Arial size=2>However, whilst I was fiddling it occurs to me that
the current mpegrecorder.cpp uses this in the StartRecording loop:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> ret =
read(readfd, buffer, 256000);<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Someone with a PVR card might want to try dropping
the read size to say 64000. Just eyeballing the code, but this would
appear to make the record loop more responsive and speedup the pausing
code? I don't have one, so feedback appreciated..</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>The other thing I don't quite understand is how
much pre-buffering is required for various input sources. It seems at
least for DVB input sources that the following change works very
well:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>--- videoout_xv.cpp 10 Nov
2003 21:45:01 -0000 1.87<BR>+++
videoout_xv.cpp 23 Nov 2003 18:43:04 -0000<BR>@@ -46,7
+46,8 @@</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> const int kNumBuffers = 31;<BR> const
int kNeedFreeFrames = 1;<BR>-const int kPrebufferFrames = 12;<BR>+//const int
kPrebufferFrames = 12;<BR>+const int kPrebufferFrames = 2;<BR> const int
kKeepPrebuffer = 2;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> struct XvData<BR></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>What are the issues with reducing this? Also,
what is the difference between kKeppPrebuffer and kPrebufferFrames?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>In any case, with these changes, at least for the
times when the pause runs quickly, the channel change time is pretty good
really. Any chance someone could pitch in with some feedback and lets see
if we can't tune this a little</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Ed</DIV></FONT></BODY></HTML>