Navigation Menu

Skip to content

Commit

Permalink
Apply timestretch setting to DVD stills.
Browse files Browse the repository at this point in the history
Refs #11292
  • Loading branch information
Richard committed Jun 30, 2013
1 parent 21aea82 commit bc9cc19
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
28 changes: 24 additions & 4 deletions mythtv/libs/libmythtv/DVD/mythdvdplayer.cpp
Expand Up @@ -437,7 +437,21 @@ uint64_t MythDVDPlayer::GetBookmark(void)

void MythDVDPlayer::ChangeSpeed(void)
{
if (m_stillFrameLength > 0)
{
m_stillFrameTimerLock.lock();
// Get the timestretched elapsed time and transform
// it to what the unstretched value would have been
// had we been playing with the new timestretch value
// all along
int elapsed = (int)(m_stillFrameTimer.elapsed() * play_speed / next_play_speed);
m_stillFrameTimer.restart();
m_stillFrameTimer.addMSecs(elapsed);
m_stillFrameTimerLock.unlock();
}

MythPlayer::ChangeSpeed();

if (decoder)
decoder->UpdateFramesPlayed();
if (play_speed != normal_speed && player_ctx->buffer->IsDVD())
Expand Down Expand Up @@ -471,7 +485,7 @@ int64_t MythDVDPlayer::GetSecondsPlayed(bool, int divisor) const
if (m_stillFrameLength == 255)
played = -1;
else
played = m_stillFrameTimer.elapsed() / 1000;
played = m_stillFrameTimer.elapsed() * play_speed / divisor;
}

return played;
Expand Down Expand Up @@ -671,6 +685,11 @@ void MythDVDPlayer::GoToDVDProgram(bool direction)
player_ctx->buffer->DVD()->GoToNextProgram();
}

bool MythDVDPlayer::IsInStillFrame() const
{
return (m_stillFrameLength > 0);
}

int MythDVDPlayer::GetNumAngles(void) const
{
if (player_ctx->buffer->DVD() && player_ctx->buffer->DVD()->IsOpen())
Expand Down Expand Up @@ -732,13 +751,14 @@ void MythDVDPlayer::StillFrameCheck(void)
(m_stillFrameLength > 0) && (m_stillFrameLength < 0xff))
{
m_stillFrameTimerLock.lock();
int elapsedTime = m_stillFrameTimer.elapsed() / 1000;
int elapsedTime = (int)(m_stillFrameTimer.elapsed() * play_speed / 1000);
m_stillFrameTimerLock.unlock();
if (elapsedTime >= m_stillFrameLength)
{
LOG(VB_PLAYBACK, LOG_INFO, LOC +
QString("Stillframe timeout after %1 seconds")
.arg(m_stillFrameLength));
QString("Stillframe timeout after %1 seconds (timestretch %2)")
.arg(m_stillFrameLength)
.arg(play_speed));
player_ctx->buffer->DVD()->SkipStillFrame();
m_stillFrameLength = 0;
}
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/DVD/mythdvdplayer.h
Expand Up @@ -28,6 +28,7 @@ class MythDVDPlayer : public MythPlayer
// DVD public stuff
virtual bool GoToMenu(QString str);
virtual void GoToDVDProgram(bool direction);
virtual bool IsInStillFrame() const;

// DVD ringbuffer methods
void ResetStillFrameTimer(void);
Expand Down
17 changes: 10 additions & 7 deletions mythtv/libs/libmythtv/mythplayer.cpp
Expand Up @@ -3087,15 +3087,18 @@ void MythPlayer::UnpauseDecoder(void)
return;
}

int tries = 0;
unpauseDecoder = true;
while (decoderThread && !killdecoder && (tries++ < 100) &&
!decoderThreadUnpause.wait(&decoderPauseLock, 100))
if (!IsInStillFrame())
{
LOG(VB_GENERAL, LOG_WARNING, LOC +
"Waited 100ms for decoder to unpause");
int tries = 0;
unpauseDecoder = true;
while (decoderThread && !killdecoder && (tries++ < 100) &&
!decoderThreadUnpause.wait(&decoderPauseLock, 100))
{
LOG(VB_GENERAL, LOG_WARNING, LOC +
"Waited 100ms for decoder to unpause");
}
unpauseDecoder = false;
}
unpauseDecoder = false;
decoderPauseLock.unlock();
}

Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/mythplayer.h
Expand Up @@ -327,6 +327,7 @@ class MTV_PUBLIC MythPlayer
// DVD public stuff
virtual bool GoToMenu(QString str) { return false; }
virtual void GoToDVDProgram(bool direction) { (void) direction; }
virtual bool IsInStillFrame() const { return false; }

// Position Map Stuff
bool PosMapFromEnc(uint64_t start,
Expand Down

0 comments on commit bc9cc19

Please sign in to comment.