<ClCompile Include="..\..\xbmc\addons\Skin.cpp" />
<ClCompile Include="..\..\xbmc\Application.cpp" />
<ClCompile Include="..\..\xbmc\ApplicationMessenger.cpp" />
+ <ClCompile Include="..\..\xbmc\ApplicationPlayer.cpp" />
<ClCompile Include="..\..\xbmc\AppParamParser.cpp" />
<ClCompile Include="..\..\xbmc\Autorun.cpp" />
<ClCompile Include="..\..\xbmc\AutoSwitch.cpp" />
<ClCompile Include="..\..\xbmc\TextureDatabase.cpp" />
<ClCompile Include="..\..\xbmc\DatabaseManager.cpp" />
<ClInclude Include="..\..\xbmc\addons\AddonCallbacksCodec.h" />
+ <ClInclude Include="..\..\xbmc\ApplicationPlayer.h" />
<ClInclude Include="..\..\xbmc\AppParamParser.h" />
<ClInclude Include="..\..\xbmc\cores\AudioEngine\AEAudioFormat.h" />
<ClInclude Include="..\..\xbmc\cores\AudioEngine\AEFactory.h" />
<ClCompile Include="..\..\xbmc\utils\ActorProtocol.cpp">
<Filter>utils</Filter>
</ClCompile>
+ <ClCompile Include="..\..\xbmc\ApplicationPlayer.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\xbmc\win32\pch.h">
<ClInclude Include="..\..\xbmc\utils\ActorProtocol.h">
<Filter>utils</Filter>
</ClInclude>
+ <ClInclude Include="..\..\xbmc\ApplicationPlayer.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\xbmc\win32\XBMC_PC.rc">
//extern IDirectSoundRenderer* m_pAudioDecoder;
CApplication::CApplication(void)
- : m_pPlayer()
+ : m_pPlayer(new CApplicationPlayer)
, m_itemCurrentFile(new CFileItem)
, m_stackFileItemToUpdate(new CFileItem)
, m_progressTrackingVideoResumeBookmark(*new CBookmark)
m_eForcedNextPlayer = EPC_NONE;
m_strPlayListFile = "";
m_nextPlaylistItem = -1;
- m_iPlayerOPSeq = 0;
m_bPlaybackStarting = false;
m_ePlayState = PLAY_STATE_NONE;
m_skinReloading = false;
m_splash = NULL;
m_threadID = 0;
- m_eCurrentPlayer = EPC_NONE;
m_progressTrackingPlayCountUpdate = false;
m_currentStackPosition = 0;
m_lastFrameTime = 0;
delete m_seekHandler;
delete m_playerController;
delete m_pInertialScrollingHandler;
+ delete m_pPlayer;
}
bool CApplication::OnEvent(XBMC_Event& newEvent)
bool bPreviousPlayingState=false;
bool bPreviousRenderingState=false;
- if (g_application.m_pPlayer && g_application.IsPlayingVideo())
+ if (g_application.IsPlayingVideo())
{
- bPreviousPlayingState = !g_application.m_pPlayer->IsPaused();
+ bPreviousPlayingState = !g_application.IsPaused();
if (bPreviousPlayingState)
g_application.m_pPlayer->Pause();
#ifdef HAS_VIDEO_PLAYBACK
}
}
- if (g_application.m_pPlayer && g_application.IsPlayingVideo())
+ if (g_application.IsPlayingVideo())
{
if (bPreviousPlayingState)
g_application.m_pPlayer->Pause();
// Less fps in DPMS
bool lowfps = m_dpmsIsActive || g_Windowing.EnableFrameLimiter();
// Whether externalplayer is playing and we're unfocused
- bool extPlayerActive = m_eCurrentPlayer == EPC_EXTPLAYER && IsPlaying() && !m_AppFocused;
+ bool extPlayerActive = m_pPlayer->GetCurrentPlayer() == EPC_EXTPLAYER && IsPlaying() && !m_AppFocused;
m_bPresentFrame = false;
if (!extPlayerActive && g_graphicsContext.IsFullScreenVideo() && !IsPaused() && g_renderManager.RendererHandlesPresent())
if (iWin == WINDOW_FULLSCREEN_VIDEO)
{
// current active window is full screen video.
- if (g_application.m_pPlayer && g_application.m_pPlayer->IsInMenu())
+ if (g_application.m_pPlayer->IsInMenu())
{
// if player is in some sort of menu, (ie DVDMENU) map buttons differently
action = CButtonTranslator::GetInstance().GetAction(WINDOW_VIDEO_MENU, key);
// Now check with the playlist player if action can be handled.
// In case of the action PREV_ITEM, we only allow the playlist player to take it if we're less than 3 seconds into playback.
- if (!(action.GetID() == ACTION_PREV_ITEM && m_pPlayer && m_pPlayer->CanSeek() && GetTime() > 3) )
+ if (!(action.GetID() == ACTION_PREV_ITEM && m_pPlayer->CanSeek() && GetTime() > 3) )
{
if (g_playlistPlayer.OnAction(action))
return true;
if (g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO ||
(g_windowManager.GetActiveWindow() == WINDOW_DIALOG_VIDEO_OSD && (action.GetID() == ACTION_NEXT_ITEM || action.GetID() == ACTION_PREV_ITEM || action.GetID() == ACTION_CHANNEL_UP || action.GetID() == ACTION_CHANNEL_DOWN)))
{
- if (m_pPlayer != NULL && m_pPlayer->OnAction(action))
+ if (m_pPlayer->OnAction(action))
return true;
}
// In case the playlist player nor the player didn't handle PREV_ITEM, because we are past the 3 secs limit.
// If so, we just jump to the start of the track.
- if (action.GetID() == ACTION_PREV_ITEM && m_pPlayer && m_pPlayer->CanSeek())
+ if (action.GetID() == ACTION_PREV_ITEM && m_pPlayer->CanSeek())
{
SeekTime(0);
SetPlaySpeed(1);
// Check for global volume control
if (action.GetAmount() && (action.GetID() == ACTION_VOLUME_UP || action.GetID() == ACTION_VOLUME_DOWN))
{
- if (!m_pPlayer || !m_pPlayer->IsPassthrough())
+ if (!m_pPlayer->IsPassthrough())
{
if (m_muted)
UnMute();
if (iWin == WINDOW_FULLSCREEN_VIDEO)
{
// check if we're in a DVD menu
- if(g_application.m_pPlayer && g_application.m_pPlayer->IsInMenu())
+ if(g_application.m_pPlayer->IsInMenu())
iWin = WINDOW_VIDEO_MENU;
// check for LiveTV and switch to it's virtual window
else if (g_PVRManager.IsStarted() && g_application.CurrentFileItem().HasPVRChannelInfoTag())
StopServices();
//Sleep(5000);
- if (m_pPlayer)
- {
- CLog::Log(LOGNOTICE, "stop player");
- ++m_iPlayerOPSeq;
- m_pPlayer->CloseFile();
- m_pPlayer.reset();
- }
+ CLog::Log(LOGNOTICE, "stop player");
+ m_pPlayer->ClosePlayer();
#if HAS_FILESYTEM_DAAP
CLog::Log(LOGNOTICE, "stop daap clients");
*m_itemCurrentFile = item;
m_currentStackPosition = 0;
- m_eCurrentPlayer = EPC_NONE; // must be reset on initial play otherwise last player will be used
+ m_pPlayer->ResetPlayer(); // must be reset on initial play otherwise last player will be used
if (seconds > 0)
{
// Make sure it doesn't have a player
// so we actually select one normally
- m_eCurrentPlayer = EPC_NONE;
+ m_pPlayer->ResetPlayer();
// keep the tuxbox:// url as playing url
// and give the new url to the player
if( m_eForcedNextPlayer != EPC_NONE )
eNewCore = m_eForcedNextPlayer;
- else if( m_eCurrentPlayer == EPC_NONE )
+ else if( m_pPlayer->GetCurrentPlayer() == EPC_NONE )
eNewCore = CPlayerCoreFactory::Get().GetDefaultPlayer(item);
else
- eNewCore = m_eCurrentPlayer;
+ eNewCore = m_pPlayer->GetCurrentPlayer();
}
else
{
// We should restart the player, unless the previous and next tracks are using
// one of the players that allows gapless playback (paplayer, dvdplayer)
- if (m_pPlayer)
- {
- if ( !(m_eCurrentPlayer == eNewCore && (m_eCurrentPlayer == EPC_DVDPLAYER || m_eCurrentPlayer == EPC_PAPLAYER
-#if defined(HAS_OMXPLAYER)
- || m_eCurrentPlayer == EPC_OMXPLAYER
-#endif
- )) )
- {
- ++m_iPlayerOPSeq;
- m_pPlayer->CloseFile();
- m_pPlayer.reset();
- }
- else
- {
- // XXX: we had to stop the previous playing item, it was done in dvdplayer::OpenFile.
- // but in paplayer::OpenFile, it sometimes just fade in without call CloseFile.
- // but if we do not stop it, we can not distingush callbacks from previous
- // item and current item, it will confused us then we can not make correct delay
- // callback after the starting state.
- ++m_iPlayerOPSeq;
- m_pPlayer->CloseFile();
- }
- }
+ m_pPlayer->ClosePlayerGapless(eNewCore);
// now reset play state to starting, since we already stopped the previous playing item if there is.
// and from now there should be no playback callback from previous playing item be called.
m_ePlayState = PLAY_STATE_STARTING;
- if (!m_pPlayer)
- {
- m_eCurrentPlayer = eNewCore;
- m_pPlayer.reset(CPlayerCoreFactory::Get().CreatePlayer(eNewCore, *this));
- }
+ m_pPlayer->CreatePlayer(eNewCore, *this);
PlayBackRet iResult;
- if (m_pPlayer)
+ if (m_pPlayer->HasPlayer())
{
/* When playing video pause any low priority jobs, they will be unpaused when playback stops.
* This should speed up player startup for files on internet filesystems (eg. webdav) and
// don't hold graphicscontext here since player
// may wait on another thread, that requires gfx
CSingleExit ex(g_graphicsContext);
- // In busy dialog of OpenFile there's a chance to call another place delete the player
- // e.g. another PlayFile call switch player.
- // Here we use a holdPlace to keep the player not be deleted during OpenFile call
- boost::shared_ptr<IPlayer> holdPlace(m_pPlayer);
- // op seq for detect cancel (CloseFile be called or OpenFile be called again) during OpenFile.
- unsigned int startingSeq = ++m_iPlayerOPSeq;
-
- iResult = m_pPlayer->OpenFile(item, options) ? PLAYBACK_OK : PLAYBACK_FAIL;
- // check whether the OpenFile was canceled by either CloseFile or another OpenFile.
- if (m_iPlayerOPSeq != startingSeq)
- iResult = PLAYBACK_CANCELED;
+
+ iResult = m_pPlayer->OpenFile(item, options);
}
else
{
}
// if player has volume control, set it.
- if (m_pPlayer && m_pPlayer->ControlsVolume())
+ if (m_pPlayer->ControlsVolume())
{
m_pPlayer->SetVolume(m_volumeLevel);
m_pPlayer->SetMute(m_muted);
bool CApplication::IsPlaying() const
{
- if (!m_pPlayer)
- return false;
- if (!m_pPlayer->IsPlaying())
- return false;
- return true;
+ return m_pPlayer->IsPlaying();
}
bool CApplication::IsPaused() const
{
- if (!m_pPlayer)
- return false;
- if (!m_pPlayer->IsPlaying())
- return false;
- return m_pPlayer->IsPaused();
+ return (m_pPlayer->IsPlaying() && m_pPlayer->IsPaused());
}
bool CApplication::IsPlayingAudio() const
{
- if (!m_pPlayer)
- return false;
- if (!m_pPlayer->IsPlaying())
- return false;
- if (m_pPlayer->HasVideo())
- return false;
- if (m_pPlayer->HasAudio())
- return true;
- return false;
+ return (m_pPlayer->IsPlaying() && !m_pPlayer->HasVideo() && m_pPlayer->HasAudio());
}
bool CApplication::IsPlayingVideo() const
{
- if (!m_pPlayer)
- return false;
- if (!m_pPlayer->IsPlaying())
- return false;
- if (m_pPlayer->HasVideo())
- return true;
-
- return false;
+ return (m_pPlayer->IsPlaying() && m_pPlayer->HasVideo());
}
bool CApplication::IsPlayingFullScreenVideo() const
}
// Update bookmark for save
- m_progressTrackingVideoResumeBookmark.player = CPlayerCoreFactory::Get().GetPlayerName(m_eCurrentPlayer);
+ m_progressTrackingVideoResumeBookmark.player = CPlayerCoreFactory::Get().GetPlayerName(m_pPlayer->GetCurrentPlayer());
m_progressTrackingVideoResumeBookmark.playerState = m_pPlayer->GetPlayerState();
m_progressTrackingVideoResumeBookmark.thumbNailImage.Empty();
if (g_PVRManager.IsPlayingTV() || g_PVRManager.IsPlayingRadio())
g_PVRManager.SaveCurrentChannelSettings();
- if (m_pPlayer)
- {
- ++m_iPlayerOPSeq;
- m_pPlayer->CloseFile();
- }
+ m_pPlayer->CloseFile();
// turn off visualisation window when stopping
if ((iWin == WINDOW_VISUALISATION
CPlayList& playlist = g_playlistPlayer.GetPlaylist(g_playlistPlayer.GetCurrentPlaylist());
if (iNext < 0 || iNext >= playlist.size())
{
- if (m_pPlayer) m_pPlayer->OnNothingToQueueNotify();
+ m_pPlayer->OnNothingToQueueNotify();
return true; // nothing to do
}
#endif
// ok - send the file to the player, if it accepts it
- if (m_pPlayer)
+ if (m_pPlayer->QueueNextFile(file))
{
- if (m_pPlayer->QueueNextFile(file))
- {
- // player accepted the next file
- m_nextPlaylistItem = iNext;
- }
- else
- {
- /* Player didn't accept next file: *ALWAYS* advance playlist in this case so the player can
- queue the next (if it wants to) and it doesn't keep looping on this song */
- g_playlistPlayer.SetCurrentSong(iNext);
- }
+ // player accepted the next file
+ m_nextPlaylistItem = iNext;
+ }
+ else
+ {
+ /* Player didn't accept next file: *ALWAYS* advance playlist in this case so the player can
+ queue the next (if it wants to) and it doesn't keep looping on this song */
+ g_playlistPlayer.SetCurrentSong(iNext);
}
return true;
// reset any forced player
m_eForcedNextPlayer = EPC_NONE;
- if (m_pPlayer)
- {
- ++m_iPlayerOPSeq;
- m_pPlayer->CloseFile();
- m_pPlayer.reset();
- }
+ m_pPlayer->ClosePlayer();
// Reset playspeed
m_iPlaySpeed = 1;
CheckPlayingProgress();
// update sound
- if (m_pPlayer)
- m_pPlayer->DoAudioWork();
+ m_pPlayer->DoAudioWork();
// do any processing that isn't needed on each run
if( m_slowTimer.GetElapsedMilliseconds() > 500 )
if ( !IsPlayingVideo() && !IsPlayingAudio())
return ;
- if( !m_pPlayer )
+ if( !m_pPlayer->HasPlayer() )
return ;
SaveFileState();
m_itemCurrentFile->m_lStartOffset = (long)(time * 75.0);
// reopen the file
- if ( PlayFile(*m_itemCurrentFile, true) == PLAYBACK_OK && m_pPlayer )
+ if ( PlayFile(*m_itemCurrentFile, true) == PLAYBACK_OK )
m_pPlayer->SetPlayerState(state);
}
CAnnouncementManager::Announce(Application, "xbmc", "OnVolumeChanged", data);
// if player has volume control, set it.
- if (m_pPlayer && m_pPlayer->ControlsVolume())
+ if (m_pPlayer->ControlsVolume())
{
m_pPlayer->SetVolume(m_volumeLevel);
m_pPlayer->SetMute(m_muted);
{
double rc = 0.0;
- if (IsPlaying() && m_pPlayer)
+ if (IsPlaying())
{
if (m_itemCurrentFile->IsStack() && m_currentStack->Size() > 0)
rc = (*m_currentStack)[m_currentStack->Size() - 1]->m_lEndOffset;
{
double rc = 0.0;
- if (IsPlaying() && m_pPlayer)
+ if (IsPlaying())
{
if (m_itemCurrentFile->IsStack() && m_currentStack->Size() > 0)
{
// consistent with GetTime() and GetTotalTime().
void CApplication::SeekTime( double dTime )
{
- if (IsPlaying() && m_pPlayer && (dTime >= 0.0))
+ if (IsPlaying() && (dTime >= 0.0))
{
if (!m_pPlayer->CanSeek()) return;
if (m_itemCurrentFile->IsStack() && m_currentStack->Size() > 0)
float CApplication::GetPercentage() const
{
- if (IsPlaying() && m_pPlayer)
+ if (IsPlaying())
{
if (m_pPlayer->GetTotalTime() == 0 && IsPlayingAudio() && m_itemCurrentFile->HasMusicInfoTag())
{
float CApplication::GetCachePercentage() const
{
- if (IsPlaying() && m_pPlayer)
+ if (IsPlaying())
{
// Note that the player returns a relative cache percentage and we want an absolute percentage
if (m_itemCurrentFile->IsStack() && m_currentStack->Size() > 0)
void CApplication::SeekPercentage(float percent)
{
- if (IsPlaying() && m_pPlayer && (percent >= 0.0))
+ if (IsPlaying() && (percent >= 0.0))
{
if (!m_pPlayer->CanSeek()) return;
if (m_itemCurrentFile->IsStack() && m_currentStack->Size() > 0)
PLAYERCOREID CApplication::GetCurrentPlayer()
{
- return m_eCurrentPlayer;
+ return m_pPlayer->GetCurrentPlayer();
}
void CApplication::UpdateLibraries()
#include "windowing/XBMC_events.h"
#include "threads/Thread.h"
+#include "ApplicationPlayer.h"
+
class CSeekHandler;
class CKaraokeLyricsManager;
class CInertialScrollingHandler;
int m_iPlayList;
};
-typedef enum
-{
- PLAYBACK_CANCELED = -1,
- PLAYBACK_FAIL = 0,
- PLAYBACK_OK = 1,
-} PlayBackRet;
-
class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMsgTargetCallback,
public ISettingCallback, public ISettingsHandler, public ISubSettings
{
+ friend class CApplicationPlayer;
public:
enum ESERVERS
MEDIA_DETECT::CDetectDVDMedia m_DetectDVDType;
#endif
- boost::shared_ptr<IPlayer> m_pPlayer;
+ CApplicationPlayer* m_pPlayer;
inline bool IsInScreenSaver() { return m_bScreenSave; };
int m_iScreenSaveLock; // spiff: are we checking for a lock? if so, ignore the screensaver state, if -1 we have failed to input locks
- unsigned int m_iPlayerOPSeq; // used to detect whether an OpenFile request on player is canceled by us.
bool m_bPlaybackStarting;
typedef enum
{
CStdString m_prevMedia;
CSplash* m_splash;
ThreadIdentifier m_threadID; // application thread ID. Used in applicationMessanger to know where we are firing a thread with delay from.
- PLAYERCOREID m_eCurrentPlayer;
bool m_bInitializing;
bool m_bPlatformDirectories;
break;
case TMSG_MEDIA_PAUSE:
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
g_application.ResetScreenSaver();
g_application.WakeUpScreenSaverAndDPMS();
--- /dev/null
+/*
+ * Copyright (C) 2005-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ApplicationPlayer.h"
+#include "cores/IPlayer.h"
+
+CApplicationPlayer::CApplicationPlayer()
+{
+ m_iPlayerOPSeq = 0;
+ m_eCurrentPlayer = EPC_NONE;
+}
+
+boost::shared_ptr<IPlayer> CApplicationPlayer::GetInternal() const
+{
+ CSingleLock lock(m_player_lock);
+ return m_pPlayer;
+}
+
+void CApplicationPlayer::ClosePlayer()
+{
+ CSingleLock lock(m_player_lock);
+ if (m_pPlayer)
+ {
+ CloseFile();
+ m_pPlayer.reset();
+ }
+}
+
+void CApplicationPlayer::CloseFile()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ {
+ ++m_iPlayerOPSeq;
+ player->CloseFile();
+ }
+}
+
+void CApplicationPlayer::ClosePlayerGapless(PLAYERCOREID newCore)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (!player)
+ return;
+
+ bool gaplessSupported = (m_eCurrentPlayer == EPC_DVDPLAYER || m_eCurrentPlayer == EPC_PAPLAYER);
+#if defined(HAS_OMXPLAYER)
+ gaplessSupported = gaplessSupported || (m_eCurrentPlayer == EPC_OMXPLAYER);
+#endif
+ gaplessSupported = gaplessSupported && (m_eCurrentPlayer == newCore);
+ if (!gaplessSupported)
+ {
+ ClosePlayer();
+ }
+ else
+ {
+ // XXX: we had to stop the previous playing item, it was done in dvdplayer::OpenFile.
+ // but in paplayer::OpenFile, it sometimes just fade in without call CloseFile.
+ // but if we do not stop it, we can not distingush callbacks from previous
+ // item and current item, it will confused us then we can not make correct delay
+ // callback after the starting state.
+ CloseFile();
+ }
+}
+
+void CApplicationPlayer::CreatePlayer(PLAYERCOREID newCore, IPlayerCallback& callback)
+{
+ CSingleLock lock(m_player_lock);
+ if (!m_pPlayer)
+ {
+ m_eCurrentPlayer = newCore;
+ m_pPlayer.reset(CPlayerCoreFactory::Get().CreatePlayer(newCore, callback));
+ }
+}
+
+PlayBackRet CApplicationPlayer::OpenFile(const CFileItem& item, const CPlayerOptions& options)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ PlayBackRet iResult = PLAYBACK_FAIL;
+ if (player)
+ {
+ // op seq for detect cancel (CloseFile be called or OpenFile be called again) during OpenFile.
+ unsigned int startingSeq = ++m_iPlayerOPSeq;
+
+ iResult = player->OpenFile(item, options) ? PLAYBACK_OK : PLAYBACK_FAIL;
+ // check whether the OpenFile was canceled by either CloseFile or another OpenFile.
+ if (m_iPlayerOPSeq != startingSeq)
+ iResult = PLAYBACK_CANCELED;
+ }
+ return iResult;
+}
+
+bool CApplicationPlayer::HasPlayer() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return player != NULL;
+}
+
+void CApplicationPlayer::RegisterAudioCallback(IAudioCallback* pCallback)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->RegisterAudioCallback(pCallback);
+}
+
+void CApplicationPlayer::UnRegisterAudioCallback()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->UnRegisterAudioCallback();
+}
+
+int CApplicationPlayer::GetChapter()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetChapter();
+ else
+ return -1;
+}
+
+int CApplicationPlayer::GetChapterCount()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetChapterCount();
+ else
+ return 0;
+}
+
+void CApplicationPlayer::GetChapterName(CStdString& strChapterName)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->GetChapterName(strChapterName);
+}
+
+bool CApplicationPlayer::HasAudio() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->HasAudio());
+}
+
+bool CApplicationPlayer::HasVideo() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->HasVideo());
+}
+
+bool CApplicationPlayer::IsPaused() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->IsPaused());
+}
+
+bool CApplicationPlayer::IsPlaying() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->IsPlaying());
+}
+
+void CApplicationPlayer::Pause()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->Pause();
+}
+
+bool CApplicationPlayer::ControlsVolume() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->ControlsVolume());
+}
+
+void CApplicationPlayer::SetMute(bool bOnOff)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->SetMute(bOnOff);
+}
+
+void CApplicationPlayer::SetVolume(float volume)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->SetVolume(volume);
+}
+
+void CApplicationPlayer::Seek(bool bPlus, bool bLargeStep)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->Seek(bPlus, bLargeStep);
+}
+
+void CApplicationPlayer::SeekPercentage(float fPercent)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->SeekPercentage(fPercent);
+}
+
+bool CApplicationPlayer::IsPassthrough() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->IsPassthrough());
+}
+
+bool CApplicationPlayer::CanSeek()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->CanSeek());
+}
+
+bool CApplicationPlayer::SeekScene(bool bPlus)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->SeekScene(bPlus));
+}
+
+void CApplicationPlayer::SeekTime(int64_t iTime)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->SeekTime(iTime);
+}
+
+CStdString CApplicationPlayer::GetPlayingTitle()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetPlayingTitle();
+ else
+ return "";
+}
+
+int64_t CApplicationPlayer::GetTime() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetTime();
+ else
+ return 0;
+}
+
+int CApplicationPlayer::GetPictureHeight()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetPictureHeight();
+ else
+ return 0;
+}
+
+int CApplicationPlayer::GetPictureWidth()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetPictureWidth();
+ else
+ return 0;
+}
+
+int CApplicationPlayer::GetSampleRate()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetSampleRate();
+ else
+ return 0;
+}
+
+bool CApplicationPlayer::IsCaching() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->IsCaching());
+}
+
+bool CApplicationPlayer::IsInMenu() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->IsInMenu());
+}
+
+bool CApplicationPlayer::HasMenu() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->HasMenu());
+}
+
+int CApplicationPlayer::GetCacheLevel() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetCacheLevel();
+ else
+ return 0;
+}
+
+int CApplicationPlayer::GetSubtitleCount()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetSubtitleCount();
+ else
+ return 0;
+}
+
+int CApplicationPlayer::GetBitsPerSample()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetBitsPerSample();
+ else
+ return 0;
+}
+
+int CApplicationPlayer::GetAudioStream()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetAudioStream();
+ else
+ return 0;
+}
+
+int CApplicationPlayer::GetSubtitle()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetSubtitle();
+ else
+ return 0;
+}
+
+bool CApplicationPlayer::GetSubtitleVisible()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->GetSubtitleVisible());
+}
+
+bool CApplicationPlayer::CanRecord()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->CanRecord());
+}
+
+bool CApplicationPlayer::CanPause()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->CanPause());
+}
+
+bool CApplicationPlayer::IsRecording() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->IsRecording());
+}
+
+TextCacheStruct_t* CApplicationPlayer::GetTeletextCache()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetTeletextCache();
+ else
+ return NULL;
+}
+
+int64_t CApplicationPlayer::GetTotalTime() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetTotalTime();
+ else
+ return 0;
+}
+
+float CApplicationPlayer::GetPercentage() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetPercentage();
+ else
+ return 0.0;
+}
+
+float CApplicationPlayer::GetCachePercentage() const
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetCachePercentage();
+ else
+ return 0.0;
+}
+
+void CApplicationPlayer::ToFFRW(int iSpeed)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->ToFFRW(iSpeed);
+}
+
+void CApplicationPlayer::DoAudioWork()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->DoAudioWork();
+}
+
+CStdString CApplicationPlayer::GetPlayerState()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetPlayerState();
+ else
+ return "";
+}
+
+bool CApplicationPlayer::QueueNextFile(const CFileItem &file)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->QueueNextFile(file));
+}
+
+bool CApplicationPlayer::GetStreamDetails(CStreamDetails &details)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->GetStreamDetails(details));
+}
+
+bool CApplicationPlayer::SetPlayerState(CStdString state)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->SetPlayerState(state));
+}
+
+void CApplicationPlayer::OnNothingToQueueNotify()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->OnNothingToQueueNotify();
+}
+
+void CApplicationPlayer::GetVideoStreamInfo(SPlayerVideoStreamInfo &info)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->GetVideoStreamInfo(info);
+}
+
+void CApplicationPlayer::GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->GetAudioStreamInfo(index, info);
+}
+
+bool CApplicationPlayer::OnAction(const CAction &action)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->OnAction(action));
+}
+
+bool CApplicationPlayer::Record(bool bOnOff)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->Record(bOnOff));
+}
+
+int CApplicationPlayer::GetAudioStreamCount()
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->GetAudioStreamCount();
+ else
+ return 0;
+}
+
+void CApplicationPlayer::SetAudioStream(int iStream)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->SetAudioStream(iStream);
+}
+
+void CApplicationPlayer::GetSubtitleStreamInfo(int index, SPlayerSubtitleStreamInfo &info)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->GetSubtitleStreamInfo(index, info);
+}
+
+void CApplicationPlayer::SetSubtitle(int iStream)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->SetSubtitle(iStream);
+}
+
+void CApplicationPlayer::SetSubtitleVisible(bool bVisible)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->SetSubtitleVisible(bVisible);
+}
+
+int CApplicationPlayer::AddSubtitle(const CStdString& strSubPath)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->AddSubtitle(strSubPath);
+ else
+ return 0;
+}
+
+void CApplicationPlayer::SetSubTitleDelay(float fValue)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->SetSubTitleDelay(fValue);
+}
+
+void CApplicationPlayer::SetAVDelay(float fValue)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->SetAVDelay(fValue);
+}
+
+void CApplicationPlayer::SetDynamicRangeCompression(long drc)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->SetDynamicRangeCompression(drc);
+}
+
+bool CApplicationPlayer::SwitchChannel(const PVR::CPVRChannel &channel)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->SwitchChannel(channel));
+}
+
+void CApplicationPlayer::LoadPage(int p, int sp, unsigned char* buffer)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->LoadPage(p, sp, buffer);
+}
+
+void CApplicationPlayer::GetAudioCapabilities(std::vector<int> &audioCaps)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->GetAudioCapabilities(audioCaps);
+}
+
+void CApplicationPlayer::GetSubtitleCapabilities(std::vector<int> &subCaps)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->GetSubtitleCapabilities(subCaps);
+}
+
+void CApplicationPlayer::GetAudioInfo( CStdString& strAudioInfo)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->GetAudioInfo(strAudioInfo);
+}
+
+void CApplicationPlayer::GetVideoInfo( CStdString& strVideoInfo)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->GetVideoInfo(strVideoInfo);
+}
+
+void CApplicationPlayer::GetGeneralInfo( CStdString& strVideoInfo)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->GetGeneralInfo(strVideoInfo);
+}
+
+bool CApplicationPlayer::GetCurrentSubtitle(CStdString& strSubtitle)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ return (player && player->GetCurrentSubtitle(strSubtitle));
+}
+
+int CApplicationPlayer::SeekChapter(int iChapter)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ return player->SeekChapter(iChapter);
+ else
+ return 0;
+}
+
+void CApplicationPlayer::GetRenderFeatures(std::vector<int> &renderFeatures)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->GetRenderFeatures(renderFeatures);
+}
+
+void CApplicationPlayer::GetDeinterlaceMethods(std::vector<int> &deinterlaceMethods)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->GetDeinterlaceMethods(deinterlaceMethods);
+}
+
+void CApplicationPlayer::GetDeinterlaceModes(std::vector<int> &deinterlaceModes)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->GetDeinterlaceModes(deinterlaceModes);
+}
+
+void CApplicationPlayer::GetScalingMethods(std::vector<int> &scalingMethods)
+{
+ boost::shared_ptr<IPlayer> player = GetInternal();
+ if (player)
+ player->GetScalingMethods(scalingMethods);
+}
+
+void CApplicationPlayer::SetPlaySpeed(int iSpeed)
+{
+ if (!IsPlayingAudio() && !IsPlayingVideo())
+ return ;
+ if (m_iPlaySpeed == iSpeed)
+ return ;
+ if (!CanSeek())
+ return;
+ if (IsPaused())
+ {
+ if (
+ ((m_iPlaySpeed > 1) && (iSpeed > m_iPlaySpeed)) ||
+ ((m_iPlaySpeed < -1) && (iSpeed < m_iPlaySpeed))
+ )
+ {
+ iSpeed = m_iPlaySpeed; // from pause to ff/rw, do previous ff/rw speed
+ }
+ Pause();
+ }
+ m_iPlaySpeed = iSpeed;
+
+ ToFFRW(m_iPlaySpeed);
+
+ // if player has volume control, set it.
+ if (ControlsVolume())
+ {
+ if (m_iPlaySpeed == 1)
+ { // restore volume
+ m_pPlayer->SetVolume(VOLUME_MAXIMUM);
+ }
+ else
+ { // mute volume
+ m_pPlayer->SetVolume(VOLUME_MINIMUM);
+ }
+ m_pPlayer->SetMute(g_application.m_muted);
+ }
+}
+
+int CApplicationPlayer::GetPlaySpeed() const
+{
+ return m_iPlaySpeed;
+}
+
--- /dev/null
+#pragma once
+
+/*
+ * Copyright (C) 2005-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <boost/shared_ptr.hpp>
+#include "threads/SingleLock.h"
+#include "cores/playercorefactory/PlayerCoreFactory.h"
+
+typedef enum
+{
+ PLAYBACK_CANCELED = -1,
+ PLAYBACK_FAIL = 0,
+ PLAYBACK_OK = 1,
+} PlayBackRet;
+
+namespace PVR
+{
+ class CPVRChannel;
+}
+
+class IAudioCallback;
+class CAction;
+class CPlayerOptions;
+class CStreamDetails;
+
+struct SPlayerAudioStreamInfo;
+struct SPlayerVideoStreamInfo;
+struct SPlayerSubtitleStreamInfo;
+struct TextCacheStruct_t;
+
+class CApplicationPlayer
+{
+ boost::shared_ptr<IPlayer> m_pPlayer;
+ unsigned int m_iPlayerOPSeq; // used to detect whether an OpenFile request on player is canceled by us.
+ PLAYERCOREID m_eCurrentPlayer;
+
+ CCriticalSection m_player_lock;
+
+public:
+ CApplicationPlayer();
+
+ // player management
+ void CloseFile();
+ void ClosePlayer();
+ void ClosePlayerGapless(PLAYERCOREID newCore);
+ void CreatePlayer(PLAYERCOREID newCore, IPlayerCallback& callback);
+ bool HasPlayer() const;
+ PLAYERCOREID GetCurrentPlayer() const { return m_eCurrentPlayer; }
+ boost::shared_ptr<IPlayer> GetInternal() const;
+ PlayBackRet OpenFile(const CFileItem& item, const CPlayerOptions& options);
+ void ResetPlayer() { m_eCurrentPlayer = EPC_NONE; }
+
+ // proxy calls
+ int AddSubtitle(const CStdString& strSubPath);
+ bool CanPause();
+ bool CanRecord();
+ bool CanSeek();
+ bool ControlsVolume() const;
+ void DoAudioWork();
+ void GetAudioCapabilities(std::vector<int> &audioCaps);
+ void GetAudioInfo( CStdString& strAudioInfo);
+ int GetAudioStream();
+ int GetAudioStreamCount();
+ void GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info);
+ int GetBitsPerSample();
+ int GetCacheLevel() const;
+ float GetCachePercentage() const;
+ int GetChapterCount();
+ int GetChapter();
+ void GetChapterName(CStdString& strChapterName);
+ void GetDeinterlaceMethods(std::vector<int> &deinterlaceMethods);
+ void GetDeinterlaceModes(std::vector<int> &deinterlaceModes);
+ bool GetCurrentSubtitle(CStdString& strSubtitle);
+ void GetGeneralInfo( CStdString& strVideoInfo);
+ float GetPercentage() const;
+ int GetPictureHeight();
+ int GetPictureWidth();
+ CStdString GetPlayerState();
+ CStdString GetPlayingTitle();
+ void GetRenderFeatures(std::vector<int> &renderFeatures);
+ int GetSampleRate();
+ void GetScalingMethods(std::vector<int> &scalingMethods);
+ bool GetStreamDetails(CStreamDetails &details);
+ int GetSubtitle();
+ void GetSubtitleCapabilities(std::vector<int> &subCaps);
+ int GetSubtitleCount();
+ void GetSubtitleStreamInfo(int index, SPlayerSubtitleStreamInfo &info);
+ bool GetSubtitleVisible();
+ TextCacheStruct_t* GetTeletextCache();
+ int64_t GetTime() const;
+ int64_t GetTotalTime() const;
+ void GetVideoInfo( CStdString& strVideoInfo);
+ void GetVideoStreamInfo(SPlayerVideoStreamInfo &info);
+ bool HasAudio() const;
+ bool HasMenu() const;
+ bool HasVideo() const;
+ bool IsCaching() const;
+ bool IsInMenu() const;
+ bool IsPaused() const;
+ bool IsPassthrough() const;
+ bool IsPlaying() const;
+ bool IsRecording() const;
+ void LoadPage(int p, int sp, unsigned char* buffer);
+ bool OnAction(const CAction &action);
+ void OnNothingToQueueNotify();
+ void Pause();
+ bool QueueNextFile(const CFileItem &file);
+ bool Record(bool bOnOff);
+ void RegisterAudioCallback(IAudioCallback* pCallback);
+ void Seek(bool bPlus = true, bool bLargeStep = false);
+ int SeekChapter(int iChapter);
+ void SeekPercentage(float fPercent = 0);
+ bool SeekScene(bool bPlus = true);
+ void SeekTime(int64_t iTime = 0);
+ void SetAudioStream(int iStream);
+ void SetAVDelay(float fValue = 0.0f);
+ void SetDynamicRangeCompression(long drc);
+ void SetMute(bool bOnOff);
+ bool SetPlayerState(CStdString state);
+ void SetSubtitle(int iStream);
+ void SetSubTitleDelay(float fValue = 0.0f);
+ void SetSubtitleVisible(bool bVisible);
+ void SetVolume(float volume);
+ bool SwitchChannel(const PVR::CPVRChannel &channel);
+ void ToFFRW(int iSpeed = 0);
+ void UnRegisterAudioCallback();
+};
strLabel.Format("%2.3f s", CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay);
break;
case PLAYER_CHAPTER:
- if(g_application.IsPlaying() && g_application.m_pPlayer)
+ if(g_application.IsPlaying())
strLabel.Format("%02d", g_application.m_pPlayer->GetChapter());
break;
case PLAYER_CHAPTERCOUNT:
- if(g_application.IsPlaying() && g_application.m_pPlayer)
+ if(g_application.IsPlaying())
strLabel.Format("%02d", g_application.m_pPlayer->GetChapterCount());
break;
case PLAYER_CHAPTERNAME:
- if(g_application.IsPlaying() && g_application.m_pPlayer)
+ if(g_application.IsPlaying())
g_application.m_pPlayer->GetChapterName(strLabel);
break;
case PLAYER_CACHELEVEL:
}
break;
case PLAYER_TIME:
- if(g_application.IsPlaying() && g_application.m_pPlayer)
+ if(g_application.IsPlaying())
strLabel = GetCurrentPlayTime(TIME_FORMAT_HH_MM);
break;
case PLAYER_DURATION:
- if(g_application.IsPlaying() && g_application.m_pPlayer)
+ if(g_application.IsPlaying())
strLabel = GetDuration(TIME_FORMAT_HH_MM);
break;
case PLAYER_PATH:
if (m_currentFile->HasMusicInfoTag() && !m_currentFile->GetMusicInfoTag()->GetTitle().IsEmpty())
return m_currentFile->GetMusicInfoTag()->GetTitle();
// don't have the title, so use dvdplayer, label, or drop down to title from path
- if (g_application.m_pPlayer && !g_application.m_pPlayer->GetPlayingTitle().IsEmpty())
+ if (!g_application.m_pPlayer->GetPlayingTitle().IsEmpty())
return g_application.m_pPlayer->GetPlayingTitle();
if (!m_currentFile->GetLabel().IsEmpty())
return m_currentFile->GetLabel();
}
else
{
- if (g_application.m_pPlayer && !g_application.m_pPlayer->GetPlayingTitle().IsEmpty())
+ if (!g_application.m_pPlayer->GetPlayingTitle().IsEmpty())
return g_application.m_pPlayer->GetPlayingTitle();
}
}
strLabel = GetVideoLabel(info);
break;
case VIDEOPLAYER_VIDEO_CODEC:
- if(g_application.IsPlaying() && g_application.m_pPlayer)
+ if(g_application.IsPlaying())
{
UpdateAVInfo();
strLabel = m_videoInfo.videoCodecName;
}
break;
case VIDEOPLAYER_VIDEO_RESOLUTION:
- if(g_application.IsPlaying() && g_application.m_pPlayer)
+ if(g_application.IsPlaying())
return CStreamDetails::VideoDimsToResolutionDescription(g_application.m_pPlayer->GetPictureWidth(), g_application.m_pPlayer->GetPictureHeight());
break;
case VIDEOPLAYER_AUDIO_CODEC:
- if(g_application.IsPlaying() && g_application.m_pPlayer)
+ if(g_application.IsPlaying())
{
UpdateAVInfo();
strLabel = m_audioInfo.audioCodecName;
}
break;
case VIDEOPLAYER_VIDEO_ASPECT:
- if (g_application.IsPlaying() && g_application.m_pPlayer)
+ if (g_application.IsPlaying())
{
UpdateAVInfo();
strLabel = CStreamDetails::VideoAspectToAspectDescription(m_videoInfo.videoAspectRatio);
}
break;
case VIDEOPLAYER_AUDIO_CHANNELS:
- if(g_application.IsPlaying() && g_application.m_pPlayer)
+ if(g_application.IsPlaying())
{
UpdateAVInfo();
strLabel.Format("%i", m_audioInfo.channels);
}
break;
case VIDEOPLAYER_STEREOSCOPIC_MODE:
- if(g_application.IsPlaying() && g_application.m_pPlayer)
+ if(g_application.m_pPlayer->IsPlaying())
{
UpdateAVInfo();
strLabel = m_videoInfo.stereoMode;
case PLAYER_CHAPTER:
case PLAYER_CHAPTERCOUNT:
{
- if( g_application.IsPlaying() && g_application.m_pPlayer)
+ if( g_application.IsPlaying())
{
switch( info )
{
bReturn = m_playerShowTime;
break;
case PLAYER_PASSTHROUGH:
- bReturn = g_application.m_pPlayer && g_application.m_pPlayer->IsPassthrough();
+ bReturn = g_application.m_pPlayer->IsPassthrough();
break;
case PLAYER_ISINTERNETSTREAM:
bReturn = m_currentFile && URIUtils::IsInternetStream(m_currentFile->GetPath());
}
break;
case VIDEOPLAYER_IS_STEREOSCOPIC:
- if(g_application.IsPlaying() && g_application.m_pPlayer)
+ if(g_application.m_pPlayer->IsPlaying())
{
UpdateAVInfo();
bReturn = !m_videoInfo.stereoMode.empty();
void CGUIInfoManager::UpdateAVInfo()
{
- if(g_application.IsPlaying() && g_application.m_pPlayer)
+ if(g_application.IsPlaying())
{
if (!m_AVInfoValid)
{
CreateBuffers();
- if (g_application.m_pPlayer)
- g_application.m_pPlayer->RegisterAudioCallback(this);
- CAEFactory::RegisterAudioCallback(this);
+ g_application.m_pPlayer->RegisterAudioCallback(this);
return true;
}
void CVisualisation::Stop()
{
- if (g_application.m_pPlayer) g_application.m_pPlayer->UnRegisterAudioCallback();
- CAEFactory::UnregisterAudioCallback();
+ g_application.m_pPlayer->UnRegisterAudioCallback();
if (Initialized())
{
CAddonDll<DllVisualisation, Visualisation, VIS_PROPS>::Stop();
//disable non-linear stretch when a dvd menu is shown, parts of the menu are rendered through the overlay renderer
//having non-linear stretch on breaks the alignment
- if (g_application.m_pPlayer && g_application.m_pPlayer->IsInMenu())
+ if (g_application.m_pPlayer->IsInMenu())
m_pYUVShader->SetNonLinStretch(1.0);
else
m_pYUVShader->SetNonLinStretch(pow(CDisplaySettings::Get().GetPixelRatio(), g_advancedSettings.m_videoNonLinStretchRatio));
//disable non-linear stretch when a dvd menu is shown, parts of the menu are rendered through the overlay renderer
//having non-linear stretch on breaks the alignment
- if (g_application.m_pPlayer && g_application.m_pPlayer->IsInMenu())
+ if (g_application.m_pPlayer->IsInMenu())
m_pVideoFilterShader->SetNonLinStretch(1.0);
else
m_pVideoFilterShader->SetNonLinStretch(pow(CDisplaySettings::Get().GetPixelRatio(), g_advancedSettings.m_videoNonLinStretchRatio));
//disable non-linear stretch when a dvd menu is shown, parts of the menu are rendered through the overlay renderer
//having non-linear stretch on breaks the alignment
- if (g_application.m_pPlayer && g_application.m_pPlayer->IsInMenu())
+ if (g_application.m_pPlayer->IsInMenu())
m_pVideoFilterShader->SetNonLinStretch(1.0);
else
m_pVideoFilterShader->SetNonLinStretch(pow(CDisplaySettings::Get().GetPixelRatio(), g_advancedSettings.m_videoNonLinStretchRatio));
//disable non-linear stretch when a dvd menu is shown, parts of the menu are rendered through the overlay renderer
//having non-linear stretch on breaks the alignment
- if (g_application.m_pPlayer && g_application.m_pPlayer->IsInMenu())
+ if (g_application.m_pPlayer->IsInMenu())
m_pVideoFilterShader->SetNonLinStretch(1.0);
else
m_pVideoFilterShader->SetNonLinStretch(pow(CDisplaySettings::Get().GetPixelRatio(), g_advancedSettings.m_videoNonLinStretchRatio));
void CGUIDialogSeekBar::FrameMove()
{
- if (!g_application.m_pPlayer)
+ if (!g_application.m_pPlayer->HasPlayer())
{
Close(true);
return;
if (g_application.IsPlayingVideo())
{
#endif
- if (!g_application.m_pPlayer->IsPaused())
+ if (!g_application.IsPaused())
g_application.ResetScreenSaver();
g_graphicsContext.SetViewWindow(m_posX, m_posY, m_posX + m_width, m_posY + m_height);
color_t alpha = g_graphicsContext.MergeAlpha(0xFF000000) >> 24;
g_renderManager.Render(false, 0, alpha);
#else
- ((CDummyVideoPlayer *)g_application.m_pPlayer)->Render();
+ ((CDummyVideoPlayer *)g_application.m_pPlayer->GetInternal())->Render();
#endif
}
CGUIControl::Render();
}
else if (parameter.Equals("rewind") || parameter.Equals("forward"))
{
- if (g_application.IsPlaying() && !g_application.m_pPlayer->IsPaused())
+ if (g_application.IsPlaying() && !g_application.IsPaused())
{
int iPlaySpeed = g_application.GetPlaySpeed();
if (parameter.Equals("rewind") && iPlaySpeed == 1) // Enables Rewinding
}
else if( parameter.Equals("showvideomenu") )
{
- if( g_application.IsPlaying() && g_application.m_pPlayer )
+ if( g_application.IsPlaying() )
g_application.m_pPlayer->OnAction(CAction(ACTION_SHOW_VIDEOMENU));
}
else if( parameter.Equals("record") )
{
- if( g_application.IsPlaying() && g_application.m_pPlayer && g_application.m_pPlayer->CanRecord())
+ if( g_application.IsPlaying() && g_application.m_pPlayer->CanRecord())
g_application.m_pPlayer->Record(!g_application.m_pPlayer->IsRecording());
}
else if (parameter.Left(9).Equals("partymode"))
{
case Video:
case Audio:
- if (g_application.m_pPlayer && !g_application.m_pPlayer->CanPause())
+ if (!g_application.m_pPlayer->CanPause())
return FailedToExecute;
if (parameterObject["play"].isString())
{
case Video:
case Audio:
- if (g_application.m_pPlayer && !g_application.m_pPlayer->CanSeek())
+ if (!g_application.m_pPlayer->CanSeek())
return FailedToExecute;
if (parameterObject["value"].isObject())
switch (GetPlayer(parameterObject["playerid"]))
{
case Video:
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
int index = -1;
if (parameterObject["stream"].isString())
switch (GetPlayer(parameterObject["playerid"]))
{
case Video:
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
int index = -1;
if (parameterObject["subtitle"].isString())
{
case Video:
case Audio:
- if (g_application.m_pPlayer)
- result = g_application.m_pPlayer->CanSeek();
- else
- result = false;
+ result = g_application.m_pPlayer->CanSeek();
break;
case Picture:
{
case Video:
case Audio:
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
result = CVariant(CVariant::VariantTypeObject);
int index = g_application.m_pPlayer->GetAudioStream();
switch (player)
{
case Video:
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
for (int index = 0; index < g_application.m_pPlayer->GetAudioStreamCount(); index++)
{
switch (player)
{
case Video:
- if (g_application.m_pPlayer)
- result = g_application.m_pPlayer->GetSubtitleVisible();
+ result = g_application.m_pPlayer->GetSubtitleVisible();
break;
case Audio:
switch (player)
{
case Video:
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
result = CVariant(CVariant::VariantTypeObject);
int index = CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream;
switch (player)
{
case Video:
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
for (int index = 0; index < g_application.m_pPlayer->GetSubtitleCount(); index++)
{
void Player::setSubtitles(const char* cLine)
{
TRACE;
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
int nStream = g_application.m_pPlayer->AddSubtitle(cLine);
if(nStream >= 0)
void Player::showSubtitles(bool bVisible)
{
TRACE;
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn = bVisible != 0;
g_application.m_pPlayer->SetSubtitleVisible(bVisible != 0);
String Player::getSubtitles()
{
TRACE;
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
SPlayerSubtitleStreamInfo info;
g_application.m_pPlayer->GetSubtitleStreamInfo(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleStream, info);
{
TRACE;
CLog::Log(LOGWARNING,"'xbmc.Player().disableSubtitles()' is deprecated and will be removed in future releases, please use 'xbmc.Player().showSubtitles(false)' instead");
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleOn = false;
g_application.m_pPlayer->SetSubtitleVisible(false);
std::vector<String>* Player::getAvailableSubtitleStreams()
{
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
int subtitleCount = g_application.m_pPlayer->GetSubtitleCount();
std::vector<String>* ret = new std::vector<String>(subtitleCount);
void Player::setSubtitleStream(int iStream)
{
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
int streamCount = g_application.m_pPlayer->GetSubtitleCount();
if(iStream < streamCount)
std::vector<String>* Player::getAvailableAudioStreams()
{
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
int streamCount = g_application.m_pPlayer->GetAudioStreamCount();
std::vector<String>* ret = new std::vector<String>(streamCount);
void Player::setAudioStream(int iStream)
{
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
int streamCount = g_application.m_pPlayer->GetAudioStreamCount();
if(iStream < streamCount)
// if playback is paused or playback speed != 1, return
if (g_application.IsPlayingAudio())
{
- if (g_application.m_pPlayer->IsPaused())
+ if (g_application.IsPaused())
return false;
if (g_application.GetPlaySpeed() != 1)
return false;
}
else if (rate == 0)
{
- if (g_application.m_pPlayer && g_application.m_pPlayer->IsPlaying() && !g_application.m_pPlayer->IsPaused())
+ if (g_application.IsPlaying() && !g_application.IsPaused())
{
CApplicationMessenger::Get().MediaPause();
}
}
else
{
- if (g_application.m_pPlayer && g_application.m_pPlayer->IsPlaying() && g_application.m_pPlayer->IsPaused())
+ if (g_application.IsPlaying() && g_application.IsPaused())
{
CApplicationMessenger::Get().MediaPause();
}
{
CLog::Log(LOGDEBUG, "AIRPLAY: got GET request %s", uri.c_str());
- if (g_application.m_pPlayer && g_application.m_pPlayer->GetTotalTime())
+ if (g_application.m_pPlayer->GetTotalTime())
{
float position = ((float) g_application.m_pPlayer->GetTime()) / 1000;
responseBody.Format("duration: %.6f\r\nposition: %.6f\r\n", (float)g_application.m_pPlayer->GetTotalTime() / 1000, position);
{
const char* found = strstr(queryString.c_str(), "position=");
- if (found && g_application.m_pPlayer)
+ if (found && g_application.m_pPlayer->HasPlayer())
{
int64_t position = (int64_t) (atof(found + strlen("position=")) * 1000.0);
g_application.m_pPlayer->SeekTime(position);
{
status = AIRPLAY_STATUS_NEED_AUTH;
}
- else if (g_application.m_pPlayer)
+ else if (g_application.m_pPlayer->HasPlayer())
{
if (g_application.m_pPlayer->GetTotalTime())
{
position = ((float) g_application.m_pPlayer->GetTime()) / 1000;
duration = ((float) g_application.m_pPlayer->GetTotalTime()) / 1000;
- playing = g_application.m_pPlayer ? !g_application.m_pPlayer->IsPaused() : false;
+ playing = !g_application.m_pPlayer->IsPaused();
cachePosition = position + (duration * g_application.m_pPlayer->GetCachePercentage() / 100.0f);
}
if (!device)
return 0;
- /*if (num_bytes && g_application.m_pPlayer)
+ /*if (num_bytes && g_application.m_pPlayer->HasPlayer())
g_application.m_pPlayer->SetCaching(CACHESTATE_NONE);*///TODO
ao_device_xbmc* device_xbmc = (ao_device_xbmc*) device;
if (!database)
return;
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
/* set the default settings first */
CVideoSettings loadedChannelSettings = CMediaSettings::Get().GetDefaultVideoSettings();
return;
}
- if (g_PVRManager.IsPlaying() && pItem->HasPVRChannelInfoTag() && g_application.m_pPlayer)
+ if (g_PVRManager.IsPlaying() && pItem->HasPVRChannelInfoTag() && g_application.m_pPlayer->HasPlayer())
{
CPVRChannel *channel = pItem->GetPVRChannelInfoTag();
if (!g_PVRManager.CheckParentalLock(*channel) ||
{
/* try a fast switch */
if (channel && (g_PVRManager.IsPlayingTV() || g_PVRManager.IsPlayingRadio()) &&
- (channel->IsRadio() == g_PVRManager.IsPlayingRadio()) && g_application.m_pPlayer)
+ (channel->IsRadio() == g_PVRManager.IsPlayingRadio()))
{
if (channel->StreamURL().IsEmpty())
bSwitchSuccessful = g_application.m_pPlayer->SwitchChannel(*channel);
CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay -= 0.1f;
if (CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay < -g_advancedSettings.m_videoSubsDelayRange)
CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay = -g_advancedSettings.m_videoSubsDelayRange;
- if (g_application.m_pPlayer)
- g_application.m_pPlayer->SetSubTitleDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay);
+ g_application.m_pPlayer->SetSubTitleDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay);
ShowSlider(action.GetID(), 22006, CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay,
-g_advancedSettings.m_videoSubsDelayRange, 0.1f,
CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay += 0.1f;
if (CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay > g_advancedSettings.m_videoSubsDelayRange)
CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay = g_advancedSettings.m_videoSubsDelayRange;
- if (g_application.m_pPlayer)
- g_application.m_pPlayer->SetSubTitleDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay);
+ g_application.m_pPlayer->SetSubTitleDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay);
ShowSlider(action.GetID(), 22006, CMediaSettings::Get().GetCurrentVideoSettings().m_SubtitleDelay,
-g_advancedSettings.m_videoSubsDelayRange, 0.1f,
CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay -= 0.025f;
if (CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay < -g_advancedSettings.m_videoAudioDelayRange)
CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay = -g_advancedSettings.m_videoAudioDelayRange;
- if (g_application.m_pPlayer)
- g_application.m_pPlayer->SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay);
+ g_application.m_pPlayer->SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay);
ShowSlider(action.GetID(), 297, CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay,
-g_advancedSettings.m_videoAudioDelayRange, 0.025f,
CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay += 0.025f;
if (CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay > g_advancedSettings.m_videoAudioDelayRange)
CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay = g_advancedSettings.m_videoAudioDelayRange;
- if (g_application.m_pPlayer)
- g_application.m_pPlayer->SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay);
+ g_application.m_pPlayer->SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay);
ShowSlider(action.GetID(), 297, CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay,
-g_advancedSettings.m_videoAudioDelayRange, 0.025f,
CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification =
std::max(std::min(CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification, sliderMax), sliderMin);
- if (g_application.m_pPlayer)
- g_application.m_pPlayer->SetDynamicRangeCompression((long)(CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification * 100));
+ g_application.m_pPlayer->SetDynamicRangeCompression((long)(CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification * 100));
ShowSlider(action.GetID(), 660, CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification, sliderMin, 1.0f, sliderMax);
return true;
else
slider->SetTextValue(CGUIDialogAudioSubtitleSettings::FormatDelay(slider->GetFloatValue(), 0.025f));
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
if (m_sliderAction == ACTION_AUDIO_DELAY)
{
{
m_usePopupSliders = g_SkinInfo->HasSkinFile("DialogSlider.xml");
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
g_application.m_pPlayer->GetAudioCapabilities(m_audioCaps);
g_application.m_pPlayer->GetSubtitleCapabilities(m_subCaps);
AddSlider(AUDIO_SETTINGS_VOLUME, 13376, &m_volume, VOLUME_MINIMUM, VOLUME_MAXIMUM / 100.0f, VOLUME_MAXIMUM, PercentAsDecibel, false);
if (SupportsAudioFeature(IPC_AUD_AMP))
AddSlider(AUDIO_SETTINGS_VOLUME_AMPLIFICATION, 660, &CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification, VOLUME_DRC_MINIMUM * 0.01f, (VOLUME_DRC_MAXIMUM - VOLUME_DRC_MINIMUM) / 6000.0f, VOLUME_DRC_MAXIMUM * 0.01f, FormatDecibel, false);
- if (g_application.m_pPlayer && g_application.m_pPlayer->IsPassthrough())
+ if (g_application.m_pPlayer->IsPassthrough())
{
EnableSettings(AUDIO_SETTINGS_VOLUME,false);
EnableSettings(AUDIO_SETTINGS_VOLUME_AMPLIFICATION,false);
g_application.SetVolume(m_volume, false); //false - value is not in percent
else if (setting.id == AUDIO_SETTINGS_VOLUME_AMPLIFICATION)
{
- if (g_application.m_pPlayer)
- g_application.m_pPlayer->SetDynamicRangeCompression((long)(CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification * 100));
+ g_application.m_pPlayer->SetDynamicRangeCompression((long)(CMediaSettings::Get().GetCurrentVideoSettings().m_VolumeAmplification * 100));
}
else if (setting.id == AUDIO_SETTINGS_DELAY)
{
- if (g_application.m_pPlayer)
- g_application.m_pPlayer->SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay);
+ g_application.m_pPlayer->SetAVDelay(CMediaSettings::Get().GetCurrentVideoSettings().m_AudioDelay);
}
else if (setting.id == AUDIO_SETTINGS_STREAM)
{
{
m_volume = g_application.GetVolume(false);
UpdateSetting(AUDIO_SETTINGS_VOLUME);
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
// these settings can change on the fly
UpdateSetting(AUDIO_SETTINGS_DELAY);
void CGUIDialogVideoBookmarks::GotoBookmark(int item)
{
if (item < 0 || item >= (int)m_bookmarks.size()) return;
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
{
g_application.m_pPlayer->SetPlayerState(m_bookmarks[item].playerState);
g_application.SeekTime((double)m_bookmarks[item].timeInSeconds);
bookmark.timeInSeconds = (int)g_application.GetTime();
bookmark.totalTimeInSeconds = (int)g_application.GetTotalTime();
- if( g_application.m_pPlayer )
+ if( g_application.m_pPlayer->HasPlayer() )
bookmark.playerState = g_application.m_pPlayer->GetPlayerState();
else
bookmark.playerState.Empty();
if (m_bShowCurrentTime)
g_infoManager.SetDisplayAfterSeek();
- if (!g_application.m_pPlayer) return;
+ if (!g_application.m_pPlayer->HasPlayer()) return;
if( g_application.m_pPlayer->IsCaching() )
{
void CGUIWindowFullScreen::Render()
{
- if (g_application.m_pPlayer)
+ if (g_application.m_pPlayer->HasPlayer())
RenderTTFSubtitles();
CGUIWindow::Render();
}