Skip to content
This repository
Browse code

Merge pull request #3201 from FernetMenta/aefixes

ActiveAE: fixes
  • Loading branch information...
commit 17596005e61eac32db5b101824f3a2f9dd1a4f8b 2 parents 9d75119 + 2b6a889
Rainer Hochecker authored September 07, 2013
31  xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
@@ -396,7 +396,7 @@ void CActiveAE::StateMachine(int signal, Protocol *port, Message *msg)
396 396
             m_sink.m_controlPort.SendOutMessage(CSinkControlProtocol::SILENCEMODE, &silence, sizeof(bool));
397 397
           }
398 398
           LoadSettings();
399  
-          ChangeResampleQuality();
  399
+          ChangeResamplers();
400 400
           if (!NeedReconfigureBuffers() && !NeedReconfigureSink())
401 401
             return;
402 402
           m_state = AE_TOP_RECONFIGURING;
@@ -423,8 +423,9 @@ 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)
  426
+          if (stream->m_paused != true && m_streams.size() == 1)
427 427
             FlushEngine();
  428
+          stream->m_paused = true;
428 429
           return;
429 430
         case CActiveAEControlProtocol::RESUMESTREAM:
430 431
           stream = *(CActiveAEStream**)msg->data;
@@ -898,12 +899,6 @@ void CActiveAE::Configure(AEAudioFormat *desiredFmt)
898 899
       outputFormat.m_dataFormat = AE_FMT_FLOATP;
899 900
       outputFormat.m_sampleRate = 48000;
900 901
 
901  
-      if (g_advancedSettings.m_audioResample)
902  
-      {
903  
-        outputFormat.m_sampleRate = g_advancedSettings.m_audioResample;
904  
-        CLog::Log(LOGINFO, "CActiveAE::Configure - Forcing samplerate to %d", inputFormat.m_sampleRate);
905  
-      }
906  
-
907 902
       // setup encoder
908 903
       if (!m_encoder)
909 904
       {
@@ -982,7 +977,7 @@ void CActiveAE::Configure(AEAudioFormat *desiredFmt)
982 977
       if (!(*it)->m_resampleBuffers)
983 978
       {
984 979
         (*it)->m_resampleBuffers = new CActiveAEBufferPoolResample((*it)->m_inputBuffers->m_format, outputFormat, m_settings.resampleQuality);
985  
-        (*it)->m_resampleBuffers->Create(MAX_CACHE_LEVEL*1000, false);
  980
+        (*it)->m_resampleBuffers->Create(MAX_CACHE_LEVEL*1000, false, m_settings.stereoupmix);
986 981
       }
987 982
       if (m_mode == MODE_TRANSCODE || m_streams.size() > 1)
988 983
         (*it)->m_resampleBuffers->m_fillPackets = true;
@@ -1006,7 +1001,7 @@ void CActiveAE::Configure(AEAudioFormat *desiredFmt)
1006 1001
         vizFormat.m_dataFormat = AE_FMT_FLOAT;
1007 1002
         m_vizBuffers = new CActiveAEBufferPoolResample(m_internalFormat, vizFormat, m_settings.resampleQuality);
1008 1003
         // TODO use cache of sync + water level
1009  
-        m_vizBuffers->Create(2000, false);
  1004
+        m_vizBuffers->Create(2000, false, false);
1010 1005
         m_vizInitialized = false;
1011 1006
       }
1012 1007
     }
@@ -1022,7 +1017,7 @@ void CActiveAE::Configure(AEAudioFormat *desiredFmt)
1022 1017
   if (!m_sinkBuffers)
1023 1018
   {
1024 1019
     m_sinkBuffers = new CActiveAEBufferPoolResample(sinkInputFormat, m_sinkFormat, m_settings.resampleQuality);
1025  
-    m_sinkBuffers->Create(MAX_WATER_LEVEL*1000, true);
  1020
+    m_sinkBuffers->Create(MAX_WATER_LEVEL*1000, true, false);
1026 1021
   }
1027 1022
 
1028 1023
   // reset gui sounds
@@ -1191,14 +1186,19 @@ void CActiveAE::DiscardSound(CActiveAESound *sound)
1191 1186
   }
1192 1187
 }
1193 1188
 
1194  
-void CActiveAE::ChangeResampleQuality()
  1189
