[pvr] remove channel settings related functionality from the PVR parts since
authorSam Stenvall <neggelandia@gmail.com>
Sat, 24 May 2014 12:04:02 +0000 (15:04 +0300)
committerSam Stenvall <neggelandia@gmail.com>
Sun, 13 Jul 2014 08:36:20 +0000 (11:36 +0300)
they're now obsolete

xbmc/pvr/PVRDatabase.cpp
xbmc/pvr/PVRDatabase.h
xbmc/pvr/PVRManager.cpp
xbmc/pvr/PVRManager.h
xbmc/pvr/addons/PVRClients.cpp
xbmc/pvr/addons/PVRClients.h

index b27b51e..0072b78 100644 (file)
@@ -118,39 +118,6 @@ void CPVRDatabase::CreateTables()
       ")"
   );
 
-  CLog::Log(LOGDEBUG, "PVR - %s - creating table 'channelsettings'", __FUNCTION__);
-  m_pDS->exec(
-      "CREATE TABLE channelsettings ("
-        "idChannel            integer primary key, "
-        "iInterlaceMethod     integer, "
-        "iViewMode            integer, "
-        "fCustomZoomAmount    float, "
-        "fPixelRatio          float, "
-        "iAudioStream         integer, "
-        "iSubtitleStream      integer,"
-        "fSubtitleDelay       float, "
-        "bSubtitles           bool, "
-        "fBrightness          float, "
-        "fContrast            float, "
-        "fGamma               float,"
-        "fVolumeAmplification float, "
-        "fAudioDelay          float, "
-        "bOutputToAllSpeakers bool, "
-        "bCrop                bool, "
-        "iCropLeft            integer, "
-        "iCropRight           integer, "
-        "iCropTop             integer, "
-        "iCropBottom          integer, "
-        "fSharpness           float, "
-        "fNoiseReduction      float, "
-        "fCustomVerticalShift float, "
-        "bCustomNonLinStretch bool, "
-        "bPostProcess         bool, "
-        "iScalingMethod       integer, "
-        "iDeinterlaceMode     integer "
-      ")"
-  );
-
   // disable all PVR add-on when started the first time
   ADDON::VECADDONS addons;
   if (!CAddonMgr::Get().GetAddons(ADDON_PVRDLL, addons, true))
@@ -175,26 +142,6 @@ void CPVRDatabase::UpdateTables(int iVersion)
   if (iVersion < 13)
     m_pDS->exec("ALTER TABLE channels ADD idEpg integer;");
 
-  if (iVersion < 14)
-    m_pDS->exec("ALTER TABLE channelsettings ADD fCustomVerticalShift float;");
-
-  if (iVersion < 15)
-  {
-    m_pDS->exec("ALTER TABLE channelsettings ADD bCustomNonLinStretch bool;");
-    m_pDS->exec("ALTER TABLE channelsettings ADD bPostProcess bool;");
-    m_pDS->exec("ALTER TABLE channelsettings ADD iScalingMethod integer;");
-  }
-  if (iVersion < 16)
-  {
-    /* sqlite apparently can't delete columns from an existing table, so just leave the extra column alone */
-  }
-  if (iVersion < 17)
-  {
-    m_pDS->exec("ALTER TABLE channelsettings ADD iDeinterlaceMode integer");
-    m_pDS->exec("UPDATE channelsettings SET iDeinterlaceMode = 2 WHERE iInterlaceMethod NOT IN (0,1)"); // anything other than none: method auto => mode force
-    m_pDS->exec("UPDATE channelsettings SET iDeinterlaceMode = 1 WHERE iInterlaceMethod = 1"); // method auto => mode auto
-    m_pDS->exec("UPDATE channelsettings SET iDeinterlaceMode = 0, iInterlaceMethod = 1 WHERE iInterlaceMethod = 0"); // method none => mode off, method auto
-  }
   if (iVersion < 19)
   {
     // bit of a hack, but we need to keep the version/contents of the non-pvr databases the same to allow clean upgrades
@@ -227,6 +174,9 @@ void CPVRDatabase::UpdateTables(int iVersion)
 
   if (iVersion < 24)
     m_pDS->exec("ALTER TABLE channels ADD bIsUserSetName bool");
+  
+  if (iVersion < 25)
+    m_pDS->exec("DROP TABLE IF EXISTS channelsettings");
 }
 
 int CPVRDatabase::GetLastChannelId(void)
@@ -355,118 +305,6 @@ int CPVRDatabase::Get(CPVRChannelGroupInternal &results)
   return iReturn;
 }
 
