Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix 7.1 channel order in CoreAudio (mac).

To activate 7.1 audio (using either HDMI or DisplayPort); make sure to first launch the Audio MIDI Setup in /Application/Utilities and configure HDMI audio as 8 channels-24 bits (the default is just stereo). It is recommended to disable DTS and AC3 passthrough as it would reset the hdmi audio in two channels mode, which would break future multi-channels playback.
Note that for the time being, E-AC3, TrueHD and DTS-HD MA bitstreaming do NOT work under MacOS. That's until Apple provide the required 192kHz digital sampling rate (the hardware supports it!).

[backport SHA:a79e8179a940c4fae0b952e57c09a277ab2fddc9]
  • Loading branch information...
commit 8dd67eb80e2d8d79de1ec675dd2b535da45e0ff1 1 parent 8119784
@jyavenard jyavenard authored
Showing with 45 additions and 1 deletion.
  1. +45 −1 mythtv/libs/libmyth/audiooutputca.cpp
View
46 mythtv/libs/libmyth/audiooutputca.cpp
@@ -17,7 +17,7 @@
* $Id$
*
* = AUTHORS
- * Jeremiah Morris, Andrew Kimpton, Nigel Pearson
+ * Jeremiah Morris, Andrew Kimpton, Nigel Pearson, Jean-Yves Avenard
*****************************************************************************/
#include <CoreServices/CoreServices.h>
@@ -31,6 +31,10 @@ using namespace std;
#include "config.h"
#include "SoundTouch.h"
+#define LOC QString("CoreAudio: ")
+#define LOC_WARN QString("CoreAudio, Warning: ")
+#define LOC_ERR QString("CoreAudio, Error: ")
+
#define CHANNELS_MIN 1
#define CHANNELS_MAX 8
@@ -266,11 +270,16 @@ AudioOutputSettings* AudioOutputCA::GetOutputSettings()
else
{
for (int i = CHANNELS_MIN; i <= CHANNELS_MAX; i++)
+ {
if (channels[i])
{
Debug(QString("Support %1 channels").arg(i));
+ // In case 8 channels are supported but not 6, fake 6
+ if (i == 8 && !channels[6])
+ settings->AddSupportedChannels(6);
settings->AddSupportedChannels(i);
}
+ }
free(channels);
}
@@ -333,6 +342,35 @@ void AudioOutputCA::CloseDevice()
d->CloseSPDIF();
}
+template <class AudioDataType>
+static inline void _ReorderSmpteToCA(AudioDataType *buf, uint frames)
+{
+ AudioDataType tmpLS, tmpRS, tmpRLs, tmpRRs, *buf2;
+ for (uint i = 0; i < frames; i++)
+ {
+ buf = buf2 = buf + 4;
+ tmpRLs = *buf++;
+ tmpRRs = *buf++;
+ tmpLS = *buf++;
+ tmpRS = *buf++;
+
+ *buf2++ = tmpLS;
+ *buf2++ = tmpRS;
+ *buf2++ = tmpRLs;
+ *buf2++ = tmpRRs;
+ }
+}
+
+static inline void ReorderSmpteToCA(void *buf, uint frames, AudioFormat format)
+{
+ switch(AudioOutputSettings::FormatToBits(format))
+ {
+ case 8: _ReorderSmpteToCA((uchar *)buf, frames); break;
+ case 16: _ReorderSmpteToCA((short *)buf, frames); break;
+ default: _ReorderSmpteToCA((int *)buf, frames); break;
+ }
+}
+
/** Object-oriented part of callback */
bool AudioOutputCA::RenderAudio(unsigned char *aubuf,
int size, unsigned long long timestamp)
@@ -357,6 +395,12 @@ bool AudioOutputCA::RenderAudio(unsigned char *aubuf,
bzero(aubuf + written_size, size - written_size);
}
+ //Audio received is in SMPTE channel order, reorder to CA unless passthru
+ if (!passthru && channels == 8)
+ {
+ ReorderSmpteToCA(aubuf, size / output_bytes_per_frame, output_format);
+ }
+
/* update audiotime (bufferedBytes is read by GetBufferedOnSoundcard) */
UInt64 nanos = AudioConvertHostTimeToNanos(
timestamp - AudioGetCurrentHostTime());
Please sign in to comment.
Something went wrong with that request. Please try again.