From e4b9d679fbecd3662f05c65c383fa92c6777c4fa Mon Sep 17 00:00:00 2001 From: Yue Wang Date: Sun, 18 Sep 2016 19:12:45 -0700 Subject: [PATCH] options for sample rate syncing and device hogging --- src/output/plugins/OSXOutputPlugin.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index 3e7d9682a..dfcfc1a8d 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -41,6 +41,8 @@ struct OSXOutput { /* only applicable with kAudioUnitSubType_HALOutput */ const char *device_name; const char *channel_map; + bool hog_device; + bool sync_sample_rate; AudioDeviceID dev_id; AudioComponentInstance au; @@ -101,6 +103,8 @@ osx_output_configure(OSXOutput *oo, const ConfigBlock &block) } 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 * @@ -631,7 +635,7 @@ osx_output_enable(AudioOutput *ao, Error &error) return false; } - if (oo->component_subtype == kAudioUnitSubType_HALOutput) { + if (oo->hog_device) { osx_output_hog_device(oo->dev_id, true); } @@ -661,7 +665,7 @@ osx_output_disable(AudioOutput *ao) AudioComponentInstanceDispose(oo->au); - if (oo->component_subtype == kAudioUnitSubType_HALOutput) { + if (oo->hog_device) { osx_output_hog_device(oo->dev_id, false); } } @@ -717,7 +721,9 @@ osx_output_open(AudioOutput *ao, AudioFormat &audio_format, od->asbd.mBytesPerFrame = od->asbd.mBytesPerPacket; od->asbd.mChannelsPerFrame = audio_format.channels; - osx_output_sync_device_sample_rate(od->dev_id, od->asbd); + if (od->sync_sample_rate) { + osx_output_sync_device_sample_rate(od->dev_id, od->asbd); + } OSStatus status = AudioUnitSetProperty(od->au, kAudioUnitProperty_StreamFormat,