3 * Copyright (C) 2011-2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
24 #if defined(TARGET_DARWIN_OSX)
28 #include "ICoreAudioSource.h"
29 #include "CoreAudioStream.h"
31 #include <CoreAudio/CoreAudio.h>
33 typedef std::list<UInt32> CoreAudioDataSourceList;
34 typedef std::list<AudioDeviceID> CoreAudioDeviceList;
36 class CCoreAudioChannelLayout;
38 class CCoreAudioDevice
42 CCoreAudioDevice(AudioDeviceID deviceId);
43 virtual ~CCoreAudioDevice();
45 bool Open(AudioDeviceID deviceId);
50 void RemoveObjectListenerProc(AudioObjectPropertyListenerProc callback, void *pClientData);
51 bool SetObjectListenerProc(AudioObjectPropertyListenerProc callback, void *pClientData);
53 AudioDeviceID GetId() {return m_DeviceId;}
54 std::string GetName();
55 UInt32 GetTotalOutputChannels();
56 bool GetStreams(AudioStreamIdList *pList);
58 bool SetHogStatus(bool hog);
60 bool SetMixingSupport(UInt32 mix);
61 bool GetMixingSupport();
62 bool SetCurrentVolume(Float32 vol);
63 bool GetPreferredChannelLayout(CCoreAudioChannelLayout &layout);
64 bool GetDataSources(CoreAudioDataSourceList *pList);
65 Float64 GetNominalSampleRate();
66 bool SetNominalSampleRate(Float64 sampleRate);
67 UInt32 GetNumLatencyFrames();
68 UInt32 GetBufferSize();
69 bool SetBufferSize(UInt32 size);
71 virtual bool SetInputSource(ICoreAudioSource *pSource, unsigned int frameSize, unsigned int outputBufferIndex);
76 static OSStatus DirectRenderCallback(AudioDeviceID inDevice,
77 const AudioTimeStamp *inNow, const AudioBufferList *inInputData, const AudioTimeStamp *inInputTime,
78 AudioBufferList *outOutputData, const AudioTimeStamp *inOutputTime, void *inClientData);
81 ICoreAudioSource *m_pSource;
82 AudioDeviceID m_DeviceId;
84 AudioDeviceIOProc m_IoProc;
85 AudioObjectPropertyListenerProc m_ObjectListenerProc;
87 Float64 m_SampleRateRestore;
89 unsigned int m_frameSize;
90 unsigned int m_OutputBufferIndex;
91 unsigned int m_BufferSizeRestore;