Skip to content
Browse files

Change how we retry and cancel playback should refreshing the playlis…

…t failed.

In theory, PlayListWorker shouldn't even run for VOD stream ; and it wasn't running originally. However, this prevented some live stream to work incorrectly marked as VOD. While this was properly fixed in 0d69c75, PlayListWorker is still running no matter what as it helps determine if a stream is still valid and hasn't been deleted in the mean time
So reduce the playlist refresh time when running in VOD mode ; waiting times are doubled.
  • Loading branch information...
1 parent 62ba11a commit 47b647e14c6ad895d1dc2c60cf606def086fe95c @jyavenard jyavenard committed May 22, 2012
Showing with 21 additions and 21 deletions.
  1. +21 −21 mythtv/libs/libmythtv/HLS/httplivestreambuffer.cpp
View
42 mythtv/libs/libmythtv/HLS/httplivestreambuffer.cpp
@@ -1211,7 +1211,8 @@ class PlaylistWorker : public MThread
void run(void)
{
double wait = 0.5;
- int tries = 0;
+ double factor = m_parent->GetCurrentStream()->Live() ? 1.0 : 2.0;
+
QWaitCondition mcond;
while (!m_interrupted)
@@ -1241,25 +1242,35 @@ class PlaylistWorker : public MThread
if (ReloadPlaylist() != RET_OK)
{
/* No change in playlist, then backoff */
- tries++;
- if (tries == 1) wait = 0.5;
- else if (tries == 2) wait = 1;
- else if (tries >= 3) wait = 2;
+ m_retries++;
+ if (m_retries == 1) wait = 0.5;
+ else if (m_retries == 2) wait = 1;
+ else if (m_retries >= 3) wait = 2;
+
+ // If we haven't been able to reload the playlist after x times
+ // it probably means the stream got deleted, so abort
+ if (m_retries > PLAYLIST_FAILURE)
+ {
+ LOG(VB_PLAYBACK, LOG_ERR, LOC +
+ QString("reloading the playlist failed after %1 attempts."
+ "aborting.").arg(PLAYLIST_FAILURE));
+ m_parent->m_error = true;
+ }
/* Can we afford to backoff? */
if (m_parent->m_streamworker->CurrentPlaybackBuffer() < 3)
{
- if (tries == 0)
+ if (m_retries == 1)
continue; // restart immediately if it's the first try
- tries = 0;
+ m_retries = 0;
wait = 0.5;
}
}
else
{
// make streamworker process things
m_parent->m_streamworker->Wakeup();
- tries = 0;
+ m_retries = 0;
wait = 0.5;
}
@@ -1274,7 +1285,7 @@ class PlaylistWorker : public MThread
}
/* determine next time to update playlist */
- m_wakeup = ((int64_t)(hls->TargetDuration() * wait)
+ m_wakeup = ((int64_t)(hls->TargetDuration() * wait * factor)
* (int64_t)1000);
}
}
@@ -1293,20 +1304,9 @@ class PlaylistWorker : public MThread
{
LOG(VB_PLAYBACK, LOG_ERR, LOC + "reloading playlist failed");
m_parent->FreeStreamsList(streams);
-
- // If we haven't been able to reload the playlist after x times
- // it probably means the stream got deleted, so abort
- m_retries++;
- if (m_retries > PLAYLIST_FAILURE)
- {
- LOG(VB_PLAYBACK, LOG_ERR, LOC +
- QString("reloading the playlist failed after %1 attempts."
- "aborting.").arg(PLAYLIST_FAILURE));
- m_parent->m_error = true;
- }
return RET_ERROR;
}
- m_retries = 0;
+
/* merge playlists */
int count = streams->size();
for (int n = 0; n < count; n++)

0 comments on commit 47b647e

Please sign in to comment.
Something went wrong with that request. Please try again.