11 #include "cores/AudioEngine/Sinks/osx/CoreAudioStream.h" 12 #include "threads/SystemClock.h" 18 #include <CoreAudio/CoreAudio.h> 20 typedef std::vector<UInt32> CoreAudioDataSourceList;
21 typedef std::list<AudioDeviceID> CoreAudioDeviceList;
32 bool Open(AudioDeviceID deviceId);
37 void RemoveObjectListenerProc(AudioObjectPropertyListenerProc callback,
void *pClientData);
38 bool SetObjectListenerProc(AudioObjectPropertyListenerProc callback,
void *pClientData);
40 AudioDeviceID GetId()
const {
return m_DeviceId;}
41 std::string GetName()
const;
42 bool IsDigital()
const;
43 UInt32 GetTransportType()
const;
44 UInt32 GetTotalOutputChannels()
const;
45 UInt32 GetNumChannelsOfStream(UInt32 streamIdx)
const;
46 bool GetStreams(AudioStreamIdList *pList);
48 bool SetHogStatus(
bool hog);
50 bool SetMixingSupport(UInt32 mix);
51 bool GetMixingSupport();
52 bool SetCurrentVolume(Float32 vol);
55 bool GetDataSources(CoreAudioDataSourceList *pList)
const;
56 bool GetDataSource(UInt32 &dataSourceId)
const;
57 bool SetDataSource(UInt32 &dataSourceId);
58 std::string GetDataSourceName(UInt32 dataSourceId)
const;
59 std::string GetCurrentDataSourceName()
const;
60 Float64 GetNominalSampleRate();
61 bool SetNominalSampleRate(Float64 sampleRate);
62 UInt32 GetNumLatencyFrames();
63 UInt32 GetBufferSize();
64 bool SetBufferSize(UInt32 size);
66 static void RegisterDeviceChangedCB(
bool bRegister, AudioObjectPropertyListenerProc callback,
void *ref);
67 static void RegisterDefaultOutputDeviceChangedCB(
bool bRegister, AudioObjectPropertyListenerProc callback,
void *ref);
69 static void SuppressDefaultOutputDeviceCB(
unsigned int suppressTimeMs)
71 m_callbackSuppressTimer.Set(std::chrono::milliseconds(suppressTimeMs));
74 bool AddIOProc(AudioDeviceIOProc ioProc,
void* pCallbackData);
77 bool m_Started =
false;
78 AudioDeviceID m_DeviceId = 0;
79 int m_MixerRestore = -1;
80 AudioDeviceIOProc m_IoProc =
nullptr;
81 AudioObjectPropertyListenerProc m_ObjectListenerProc =
nullptr;
83 Float64 m_SampleRateRestore = 0.0;
85 unsigned int m_frameSize = 0;
86 unsigned int m_OutputBufferIndex = 0;
87 unsigned int m_BufferSizeRestore = 0;
90 static AudioObjectPropertyListenerProc m_defaultOutputDeviceChangedCB;
91 static OSStatus defaultOutputDeviceChanged(AudioObjectID inObjectID,
92 UInt32 inNumberAddresses,
93 const AudioObjectPropertyAddress inAddresses[],
Definition: SystemClock.h:31
Definition: CoreAudioDevice.h:25
Definition: CoreAudioChannelLayout.h:58