ActiveAE: fix overwrite of sink latency and cache time
authorRainer Hochecker <fernetmenta@online.de>
Thu, 2 Jan 2014 08:38:15 +0000 (09:38 +0100)
committerRainer Hochecker <fernetmenta@online.de>
Thu, 2 Jan 2014 08:56:42 +0000 (09:56 +0100)
xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp
xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.h

index 843321f..ddde944 100644 (file)
@@ -38,8 +38,6 @@ void CEngineStats::Reset(unsigned int sampleRate)
   CSingleLock lock(m_lock);
   m_sinkUpdate = XbmcThreads::SystemClockMillis();
   m_sinkDelay = 0;
-  m_sinkCacheTotal = 0;
-  m_sinkLatency = 0;
   m_sinkSampleRate = sampleRate;
   m_bufferedSamples = 0;
   m_suspended = false;
@@ -1453,18 +1451,22 @@ bool CActiveAE::InitSink()
       m_extError = true;
       return false;
     }
-    AEAudioFormat *data;
-    data = (AEAudioFormat*)reply->data;
+    SinkReply *data;
+    data = (SinkReply*)reply->data;
     if (data)
     {
-      m_sinkFormat = *data;
+      m_sinkFormat = data->format;
+      m_sinkHasVolume = data->hasVolume;
+      m_stats.SetSinkCacheTotal(data->cacheTotal);
+      m_stats.SetSinkLatency(data->latency);
     }
-    m_sinkHasVolume = m_sink.HasVolume();
     reply->Release();
   }
   else
   {
     CLog::Log(LOGERROR, "ActiveAE::%s - failed to init", __FUNCTION__);
+    m_stats.SetSinkCacheTotal(0);
+    m_stats.SetSinkLatency(0);
     m_extError = true;
     return false;
   }
index 7053313..89caaea 100644 (file)
@@ -76,13 +76,6 @@ void CActiveAESink::Dispose()
   }
 }
 
-bool CActiveAESink::HasVolume()
-{
-  if (!m_sink)
-    return false;
-  return m_sink->HasVolume();
-}
-
 AEDeviceType CActiveAESink::GetDeviceType(const std::string &device)
 {
   std::string dev = device;
@@ -162,11 +155,14 @@ void CActiveAESink::StateMachine(int signal, Protocol *port, Message *msg)
 
           if (!m_extError)
           {
-            m_stats->SetSinkCacheTotal(m_sink->GetCacheTotal());
-            m_stats->SetSinkLatency(m_sink->GetLatency());
+            SinkReply reply;
+            reply.format = m_sinkFormat;
+            reply.cacheTotal = m_sink->GetCacheTotal();
+            reply.latency = m_sink->GetLatency();
+            reply.hasVolume = m_sink->HasVolume();
             m_state = S_TOP_CONFIGURED_IDLE;
             m_extTimeout = 10000;
-            msg->Reply(CSinkControlProtocol::ACC, &m_sinkFormat, sizeof(AEAudioFormat));
+            msg->Reply(CSinkControlProtocol::ACC, &reply, sizeof(SinkReply));
           }
           else
           {
index 8b6aa05..7dd3517 100644 (file)
@@ -41,6 +41,14 @@ struct SinkConfig
   const std::string *device;
 };
 
+struct SinkReply
+{
+  AEAudioFormat format;
+  float cacheTotal;
+  float latency;
+  bool hasVolume;
+};
+
 class CSinkControlProtocol : public Protocol
 {
 public:
@@ -87,7 +95,6 @@ public:
   std::string GetDefaultDevice(bool passthrough);
   void Start();
   void Dispose();
-  bool HasVolume();
   AEDeviceType GetDeviceType(const std::string &device);
   bool HasPassthroughDevice();
   CSinkControlProtocol m_controlPort;