Skip to content
This repository
Browse code

Merge pull request #3153 from FernetMenta/aefixes

ActiveAE fixes
  • Loading branch information...
commit 6aeac5d94535566368e486dfb0211954c417db97 2 parents 79682f9 + 48a959b
Rainer Hochecker authored
34  xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
@@ -800,7 +800,8 @@ void CActiveAE::Configure(AEAudioFormat *desiredFmt)
800 800
   bool initSink = false;
801 801
 
802 802
   AEAudioFormat sinkInputFormat, inputFormat;
803  
-  m_mode = MODE_PCM;
  803
+  AEAudioFormat oldInternalFormat = m_internalFormat;
  804
+  bool updateMode = true;
804 805
 
805 806
   if (m_streams.empty())
806 807
   {
@@ -821,6 +822,7 @@ void CActiveAE::Configure(AEAudioFormat *desiredFmt)
821 822
   else if (m_streams.size() > 1 && m_silenceBuffers == NULL)
822 823
   {
823 824
     inputFormat = m_sinkRequestFormat;
  825
+    updateMode = false;
824 826
   }
825 827
   else
826 828
   {
@@ -828,7 +830,7 @@ void CActiveAE::Configure(AEAudioFormat *desiredFmt)
828 830
   }
829 831
 
830 832
   m_sinkRequestFormat = inputFormat;
831  
-  ApplySettingsToFormat(m_sinkRequestFormat, m_settings, true);
  833
+  ApplySettingsToFormat(m_sinkRequestFormat, m_settings, updateMode);
832 834
   std::string device = AE_IS_RAW(m_sinkRequestFormat.m_dataFormat) ? m_settings.passthoughdevice : m_settings.device;
833 835
   std::string driver;
834 836
   CAESinkFactory::ParseDevice(device, driver);
@@ -1031,10 +1033,13 @@ void CActiveAE::Configure(AEAudioFormat *desiredFmt)
1031 1033
   }
1032 1034
 
1033 1035
   // reset gui sounds
1034  
-  std::vector<CActiveAESound*>::iterator it;
1035  
-  for (it = m_sounds.begin(); it != m_sounds.end(); ++it)
  1036
+  if (!CompareFormat(oldInternalFormat, m_internalFormat))
1036 1037
   {
1037  
-    (*it)->SetConverted(false);
  1038
+    std::vector<CActiveAESound*>::iterator it;
  1039
+    for (it = m_sounds.begin(); it != m_sounds.end(); ++it)
  1040
+    {
  1041
+      (*it)->SetConverted(false);
  1042
+    }
1038 1043
   }
1039 1044
 
1040 1045
   ClearDiscardedBuffers();
@@ -1206,6 +1211,9 @@ void CActiveAE::ChangeResampleQuality()
1206 1211
 
1207 1212
 void CActiveAE::ApplySettingsToFormat(AEAudioFormat &format, AudioSettings &settings, bool setmode)
1208 1213
 {
  1214
+  if (setmode)
  1215
+    m_mode = MODE_PCM;
  1216
+
1209 1217
   // raw pass through
1210 1218
   if (m_settings.mode != AUDIO_ANALOG && AE_IS_RAW(format.m_dataFormat))
1211 1219
   {
@@ -1469,7 +1477,9 @@ bool CActiveAE::RunStages()
1469 1477
     }
1470 1478
     else
1471 1479
     {
1472  
-      if ((*it)->m_inputBuffers->m_allSamples.size() == (*it)->m_inputBuffers->m_freeSamples.size())
  1480
+      if ((*it)->m_resampleBuffers->m_inputSamples.empty() &&
  1481
+          (*it)->m_resampleBuffers->m_outputSamples.empty() &&
  1482
+          (*it)->m_processingSamples.empty())
1473 1483
       {
1474 1484
         (*it)->m_streamPort->SendInMessage(CActiveAEDataProtocol::STREAMDRAINED);
1475 1485
         (*it)->m_drain = false;
@@ -1482,11 +1492,17 @@ bool CActiveAE::RunStages()
1482 1492
         {
1483 1493
           CActiveAEStream *slave = (CActiveAEStream*)((*it)->m_streamSlave);
1484 1494
           slave->m_paused = false;
1485  
-          Configure(&slave->m_format);
  1495
+
  1496
+          // TODO: find better solution for this
  1497
+          // gapless bites audiophile
  1498
+          if (g_advancedSettings.m_audioAudiophile)
  1499
+            Configure(&slave->m_format);
  1500
+
1486 1501
           (*it)->m_streamSlave = NULL;
1487 1502
         }
1488 1503
         (*it)->m_streamDrained = true;
1489 1504
         (*it)->m_streamDraining = false;
  1505
+        (*it)->m_streamFading = false;
1490 1506
       }
1491 1507
     }
1492 1508
   }
@@ -2251,7 +2267,11 @@ void CActiveAE::ResampleSounds()
2251 2267
   for (it = m_sounds.begin(); it != m_sounds.end(); ++it)
2252 2268
   {
2253 2269
     if (!(*it)->IsConverted())
  2270
+    {
2254 2271
       ResampleSound(*it);
  2272
+      // only do one sound, then yield to main loop
  2273
+      break;
  2274
+    }
2255 2275
   }
2256 2276
 }
2257 2277
 

0 notes on commit 6aeac5d

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