-bool CPVRDatabase::DeleteChannelSettings()
-{
-  CLog::Log(LOGDEBUG, "PVR - %s - deleting all channel settings from the database", __FUNCTION__);
-  return DeleteValues("channelsettings");
-}
-
-bool CPVRDatabase::DeleteChannelSettings(const CPVRChannel &channel)
-{
-  bool bReturn(false);
-
-  /* invalid channel */
-  if (channel.ChannelID() <= 0)
-  {
-    CLog::Log(LOGERROR, "PVR - %s - invalid channel id: %i", __FUNCTION__, channel.ChannelID());
-    return bReturn;
-  }
-
-  Filter filter;
-  filter.AppendWhere(PrepareSQL("idChannel = %u", channel.ChannelID()));
-
-  return DeleteValues("channelsettings", filter);
-}
-
-bool CPVRDatabase::GetChannelSettings(const CPVRChannel &channel, CVideoSettings &settings)
-{
-  bool bReturn(false);
-
-  /* invalid channel */
-  if (channel.ChannelID() <= 0)
-  {
-    CLog::Log(LOGERROR, "PVR - %s - invalid channel id: %i", __FUNCTION__, channel.ChannelID());
-    return bReturn;
-  }
-
-  CStdString strQuery = PrepareSQL("SELECT * FROM channelsettings WHERE idChannel = %u;", channel.ChannelID());
-
-  if (ResultQuery(strQuery))
-  {
-    try
-    {
-      if (m_pDS->num_rows() > 0)
-      {
-        settings.m_AudioDelay           = m_pDS->fv("fAudioDelay").get_asFloat();
-        settings.m_AudioStream          = m_pDS->fv("iAudioStream").get_asInt();
-        settings.m_Brightness           = m_pDS->fv("fBrightness").get_asFloat();
-        settings.m_Contrast             = m_pDS->fv("fContrast").get_asFloat();
-        settings.m_CustomPixelRatio     = m_pDS->fv("fPixelRatio").get_asFloat();
-        settings.m_CustomNonLinStretch  = m_pDS->fv("bCustomNonLinStretch").get_asBool();
-        settings.m_NoiseReduction       = m_pDS->fv("fNoiseReduction").get_asFloat();
-        settings.m_PostProcess          = m_pDS->fv("bPostProcess").get_asBool();
-        settings.m_Sharpness            = m_pDS->fv("fSharpness").get_asFloat();
-        settings.m_CustomZoomAmount     = m_pDS->fv("fCustomZoomAmount").get_asFloat();
-        settings.m_CustomVerticalShift  = m_pDS->fv("fCustomVerticalShift").get_asFloat();
-        settings.m_Gamma                = m_pDS->fv("fGamma").get_asFloat();
-        settings.m_SubtitleDelay        = m_pDS->fv("fSubtitleDelay").get_asFloat();
-        settings.m_SubtitleOn           = m_pDS->fv("bSubtitles").get_asBool();
-        settings.m_SubtitleStream       = m_pDS->fv("iSubtitleStream").get_asInt();
-        settings.m_ViewMode             = m_pDS->fv("iViewMode").get_asInt();
-        settings.m_Crop                 = m_pDS->fv("bCrop").get_asBool();
-        settings.m_CropLeft             = m_pDS->fv("iCropLeft").get_asInt();
-        settings.m_CropRight            = m_pDS->fv("iCropRight").get_asInt();
-        settings.m_CropTop              = m_pDS->fv("iCropTop").get_asInt();
-        settings.m_CropBottom           = m_pDS->fv("iCropBottom").get_asInt();
-        settings.m_InterlaceMethod      = (EINTERLACEMETHOD)m_pDS->fv("iInterlaceMethod").get_asInt();
-        settings.m_DeinterlaceMode      = (EDEINTERLACEMODE)m_pDS->fv("iDeinterlaceMode").get_asInt();
-        settings.m_VolumeAmplification  = m_pDS->fv("fVolumeAmplification").get_asFloat();
-        settings.m_OutputToAllSpeakers  = m_pDS->fv("bOutputToAllSpeakers").get_asBool();
-        settings.m_ScalingMethod        = (ESCALINGMETHOD)m_pDS->fv("iScalingMethod").get_asInt();
-
-        bReturn = true;
-      }
-
-      m_pDS->close();
-    }
-    catch(...)
-    {
-      CLog::Log(LOGERROR, "PVR - %s - failed to get channel settings for channel '%s'", __FUNCTION__, channel.ChannelName().c_str());
-    }
-  }
-  else
-  {
-    CLog::Log(LOGERROR, "PVR - %s - query failed", __FUNCTION__);
-  }
-
-  return bReturn;
-}
-
-bool CPVRDatabase::PersistChannelSettings(const CPVRChannel &channel, const CVideoSettings &settings)
-{
-  /* invalid channel */
-  if (channel.ChannelID() <= 0)
-  {
-    CLog::Log(LOGERROR, "PVR - %s - invalid channel id: %i", __FUNCTION__, channel.ChannelID());
-    return false;
-  }
-
-  CStdString strQuery = PrepareSQL(
-      "REPLACE INTO channelsettings "
-        "(idChannel, iInterlaceMethod, iViewMode, fCustomZoomAmount, fPixelRatio, iAudioStream, iSubtitleStream, fSubtitleDelay, "
-         "bSubtitles, fBrightness, fContrast, fGamma, fVolumeAmplification, fAudioDelay, bOutputToAllSpeakers, bCrop, iCropLeft, "
-         "iCropRight, iCropTop, iCropBottom, fSharpness, fNoiseReduction, fCustomVerticalShift, bCustomNonLinStretch, bPostProcess, iScalingMethod, iDeinterlaceMode) VALUES "
-         "(%i, %i, %i, %f, %f, %i, %i, %f, %i, %f, %f, %f, %f, %f, %i, %i, %i, %i, %i, %i, %f, %f, %f, %i, %i, %i, %i);",
-       channel.ChannelID(), settings.m_InterlaceMethod, settings.m_ViewMode, settings.m_CustomZoomAmount, settings.m_CustomPixelRatio,
-       settings.m_AudioStream, settings.m_SubtitleStream, settings.m_SubtitleDelay, settings.m_SubtitleOn ? 1 :0,
-       settings.m_Brightness, settings.m_Contrast, settings.m_Gamma, settings.m_VolumeAmplification, settings.m_AudioDelay,
-       settings.m_OutputToAllSpeakers ? 1 : 0, settings.m_Crop ? 1 : 0, settings.m_CropLeft, settings.m_CropRight, settings.m_CropTop,
-       settings.m_CropBottom, settings.m_Sharpness, settings.m_NoiseReduction, settings.m_CustomVerticalShift,
-       settings.m_CustomNonLinStretch ? 1 : 0, settings.m_PostProcess ? 1 : 0, settings.m_ScalingMethod, settings.m_DeinterlaceMode);
-
-  return ExecuteQuery(strQuery);
-}
-
 /********** Channel group methods **********/
 
 bool CPVRDatabase::RemoveChannelsFromGroup(const CPVRChannelGroup &group)
