Skip to content

Commit

Permalink
player: further cleanup of playing state
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta committed Jul 16, 2016
1 parent 164dd50 commit 6a5120c
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 63 deletions.
13 changes: 7 additions & 6 deletions xbmc/ApplicationPlayer.cpp
Expand Up @@ -193,10 +193,9 @@ bool CApplicationPlayer::HasRDS() const
return (player && player->HasRDS());
}

bool CApplicationPlayer::IsPaused() const
bool CApplicationPlayer::IsPaused()
{
std::shared_ptr<IPlayer> player = GetInternal();
return (player && player->IsPaused());
return (GetPlaySpeed() == 0);
}

bool CApplicationPlayer::IsPlaying() const
Expand All @@ -205,9 +204,9 @@ bool CApplicationPlayer::IsPlaying() const
return (player && player->IsPlaying());
}

bool CApplicationPlayer::IsPausedPlayback() const
bool CApplicationPlayer::IsPausedPlayback()
{
return (IsPlaying() && IsPaused());
return (IsPlaying() && (GetPlaySpeed() == 0));
}

bool CApplicationPlayer::IsPlayingAudio() const
Expand All @@ -229,7 +228,10 @@ void CApplicationPlayer::Pause()
{
std::shared_ptr<IPlayer> player = GetInternal();
if (player)
{
player->Pause();
m_speedUpdate.SetExpired();
}
}

void CApplicationPlayer::SetMute(bool bOnOff)
Expand Down Expand Up @@ -749,7 +751,6 @@ int CApplicationPlayer::GetPlaySpeed()
}
else
return 0;

}

void CApplicationPlayer::FrameMove()
Expand Down
4 changes: 2 additions & 2 deletions xbmc/ApplicationPlayer.h
Expand Up @@ -145,8 +145,8 @@ class CApplicationPlayer
bool HasRDS() const;
bool IsCaching() const;
bool IsInMenu() const;
bool IsPaused() const;
bool IsPausedPlayback() const;
bool IsPaused();
bool IsPausedPlayback();
bool IsPassthrough() const;
bool IsPlaying() const;
bool IsPlayingAudio() const;
Expand Down
26 changes: 13 additions & 13 deletions xbmc/GUIInfoManager.cpp
Expand Up @@ -6963,46 +6963,46 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI
bReturn = g_application.m_pPlayer->IsPlayingVideo();
break;
case PLAYER_PLAYING:
bReturn = !g_application.m_pPlayer->IsPausedPlayback() && (g_application.m_pPlayer->GetPlaySpeed() == 1);
bReturn = g_application.m_pPlayer->GetPlaySpeed() == 1;
break;
case PLAYER_PAUSED:
bReturn = g_application.m_pPlayer->IsPausedPlayback();
break;
case PLAYER_REWINDING:
bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() < 1;
bReturn = g_application.m_pPlayer->GetPlaySpeed() < 0;
break;
case PLAYER_FORWARDING:
bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() > 1;
bReturn = g_application.m_pPlayer->GetPlaySpeed() > 1;
break;
case PLAYER_REWINDING_2x:
bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == -2;
bReturn = g_application.m_pPlayer->GetPlaySpeed() == -2;
break;
case PLAYER_REWINDING_4x:
bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == -4;
bReturn = g_application.m_pPlayer->GetPlaySpeed() == -4;
break;
case PLAYER_REWINDING_8x:
bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == -8;
bReturn = g_application.m_pPlayer->GetPlaySpeed() == -8;
break;
case PLAYER_REWINDING_16x:
bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == -16;
bReturn = g_application.m_pPlayer->GetPlaySpeed() == -16;
break;
case PLAYER_REWINDING_32x:
bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == -32;
bReturn = g_application.m_pPlayer->GetPlaySpeed() == -32;
break;
case PLAYER_FORWARDING_2x:
bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == 2;
bReturn = g_application.m_pPlayer->GetPlaySpeed() == 2;
break;
case PLAYER_FORWARDING_4x:
bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == 4;
bReturn = g_application.m_pPlayer->GetPlaySpeed() == 4;
break;
case PLAYER_FORWARDING_8x:
bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == 8;
bReturn = g_application.m_pPlayer->GetPlaySpeed() == 8;
break;
case PLAYER_FORWARDING_16x:
bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == 16;
bReturn = g_application.m_pPlayer->GetPlaySpeed() == 16;
break;
case PLAYER_FORWARDING_32x:
bReturn = !g_application.m_pPlayer->IsPausedPlayback() && g_application.m_pPlayer->GetPlaySpeed() == 32;
bReturn = g_application.m_pPlayer->GetPlaySpeed() == 32;
break;
case PLAYER_CAN_RECORD:
bReturn = g_application.m_pPlayer->CanRecord();
Expand Down
5 changes: 0 additions & 5 deletions xbmc/cores/ExternalPlayer/ExternalPlayer.cpp
Expand Up @@ -498,11 +498,6 @@ void CExternalPlayer::Pause()
{
}

bool CExternalPlayer::IsPaused() const
{
return false;
}