+void CActiveAE::ChangeResamplers()
1195 1190
 {
1196 1191
   std::list<CActiveAEStream*>::iterator it;
1197 1192
   for(it=m_streams.begin(); it!=m_streams.end(); ++it)
1198 1193
   {
1199  
-    if ((*it)->m_resampleBuffers && (*it)->m_resampleBuffers->m_resampler && ((*it)->m_resampleBuffers->m_resampleQuality != m_settings.resampleQuality))
  1194
+    if ((*it)->m_resampleBuffers && (*it)->m_resampleBuffers->m_resampler &&
  1195
+        (((*it)->m_resampleBuffers->m_resampleQuality != m_settings.resampleQuality) ||
  1196
+        ((*it)->m_resampleBuffers->m_stereoUpmix != m_settings.stereoupmix)))
  1197
+    {
1200 1198
       (*it)->m_resampleBuffers->m_changeResampler = true;
  1199
+    }
1201 1200
     (*it)->m_resampleBuffers->m_resampleQuality = m_settings.resampleQuality;
  1201
+    (*it)->m_resampleBuffers->m_stereoUpmix = m_settings.stereoupmix;
1202 1202
   }
1203 1203
 }
1204 1204
 
@@ -1237,7 +1237,9 @@ void CActiveAE::ApplySettingsToFormat(AEAudioFormat &format, AudioSettings &sett
1237 1237
   else
1238 1238
   {
1239 1239
     format.m_dataFormat = AE_FMT_FLOAT;
1240  
-    if ((format.m_channelLayout.Count() > 2) || settings.stereoupmix)
  1240
+    if ((format.m_channelLayout.Count() > 2) ||
  1241
+         settings.stereoupmix ||
  1242
+         !g_advancedSettings.m_audioAudiophile)
1241 1243
     {
1242 1244
       switch (settings.channels)
1243 1245
       {
@@ -2302,6 +2304,7 @@ bool CActiveAE::ResampleSound(CActiveAESound *sound)
2302 2304
                   orig_config.sample_rate,
2303 2305
                   orig_config.fmt,
2304 2306
                   orig_config.bits_per_sample,
  2307
+                  false,
2305 2308
                   NULL,
2306 2309
                   AE_QUALITY_MID);
2307 2310
 
2  xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.h
@@ -261,7 +261,7 @@ class CActiveAE : public IAE, private CThread
261 261
   void ClearDiscardedBuffers();
262 262
   void SStopSound(CActiveAESound *sound);
263 263
   void DiscardSound(CActiveAESound *sound);
264  
-  void ChangeResampleQuality();
  264
+  void ChangeResamplers();
265 265
 
266 266
   bool RunStages();
267 267
   bool HasWork();
7  xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEBuffer.cpp
@@ -145,6 +145,7 @@ CActiveAEBufferPoolResample::CActiveAEBufferPoolResample(AEAudioFormat inputForm
145 145
   m_resampleRatio = 1.0;
146 146
   m_resampleQuality = quality;
147 147
   m_changeResampler = false;
  148
+  m_stereoUpmix = false;
148 149
 }
149 150
 
150 151
 CActiveAEBufferPoolResample::~CActiveAEBufferPoolResample()
@@ -152,7 +153,7 @@ CActiveAEBufferPoolResample::~CActiveAEBufferPoolResample()
152 153
   delete m_resampler;
153 154
 }
154 155
 
155  
-bool CActiveAEBufferPoolResample::Create(unsigned int totaltime, bool remap)
  156
+bool CActiveAEBufferPoolResample::Create(unsigned int totaltime, bool remap, bool upmix)
156 157
 {
157 158
   CActiveAEBufferPool::Create(totaltime);
158 159
 
@@ -171,6 +172,7 @@ bool CActiveAEBufferPoolResample::Create(unsigned int totaltime, bool remap)
171 172
                                 m_inputFormat.m_sampleRate,
172 173
                                 CActiveAEResample::GetAVSampleFormat(m_inputFormat.m_dataFormat),
173 174
                                 CAEUtil::DataFormatToUsedBits(m_inputFormat.m_dataFormat),
  175
+                                upmix,
174 176
                                 remap ? &m_format.m_channelLayout : NULL,
175 177
                                 m_resampleQuality);
176 178
   }
@@ -178,6 +180,8 @@ bool CActiveAEBufferPoolResample::Create(unsigned int totaltime, bool remap)
178 180
   // store output sampling rate, needed when ratio gets changed
179 181
   m_outSampleRate = m_format.m_sampleRate;
180 182
 
  183
+  m_stereoUpmix = upmix;
  184
+
181 185
   return true;
182 186
 }
