Commit e4b9d679 authored by Yue Wang's avatar Yue Wang Committed by GitHub

options for sample rate syncing and device hogging

parent 2bf2bd89
...@@ -41,6 +41,8 @@ struct OSXOutput { ...@@ -41,6 +41,8 @@ struct OSXOutput {
/* only applicable with kAudioUnitSubType_HALOutput */ /* only applicable with kAudioUnitSubType_HALOutput */
const char *device_name; const char *device_name;
const char *channel_map; const char *channel_map;
bool hog_device;
bool sync_sample_rate;
AudioDeviceID dev_id; AudioDeviceID dev_id;
AudioComponentInstance au; AudioComponentInstance au;
...@@ -101,6 +103,8 @@ osx_output_configure(OSXOutput *oo, const ConfigBlock &block) ...@@ -101,6 +103,8 @@ osx_output_configure(OSXOutput *oo, const ConfigBlock &block)
} }
oo->channel_map = block.GetBlockValue("channel_map"); oo->channel_map = block.GetBlockValue("channel_map");
oo->hog_device = block.GetBlockValue("hog_device", false);
oo->sync_sample_rate = block.GetBlockValue("sync_sample_rate", false);
} }
static AudioOutput * static AudioOutput *
...@@ -631,7 +635,7 @@ osx_output_enable(AudioOutput *ao, Error &error) ...@@ -631,7 +635,7 @@ osx_output_enable(AudioOutput *ao, Error &error)
return false; return false;
} }
if (oo->component_subtype == kAudioUnitSubType_HALOutput) { if (oo->hog_device) {
osx_output_hog_device(oo->dev_id, true); osx_output_hog_device(oo->dev_id, true);
} }
...@@ -661,7 +665,7 @@ osx_output_disable(AudioOutput *ao) ...@@ -661,7 +665,7 @@ osx_output_disable(AudioOutput *ao)
AudioComponentInstanceDispose(oo->au); AudioComponentInstanceDispose(oo->au);
if (oo->component_subtype == kAudioUnitSubType_HALOutput) { if (oo->hog_device) {
osx_output_hog_device(oo->dev_id, false); osx_output_hog_device(oo->dev_id, false);
} }
} }
...@@ -717,7 +721,9 @@ osx_output_open(AudioOutput *ao, AudioFormat &audio_format, ...@@ -717,7 +721,9 @@ osx_output_open(AudioOutput *ao, AudioFormat &audio_format,
od->asbd.mBytesPerFrame = od->asbd.mBytesPerPacket; od->asbd.mBytesPerFrame = od->asbd.mBytesPerPacket;
od->asbd.mChannelsPerFrame = audio_format.channels; od->asbd.mChannelsPerFrame = audio_format.channels;
if (od->sync_sample_rate) {
osx_output_sync_device_sample_rate(od->dev_id, od->asbd); osx_output_sync_device_sample_rate(od->dev_id, od->asbd);
}
OSStatus status = OSStatus status =
AudioUnitSetProperty(od->au, kAudioUnitProperty_StreamFormat, AudioUnitSetProperty(od->au, kAudioUnitProperty_StreamFormat,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment