Skip to content
This repository
Browse code

[rbp/omxplayer] Support both analogue and hdmi audio

Thanks to stupid-boy for the original implementation.
  • Loading branch information...
commit 2506b656635ed6ca2c2d87cf8d0aef34d73e4d9d 1 parent fb23d2c
popcornmix authored August 19, 2013
12  language/English/strings.po
@@ -14332,6 +14332,11 @@ msgctxt "#36541"
14332 14332
 msgid "Allows volume control from AirPlay clients."
14333 14333
 msgstr ""
14334 14334
 
  14335
+#: system/settings/rbp.xml
  14336
+msgctxt "#36542"
  14337
+msgid "Output to both analogue (headphones) and HDMI"
  14338
+msgstr ""
  14339
+
14335 14340
 #reserved strings 365XX
14336 14341
 
14337 14342
 #: xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
@@ -14379,4 +14384,9 @@ msgstr ""
14379 14384
 #: system/settings/settings.xml
14380 14385
 msgctxt "#37016"
14381 14386
 msgid "Select this option if your receiver is capable of decoding E-AC3 streams."
14382  
-msgstr ""
  14387
+msgstr ""
  14388
+
  14389
+#: system/settings/rbp.xml
  14390
+msgctxt "#37017"
  14391
+msgid "Dual audio output"
  14392
+msgstr ""
35  system/settings/rbp.xml
@@ -53,6 +53,41 @@
53 53
         <setting id="audiooutput.dtshdpassthrough">
54 54
           <visible>false</visible>
55 55
         </setting>
  56
+        <setting id="audiooutput.eac3passthrough">
  57
+          <visible>false</visible>
  58
+        </setting>
  59
+        <setting id="audiooutput.ac3passthrough">
  60
+          <default>true</default>
  61
+          <dependencies>
  62
+            <dependency type="enable">
  63
+              <and>
  64
+                <or>
  65
+                  <condition setting="audiooutput.mode">1</condition> <!-- AUDIO_IEC958 -->
  66
+                  <condition setting="audiooutput.mode">2</condition> <!-- AUDIO_HDMI -->
  67
+                </or>
  68
+                <condition setting="audiooutput.dualaudio">false</condition>
  69
+              </and>
  70
+            </dependency>
  71
+          </dependencies>
  72
+        </setting>
  73
+        <setting id="audiooutput.dtspassthrough">
  74
+          <default>true</default>
  75
+          <dependencies>
  76
+            <dependency type="enable">
  77
+              <and>
  78
+                <or>
  79
+                  <condition setting="audiooutput.mode">1</condition> <!-- AUDIO_IEC958 -->
  80
+                  <condition setting="audiooutput.mode">2</condition> <!-- AUDIO_HDMI -->
  81
+                </or>
  82
+                <condition setting="audiooutput.dualaudio">false</condition>
  83
+              </and>
  84
+            </dependency>
  85
+          </dependencies>
  86
+        </setting>
  87
+        <setting id="audiooutput.dualaudio" type="boolean" label="37017" help="36542">
  88
+          <level>2</level>
  89
+          <default>false</default>
  90
+        </setting>
56 91
       </group>
57 92
       <group id="2">
58 93
         <visible>false</visible>
361  xbmc/cores/omxplayer/OMXAudio.cpp
@@ -184,84 +184,224 @@ bool COMXAudio::PortSettingsChanged()
184 184
     if(!m_omx_mixer.Initialize("OMX.broadcom.audio_mixer", OMX_IndexParamAudioInit))
185 185
       return false;
186 186
   }
187  
-
188  
-  if(!m_omx_render.Initialize("OMX.broadcom.audio_render", OMX_IndexParamAudioInit))
189  
-    return false;
  187
+  if(CSettings::Get().GetBool("audiooutput.dualaudio"))
  188
+  {
  189
+    if(!m_omx_splitter.Initialize("OMX.broadcom.audio_splitter", OMX_IndexParamAudioInit))
  190
+      return false;
  191
+  }
  192
+  if (CSettings::Get().GetBool("audiooutput.dualaudio") || CSettings::Get().GetInt("audiooutput.mode") == AUDIO_ANALOG)
  193
+  {
  194
+    if(!m_omx_render_analog.Initialize("OMX.broadcom.audio_render", OMX_IndexParamAudioInit))
  195
+      return false;
  196
+  }
  197
+  if (CSettings::Get().GetBool("audiooutput.dualaudio") || CSettings::Get().GetInt("audiooutput.mode") == AUDIO_HDMI)
  198
+  {
  199
+    if(!m_omx_render_hdmi.Initialize("OMX.broadcom.audio_render", OMX_IndexParamAudioInit))
  200
+      return false;
  201
+  }
190 202
 
