2 * Copyright (C) 2011-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "CoreAudioAEHAL.h"
22 #include "CoreAudioAE.h"
23 #include "utils/log.h"
28 std::string GetError(OSStatus error)
32 *(UInt32 *)(buffer + 1) = CFSwapInt32HostToBig(error);
33 if (isprint(buffer[1]) && isprint(buffer[2]) &&
34 isprint(buffer[3]) && isprint(buffer[4]))
36 buffer[0] = buffer[5] = '\'';
41 // no, format it as an integer
42 sprintf(buffer, "%d", (int)error);
45 return std::string(buffer);
48 const char* StreamDescriptionToString(AudioStreamBasicDescription desc, std::string &str)
51 (desc.mFormatID >> 24) & 0xFF,
52 (desc.mFormatID >> 16) & 0xFF,
53 (desc.mFormatID >> 8) & 0xFF,
54 desc.mFormatID & 0xFF,
58 std::stringstream sstr;
59 switch (desc.mFormatID)
61 case kAudioFormatLinearPCM:
65 << ((desc.mFormatFlags & kAudioFormatFlagIsNonMixable) ? "" : "Mixable " )
66 << ((desc.mFormatFlags & kAudioFormatFlagIsNonInterleaved) ? "Non-" : "" )
68 << desc.mChannelsPerFrame
70 << desc.mBitsPerChannel
72 << ((desc.mFormatFlags & kAudioFormatFlagIsFloat) ? "Floating Point " : "Signed Integer ")
73 << ((desc.mFormatFlags & kAudioFormatFlagIsBigEndian) ? "BE" : "LE")
75 << (UInt32)desc.mSampleRate
83 << ((desc.mFormatFlags & kAudioFormatFlagIsBigEndian) ? "BE" : "LE")
85 << (UInt32)desc.mSampleRate
89 case kAudioFormat60958AC3:
92 << "] AC-3/DTS for S/PDIF "
93 << ((desc.mFormatFlags & kAudioFormatFlagIsBigEndian) ? "BE" : "LE")
95 << (UInt32)desc.mSampleRate