Merge pull request #3369 from wsoltys/cleanup
authorwsoltys <wiso@xbmc.org>
Wed, 2 Oct 2013 20:20:24 +0000 (13:20 -0700)
committerwsoltys <wiso@xbmc.org>
Wed, 2 Oct 2013 20:20:24 +0000 (13:20 -0700)
small cleanups and fixes

17 files changed:
xbmc/addons/AddonInstaller.cpp
xbmc/cores/AudioEngine/Sinks/AESinkDirectSound.cpp
xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp
xbmc/cores/VideoRenderers/RenderFlags.cpp
xbmc/cores/VideoRenderers/RenderFlags.h
xbmc/epg/Epg.cpp
xbmc/filesystem/HTSPDirectory.cpp
xbmc/input/ButtonTranslator.cpp
xbmc/interfaces/json-rpc/PlayerOperations.cpp
xbmc/interfaces/json-rpc/PlayerOperations.h
xbmc/interfaces/python/PythonInvoker.cpp
xbmc/interfaces/python/PythonInvoker.h
xbmc/peripherals/devices/Peripheral.cpp
xbmc/utils/GroupUtils.cpp
xbmc/utils/StringUtils.cpp
xbmc/utils/XMLUtils.cpp
xbmc/utils/XMLUtils.h

index 3238c03..d016089 100644 (file)
@@ -111,7 +111,7 @@ void CAddonInstaller::OnJobProgress(unsigned int jobID, unsigned int progress, u
 bool CAddonInstaller::IsDownloading() const
 {
   CSingleLock lock(m_critSection);
-  return m_downloadJobs.size() > 0;
+  return !m_downloadJobs.empty();
 }
 
 void CAddonInstaller::GetInstallList(VECADDONS &addons) const
index f4e7649..1d89c1f 100644 (file)
@@ -116,6 +116,7 @@ static BOOL CALLBACK DSEnumCallback(LPGUID lpGuid, LPCTSTR lpcstrDescription, LP
 CAESinkDirectSound::CAESinkDirectSound() :
   m_pBuffer       (NULL ),
   m_pDSound       (NULL ),
+  m_encodedFormat (AE_FMT_INVALID),
   m_AvgBytesPerSec(0    ),
   m_dwChunkSize   (0    ),
   m_dwFrameSize   (0    ),
@@ -271,6 +272,7 @@ bool CAESinkDirectSound::Initialize(AEAudioFormat &format, std::string &device)
 
   AEChannelsFromSpeakerMask(wfxex.dwChannelMask);
   format.m_channelLayout = m_channelLayout;
+  m_encodedFormat = format.m_dataFormat;
   format.m_frames = uiFrameCount;
   format.m_frameSamples = format.m_frames * format.m_channelLayout.Count();
   format.m_frameSize = (AE_IS_RAW(format.m_dataFormat) ? wfxex.Format.wBitsPerSample >> 3 : sizeof(float)) * format.m_channelLayout.Count();
index 1e87712..623c035 100644 (file)
@@ -192,6 +192,7 @@ CAESinkWASAPI::CAESinkWASAPI() :
   m_uiBufferLen(0),
   m_avgTimeWaiting(50),
   m_sinkLatency(0.0),
+  m_lastWriteToBuffer(0),
   m_pBuffer(NULL),
   m_bufferPtr(0)
 {
index 6c4dde0..167ae7d 100644 (file)
@@ -83,7 +83,7 @@ namespace RenderManager {
     return 0;
   }
 
-  unsigned int GetStereoModeFlags(const std::string mode)
+  unsigned int GetStereoModeFlags(const std::string& mode)
   {
     static std::map<std::string, unsigned int> convert;
     if(convert.empty())
index c20557c..84ee937 100644 (file)
@@ -88,7 +88,7 @@ namespace RenderManager {
   unsigned int GetFlagsChromaPosition(unsigned int chroma_position);
   unsigned int GetFlagsColorPrimaries(unsigned int color_primaries);
   unsigned int GetFlagsColorTransfer(unsigned int color_transfer);
-  unsigned int GetStereoModeFlags(const std::string mode);
+  unsigned int GetStereoModeFlags(const std::string& mode);
   std::string  GetStereoModeInvert(const std::string& mode);
 
 }
index 7cef997..911cb73 100644 (file)
@@ -150,7 +150,7 @@ bool CEpg::HasValidEntries(void) const
   CSingleLock lock(m_critSection);
 
   return (m_iEpgID > 0 && /* valid EPG ID */
-      m_tags.size() > 0 && /* contains at least 1 tag */
+      !m_tags.empty()  && /* contains at least 1 tag */
       m_tags.rbegin()->second->EndAsUTC() >= CDateTime::GetCurrentDateTime().GetAsUTCDateTime()); /* the last end time hasn't passed yet */
 }
 
@@ -580,7 +580,7 @@ CDateTime CEpg::GetFirstDate(void) const
   CDateTime first;
 
   CSingleLock lock(m_critSection);
-  if (m_tags.size() > 0)
+  if (!m_tags.empty())
     first = m_tags.begin()->second->StartAsUTC();
 
   return first;
@@ -591,7 +591,7 @@ CDateTime CEpg::GetLastDate(void) const
   CDateTime last;
 
   CSingleLock lock(m_critSection);
-  if (m_tags.size() > 0)
+  if (!m_tags.empty())
     last = m_tags.rbegin()->second->StartAsUTC();
 
   return last;
index d05ccf6..75f79b5 100644 (file)
@@ -42,7 +42,9 @@ struct SSession
   SSession()
   {
     session = NULL;
+    port    = 0;
     refs    = 0;
+    last    = 0;
   }
 
   std::string            hostname;
index 4788ef7..ca4ff01 100644 (file)
@@ -1116,7 +1116,7 @@ void CButtonTranslator::MapWindowActions(TiXmlNode *pWindow, int windowID)
       }
 
       // add our map to our table
-      if (map.size() > 0)
+      if (!map.empty())
         m_translatorMap.insert(pair<int, buttonMap>( windowID, map));
     }
   }
