Skip to content
This repository
Browse code

changed, include AE_FMT_S16NE as avaliable format on audiotrack sink

  • Loading branch information...
commit e56539477257718839e9644968ed78801248b573 1 parent 37b8fb7
authored July 14, 2013
19  xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp
@@ -73,7 +73,7 @@ CAESinkAUDIOTRACK::CAESinkAUDIOTRACK()
73 73
   : CThread("AudioTrack")
74 74
 {
75 75
   m_sinkbuffer = NULL;
76  
-  m_alignedS16LE = NULL;
  76
+  m_alignedS16 = NULL;
77 77
   m_volume_changed = false;
78 78
   m_min_frames = 0;
79 79
   m_sink_frameSize = 0;
@@ -166,8 +166,8 @@ void CAESinkAUDIOTRACK::Deinitialize()
166 166
   m_wake.Set();
167 167
   StopThread();
168 168
   delete m_sinkbuffer, m_sinkbuffer = NULL;
169  
-  if (m_alignedS16LE)
170  
-    _aligned_free(m_alignedS16LE), m_alignedS16LE = NULL;
  169
+  if (m_alignedS16)
  170
+    _aligned_free(m_alignedS16), m_alignedS16 = NULL;
171 171
 }
172 172
 
173 173
 bool CAESinkAUDIOTRACK::IsCompatible(const AEAudioFormat format, const std::string &device)
@@ -216,7 +216,7 @@ unsigned int CAESinkAUDIOTRACK::AddPackets(uint8_t *data, unsigned int frames, b
216 216
 {
217 217
   // write as many frames of audio as we can fit into our internal buffer.
218 218
 
219  
-  // our internal sink buffer is always AE_FMT_S16LE
  219
+  // our internal sink buffer is always AE_FMT_S16
220 220
   unsigned int write_frames = m_sinkbuffer->GetWriteSize() / m_sink_frameSize;
221 221
   if (write_frames > frames)
222 222
     write_frames = frames;
@@ -225,17 +225,19 @@ unsigned int CAESinkAUDIOTRACK::AddPackets(uint8_t *data, unsigned int frames, b
225 225
   {
226 226
     switch(m_format.m_dataFormat)
227 227
     {
  228
+      // 99.95 percent of Android is LE so treat NE the same.
228 229
       case AE_FMT_S16LE:
  230
+      case AE_FMT_S16NE:
229 231
         m_sinkbuffer->Write(data, write_frames * m_sink_frameSize);
230 232
         m_wake.Set();
231 233
         break;
232 234
 #if defined(__ARM_NEON__)
233 235
       case AE_FMT_FLOAT:
234  
-        if (!m_alignedS16LE)
235  
-          m_alignedS16LE = (int16_t*)_aligned_malloc(m_format.m_frames * m_sink_frameSize, 16);
  236
+        if (!m_alignedS16)
  237
+          m_alignedS16 = (int16_t*)_aligned_malloc(m_format.m_frames * m_sink_frameSize, 16);
236 238
         // neon convert AE_FMT_S16LE to AE_FMT_FLOAT
237  
-        pa_sconv_s16le_from_f32ne_neon(write_frames * m_format.m_channelLayout.Count(), (const float32_t *)data, m_alignedS16LE);
238  
-        m_sinkbuffer->Write((unsigned char*)m_alignedS16LE, write_frames * m_sink_frameSize);
  239
+        pa_sconv_s16le_from_f32ne_neon(write_frames * m_format.m_channelLayout.Count(), (const float32_t *)data, m_alignedS16);
  240
+        m_sinkbuffer->Write((unsigned char*)m_alignedS16, write_frames * m_sink_frameSize);
239 241
         m_wake.Set();
240 242
         break;
241 243
 #endif
@@ -282,6 +284,7 @@ void CAESinkAUDIOTRACK::EnumerateDevicesEx(AEDeviceInfoList &list, bool force)
282 284
   m_info.m_sampleRates.push_back(44100);
283 285
   m_info.m_sampleRates.push_back(48000);
284 286
   m_info.m_dataFormats.push_back(AE_FMT_S16LE);
  287
+  m_info.m_dataFormats.push_back(AE_FMT_S16NE);
285 288
 #if defined(__ARM_NEON__)
286 289
   if (g_cpuInfo.GetCPUFeatures() & CPU_FEATURE_NEON)
287 290
     m_info.m_dataFormats.push_back(AE_FMT_FLOAT);
2  xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.h
@@ -53,7 +53,7 @@ class CAESinkAUDIOTRACK : public CThread, public IAESink
53 53
   double             m_volume;
54 54
   bool               m_volume_changed;
55 55
   volatile int       m_min_frames;
56  
-  int16_t           *m_alignedS16LE;
  56
+  int16_t           *m_alignedS16;
57 57
   AERingBuffer      *m_sinkbuffer;
58 58
   unsigned int       m_sink_frameSize;
59 59
   double             m_sinkbuffer_sec;

2 notes on commit e565394

davilla
Collaborator

@FernetMenta, ActiveAE assumes AE_FMT_S16NE is present if AE_FMT_S16LE is an available format.

Rainer Hochecker
Collaborator

where does it assume AE_FMT_S16NE? ffmpeg only can handle those formats: https://github.com/FernetMenta/xbmc/blob/sledgehammer/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResample.cpp#L185

If the format is not supported, it falls back to float and needs the convert function in ActiveAESink. Maybe CActiveAEResample::GetAVSampleFormat should be fixed to treat LE like NE on LE systems.

Garrett Brown

Shouldn't the __BIG_ENDIAN__ macro be able to resolve NE on android?

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