bool CExternalPlayer::HasVideo() const
{
return true;
Expand Down
3 changes: 1 addition & 2 deletions xbmc/cores/ExternalPlayer/ExternalPlayer.h
Expand Up @@ -38,8 +38,7 @@ class CExternalPlayer : public IPlayer, public CThread
virtual bool OpenFile(const CFileItem& file, const CPlayerOptions &options);
virtual bool CloseFile(bool reopen = false);
virtual bool IsPlaying() const;
virtual void Pause();
virtual bool IsPaused() const;
virtual void Pause() override;
virtual bool HasVideo() const;
virtual bool HasAudio() const;
virtual void ToggleOSD() { }; // empty
Expand Down
1 change: 0 additions & 1 deletion xbmc/cores/IPlayer.h
Expand Up @@ -244,7 +244,6 @@ class IPlayer
virtual bool IsPlaying() const { return false;}
virtual bool CanPause() { return true; };
virtual void Pause() = 0;
virtual bool IsPaused() const = 0;
virtual bool HasVideo() const = 0;
virtual bool HasAudio() const = 0;
virtual bool HasRDS() const { return false; }
Expand Down
24 changes: 4 additions & 20 deletions xbmc/cores/VideoPlayer/VideoPlayer.cpp
Expand Up @@ -2977,35 +2977,19 @@ bool CVideoPlayer::CanPause()

void CVideoPlayer::Pause()
{
CSingleLock lock(m_StateSection);
if (!m_State.canpause)
return;
lock.Leave();

if(m_playSpeed != DVD_PLAYSPEED_PAUSE && IsCaching())
// toggle between pause and normal speed
if (GetSpeed() == 0)
{
SetCaching(CACHESTATE_DONE);
return;
}

// return to normal speed if it was paused before, pause otherwise
if (m_playSpeed == DVD_PLAYSPEED_PAUSE)
{
SetPlaySpeed(DVD_PLAYSPEED_NORMAL);
SetSpeed(1);
m_callback.OnPlayBackResumed();
}
else
{
SetPlaySpeed(DVD_PLAYSPEED_PAUSE);
SetSpeed(0);
m_callback.OnPlayBackPaused();
}
}

bool CVideoPlayer::IsPaused() const
{
return m_playSpeed == DVD_PLAYSPEED_PAUSE || IsCaching();
}

bool CVideoPlayer::HasVideo() const
{
return m_HasVideo;
Expand Down
3 changes: 1 addition & 2 deletions xbmc/cores/VideoPlayer/VideoPlayer.h
Expand Up @@ -242,8 +242,7 @@ class CVideoPlayer : public IPlayer, public CThread, public IVideoPlayer, public
virtual bool OpenFile(const CFileItem& file, const CPlayerOptions &options);
virtual bool CloseFile(bool reopen = false);
virtual bool IsPlaying() const;
virtual void Pause();
virtual bool IsPaused() const;
virtual void Pause() override;
virtual bool HasVideo() const;
virtual bool HasAudio() const;
virtual bool HasRDS() const;
Expand Down
5 changes: 0 additions & 5 deletions xbmc/cores/paplayer/PAPlayer.cpp
Expand Up @@ -915,11 +915,6 @@ bool PAPlayer::IsPlaying() const
return m_isPlaying;
}

bool PAPlayer::IsPaused() const
{
return m_isPaused;
}

void PAPlayer::Pause()
{
if (m_isPaused)
Expand Down
3 changes: 1 addition & 2 deletions xbmc/cores/paplayer/PAPlayer.h
Expand Up @@ -50,8 +50,7 @@ friend class CQueueNextFileJob;
virtual void OnNothingToQueueNotify();
virtual bool CloseFile(bool reopen = false);
virtual bool IsPlaying() const;
virtual void Pause();
virtual bool IsPaused() const;
virtual void Pause() override;
virtual bool HasVideo() const { return false; }
virtual bool HasAudio() const { return true; }
virtual bool CanSeek();
Expand Down
7 changes: 5 additions & 2 deletions xbmc/network/upnp/UPnPPlayer.cpp
Expand Up @@ -604,12 +604,15 @@ bool CUPnPPlayer::OnAction(const CAction &action)

void CUPnPPlayer::SetSpeed(int iSpeed)
{
m_playspeed = 1;

}

int CUPnPPlayer::GetSpeed()
{
return m_playspeed;
if (IsPaused())
return 0;
else
return 1;
}

} /* namespace UPNP */
6 changes: 3 additions & 3 deletions xbmc/network/upnp/UPnPPlayer.h
Expand Up @@ -44,8 +44,7 @@ class CUPnPPlayer
virtual bool QueueNextFile(const CFileItem &file);
virtual bool CloseFile(bool reopen = false);
virtual bool IsPlaying() const;
virtual void Pause();
virtual bool IsPaused() const;
virtual void Pause() override;
virtual bool HasVideo() const { return false; }
virtual bool HasAudio() const { return false; }
virtual void Seek(bool bPlus, bool bLargeStep, bool bChapterOverride);
Expand Down Expand Up @@ -80,13 +79,14 @@ class CUPnPPlayer
int PlayFile(const CFileItem& file, const CPlayerOptions& options, CGUIDialogBusy*& dialog, XbmcThreads::EndTime& timeout);

private:
bool IsPaused() const;

PLT_MediaController* m_control;
CUPnPPlayerController* m_delegate;
std::string m_current_uri;
std::string m_current_meta;
bool m_started;
bool m_stopremote;
int m_playspeed;
};

} /* namespace UPNP */

0 comments on commit 6a5120c

Please sign in to comment.