Merge pull request #4670 from fritsch/pacork
authorPeter Frühberger <Peter.Fruehberger@gmail.com>
Fri, 9 May 2014 12:32:21 +0000 (14:32 +0200)
committerTrent Nelson <trent.nelson@pivosgroup.com>
Sat, 7 Jun 2014 05:27:33 +0000 (13:27 +0800)
AESinkPULSE: Start stream corked. Resume when starting to add packets

xbmc/cores/AudioEngine/Sinks/AESinkPULSE.cpp
xbmc/cores/AudioEngine/Sinks/AESinkPULSE.h

index 54af197..ff6fd9b 100644 (file)
@@ -694,7 +694,8 @@ bool CAESinkPULSE::Initialize(AEAudioFormat &format, std::string &device)
   m_format = format;
   format.m_dataFormat = m_passthrough ? AE_FMT_S16NE : format.m_dataFormat;
 
-  Pause(false);
+  // Cork stream will resume when adding first package
+  Pause(true);
   {
     CSingleLock lock(m_sec);
     m_IsAllocated = true;
@@ -772,6 +773,11 @@ unsigned int CAESinkPULSE::AddPackets(uint8_t *data, unsigned int frames, bool h
   if (!m_IsAllocated)
     return frames;
 
+  if (m_IsStreamPaused)
+  {
+    Pause(false);
+  }
+
   pa_threaded_mainloop_lock(m_MainLoop);
 
   unsigned int available = frames * m_format.m_frameSize;
@@ -907,16 +913,15 @@ bool CAESinkPULSE::IsInitialized()
  return m_IsAllocated; 
 }
 
-bool CAESinkPULSE::Pause(bool pause)
+void CAESinkPULSE::Pause(bool pause)
 {
   pa_threaded_mainloop_lock(m_MainLoop);
 
   if (!WaitForOperation(pa_stream_cork(m_Stream, pause ? 1 : 0, NULL, NULL), m_MainLoop, pause ? "Pause" : "Resume"))
     pause = !pause;
 
+  m_IsStreamPaused = pause;
   pa_threaded_mainloop_unlock(m_MainLoop);
-
-  return pause;
 }
 
 inline bool CAESinkPULSE::WaitForOperation(pa_operation *op, pa_threaded_mainloop *mainloop, const char *LogEntry = "")
index 39fda73..727472e 100644 (file)
@@ -51,12 +51,13 @@ public:
   bool IsInitialized();
   CCriticalSection m_sec;
 private:
-  bool Pause(bool pause);
+  void Pause(bool pause);
   static inline bool WaitForOperation(pa_operation *op, pa_threaded_mainloop *mainloop, const char *LogEntry);
   static bool SetupContext(const char *host, pa_context **context, pa_threaded_mainloop **mainloop);
 
   bool m_IsAllocated;
   bool m_passthrough;
+  bool m_IsStreamPaused;
 
   AEAudioFormat m_format;
   unsigned int m_BytesPerSecond;