index 2838542..d0793a5 100644 (file)
@@ -59,7 +59,7 @@ namespace PVR
      * @brief Get the minimal database version that is required to operate correctly.
      * @return The minimal database version.
      */
-    virtual int GetSchemaVersion() const { return 24; };
+    virtual int GetSchemaVersion() const { return 25; };
 
     /*!
      * @brief Get the default sqlite database filename.
@@ -107,39 +107,6 @@ namespace PVR
 
     //@}
 
-    /*! @name Channel settings methods */
-    //@{
-
-    /*!
-     * @brief Remove all channel settings from the database.
-     * @return True if all channels were removed successfully, false if not.
-     */
-    bool DeleteChannelSettings();
-
-    /*!
-     * @brief Remove channel settings from the database.
-     * @return True if channel were removed successfully, false if not.
-     */
-    bool DeleteChannelSettings(const CPVRChannel &channel);
-
-    /*!
-     * @brief Get the channel settings from the database.
-     * @param channel The channel to get the settings for.
-     * @param settings Store the settings in here.
-     * @return True if the settings were fetched successfully, false if not.
-     */
-    bool GetChannelSettings(const CPVRChannel &channel, CVideoSettings &settings);
-
-    /*!
-     * @brief Store channel settings in the database.
-     * @param channel The channel to store the settings for.
-     * @param settings The settings to store.
-     * @return True if the settings were stored successfully, false if not.
-     */
-    bool PersistChannelSettings(const CPVRChannel &channel, const CVideoSettings &settings);
-
-    //@}
-
     /*! @name Channel group methods */
     //@{
 
index 198886e..953a3fe 100644 (file)
@@ -923,16 +923,6 @@ bool CPVRManager::CheckParentalPIN(const char *strTitle /* = NULL */)
   return bValidPIN;
 }
 