@@ -1554,7 +1554,7 @@ void CButtonTranslator::MapTouchActions(int windowID, TiXmlNode *pTouch)
   }
 
   // add the modified touch map with the window ID
-  if (map.size() > 0)
+  if (!map.empty())
     m_touchMap.insert(std::pair<int, buttonMap>(windowID, map));
 }
 
index 1fe759e..1a7ca3b 100644 (file)
@@ -966,7 +966,7 @@ int CPlayerOperations::GetPlaylist(PlayerType player)
   }
 }
 
-JSONRPC_STATUS CPlayerOperations::StartSlideshow(const std::string path, bool recursive, bool random)
+JSONRPC_STATUS CPlayerOperations::StartSlideshow(const std::string& path, bool recursive, bool random)
 {
   int flags = 0;
   if (recursive)
index 39ec077..ddecde8 100644 (file)
@@ -68,7 +68,7 @@ namespace JSONRPC
     static int GetActivePlayers();
     static PlayerType GetPlayer(const CVariant &player);
     static int GetPlaylist(PlayerType player);
-    static JSONRPC_STATUS StartSlideshow(const std::string path, bool recursive, bool random);
+    static JSONRPC_STATUS StartSlideshow(const std::string& path, bool recursive, bool random);
     static void SendSlideshowAction(int actionID);
     static void OnPlaylistChanged();
     static JSONRPC_STATUS GetPropertyValue(PlayerType player, const CStdString &property, CVariant &result);
index 5f83f23..dc9dae0 100644 (file)
@@ -588,7 +588,7 @@ bool CPythonInvoker::initializeModule(PythonModuleInitialization module)
   return true;
 }
 
-void CPythonInvoker::addPath(const std::string path)
+void CPythonInvoker::addPath(const std::string& path)
 {
   if (path.empty())
     return;
index 71b8196..0a8a5e6 100644 (file)
@@ -64,7 +64,7 @@ protected:
 private:
   void initializeModules(const std::map<std::string, PythonModuleInitialization> &modules);
   bool initializeModule(PythonModuleInitialization module);
-  void addPath(const std::string path);
+  void addPath(const std::string& path);
 
   std::string m_pythonPath;
   void *m_threadState;
index 084dea0..056600d 100644 (file)
@@ -234,7 +234,7 @@ bool CPeripheral::HasSetting(const CStdString &strKey) const
 
 bool CPeripheral::HasSettings(void) const
 {
-  return m_settings.size() > 0;
+  return !m_settings.empty();
 }
 
 bool CPeripheral::HasConfigurableSettings(void) const
index e9471f6..8fd9909 100644 (file)
@@ -57,7 +57,7 @@ bool GroupUtils::Group(GroupBy groupBy, const std::string &baseDir, const CFileI
       groupedItems.Add(item);
   }
 
-  if ((groupBy & GroupBySet) && setMap.size() > 0)
+  if ((groupBy & GroupBySet) && !setMap.empty())
   {
     CVideoDbUrl itemsUrl;
     if (!itemsUrl.FromString(baseDir))
index a7ed17b..21456bf 100644 (file)
@@ -99,6 +99,7 @@ string StringUtils::FormatV(const char *fmt, va_list args)
     cstr = new_cstr;
   }
 
+  free(cstr);
   return "";
 }
 
index a73bbaf..78ae82a 100644 (file)
@@ -191,7 +191,7 @@ bool XMLUtils::GetAdditiveString(const TiXmlNode* pRootNode, const char* strTag,
   Parses the XML for multiple tags of the given name.
   Does not clear the array to support chaining.
 */
-bool XMLUtils::GetStringArray(const TiXmlNode* pRootNode, const char* strTag, std::vector<std::string>& arrayValue, bool clear /* = false */, const std::string separator /* = "" */)
+bool XMLUtils::GetStringArray(const TiXmlNode* pRootNode, const char* strTag, std::vector<std::string>& arrayValue, bool clear /* = false */, const std::string& separator /* = "" */)
 {
   std::string strTemp;
   const TiXmlElement* node = pRootNode->FirstChildElement(strTag);
index bb34373..5b0a4dd 100644 (file)
@@ -55,7 +55,7 @@ public:
    \param clear       if true, clears the string prior to adding tags, if tags are available. Defaults to false.
    */
   static bool GetAdditiveString(const TiXmlNode* rootNode, const char* tag, const CStdString& separator, CStdString& value, bool clear = false);
-  static bool GetStringArray(const TiXmlNode* rootNode, const char* tag, std::vector<std::string>& arrayValue, bool clear = false, const std::string separator = "");
+  static bool GetStringArray(const TiXmlNode* rootNode, const char* tag, std::vector<std::string>& arrayValue, bool clear = false, const std::string& separator = "");
   static bool GetEncoding(const CXBMCTinyXML* pDoc, CStdString& strEncoding);
   static bool GetPath(const TiXmlNode* pRootNode, const char* strTag, CStdString& strStringValue);
   static bool GetFloat(const TiXmlNode* pRootNode, const char* strTag, float& value, const float min, const float max);