AESinkPULSE: Take care when using m_encodedRate when doing passthrough fallback to...
authorfritsch <peter.fruehberger@gmail.com>
Sat, 18 Jan 2014 14:54:28 +0000 (15:54 +0100)
committerfritsch <peter.fruehberger@gmail.com>
Sat, 18 Jan 2014 16:58:40 +0000 (17:58 +0100)
xbmc/cores/AudioEngine/Sinks/AESinkPULSE.cpp

index 7062bcd..08cb37e 100644 (file)
@@ -445,7 +445,22 @@ bool CAESinkPULSE::Initialize(AEAudioFormat &format, std::string &device)
   if(!passthrough)
     pa_format_info_set_sample_format(info[0], AEFormatToPulseFormat(format.m_dataFormat));
   pa_format_info_set_channels(info[0], m_Channels);
-  unsigned int samplerate = passthrough ? format.m_encodedRate : format.m_sampleRate;
+
+  // PA requires m_encodedRate in order to do EAC3
+  unsigned int samplerate;
+  if (passthrough)
+  {
+    if (format.m_encodedRate == 0)
+    {
+      CLog::Log(LOGNOTICE, "PulseAudio: Passthrough in use but m_encodedRate is not set - fallback to m_sampleRate");
+      samplerate = format.m_sampleRate;
+    }
+    else
+      samplerate = format.m_encodedRate;
+  }
+  else
+    samplerate = format.m_sampleRate;
+
   pa_format_info_set_rate(info[0], samplerate);
 
   if (!pa_format_info_valid(info[0]))