Protect Player!
authorVoyager1 <voyager@xbmc.org>
Wed, 19 Jun 2013 19:32:36 +0000 (21:32 +0200)
committerVoyager1 <voyager@xbmc.org>
Sun, 4 Aug 2013 10:14:29 +0000 (12:14 +0200)
25 files changed:
project/VS2010Express/XBMC.vcxproj
project/VS2010Express/XBMC.vcxproj.filters
xbmc/Application.cpp
xbmc/Application.h
xbmc/ApplicationMessenger.cpp
xbmc/ApplicationPlayer.cpp [new file with mode: 0644]
xbmc/ApplicationPlayer.h [new file with mode: 0644]
xbmc/GUIInfoManager.cpp
xbmc/addons/Visualisation.cpp
xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
xbmc/dialogs/GUIDialogSeekBar.cpp
xbmc/guilib/GUIVideoControl.cpp
xbmc/interfaces/Builtins.cpp
xbmc/interfaces/json-rpc/PlayerOperations.cpp
xbmc/interfaces/legacy/Player.cpp
xbmc/music/windows/GUIWindowMusicBase.cpp
xbmc/network/AirPlayServer.cpp
xbmc/network/AirTunesServer.cpp
xbmc/pvr/addons/PVRClients.cpp
xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp
xbmc/pvr/windows/GUIWindowPVRCommon.cpp
xbmc/video/PlayerController.cpp
xbmc/video/dialogs/GUIDialogAudioSubtitleSettings.cpp
xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp
xbmc/video/windows/GUIWindowFullScreen.cpp

index 32f29fd..8c7951f 100644 (file)
     <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" />
index 85b11d2..68906ae 100644 (file)
     <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">
index b4fa73b..c090552 100644 (file)
@@ -377,7 +377,7 @@ using namespace XbmcThreads;
 
 //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)
@@ -400,7 +400,6 @@ CApplication::CApplication(void)
   m_eForcedNextPlayer = EPC_NONE;
   m_strPlayListFile = "";
   m_nextPlaylistItem = -1;
-  m_iPlayerOPSeq = 0;
   m_bPlaybackStarting = false;
   m_ePlayState = PLAY_STATE_NONE;
   m_skinReloading = false;
@@ -432,7 +431,6 @@ CApplication::CApplication(void)
 
   m_splash = NULL;
   m_threadID = 0;
-  m_eCurrentPlayer = EPC_NONE;
   m_progressTrackingPlayCountUpdate = false;
   m_currentStackPosition = 0;
   m_lastFrameTime = 0;
@@ -461,6 +459,7 @@ CApplication::~CApplication(void)
   delete m_seekHandler;
   delete m_playerController;
   delete m_pInertialScrollingHandler;
+  delete m_pPlayer;
 }
 
 bool CApplication::OnEvent(XBMC_Event& newEvent)
@@ -1776,9 +1775,9 @@ void CApplication::LoadSkin(const SkinPtr& skin)
 
   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
@@ -1882,7 +1881,7 @@ void CApplication::LoadSkin(const SkinPtr& skin)
     }
   }
 
-  if (g_application.m_pPlayer && g_application.IsPlayingVideo())
+  if (g_application.IsPlayingVideo())
   {
     if (bPreviousPlayingState)
       g_application.m_pPlayer->Pause();
@@ -2067,7 +2066,7 @@ void CApplication::Render()
     // 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())
@@ -2256,7 +2255,7 @@ bool CApplication::OnKey(const CKey& key)
   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);
@@ -2542,7 +2541,7 @@ bool CApplication::OnAction(const CAction &action)
 
   // 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;
@@ -2552,7 +2551,7 @@ bool CApplication::OnAction(const CAction &action)
   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;
   }
 
@@ -2565,7 +2564,7 @@ bool CApplication::OnAction(const CAction &action)
 
   // 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);
@@ -2735,7 +2734,7 @@ bool CApplication::OnAction(const CAction &action)
   // 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();
@@ -3173,7 +3172,7 @@ int CApplication::GetActiveWindowID(void)
   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())
@@ -3399,13 +3398,8 @@ void CApplication::Stop(int exitCode)
     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");
@@ -3666,7 +3660,7 @@ PlayBackRet CApplication::PlayStack(const CFileItem& item, bool bRestart)
 
     *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)
     {
@@ -3776,7 +3770,7 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart)
 
       // 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
@@ -3810,10 +3804,10 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart)
 
     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
   {
@@ -3929,42 +3923,16 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart)
 
   // 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
@@ -3978,17 +3946,8 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart)
     // 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
   {
@@ -4006,7 +3965,7 @@ PlayBackRet CApplication::PlayFile(const CFileItem& item, bool bRestart)
     }
 
     // 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);
@@ -4231,45 +4190,22 @@ void CApplication::OnPlayBackSeekChapter(int iChapter)
 
 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
