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 "CoreAudioHelpers.h"
26 std::string GetError(OSStatus error)
30 *(UInt32 *)(buffer + 1) = CFSwapInt32HostToBig(error);
31 if (isprint(buffer[1]) && isprint(buffer[2]) &&
32 isprint(buffer[3]) && isprint(buffer[4]))
34 buffer[0] = buffer[5] = '\'';
39 // no, format it as an integer
40 sprintf(buffer, "%d", (int)error);
43 return std::string(buffer);
46 const char* StreamDescriptionToString(AudioStreamBasicDescription desc, std::string &str)
49 (desc.mFormatID >> 24) & 0xFF,
50 (desc.mFormatID >> 16) & 0xFF,
51 (desc.mFormatID >> 8) & 0xFF,
52 desc.mFormatID & 0xFF,
56 std::stringstream sstr;
57 switch (desc.mFormatID)
59 case kAudioFormatLinearPCM:
63 << ((desc.mFormatFlags & kAudioFormatFlagIsNonMixable) ? "" : "Mixable " )
64 << ((desc.mFormatFlags & kAudioFormatFlagIsNonInterleaved) ? "Non-" : "" )
66 << desc.mChannelsPerFrame
68 << desc.mBitsPerChannel
70 << ((desc.mFormatFlags & kAudioFormatFlagIsFloat) ? "Floating Point " : "Signed Integer ")
71 << ((desc.mFormatFlags & kAudioFormatFlagIsBigEndian) ? "BE" : "LE")
73 << (UInt32)desc.mSampleRate
81 << ((desc.mFormatFlags & kAudioFormatFlagIsBigEndian) ? "BE" : "LE")
83 << (UInt32)desc.mSampleRate
87 case kAudioFormat60958AC3:
90 << "] AC-3/DTS for S/PDIF "
91 << ((desc.mFormatFlags & kAudioFormatFlagIsBigEndian) ? "BE" : "LE")
93 << (UInt32)desc.mSampleRate