191 203
   ApplyVolume();
192 204
 
193  
-  if(!m_Passthrough)
  205
+  if( m_omx_mixer.IsInitialized() )
194 206
   {
195 207
     /* setup mixer output */
196 208
     OMX_INIT_STRUCTURE(m_pcm_output);
197  
-    m_pcm_output.nPortIndex      = m_omx_decoder.GetOutputPort();
  209
+    m_pcm_output.nPortIndex = m_omx_decoder.GetOutputPort();
198 210
     omx_err = m_omx_decoder.GetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
199 211
     if(omx_err != OMX_ErrorNone)
200 212
     {
201  
-       CLog::Log(LOGERROR, "%s::%s - error SetParameter 1 output omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
  213
+      CLog::Log(LOGERROR, "%s::%s - error m_omx_decoder GetParameter omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
  214
+      return false;
202 215
     }
203  
-    m_pcm_output.nPortIndex      = m_omx_mixer.GetOutputPort();
204 216
 
205 217
     /* mixer output is always stereo */
206 218
     m_pcm_output.eChannelMapping[0] = OMX_AUDIO_ChannelLF;
207 219
     m_pcm_output.eChannelMapping[1] = OMX_AUDIO_ChannelRF;
208 220
     m_pcm_output.nChannels = 2;
209 221
 
  222
+    m_pcm_output.nPortIndex = m_omx_mixer.GetOutputPort();
210 223
     omx_err = m_omx_mixer.SetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
211 224
     if(omx_err != OMX_ErrorNone)
212 225
     {
213  
-      CLog::Log(LOGERROR, "%s::%s - error SetParameter 1 output omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
  226
+      CLog::Log(LOGERROR, "%s::%s - error m_omx_mixer SetParameter omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
  227
+      return false;
214 228
     }
  229
+
215 230
     CLog::Log(LOGDEBUG, "%s::%s - Output bps %d samplerate %d channels %d buffer size %d bytes per second %d",
216 231
         CLASSNAME, __func__, (int)m_pcm_output.nBitPerSample, (int)m_pcm_output.nSamplingRate, (int)m_pcm_output.nChannels, m_BufferLen, m_BytesPerSec);
217 232
     PrintPCM(&m_pcm_output, std::string("output"));
218  
-  }
219 233
 
220  
-  m_omx_tunnel_clock.Initialize(m_omx_clock, m_omx_clock->GetInputPort(), &m_omx_render, m_omx_render.GetInputPort()+1);
  234
+    if( m_omx_splitter.IsInitialized() )
  235
+    {
  236
+      m_pcm_output.nPortIndex = m_omx_splitter.GetInputPort();
  237
+      omx_err = m_omx_splitter.SetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
  238
+      if(omx_err != OMX_ErrorNone)
  239
+      {
  240
+        CLog::Log(LOGERROR, "%s::%s - error m_omx_splitter SetParameter omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
  241
+        return false;
  242
+      }
  243
+
  244
+      // Splitter will copy input params to output when input port is enabled.
  245
+      omx_err = m_omx_splitter.SetStateForComponent(OMX_StateIdle);
  246
+      if(omx_err != OMX_ErrorNone)
  247
+      {
  248
+        CLog::Log(LOGERROR, "COMXAudio::AddPackets - Error setting OMX_StateIdle 0x%08x for m_omx_splitter", omx_err);
  249
+        return false;
  250
+      }
  251
+      m_omx_splitter.EnablePort(m_omx_splitter.GetInputPort(), false);
  252
+      m_omx_splitter.DisablePort(m_omx_splitter.GetInputPort(), false);
  253
+    }
221 254
 
222  
-  omx_err = m_omx_tunnel_clock.Establish(false);
223  
-  if(omx_err != OMX_ErrorNone)
  255
+    if( m_omx_render_analog.IsInitialized() )
  256
+    {
  257
+      m_pcm_output.nPortIndex = m_omx_render_analog.GetInputPort();
  258
+      omx_err = m_omx_render_analog.SetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
  259
+      if(omx_err != OMX_ErrorNone)
  260
+      {
  261
+        CLog::Log(LOGERROR, "%s::%s - error m_omx_render_analog SetParameter omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
  262
+        return false;
  263
+      }
  264
+    }
  265
+
  266
+    if( m_omx_render_hdmi.IsInitialized() )
  267
+    {
  268
+      m_pcm_output.nPortIndex = m_omx_render_hdmi.GetInputPort();
  269
+      omx_err = m_omx_render_hdmi.SetParameter(OMX_IndexParamAudioPcm, &m_pcm_output);
  270
+      if(omx_err != OMX_ErrorNone)
  271
+      {
  272
+        CLog::Log(LOGERROR, "%s::%s - error m_omx_render_hdmi SetParameter omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
  273
+        return false;
  274
+      }
  275
+    }
  276
+  }
  277
+  if( m_omx_render_analog.IsInitialized() )
224 278
   {
225  
-    CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_clock.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
226  
-    return false;
  279
+    m_omx_tunnel_clock_analog.Initialize(m_omx_clock, m_omx_clock->GetInputPort(),
  280
+      &m_omx_render_analog, m_omx_render_analog.GetInputPort()+1);
  281
+
  282
+    omx_err = m_omx_tunnel_clock_analog.Establish(false);
  283
+    if(omx_err != OMX_ErrorNone)
  284
+    {
  285
+      CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_clock_analog.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
  286
+      return false;
  287
+    }
  288
+    m_omx_render_analog.ResetEos();
227 289
   }
  290
+  if( m_omx_render_hdmi.IsInitialized() )
  291
+  {
  292
+    m_omx_tunnel_clock_hdmi.Initialize(m_omx_clock, m_omx_clock->GetInputPort() + (m_omx_render_analog.IsInitialized() ? 2 : 0),
  293
+      &m_omx_render_hdmi, m_omx_render_hdmi.GetInputPort()+1);
228 294
 
229  
-  m_omx_render.ResetEos();
  295
+    omx_err = m_omx_tunnel_clock_hdmi.Establish(false);
  296
+    if(omx_err != OMX_ErrorNone)
  297
+    {
  298
+      CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_clock_hdmi.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
  299
+      return false;
  300
+    }
  301
+    m_omx_render_hdmi.ResetEos();
  302
+  }
230 303
 
231  
-  // By default audio_render is the clock master, and if output samples don't fit the timestamps, it will speed up/slow down the clock.
232  
-  // This tends to be better for maintaining audio sync and avoiding audio glitches, but can affect video/display sync
233  
-  if(CSettings::Get().GetBool("videoplayer.usedisplayasclock"))
  304
+  if( m_omx_render_analog.IsInitialized() )
234 305
   {
235  
-    OMX_CONFIG_BOOLEANTYPE configBool;
236  
-    OMX_INIT_STRUCTURE(configBool);
237  
-    configBool.bEnabled = OMX_FALSE;
  306
+    // By default audio_render is the clock master, and if output samples don't fit the timestamps, it will speed up/slow down the clock.
  307
+    // This tends to be better for maintaining audio sync and avoiding audio glitches, but can affect video/display sync
  308
+    if(CSettings::Get().GetBool("videoplayer.usedisplayasclock"))
  309
+    {
  310
+      OMX_CONFIG_BOOLEANTYPE configBool;
  311
+      OMX_INIT_STRUCTURE(configBool);
  312
+      configBool.bEnabled = OMX_FALSE;
238 313
 
239  
-    omx_err = m_omx_render.SetConfig(OMX_IndexConfigBrcmClockReferenceSource, &configBool);
  314
+      omx_err = m_omx_render_analog.SetConfig(OMX_IndexConfigBrcmClockReferenceSource, &configBool);
  315
+      if (omx_err != OMX_ErrorNone)
  316
+         return false;
  317
+    }
  318
+
  319
+    OMX_CONFIG_BRCMAUDIODESTINATIONTYPE audioDest;
  320
+    OMX_INIT_STRUCTURE(audioDest);
  321
+    strncpy((char *)audioDest.sName, "local", strlen("local"));
  322
+    omx_err = m_omx_render_analog.SetConfig(OMX_IndexConfigBrcmAudioDestination, &audioDest);
240 323
     if (omx_err != OMX_ErrorNone)
241  
-       return false;
  324
+    {
  325
+      CLog::Log(LOGERROR, "%s::%s - m_omx_render_analog.SetConfig omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
  326
+      return false;
  327
+    }
242 328
   }
243 329
 
244  
-  OMX_CONFIG_BRCMAUDIODESTINATIONTYPE audioDest;
245  
-  OMX_INIT_STRUCTURE(audioDest);
246  
-  strncpy((char *)audioDest.sName, m_deviceuse.c_str(), strlen(m_deviceuse.c_str()));
247  
-
248  
-  omx_err = m_omx_render.SetConfig(OMX_IndexConfigBrcmAudioDestination, &audioDest);
249  
-  if (omx_err != OMX_ErrorNone)
  330
+  if( m_omx_render_hdmi.IsInitialized() )
250 331
   {
251  
-    CLog::Log(LOGERROR, "%s::%s - m_omx_render.SetConfig omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
252  
-    return false;
  332
+    // By default audio_render is the clock master, and if output samples don't fit the timestamps, it will speed up/slow down the clock.
  333
+    // This tends to be better for maintaining audio sync and avoiding audio glitches, but can affect video/display sync
  334
+    if(CSettings::Get().GetBool("videoplayer.usedisplayasclock"))
  335
+    {
  336
+      OMX_CONFIG_BOOLEANTYPE configBool;
  337
+      OMX_INIT_STRUCTURE(configBool);
  338
+      configBool.bEnabled = OMX_FALSE;
  339
+
  340
+      omx_err = m_omx_render_hdmi.SetConfig(OMX_IndexConfigBrcmClockReferenceSource, &configBool);
  341
+      if (omx_err != OMX_ErrorNone)
  342
+         return false;
  343
+    }
  344
+
  345
+    OMX_CONFIG_BRCMAUDIODESTINATIONTYPE audioDest;
  346
+    OMX_INIT_STRUCTURE(audioDest);
  347
+    strncpy((char *)audioDest.sName, "hdmi", strlen("hdmi"));
  348
+    omx_err = m_omx_render_hdmi.SetConfig(OMX_IndexConfigBrcmAudioDestination, &audioDest);
  349
+    if (omx_err != OMX_ErrorNone)
  350
+    {
  351
+      CLog::Log(LOGERROR, "%s::%s - m_omx_render_hdmi.SetConfig omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
  352
+      return false;
  353
+    }
253 354
   }
254 355
 
255  
-  if(!m_Passthrough)
  356
+  if( m_omx_splitter.IsInitialized() )
  357
+  {
  358
+    m_omx_tunnel_splitter_analog.Initialize(&m_omx_splitter, m_omx_splitter.GetOutputPort(), &m_omx_render_analog, m_omx_render_analog.GetInputPort());
  359
+    omx_err = m_omx_tunnel_splitter_analog.Establish(false);
  360
+    if(omx_err != OMX_ErrorNone)
  361
+    {
  362
+      CLog::Log(LOGERROR, "COMXAudio::Initialize - Error m_omx_tunnel_splitter_analog.Establish 0x%08x", omx_err);
  363
+      return false;
  364
+    }
  365
+
  366
+    m_omx_tunnel_splitter_hdmi.Initialize(&m_omx_splitter, m_omx_splitter.GetOutputPort() + 1, &m_omx_render_hdmi, m_omx_render_hdmi.GetInputPort());
  367
+    omx_err = m_omx_tunnel_splitter_hdmi.Establish(false);
  368
+    if(omx_err != OMX_ErrorNone)
  369
+    {
  370
+      CLog::Log(LOGERROR, "COMXAudio::Initialize - Error m_omx_tunnel_splitter_hdmi.Establish 0x%08x", omx_err);
  371
+      return false;
  372
+    }
  373
+  }
  374
+  if( m_omx_mixer.IsInitialized() )
256 375
   {
257 376
     m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_mixer, m_omx_mixer.GetInputPort());
258  
-    m_omx_tunnel_mixer.Initialize(&m_omx_mixer, m_omx_mixer.GetOutputPort(), &m_omx_render, m_omx_render.GetInputPort());
  377
+    if( m_omx_splitter.IsInitialized() )
  378
+    {
  379
+      m_omx_tunnel_mixer.Initialize(&m_omx_mixer, m_omx_mixer.GetOutputPort(), &m_omx_splitter, m_omx_splitter.GetInputPort());
  380
+    }
  381
+    else
  382
+    {
  383
+      if( m_omx_render_analog.IsInitialized() )
  384
+      {
  385
+        m_omx_tunnel_mixer.Initialize(&m_omx_mixer, m_omx_mixer.GetOutputPort(), &m_omx_render_analog, m_omx_render_analog.GetInputPort());
  386
+      }
  387
+      if( m_omx_render_hdmi.IsInitialized() )
  388
+      {
  389
+        m_omx_tunnel_mixer.Initialize(&m_omx_mixer, m_omx_mixer.GetOutputPort(), &m_omx_render_hdmi, m_omx_render_hdmi.GetInputPort());
  390
+      }
  391
+    }
259 392
     CLog::Log(LOGDEBUG, "%s::%s - bits:%d mode:%d channels:%d srate:%d nopassthrough", CLASSNAME, __func__,
260 393
             (int)m_pcm_input.nBitPerSample, m_pcm_input.ePCMMode, (int)m_pcm_input.nChannels, (int)m_pcm_input.nSamplingRate);
261 394
   }
262 395
   else
263 396
   {
264  
-    m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_render, m_omx_render.GetInputPort());
  397
+    if( m_omx_render_analog.IsInitialized() )
  398
+    {
  399
+      m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_render_analog, m_omx_render_analog.GetInputPort());
  400
+    }
  401
+    else if( m_omx_render_hdmi.IsInitialized() )
  402
+    {
  403
+      m_omx_tunnel_decoder.Initialize(&m_omx_decoder, m_omx_decoder.GetOutputPort(), &m_omx_render_hdmi, m_omx_render_hdmi.GetInputPort());
  404
+    }
265 405
     CLog::Log(LOGDEBUG, "%s::%s - bits:%d mode:%d channels:%d srate:%d passthrough", CLASSNAME, __func__,
266 406
             0, 0, 0, 0);
267 407
   }
@@ -272,13 +412,18 @@ bool COMXAudio::PortSettingsChanged()
272 412
     CLog::Log(LOGERROR, "%s::%s - m_omx_tunnel_decoder.Establish omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
273 413
     return false;
274 414
   }
275  
-  if(!m_Passthrough)
  415
+
  416
+  if( m_omx_mixer.IsInitialized() )
276 417
   {
277 418
     omx_err = m_omx_mixer.SetStateForComponent(OMX_StateExecuting);
278 419
     if(omx_err != OMX_ErrorNone) {
279 420
       CLog::Log(LOGERROR, "%s::%s - m_omx_mixer OMX_StateExecuting omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
280 421
       return false;
281 422
     }
  423
+  }
  424
+
  425
+  if( m_omx_mixer.IsInitialized() )
  426
+  {
282 427
     omx_err = m_omx_tunnel_mixer.Establish(false);
283 428
     if(omx_err != OMX_ErrorNone)
284 429
     {
@@ -287,18 +432,39 @@ bool COMXAudio::PortSettingsChanged()
287 432
     }
288 433
   }
289 434
 
290  
-  omx_err = m_omx_render.SetStateForComponent(OMX_StateExecuting);
291  
-  if(omx_err != OMX_ErrorNone)
  435
+  if( m_omx_splitter.IsInitialized() )
292 436
   {
293  
-    CLog::Log(LOGERROR, "%s::%s - m_omx_render OMX_StateExecuting omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
294  
-    return false;
  437
+    omx_err = m_omx_splitter.SetStateForComponent(OMX_StateExecuting);
  438
+    if(omx_err != OMX_ErrorNone)
  439
+    {
  440
+      CLog::Log(LOGERROR, "%s::%s - m_omx_splitter OMX_StateExecuting 0x%08x", CLASSNAME, __func__, omx_err);
  441
+     return false;
  442
+    }
  443
+  }
  444
+  if( m_omx_render_analog.IsInitialized() )
  445
+  {
  446
+    omx_err = m_omx_render_analog.SetStateForComponent(OMX_StateExecuting);
  447
+    if(omx_err != OMX_ErrorNone)
  448
+    {
  449
+      CLog::Log(LOGERROR, "%s::%s - m_omx_render_analog OMX_StateExecuting omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
  450
+      return false;
  451
+    }
  452
+  }
  453
+  if( m_omx_render_hdmi.IsInitialized() )
  454
+  {
  455
+    omx_err = m_omx_render_hdmi.SetStateForComponent(OMX_StateExecuting);
  456
+    if(omx_err != OMX_ErrorNone)
  457
+    {
  458
+      CLog::Log(LOGERROR, "%s::%s - m_omx_render_hdmi OMX_StateExecuting omx_err(0x%08x)", CLASSNAME, __func__, omx_err);
  459
+      return false;
  460
+    }
295 461
   }
296 462
 
297 463
   m_settings_changed = true;
298 464
   return true;
299 465
 }
300 466
 
301  
-bool COMXAudio::Initialize(AEAudioFormat format, std::string& device, OMXClock *clock, CDVDStreamInfo &hints, bool bUsePassthrough, bool bUseHWDecode)
  467
+bool COMXAudio::Initialize(AEAudioFormat format, OMXClock *clock, CDVDStreamInfo &hints, bool bUsePassthrough, bool bUseHWDecode)
302 468
 {
303 469
   CSingleLock lock (m_critSection);
304 470
   OMX_ERRORTYPE omx_err;
@@ -308,12 +474,6 @@ bool COMXAudio::Initialize(AEAudioFormat format, std::string& device, OMXClock *
308 474
   if(!m_dllAvUtil.Load())
309 475
     return false;
310 476
 
311  
-  if(device == "hdmi") {
312  
-    m_deviceuse = "hdmi";
313  
-  } else {
314  
-    m_deviceuse = "local";
315  
-  }
316  
-
317 477
   m_HWDecode    = bUseHWDecode;
318 478
   m_Passthrough = bUsePassthrough;
319 479
 
@@ -592,8 +752,8 @@ bool COMXAudio::Initialize(AEAudioFormat format, std::string& device, OMXClock *
592 752
   CLog::Log(LOGDEBUG, "COMXAudio::Initialize Input bps %d samplerate %d channels %d buffer size %d bytes per second %d", 
593 753
       (int)m_pcm_input.nBitPerSample, (int)m_pcm_input.nSamplingRate, (int)m_pcm_input.nChannels, m_BufferLen, m_BytesPerSec);
594 754
   PrintPCM(&m_pcm_output, std::string("input"));
595  
-  CLog::Log(LOGDEBUG, "COMXAudio::Initialize device %s passthrough %d hwdecode %d", 
596  
-      device.c_str(), m_Passthrough, m_HWDecode);
  755
+  CLog::Log(LOGDEBUG, "COMXAudio::Initialize device passthrough %d hwdecode %d",
  756
+     m_Passthrough, m_HWDecode);
597 757
 
598 758
   return true;
599 759
 }
@@ -603,20 +763,27 @@ bool COMXAudio::Deinitialize()
603 763
 {
604 764
   CSingleLock lock (m_critSection);
605 765
 
606  
-  m_omx_tunnel_decoder.Flush();
607  
-  if(!m_Passthrough)
608  
-    m_omx_tunnel_mixer.Flush();
609  
-  m_omx_tunnel_clock.Flush();
610  
-
611  
-  m_omx_tunnel_clock.Deestablish();
612  
-  if(!m_Passthrough)
  766
+  Flush();
  767
+
  768
+  if ( m_omx_tunnel_clock_analog.IsInitialized() )
  769
+    m_omx_tunnel_clock_analog.Deestablish();
  770
+  if ( m_omx_tunnel_clock_hdmi.IsInitialized() )
  771
+    m_omx_tunnel_clock_hdmi.Deestablish();
  772
+  if ( m_omx_tunnel_splitter_analog.IsInitialized() )
  773
+    m_omx_tunnel_splitter_analog.Deestablish();
  774
+  if ( m_omx_tunnel_splitter_hdmi.IsInitialized() )
  775
+    m_omx_tunnel_splitter_hdmi.Deestablish();
  776
+  if ( m_omx_tunnel_mixer.IsInitialized() )
613 777
     m_omx_tunnel_mixer.Deestablish();
614 778
   m_omx_tunnel_decoder.Deestablish();
615 779
 
616  
-  m_omx_decoder.FlushInput();
617  
-
618  
-  m_omx_render.Deinitialize(true);
619  
-  if(!m_Passthrough)
  780
+  if ( m_omx_render_analog.IsInitialized() )
  781
+    m_omx_render_analog.Deinitialize(true);
  782
+  if ( m_omx_render_hdmi.IsInitialized() )
  783
+    m_omx_render_hdmi.Deinitialize(true);
  784
+  if ( m_omx_splitter.IsInitialized() )
  785
+    m_omx_splitter.Deinitialize(true);
  786
+  if ( m_omx_mixer.IsInitialized() )
620 787
     m_omx_mixer.Deinitialize(true);
621 788
   m_omx_decoder.Deinitialize(true);
622 789
 
@@ -651,11 +818,26 @@ void COMXAudio::Flush()
651 818
   if(!m_Initialized)
652 819
     return;
653 820
 
654  
-  m_omx_decoder.FlushInput();
  821
+  m_omx_decoder.FlushAll();
655 822
   m_omx_tunnel_decoder.Flush();
656  
-  if(!m_Passthrough)
  823
+
  824
+  if ( m_omx_mixer.IsInitialized() )
  825
+    m_omx_mixer.FlushAll();
  826
+  if( m_omx_tunnel_mixer.IsInitialized() )
657 827
     m_omx_tunnel_mixer.Flush();
658  
-  
  828
+
  829
+  if ( m_omx_splitter.IsInitialized() )
  830
+    m_omx_splitter.FlushAll();
  831
+  if ( m_omx_tunnel_splitter_analog.IsInitialized() )
  832
+    m_omx_tunnel_splitter_analog.Flush();
  833
+  if ( m_omx_tunnel_splitter_hdmi.IsInitialized() )
  834
+    m_omx_tunnel_splitter_hdmi.Flush();
  835
+
  836
+  if ( m_omx_render_analog.IsInitialized() )
  837
+    m_omx_render_analog.FlushAll();
  838
+  if ( m_omx_render_hdmi.IsInitialized() )
  839
+    m_omx_render_hdmi.FlushAll();
  840
+
659 841
   m_last_pts      = DVD_NOPTS_VALUE;
660 842
   m_LostSync      = true;
661 843
   m_setStartTime  = true;
@@ -746,19 +928,32 @@ bool COMXAudio::ApplyVolume(void)
746 928
   {
747 929
     OMX_AUDIO_CONFIG_VOLUMETYPE volume;
748 930
     OMX_INIT_STRUCTURE(volume);
749  
-    volume.nPortIndex = m_omx_render.GetInputPort();
750 931
 
751 932
     volume.bLinear    = OMX_TRUE;
752 933
     float hardwareVolume = fVolume * gain * 100.0f;
753 934
     volume.sVolume.nValue = (int)(hardwareVolume + 0.5f);
754 935
 
755  
-    OMX_ERRORTYPE omx_err =
756  
-      m_omx_render.SetConfig(OMX_IndexConfigAudioVolume, &volume);
757  
-    if(omx_err != OMX_ErrorNone)
  936
+    if(m_omx_render_analog.IsInitialized())
758 937
     {
759  
-      CLog::Log(LOGERROR, "%s::%s - error setting OMX_IndexConfigAudioVolume, error 0x%08x\n",
  938
+      volume.nPortIndex = m_omx_render_analog.GetInputPort();
  939
+      OMX_ERRORTYPE omx_err = m_omx_render_analog.SetConfig(OMX_IndexConfigAudioVolume, &volume);
  940
+      if(omx_err != OMX_ErrorNone)
  941
+      {
  942
+        CLog::Log(LOGERROR, "%s::%s - error setting OMX_IndexConfigAudioVolume, error 0x%08x\n",
760 943
                 CLASSNAME, __func__, omx_err);
761  
-      return false;
  944
+        return false;
  945
+      }
  946
+    }
  947
+    if(m_omx_render_hdmi.IsInitialized())
  948
+    {
  949
+      volume.nPortIndex = m_omx_render_hdmi.GetInputPort();
  950
+      OMX_ERRORTYPE omx_err = m_omx_render_hdmi.SetConfig(OMX_IndexConfigAudioVolume, &volume);
  951
+      if(omx_err != OMX_ErrorNone)
  952
+      {
  953
+        CLog::Log(LOGERROR, "%s::%s - error setting OMX_IndexConfigAudioVolume, error 0x%08x\n",
  954
+                CLASSNAME, __func__, omx_err);
  955
+        return false;
  956
+      }
762 957
     }
763 958
   }
764 959
   CLog::Log(LOGINFO, "%s::%s - Volume=%.2f\n", CLASSNAME, __func__, fVolume);
@@ -1043,16 +1238,32 @@ unsigned int COMXAudio::GetAudioRenderingLatency()
1043 1238
 
1044 1239
   OMX_PARAM_U32TYPE param;
1045 1240
   OMX_INIT_STRUCTURE(param);
1046  
-  param.nPortIndex = m_omx_render.GetInputPort();
1047 1241
 
1048  
-  OMX_ERRORTYPE omx_err =
1049  
-    m_omx_render.GetConfig(OMX_IndexConfigAudioRenderingLatency, &param);
  1242
+  if(m_omx_render_analog.IsInitialized())
  1243
+  {
  1244
+    param.nPortIndex = m_omx_render_analog.GetInputPort();
  1245
+
  1246
+    OMX_ERRORTYPE omx_err = m_omx_render_analog.GetConfig(OMX_IndexConfigAudioRenderingLatency, &param);
1050 1247
 
1051  
-  if(omx_err != OMX_ErrorNone)
  1248
+    if(omx_err != OMX_ErrorNone)
  1249
+    {
  1250
+      CLog::Log(LOGERROR, "%s::%s - error getting OMX_IndexConfigAudioRenderingLatency error 0x%08x\n",
  1251
+        CLASSNAME, __func__, omx_err);
  1252
+      return 0;
  1253
+    }
  1254
+  }
  1255
+  else if(m_omx_render_hdmi.IsInitialized())
1052 1256
   {
1053  
-    CLog::Log(LOGERROR, "%s::%s - error getting OMX_IndexConfigAudioRenderingLatency error 0x%08x\n",
1054  
-      CLASSNAME, __func__, omx_err);
1055  
-    return 0;
  1257
+    param.nPortIndex = m_omx_render_hdmi.GetInputPort();
  1258
+
  1259
+    OMX_ERRORTYPE omx_err = m_omx_render_hdmi.GetConfig(OMX_IndexConfigAudioRenderingLatency, &param);
  1260
+
  1261
+    if(omx_err != OMX_ErrorNone)
  1262
+    {
  1263
+      CLog::Log(LOGERROR, "%s::%s - error getting OMX_IndexConfigAudioRenderingLatency error 0x%08x\n",
  1264
+        CLASSNAME, __func__, omx_err);
  1265
+      return 0;
  1266
+    }
1056 1267
   }
1057 1268
 
1058 1269
   return param.nU32;
12  xbmc/cores/omxplayer/OMXAudio.h
@@ -60,7 +60,7 @@ class COMXAudio
60 60
   float GetCacheTime();
61 61
   float GetCacheTotal();
62 62
   COMXAudio();
63  
-  bool Initialize(AEAudioFormat format, std::string& device, OMXClock *clock, CDVDStreamInfo &hints, bool bUsePassthrough, bool bUseHWDecode);
  63
+  bool Initialize(AEAudioFormat format, OMXClock *clock, CDVDStreamInfo &hints, bool bUsePassthrough, bool bUseHWDecode);
64 64
   bool PortSettingsChanged();
65 65
   ~COMXAudio();
66 66
 
@@ -118,7 +118,6 @@ class COMXAudio
118 118
   OMX_AUDIO_CODINGTYPE m_eEncoding;
119 119
   uint8_t       *m_extradata;
120 120
   int           m_extrasize;
121  
-  std::string   m_deviceuse;
122 121
   // stuff for visualisation
123 122
   double        m_last_pts;
124 123
   int           m_vizBufferSize;
@@ -141,12 +140,17 @@ class COMXAudio
141 140
   WAVEFORMATEXTENSIBLE        m_wave_header;
142 141
   AEAudioFormat m_format;
143 142
 protected:
144  
-  COMXCoreComponent m_omx_render;
  143
+  COMXCoreComponent m_omx_render_analog;
  144
+  COMXCoreComponent m_omx_render_hdmi;
  145
+  COMXCoreComponent m_omx_splitter;
145 146
   COMXCoreComponent m_omx_mixer;
146 147
   COMXCoreComponent m_omx_decoder;
147  
-  COMXCoreTunel     m_omx_tunnel_clock;
  148
+  COMXCoreTunel     m_omx_tunnel_clock_analog;
  149
+  COMXCoreTunel     m_omx_tunnel_clock_hdmi;
148 150
   COMXCoreTunel     m_omx_tunnel_mixer;
149 151
   COMXCoreTunel     m_omx_tunnel_decoder;
  152
+  COMXCoreTunel     m_omx_tunnel_splitter_analog;
  153
+  COMXCoreTunel     m_omx_tunnel_splitter_hdmi;
150 154
   DllAvUtil         m_dllAvUtil;
151 155
 
152 156
   OMX_AUDIO_CHANNELTYPE m_input_channels[OMX_AUDIO_MAXCHANNELS];
12  xbmc/cores/omxplayer/OMXPlayerAudio.cpp
@@ -146,7 +146,8 @@ void OMXPlayerAudio::OpenStream(CDVDStreamInfo &hints, COMXAudioCodecOMX *codec)
146 146
   m_flush           = false;
147 147
   m_nChannels       = 0;
148 148
   m_stalled         = m_messageQueue.GetPacketCount(CDVDMsg::DEMUXER_PACKET) == 0;
149  
-  m_use_passthrough = (CSettings::Get().GetInt("audiooutput.mode") == AUDIO_HDMI) ? true : false ;
  149
+  m_use_passthrough = (CSettings::Get().GetInt("audiooutput.mode") == AUDIO_HDMI &&
  150
+                      !CSettings::Get().GetBool("audiooutput.dualaudio")) ? true : false ;
150 151
   m_use_hw_decode   = g_advancedSettings.m_omxHWAudioDecode;
151 152
   m_format.m_dataFormat    = GetDataFormat(m_hints);
152 153
   m_format.m_sampleRate    = 0;
@@ -580,13 +581,6 @@ bool OMXPlayerAudio::OpenDecoder()
580 581
   /* GetDataFormat is setting up evrything */
581 582
   m_format.m_dataFormat = GetDataFormat(m_hints);
582 583
 
583  
-  std::string device = "";
584  
-  
585  
-  if(CSettings::Get().GetInt("audiooutput.mode") == AUDIO_HDMI)
586  
-    device = "hdmi";
587  
-  else
588  
-    device = "local";
589  
-
590 584
   m_format.m_channelLayout.Reset();
591 585
   if (m_pAudioCodec && !m_passthrough)
592 586
     m_format.m_channelLayout = m_pAudioCodec->GetChannelMap();
@@ -601,7 +595,7 @@ bool OMXPlayerAudio::OpenDecoder()
601 595
     if (m_nChannels > 4 ) m_format.m_channelLayout += AE_CH_BL;
602 596
     if (m_nChannels > 5 ) m_format.m_channelLayout += AE_CH_BR;
603 597
   }
604  
-  bool bAudioRenderOpen = m_omxAudio.Initialize(m_format, device, m_av_clock, m_hints, m_passthrough, m_hw_decode);
  598
+  bool bAudioRenderOpen = m_omxAudio.Initialize(m_format, m_av_clock, m_hints, m_passthrough, m_hw_decode);
605 599
 
606 600
   m_codec_name = "";
607 601
   m_bad_state  = !bAudioRenderOpen;

0 notes on commit 2506b65

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