-void CPVRManager::SaveCurrentChannelSettings(void)
-{
-  m_addons->SaveCurrentChannelSettings();
-}
-
-void CPVRManager::LoadCurrentChannelSettings()
-{
-  m_addons->LoadCurrentChannelSettings();
-}
-
 void CPVRManager::SetPlayingGroup(CPVRChannelGroupPtr group)
 {
   if (m_channelGroups && group)
@@ -973,12 +963,6 @@ bool CPVRChannelGroupsUpdateJob::DoWork(void)
   return g_PVRChannelGroups->Update(false);
 }
 
-bool CPVRChannelSettingsSaveJob::DoWork(void)
-{
-  g_PVRManager.SaveCurrentChannelSettings();
-  return true;
-}
-
 bool CPVRManager::OpenLiveStream(const CFileItem &channel)
 {
   bool bReturn(false);
@@ -1499,11 +1483,6 @@ void CPVRManager::TriggerChannelGroupsUpdate(void)
   QueueJob(new CPVRChannelGroupsUpdateJob());
 }
 
-void CPVRManager::TriggerSaveChannelSettings(void)
-{
-  QueueJob(new CPVRChannelSettingsSaveJob());
-}
-
 void CPVRManager::TriggerSearchMissingChannelIcons(void)
 {
   CJobManager::GetInstance().AddJob(new CPVRSearchMissingChannelIconsJob(), NULL);
index 0d47888..95ea5f6 100644 (file)
@@ -392,11 +392,6 @@ namespace PVR
     void TriggerChannelGroupsUpdate(void);
 
     /*!
-     * @brief Let the background thread save the current video settings.
-     */
-    void TriggerSaveChannelSettings(void);
-
-    /*!
      * @brief Let the background thread search for missing channel icons.
      */
     void TriggerSearchMissingChannelIcons(void);
@@ -504,16 +499,6 @@ namespace PVR
     void SearchMissingChannelIcons(void);
 
     /*!
-     * @brief Persist the current channel settings in the database.
-     */
-    void SaveCurrentChannelSettings(void);
-
-    /*!
-     * @brief Load the settings for the current channel from the database.
-     */
-    void LoadCurrentChannelSettings(void);
-
-    /*!
      * @brief Check if channel is parental locked. Ask for PIN if neccessary.
      * @param channel The channel to open.
      * @return True if channel is unlocked (by default or PIN unlocked), false otherwise.
@@ -571,7 +556,7 @@ namespace PVR
      * @return If at least one client and all pvr data was loaded, false otherwise.
      */
     bool Load(void);
-
+    
     /*!
      * @brief Update all recordings.
      */
@@ -726,16 +711,6 @@ namespace PVR
     virtual bool DoWork();
   };
 
-  class CPVRChannelSettingsSaveJob : public CJob
-  {
-  public:
-    CPVRChannelSettingsSaveJob(void) {}
-    virtual ~CPVRChannelSettingsSaveJob() {}
-    virtual const char *GetType() const { return "pvr-save-channelsettings"; }
-
-    bool DoWork();
-  };
-
   class CPVRChannelSwitchJob : public CJob
   {
   public:
index b403fd6..20bcfa8 100644 (file)
@@ -28,8 +28,6 @@
 #include "pvr/PVRManager.h"
 #include "pvr/PVRDatabase.h"
 #include "guilib/GUIWindowManager.h"
-#include "settings/DisplaySettings.h"
-#include "settings/MediaSettings.h"
 #include "settings/Settings.h"
 #include "pvr/channels/PVRChannelGroups.h"
 #include "pvr/channels/PVRChannelGroupInternal.h"
 #include "pvr/timers/PVRTimers.h"
 #include "cores/IPlayer.h"
 
-#ifdef HAS_VIDEO_PLAYBACK
-#include "cores/VideoRenderers/RenderManager.h"
-#endif
-
 using namespace std;
 using namespace ADDON;
 using namespace PVR;
@@ -50,7 +44,6 @@ CPVRClients::CPVRClients(void) :
     CThread("PVRClient"),
     m_bChannelScanRunning(false),
     m_bIsSwitchingChannels(false),
-    m_bIsValidChannelSettings(false),
     m_playingClientId(-EINVAL),
     m_bIsPlayingLiveTV(false),
     m_bIsPlayingRecording(false),
@@ -339,8 +332,6 @@ bool CPVRClients::SwitchChannel(const CPVRChannel &channel)
   {
     CSingleLock lock(m_critSection);
     m_bIsSwitchingChannels = false;
-    if (bSwitchSuccessful)
-      m_bIsValidChannelSettings = false;
   }
 
   if (!bSwitchSuccessful)
@@ -1036,78 +1027,6 @@ void CPVRClients::ShowDialogNoClientsEnabled(void)
   g_windowManager.ActivateWindow(WINDOW_ADDON_BROWSER, params);
 }
 