@@ -4352,7 +4288,7 @@ void CApplication::UpdateFileState()
         }
 
         // 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();
 
@@ -4392,11 +4328,7 @@ void CApplication::StopPlaying()
     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
@@ -4781,7 +4713,7 @@ bool CApplication::OnMessage(CGUIMessage& message)
       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
       }
 
@@ -4801,19 +4733,16 @@ bool CApplication::OnMessage(CGUIMessage& message)
 #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;
@@ -4863,12 +4792,7 @@ bool CApplication::OnMessage(CGUIMessage& message)
         // 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;
@@ -5009,8 +4933,7 @@ void CApplication::Process()
   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 )
@@ -5175,7 +5098,7 @@ void CApplication::Restart(bool bSamePosition)
   if ( !IsPlayingVideo() && !IsPlayingAudio())
     return ;
 
-  if( !m_pPlayer )
+  if( !m_pPlayer->HasPlayer() )
     return ;
 
   SaveFileState();
@@ -5198,7 +5121,7 @@ void CApplication::Restart(bool bSamePosition)
   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);
 }
 
@@ -5314,7 +5237,7 @@ void CApplication::VolumeChanged() const
   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);
@@ -5384,7 +5307,7 @@ double CApplication::GetTotalTime() const
 {
   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;
@@ -5418,7 +5341,7 @@ double CApplication::GetTime() const
 {
   double rc = 0.0;
 
-  if (IsPlaying() && m_pPlayer)
+  if (IsPlaying())
   {
     if (m_itemCurrentFile->IsStack() && m_currentStack->Size() > 0)
     {
@@ -5439,7 +5362,7 @@ double CApplication::GetTime() const
 // 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)
@@ -5475,7 +5398,7 @@ void CApplication::SeekTime( double dTime )
 
 float CApplication::GetPercentage() const
 {
-  if (IsPlaying() && m_pPlayer)
+  if (IsPlaying())
   {
     if (m_pPlayer->GetTotalTime() == 0 && IsPlayingAudio() && m_itemCurrentFile->HasMusicInfoTag())
     {
@@ -5498,7 +5421,7 @@ float CApplication::GetPercentage() const
 
 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)
@@ -5516,7 +5439,7 @@ float CApplication::GetCachePercentage() const
 
 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)
@@ -5563,7 +5486,7 @@ void CApplication::Minimize()
 
 PLAYERCOREID CApplication::GetCurrentPlayer()
 {
-  return m_eCurrentPlayer;
+  return m_pPlayer->GetCurrentPlayer();
 }
 
 void CApplication::UpdateLibraries()
index 52a11f3..c72ba3d 100644 (file)
@@ -65,6 +65,8 @@ class CPlayerController;
 #include "windowing/XBMC_events.h"
 #include "threads/Thread.h"
 
+#include "ApplicationPlayer.h"
+
 class CSeekHandler;
 class CKaraokeLyricsManager;
 class CInertialScrollingHandler;
@@ -109,16 +111,10 @@ protected:
   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
@@ -273,12 +269,11 @@ public:
   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
   {
@@ -413,7 +408,6 @@ protected:
   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;
 
index b8563fa..4668d57 100644 (file)
@@ -504,7 +504,7 @@ void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg)
       break;
 
     case TMSG_MEDIA_PAUSE:
-      if (g_application.m_pPlayer)
+      if (g_application.m_pPlayer->HasPlayer())
       {
         g_application.ResetScreenSaver();
         g_application.WakeUpScreenSaverAndDPMS();
diff --git a/xbmc/ApplicationPlayer.cpp b/xbmc/ApplicationPlayer.cpp
new file mode 100644 (file)
index 0000000..07fbbb6
--- /dev/null
@@ -0,0 +1,686 @@
+/*
+ *      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;
+}
+
diff --git a/xbmc/ApplicationPlayer.h b/xbmc/ApplicationPlayer.h
new file mode 100644 (file)
index 0000000..e809f90
--- /dev/null
@@ -0,0 +1,145 @@
+#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();
+};
index 3261496..7d2afde 100644 (file)
@@ -1363,15 +1363,15 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa
     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:
@@ -1382,11 +1382,11 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa
     }
     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:
@@ -1429,7 +1429,7 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa
         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();
@@ -1437,7 +1437,7 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa
       }
       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();
       }
     }
@@ -1511,39 +1511,39 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa
     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;
@@ -1959,7 +1959,7 @@ bool CGUIInfoManager::GetInt(int &value, int info, int contextWindow, const CGUI
     case PLAYER_CHAPTER:
     case PLAYER_CHAPTERCOUNT:
       {
-        if( g_application.IsPlaying() && g_application.m_pPlayer)
+        if( g_application.IsPlaying())
         {
           switch( info )
           {
@@ -2423,7 +2423,7 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI
       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());
@@ -2507,7 +2507,7 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI
       }
     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();
@@ -4110,7 +4110,7 @@ void CGUIInfoManager::UpdateFPS()
 
 void CGUIInfoManager::UpdateAVInfo()
 {
-  if(g_application.IsPlaying() && g_application.m_pPlayer)
+  if(g_application.IsPlaying())
   {
     if (!m_AVInfoValid)
     {
index 5c91cb4..a30b3cc 100644 (file)
@@ -108,9 +108,7 @@ bool CVisualisation::Create(int x, int y, int w, int h, void *device)
 
     CreateBuffers();
 
-    if (g_application.m_pPlayer)
-      g_application.m_pPlayer->RegisterAudioCallback(this);
-    CAEFactory::RegisterAudioCallback(this);
+    g_application.m_pPlayer->RegisterAudioCallback(this);
 
     return true;
   }
@@ -174,8 +172,7 @@ void CVisualisation::Render()
 
 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();
index d52dead..7807368 100644 (file)
@@ -1268,7 +1268,7 @@ void CLinuxRendererGL::RenderSinglePass(int index, int field)
 
   //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));
@@ -1501,7 +1501,7 @@ void CLinuxRendererGL::RenderFromFBO()
 
     //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));
@@ -1585,7 +1585,7 @@ void CLinuxRendererGL::RenderVDPAU(int index, int field)
 
     //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));
@@ -1680,7 +1680,7 @@ void CLinuxRendererGL::RenderVAAPI(int index, int field)
 
     //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));
index 3855d5a..04898fe 100644 (file)
@@ -62,7 +62,7 @@ bool CGUIDialogSeekBar::OnMessage(CGUIMessage& message)
 
 void CGUIDialogSeekBar::FrameMove()
 {
-  if (!g_application.m_pPlayer)
+  if (!g_application.m_pPlayer->HasPlayer())
   {
     Close(true);
     return;
index ef262e9..f6e3564 100644 (file)
@@ -61,7 +61,7 @@ void CGUIVideoControl::Render()
   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);
@@ -70,7 +70,7 @@ void CGUIVideoControl::Render()
     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();
index f8f879f..ec403cc 100644 (file)
@@ -753,7 +753,7 @@ int CBuiltins::Execute(const CStdString& execString)
     }
     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
@@ -822,12 +822,12 @@ int CBuiltins::Execute(const CStdString& execString)
     }
     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"))
index 00f9bf5..e15258d 100644 (file)
@@ -233,7 +233,7 @@ JSONRPC_STATUS CPlayerOperations::PlayPause(const CStdString &method, ITransport
   {
     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())
@@ -337,7 +337,7 @@ JSONRPC_STATUS CPlayerOperations::Seek(const CStdString &method, ITransportLayer
   {
     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())
@@ -795,7 +795,7 @@ JSONRPC_STATUS CPlayerOperations::SetAudioStream(const CStdString &method, ITran
   switch (GetPlayer(parameterObject["playerid"]))
   {
     case Video:
-      if (g_application.m_pPlayer)
+      if (g_application.m_pPlayer->HasPlayer())
       {
         int index = -1;
         if (parameterObject["stream"].isString())
@@ -842,7 +842,7 @@ JSONRPC_STATUS CPlayerOperations::SetSubtitle(const CStdString &method, ITranspo
   switch (GetPlayer(parameterObject["playerid"]))
   {
     case Video:
-      if (g_application.m_pPlayer)
+      if (g_application.m_pPlayer->HasPlayer())
       {
         int index = -1;
         if (parameterObject["subtitle"].isString())
@@ -1255,10 +1255,7 @@ JSONRPC_STATUS CPlayerOperations::GetPropertyValue(PlayerType player, const CStd
     {
       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:
@@ -1363,7 +1360,7 @@ JSONRPC_STATUS CPlayerOperations::GetPropertyValue(PlayerType player, const CStd
     {
       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();
@@ -1396,7 +1393,7 @@ JSONRPC_STATUS CPlayerOperations::GetPropertyValue(PlayerType player, const CStd
     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++)
           {
@@ -1427,8 +1424,7 @@ JSONRPC_STATUS CPlayerOperations::GetPropertyValue(PlayerType player, const CStd
     switch (player)
     {
       case Video:
-        if (g_application.m_pPlayer)
-          result = g_application.m_pPlayer->GetSubtitleVisible();
+        result = g_application.m_pPlayer->GetSubtitleVisible();
         break;
         
       case Audio:
@@ -1443,7 +1439,7 @@ JSONRPC_STATUS CPlayerOperations::GetPropertyValue(PlayerType player, const CStd
     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;
@@ -1474,7 +1470,7 @@ JSONRPC_STATUS CPlayerOperations::GetPropertyValue(PlayerType player, const CStd
     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++)
           {
index 2b1bb04..2497593 100644 (file)
@@ -367,7 +367,7 @@ namespace XBMCAddon
     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)
@@ -383,7 +383,7 @@ namespace XBMCAddon
     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);
@@ -393,7 +393,7 @@ namespace XBMCAddon
     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);
@@ -411,7 +411,7 @@ namespace XBMCAddon
     {
       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);
@@ -420,7 +420,7 @@ namespace XBMCAddon
 
     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);
@@ -442,7 +442,7 @@ namespace XBMCAddon
 
     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)
@@ -455,7 +455,7 @@ namespace XBMCAddon
 
     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);
@@ -477,7 +477,7 @@ namespace XBMCAddon
 
     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)
index 4961a36..54bbc4c 100644 (file)
@@ -220,7 +220,7 @@ bool CGUIWindowMusicBase::OnMessage(CGUIMessage& message)
           // 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;
index 4b86db9..5c83e35 100644 (file)
@@ -730,14 +730,14 @@ int CAirPlayServer::CTCPClient::ProcessRequest( CStdString& responseHeader,
       }
       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();
         }
@@ -881,7 +881,7 @@ int CAirPlayServer::CTCPClient::ProcessRequest( CStdString& responseHeader,
     {
       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);
@@ -895,7 +895,7 @@ int CAirPlayServer::CTCPClient::ProcessRequest( CStdString& responseHeader,
     {
       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);
@@ -978,13 +978,13 @@ int CAirPlayServer::CTCPClient::ProcessRequest( CStdString& responseHeader,
     {
       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);
       }
 
index 005f033..b2eaaaf 100644 (file)
@@ -325,7 +325,7 @@ int CAirTunesServer::AudioOutputFunctions::ao_play(ao_device *device, char *outp
   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;
index c84bd4d..aab6345 100644 (file)
@@ -1062,7 +1062,7 @@ void CPVRClients::LoadCurrentChannelSettings(void)
   if (!database)
     return;
 
-  if (g_application.m_pPlayer)
+  if (g_application.m_pPlayer->HasPlayer())
   {
     /* set the default settings first */
     CVideoSettings loadedChannelSettings = CMediaSettings::Get().GetDefaultVideoSettings();
index 3d54dbb..3183394 100644 (file)
@@ -230,7 +230,7 @@ void CGUIDialogPVRChannelsOSD::GotoChannel(int item)
     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) ||
index 29d2e72..d649b0d 100644 (file)
@@ -706,7 +706,7 @@ bool CGUIWindowPVRCommon::PlayFile(CFileItem *item, bool bPlayMinimized /* = fal
     {
       /* 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);
index c7e9a89..938b865 100644 (file)
@@ -129,8 +129,7 @@ bool CPlayerController::OnAction(const CAction &action)
       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,
@@ -143,8 +142,7 @@ bool CPlayerController::OnAction(const CAction &action)
       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,
@@ -173,8 +171,7 @@ bool CPlayerController::OnAction(const CAction &action)
       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,
@@ -187,8 +184,7 @@ bool CPlayerController::OnAction(const CAction &action)
       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,
@@ -376,8 +372,7 @@ bool CPlayerController::OnAction(const CAction &action)
       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;
@@ -417,7 +412,7 @@ void CPlayerController::OnSliderChange(void *data, CGUISliderControl *slider)
   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)
     {
index 3cbd188..38d8a2d 100644 (file)
@@ -77,7 +77,7 @@ void CGUIDialogAudioSubtitleSettings::CreateSettings()
 {
   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);
@@ -90,7 +90,7 @@ void CGUIDialogAudioSubtitleSettings::CreateSettings()
   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);
@@ -245,13 +245,11 @@ void CGUIDialogAudioSubtitleSettings::OnSettingChanged(SettingInfo &setting)
     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)
   {
@@ -382,7 +380,7 @@ void CGUIDialogAudioSubtitleSettings::FrameMove()
 {
   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);
index 4740969..5eb1555 100644 (file)
@@ -278,7 +278,7 @@ void CGUIDialogVideoBookmarks::Clear()
 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);
@@ -307,7 +307,7 @@ bool CGUIDialogVideoBookmarks::AddBookmark(CVideoInfoTag* tag)
   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();
index 4ee956e..6d351b3 100644 (file)
@@ -563,7 +563,7 @@ void CGUIWindowFullScreen::FrameMove()
   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() )
   {
@@ -751,7 +751,7 @@ void CGUIWindowFullScreen::Process(unsigned int currentTime, CDirtyRegionList &d
 
 void CGUIWindowFullScreen::Render()
 {
-  if (g_application.m_pPlayer)
+  if (g_application.m_pPlayer->HasPlayer())
     RenderTTFSubtitles();
   CGUIWindow::Render();
 }