Skip to content
This repository
Browse code

Merge pull request #3148 from FernetMenta/aepause

ActiveAE: flush engine on pause stream if only a single stream is playin...
  • Loading branch information...
commit 5be768077e64091468562c0501cdf0f19971c0c4 2 parents e4c9e8c + e6e0545
Rainer Hochecker authored August 25, 2013
47  xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
@@ -423,6 +423,8 @@ void CActiveAE::StateMachine(int signal, Protocol *port, Message *msg)
423 423
           CActiveAEStream *stream;
424 424
           stream = *(CActiveAEStream**)msg->data;
425 425
           stream->m_paused = true;
  426
+          if (m_streams.size() == 1)
  427
+            FlushEngine();
426 428
           return;
427 429
         case CActiveAEControlProtocol::RESUMESTREAM:
428 430
           stream = *(CActiveAEStream**)msg->data;
@@ -1110,31 +1112,36 @@ void CActiveAE::SFlushStream(CActiveAEStream *stream)
1110 1112
   // flush the engine if we only have a single stream
1111 1113
   if (m_streams.size() == 1)
1112 1114
   {
1113  
-    if (m_sinkBuffers)
1114  
-      m_sinkBuffers->Flush();
1115  
-    if (m_vizBuffers)
1116  
-      m_vizBuffers->Flush();
  1115
+    FlushEngine();
  1116
+  }
  1117
+}
1117 1118
 
1118  
-    // send message to sink
1119  
-    Message *reply;
1120  
-    if (m_sink.m_controlPort.SendOutMessageSync(CSinkControlProtocol::FLUSH, 
1121  
-                                             &reply, 2000))
1122  
-    {
1123  
-      bool success = reply->signal == CSinkControlProtocol::ACC ? true : false;
1124  
-      if (!success)
1125  
-      {
1126  
-        CLog::Log(LOGERROR, "ActiveAE::%s - returned error on flush", __FUNCTION__);
1127  
-        m_extError = true;
1128  
-      }
1129  
-      reply->Release();
1130  
-    }
1131  
-    else
  1119
+void CActiveAE::FlushEngine()
  1120
+{
  1121
+  if (m_sinkBuffers)
  1122
+    m_sinkBuffers->Flush();
  1123
+  if (m_vizBuffers)
  1124
+    m_vizBuffers->Flush();
  1125
+
  1126
+  // send message to sink
  1127
+  Message *reply;
  1128
+  if (m_sink.m_controlPort.SendOutMessageSync(CSinkControlProtocol::FLUSH,
  1129
+                                           &reply, 2000))
  1130
+  {
  1131
+    bool success = reply->signal == CSinkControlProtocol::ACC ? true : false;
  1132
+    if (!success)
1132 1133
     {
1133  
-      CLog::Log(LOGERROR, "ActiveAE::%s - failed to flush", __FUNCTION__);
  1134
+      CLog::Log(LOGERROR, "ActiveAE::%s - returned error on flush", __FUNCTION__);
1134 1135
       m_extError = true;
1135 1136
     }
1136  
-    m_stats.Reset(m_sinkFormat.m_sampleRate);
  1137
+    reply->Release();
  1138
+  }
  1139
+  else
  1140
+  {
  1141
+    CLog::Log(LOGERROR, "ActiveAE::%s - failed to flush", __FUNCTION__);
  1142
+    m_extError = true;
1137 1143
   }
  1144
+  m_stats.Reset(m_sinkFormat.m_sampleRate);
1138 1145
 }
1139 1146
 
1140 1147
 void CActiveAE::ClearDiscardedBuffers()
1  xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.h
@@ -256,6 +256,7 @@ class CActiveAE : public IAE, private CThread
256 256
   CActiveAEStream* CreateStream(MsgStreamNew *streamMsg);
257 257
   void DiscardStream(CActiveAEStream *stream);
258 258
   void SFlushStream(CActiveAEStream *stream);
  259
+  void FlushEngine();
259 260
   void ClearDiscardedBuffers();
260 261
   void SStopSound(CActiveAESound *sound);
261 262
   void DiscardSound(CActiveAESound *sound);

0 notes on commit 5be7680

Please sign in to comment.
Something went wrong with that request. Please try again.