-void CPVRClients::SaveCurrentChannelSettings(void)
-{
-  CPVRChannelPtr channel;
-  {
-    CSingleLock lock(m_critSection);
-    if (!GetPlayingChannel(channel) || !m_bIsValidChannelSettings)
-      return;
-  }
-
-  CPVRDatabase *database = GetPVRDatabase();
-  if (!database)
-    return;
-
-  if (CMediaSettings::Get().GetCurrentVideoSettings() != CMediaSettings::Get().GetDefaultVideoSettings())
-  {
-    CLog::Log(LOGDEBUG, "PVR - %s - persisting custom channel settings for channel '%s'",
-        __FUNCTION__, channel->ChannelName().c_str());
-    database->PersistChannelSettings(*channel, CMediaSettings::Get().GetCurrentVideoSettings());
-  }
-  else
-  {
-    CLog::Log(LOGDEBUG, "PVR - %s - no custom channel settings for channel '%s'",
-        __FUNCTION__, channel->ChannelName().c_str());
-    database->DeleteChannelSettings(*channel);
-  }
-}
-
-void CPVRClients::LoadCurrentChannelSettings(void)
-{
-  CPVRChannelPtr channel;
-  {
-    CSingleLock lock(m_critSection);
-    if (!GetPlayingChannel(channel))
-      return;
-  }
-
-  CPVRDatabase *database = GetPVRDatabase();
-  if (!database)
-    return;
-
-  if (g_application.m_pPlayer->HasPlayer())
-  {
-    /* store the current settings so we can compare if anything has changed */
-    CVideoSettings previousSettings = CMediaSettings::Get().GetCurrentVideoSettings();
-
-    /* load the persisted channel settings and set them as current */
-    CVideoSettings loadedChannelSettings = CMediaSettings::Get().GetDefaultVideoSettings();
-    database->GetChannelSettings(*channel, loadedChannelSettings);
-    CMediaSettings::Get().GetCurrentVideoSettings() = loadedChannelSettings;
-
-    /* update the view mode if it set to custom or differs from the previous mode */
-    if (previousSettings.m_ViewMode != loadedChannelSettings.m_ViewMode || loadedChannelSettings.m_ViewMode == ViewModeCustom)
-      g_renderManager.SetViewMode(loadedChannelSettings.m_ViewMode);
-
-    /* only change the subtitle stream, if it's different */
-    if (previousSettings.m_SubtitleStream != loadedChannelSettings.m_SubtitleStream)
-      g_application.m_pPlayer->SetSubtitle(loadedChannelSettings.m_SubtitleStream);
-
-    /* only change the audio stream if it's different */
-    if (g_application.m_pPlayer->GetAudioStream() != loadedChannelSettings.m_AudioStream && loadedChannelSettings.m_AudioStream >= 0)
-      g_application.m_pPlayer->SetAudioStream(loadedChannelSettings.m_AudioStream);
-
-    g_application.m_pPlayer->SetAVDelay(loadedChannelSettings.m_AudioDelay);
-    g_application.m_pPlayer->SetDynamicRangeCompression((long)(loadedChannelSettings.m_VolumeAmplification * 100));
-    g_application.m_pPlayer->SetSubtitleVisible(loadedChannelSettings.m_SubtitleOn);
-    g_application.m_pPlayer->SetSubTitleDelay(loadedChannelSettings.m_SubtitleDelay);
-
-    /* settings can be saved on next channel switch */
-    m_bIsValidChannelSettings = true;
-  }
-}
-
 bool CPVRClients::UpdateAddons(void)
 {
   VECADDONS addons;
index 6da1ed2..74d6bda 100644 (file)
@@ -72,16 +72,6 @@ namespace PVR
      */
     void Stop(void);
 
-    /*!
-     * @brief Load the settings for the current channel from the database.
-     */
-    void LoadCurrentChannelSettings(void);
-
-    /*!
-     * @brief Persist the current channel settings in the database.
-     */
-    void SaveCurrentChannelSettings(void);
-
     /*! @name Backend methods */
     //@{
 
@@ -633,7 +623,6 @@ namespace PVR
 
     bool                  m_bChannelScanRunning;      /*!< true when a channel scan is currently running, false otherwise */
     bool                  m_bIsSwitchingChannels;        /*!< true while switching channels */
-    bool                  m_bIsValidChannelSettings;  /*!< true if current channel settings are valid and can be saved */
     int                   m_playingClientId;          /*!< the ID of the client that is currently playing */
     bool                  m_bIsPlayingLiveTV;
     bool                  m_bIsPlayingRecording;