183 187
 
@@ -198,6 +202,7 @@ void CActiveAEBufferPoolResample::ChangeResampler()
198 202
                                 m_inputFormat.m_sampleRate,
199 203
                                 CActiveAEResample::GetAVSampleFormat(m_inputFormat.m_dataFormat),
200 204
                                 CAEUtil::DataFormatToUsedBits(m_inputFormat.m_dataFormat),
  205
+                                m_stereoUpmix,
201 206
                                 NULL,
202 207
                                 m_resampleQuality);
203 208
 
3  xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEBuffer.h
@@ -90,7 +90,7 @@ class CActiveAEBufferPoolResample : public CActiveAEBufferPool
90 90
 public:
91 91
   CActiveAEBufferPoolResample(AEAudioFormat inputFormat, AEAudioFormat outputFormat, AEQuality quality);
92 92
   virtual ~CActiveAEBufferPoolResample();
93  
-  virtual bool Create(unsigned int totaltime, bool remap);
  93
+  virtual bool Create(unsigned int totaltime, bool remap, bool upmix);
94 94
   void ChangeResampler();
95 95
   bool ResampleBuffers(unsigned int timestamp = 0);
96 96
   float GetDelay();
@@ -108,6 +108,7 @@ class CActiveAEBufferPoolResample : public CActiveAEBufferPool
108 108
   double m_resampleRatio;
109 109
   AEQuality m_resampleQuality;
110 110
   unsigned int m_outSampleRate;
  111
+  bool m_stereoUpmix;
111 112
 };
112 113
 
113 114
 }
4  xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResample.cpp
@@ -36,7 +36,7 @@ CActiveAEResample::~CActiveAEResample()
36 36
   m_dllSwResample.Unload();
37 37
 }
38 38
 
39  
-bool CActiveAEResample::Init(uint64_t dst_chan_layout, int dst_channels, int dst_rate, AVSampleFormat dst_fmt, int dst_bits, uint64_t src_chan_layout, int src_channels, int src_rate, AVSampleFormat src_fmt, int src_bits, CAEChannelInfo *remapLayout, AEQuality quality)
  39
+bool CActiveAEResample::Init(uint64_t dst_chan_layout, int dst_channels, int dst_rate, AVSampleFormat dst_fmt, int dst_bits, uint64_t src_chan_layout, int src_channels, int src_rate, AVSampleFormat src_fmt, int src_bits, bool upmix, CAEChannelInfo *remapLayout, AEQuality quality)
40 40
 {
41 41
   if (!m_dllAvUtil.Load() || !m_dllSwResample.Load())
42 42
     return false;
@@ -109,7 +109,7 @@ bool CActiveAEResample::Init(uint64_t dst_chan_layout, int dst_channels, int dst
109 109
     }
110 110
   }
111 111
   // stereo upmix
112  
-  else if (m_src_channels == 2 && m_dst_channels > 2)
  112
+  else if (upmix && m_src_channels == 2 && m_dst_channels > 2)
113 113
   {
114 114
     memset(m_rematrix, 0, sizeof(m_rematrix));
115 115
     for (int out=0; out<m_dst_channels; out++)
2  xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResample.h
@@ -34,7 +34,7 @@ class CActiveAEResample
34 34
 public:
35 35
   CActiveAEResample();
36 36
   virtual ~CActiveAEResample();
37  
-  bool Init(uint64_t dst_chan_layout, int dst_channels, int dst_rate, AVSampleFormat dst_fmt, int dst_bits, uint64_t src_chan_layout, int src_channels, int src_rate, AVSampleFormat src_fmt, int src_bits, CAEChannelInfo *remapLayout, AEQuality quality);
  37
+  bool Init(uint64_t dst_chan_layout, int dst_channels, int dst_rate, AVSampleFormat dst_fmt, int dst_bits, uint64_t src_chan_layout, int src_channels, int src_rate, AVSampleFormat src_fmt, int src_bits, bool upmix, CAEChannelInfo *remapLayout, AEQuality quality);
38 38
   int Resample(uint8_t **dst_buffer, int dst_samples, uint8_t **src_buffer, int src_samples);
39 39
   int64_t GetDelay(int64_t base);
40 40
   int GetBufferedSamples();

0 notes on commit 1759600

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