From 8444c335149dcbb909156e44dcda7b1bc2ea4bee Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 8 Jun 2019 11:51:15 +0200 Subject: [PATCH 1/7] output/osx: don't use variable-length arrays --- src/output/plugins/OSXOutputPlugin.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index 775e3f993..c283c9050 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -397,8 +397,12 @@ osx_output_set_device_format(AudioDeviceID dev_id, if (err != noErr) throw FormatRuntimeError("Cannot get number of streams: %d\n", err); - int n_streams = property_size / sizeof(AudioStreamID); - AudioStreamID streams[n_streams]; + const size_t n_streams = property_size / sizeof(AudioStreamID); + static constexpr size_t MAX_STREAMS = 64; + if (n_streams > MAX_STREAMS) + throw std::runtime_error("Too many streams"); + + AudioStreamID streams[MAX_STREAMS]; err = AudioObjectGetPropertyData(dev_id, &aopa, 0, NULL, &property_size, streams); if (err != noErr) throw FormatRuntimeError("Cannot get streams: %d\n", err); @@ -407,7 +411,7 @@ osx_output_set_device_format(AudioDeviceID dev_id, int output_stream; AudioStreamBasicDescription output_format; - for (int i = 0; i < n_streams; i++) { + for (size_t i = 0; i < n_streams; i++) { UInt32 direction; AudioStreamID stream = streams[i]; aopa.mSelector = kAudioStreamPropertyDirection; @@ -433,7 +437,11 @@ osx_output_set_device_format(AudioDeviceID dev_id, streams[i], err); const size_t format_count = property_size / sizeof(AudioStreamRangedDescription); - AudioStreamRangedDescription format_list[format_count]; + static constexpr size_t MAX_FORMATS = 256; + if (format_count > MAX_FORMATS) + throw std::runtime_error("Too many formats"); + + AudioStreamRangedDescription format_list[MAX_FORMATS]; err = AudioObjectGetPropertyData(stream, &aopa, 0, NULL, &property_size, format_list); if (err != noErr) throw FormatRuntimeError("Unable to get available formats for stream %d. Error = %s", From e8044663b315e466bbc98abe56719564dfbba9ad Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 17 Jun 2019 22:09:47 +0200 Subject: [PATCH 2/7] output/{alsa,osx}: use ConstBuffer::empty() --- src/output/plugins/AlsaOutputPlugin.cxx | 2 +- src/output/plugins/OSXOutputPlugin.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx index 214abd45e..7f2007024 100644 --- a/src/output/plugins/AlsaOutputPlugin.cxx +++ b/src/output/plugins/AlsaOutputPlugin.cxx @@ -939,7 +939,7 @@ AlsaOutput::Play(const void *chunk, size_t size) assert(size % in_frame_size == 0); const auto e = pcm_export->Export({chunk, size}); - if (e.size == 0) + if (e.empty()) /* the DoP (DSD over PCM) filter converts two frames at a time and ignores the last odd frame; if there was only one frame (e.g. the last frame in the diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index c283c9050..fb1cc380d 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -921,7 +921,7 @@ OSXOutput::Play(const void *chunk, size_t size) file), the result is empty; to avoid an endless loop, bail out here, and pretend the one frame has been played */ - if (e.size == 0) + if (e.empty()) return size; size_t bytes_written = ring_buffer->push((const uint8_t *)e.data, e.size); From 8ef09a0a71ab7fea767f04e629c4e0f2a550135d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 27 May 2020 19:47:47 +0200 Subject: [PATCH 3/7] output/osx: don't use C99 designated initializers Fixes `-Wpedantic`. --- src/output/plugins/OSXOutputPlugin.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index fb1cc380d..676768271 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -197,9 +197,9 @@ OSXOutput::GetVolume() { Float32 vol; AudioObjectPropertyAddress aopa = { - .mSelector = kAudioHardwareServiceDeviceProperty_VirtualMasterVolume, - .mScope = kAudioObjectPropertyScopeOutput, - .mElement = kAudioObjectPropertyElementMaster, + kAudioHardwareServiceDeviceProperty_VirtualMasterVolume, + kAudioObjectPropertyScopeOutput, + kAudioObjectPropertyElementMaster, }; UInt32 size = sizeof(vol); OSStatus status = AudioObjectGetPropertyData(dev_id, @@ -223,9 +223,9 @@ OSXOutput::SetVolume(unsigned new_volume) { Float32 vol = new_volume / 100.0; AudioObjectPropertyAddress aopa = { - .mSelector = kAudioHardwareServiceDeviceProperty_VirtualMasterVolume, - .mScope = kAudioObjectPropertyScopeOutput, - .mElement = kAudioObjectPropertyElementMaster + kAudioHardwareServiceDeviceProperty_VirtualMasterVolume, + kAudioObjectPropertyScopeOutput, + kAudioObjectPropertyElementMaster }; UInt32 size = sizeof(vol); OSStatus status = AudioObjectSetPropertyData(dev_id, From a30d5e1b6a605e08cb1f2cc227d980d2e4a72395 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 27 May 2020 19:48:46 +0200 Subject: [PATCH 4/7] output/osx: make AudioObjectPropertyAddress variables `static constexpr` --- src/output/plugins/OSXOutputPlugin.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index 676768271..d7a98b47e 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -196,7 +196,7 @@ int OSXOutput::GetVolume() { Float32 vol; - AudioObjectPropertyAddress aopa = { + static constexpr AudioObjectPropertyAddress aopa = { kAudioHardwareServiceDeviceProperty_VirtualMasterVolume, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMaster, @@ -222,7 +222,7 @@ void OSXOutput::SetVolume(unsigned new_volume) { Float32 vol = new_volume / 100.0; - AudioObjectPropertyAddress aopa = { + static constexpr AudioObjectPropertyAddress aopa = { kAudioHardwareServiceDeviceProperty_VirtualMasterVolume, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMaster @@ -545,7 +545,7 @@ static void osx_output_hog_device(AudioDeviceID dev_id, bool hog) { pid_t hog_pid; - AudioObjectPropertyAddress aopa = { + static constexpr AudioObjectPropertyAddress aopa = { kAudioDevicePropertyHogMode, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMaster From 5eedda691a2189d9502e46495fd8469c2b889e9e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 28 May 2020 13:31:30 +0200 Subject: [PATCH 5/7] output/osx: make more AudioObjectPropertyAddress instances `static constexpr` --- src/output/plugins/OSXOutputPlugin.cxx | 98 +++++++++++++++++--------- 1 file changed, 64 insertions(+), 34 deletions(-) diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index d7a98b47e..60c1bae82 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -160,25 +160,28 @@ AudioOutput * OSXOutput::Create(EventLoop &, const ConfigBlock &block) { OSXOutput *oo = new OSXOutput(block); - AudioObjectPropertyAddress aopa; AudioDeviceID dev_id = kAudioDeviceUnknown; UInt32 dev_id_size = sizeof(dev_id); - if (oo->component_subtype == kAudioUnitSubType_SystemOutput) + static constexpr AudioObjectPropertyAddress default_system_output_device{ + kAudioHardwarePropertyDefaultSystemOutputDevice, + kAudioObjectPropertyScopeOutput, + kAudioObjectPropertyElementMaster, + }; + + static constexpr AudioObjectPropertyAddress default_output_device{ + kAudioHardwarePropertyDefaultOutputDevice, + kAudioObjectPropertyScopeOutput, + kAudioObjectPropertyElementMaster + }; + + const auto &aopa = + oo->component_subtype == kAudioUnitSubType_SystemOutput // get system output dev_id if configured - aopa = { - kAudioHardwarePropertyDefaultSystemOutputDevice, - kAudioObjectPropertyScopeOutput, - kAudioObjectPropertyElementMaster - }; - else + ? default_system_output_device /* fallback to default device initially (can still be changed by osx_output_set_device) */ - aopa = { - kAudioHardwarePropertyDefaultOutputDevice, - kAudioObjectPropertyScopeOutput, - kAudioObjectPropertyElementMaster - }; + : default_output_device; AudioObjectGetPropertyData(kAudioObjectSystemObject, &aopa, @@ -386,14 +389,34 @@ static Float64 osx_output_set_device_format(AudioDeviceID dev_id, const AudioStreamBasicDescription &target_format) { - AudioObjectPropertyAddress aopa = { + static constexpr AudioObjectPropertyAddress aopa_device_streams = { kAudioDevicePropertyStreams, kAudioObjectPropertyScopeOutput, kAudioObjectPropertyElementMaster }; + static constexpr AudioObjectPropertyAddress aopa_stream_direction = { + kAudioStreamPropertyDirection, + kAudioObjectPropertyScopeOutput, + kAudioObjectPropertyElementMaster + }; + + static constexpr AudioObjectPropertyAddress aopa_stream_phys_formats = { + kAudioStreamPropertyAvailablePhysicalFormats, + kAudioObjectPropertyScopeOutput, + kAudioObjectPropertyElementMaster + }; + + static constexpr AudioObjectPropertyAddress aopa_stream_phys_format = { + kAudioStreamPropertyPhysicalFormat, + kAudioObjectPropertyScopeOutput, + kAudioObjectPropertyElementMaster + }; + UInt32 property_size; - OSStatus err = AudioObjectGetPropertyDataSize(dev_id, &aopa, 0, NULL, &property_size); + OSStatus err = AudioObjectGetPropertyDataSize(dev_id, + &aopa_device_streams, + 0, NULL, &property_size); if (err != noErr) throw FormatRuntimeError("Cannot get number of streams: %d\n", err); @@ -403,7 +426,8 @@ osx_output_set_device_format(AudioDeviceID dev_id, throw std::runtime_error("Too many streams"); AudioStreamID streams[MAX_STREAMS]; - err = AudioObjectGetPropertyData(dev_id, &aopa, 0, NULL, &property_size, streams); + err = AudioObjectGetPropertyData(dev_id, &aopa_device_streams, 0, NULL, + &property_size, streams); if (err != noErr) throw FormatRuntimeError("Cannot get streams: %d\n", err); @@ -414,10 +438,9 @@ osx_output_set_device_format(AudioDeviceID dev_id, for (size_t i = 0; i < n_streams; i++) { UInt32 direction; AudioStreamID stream = streams[i]; - aopa.mSelector = kAudioStreamPropertyDirection; property_size = sizeof(direction); err = AudioObjectGetPropertyData(stream, - &aopa, + &aopa_stream_direction, 0, NULL, &property_size, @@ -429,9 +452,9 @@ osx_output_set_device_format(AudioDeviceID dev_id, if (direction != 0) continue; - aopa.mSelector = kAudioStreamPropertyAvailablePhysicalFormats; - err = AudioObjectGetPropertyDataSize(stream, &aopa, 0, NULL, - &property_size); + err = AudioObjectGetPropertyDataSize(stream, + &aopa_stream_phys_formats, + 0, NULL, &property_size); if (err != noErr) throw FormatRuntimeError("Unable to get format size s for stream %d. Error = %s", streams[i], err); @@ -442,7 +465,10 @@ osx_output_set_device_format(AudioDeviceID dev_id, throw std::runtime_error("Too many formats"); AudioStreamRangedDescription format_list[MAX_FORMATS]; - err = AudioObjectGetPropertyData(stream, &aopa, 0, NULL, &property_size, format_list); + err = AudioObjectGetPropertyData(stream, + &aopa_stream_phys_formats, + 0, NULL, + &property_size, format_list); if (err != noErr) throw FormatRuntimeError("Unable to get available formats for stream %d. Error = %s", streams[i], err); @@ -474,9 +500,8 @@ osx_output_set_device_format(AudioDeviceID dev_id, } if (format_found) { - aopa.mSelector = kAudioStreamPropertyPhysicalFormat; err = AudioObjectSetPropertyData(output_stream, - &aopa, + &aopa_stream_phys_format, 0, NULL, sizeof(output_format), @@ -604,7 +629,6 @@ osx_output_set_device(OSXOutput *oo) { OSStatus status; UInt32 size, numdevices; - AudioObjectPropertyAddress propaddr; CFStringRef cfname = nullptr; char errormsg[1024]; char name[256]; @@ -619,11 +643,14 @@ osx_output_set_device(OSXOutput *oo) return; /* how many audio devices are there? */ - propaddr = { kAudioHardwarePropertyDevices, - kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster }; + static constexpr AudioObjectPropertyAddress aopa_hw_devices{ + kAudioHardwarePropertyDevices, + kAudioObjectPropertyScopeGlobal, + kAudioObjectPropertyElementMaster, + }; + status = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, - &propaddr, 0, nullptr, &size); + &aopa_hw_devices, 0, nullptr, &size); if (status != noErr) { osx_os_status_to_cstring(status, errormsg, sizeof(errormsg)); throw FormatRuntimeError("Unable to determine number of OS X audio devices: %s", @@ -634,7 +661,7 @@ osx_output_set_device(OSXOutput *oo) numdevices = size / sizeof(AudioDeviceID); std::unique_ptr deviceids(new AudioDeviceID[numdevices]); status = AudioObjectGetPropertyData(kAudioObjectSystemObject, - &propaddr, 0, nullptr, + &aopa_hw_devices, 0, nullptr, &size, deviceids.get()); if (status != noErr) { osx_os_status_to_cstring(status, errormsg, sizeof(errormsg)); @@ -643,12 +670,15 @@ osx_output_set_device(OSXOutput *oo) } /* which audio device matches oo->device_name? */ - propaddr = { kAudioObjectPropertyName, - kAudioObjectPropertyScopeGlobal, - kAudioObjectPropertyElementMaster }; + static constexpr AudioObjectPropertyAddress aopa_name{ + kAudioObjectPropertyName, + kAudioObjectPropertyScopeGlobal, + kAudioObjectPropertyElementMaster, + }; + size = sizeof(CFStringRef); for (i = 0; i < numdevices; i++) { - status = AudioObjectGetPropertyData(deviceids[i], &propaddr, + status = AudioObjectGetPropertyData(deviceids[i], &aopa_name, 0, nullptr, &size, &cfname); if (status != noErr) { From 44cfdff39a8dd1f0077aba9bef62b275f85f97d4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 28 May 2020 13:39:58 +0200 Subject: [PATCH 6/7] output/osx: make variables more local --- src/output/plugins/OSXOutputPlugin.cxx | 34 ++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index 60c1bae82..5b2f11e6e 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -160,8 +160,6 @@ AudioOutput * OSXOutput::Create(EventLoop &, const ConfigBlock &block) { OSXOutput *oo = new OSXOutput(block); - AudioDeviceID dev_id = kAudioDeviceUnknown; - UInt32 dev_id_size = sizeof(dev_id); static constexpr AudioObjectPropertyAddress default_system_output_device{ kAudioHardwarePropertyDefaultSystemOutputDevice, @@ -183,6 +181,8 @@ OSXOutput::Create(EventLoop &, const ConfigBlock &block) changed by osx_output_set_device) */ : default_output_device; + AudioDeviceID dev_id = kAudioDeviceUnknown; + UInt32 dev_id_size = sizeof(dev_id); AudioObjectGetPropertyData(kAudioObjectSystemObject, &aopa, 0, @@ -252,7 +252,6 @@ osx_output_parse_channel_map(const char *device_name, SInt32 channel_map[], UInt32 num_channels) { - char *endptr; unsigned int inserted_channels = 0; bool want_number = true; @@ -270,6 +269,7 @@ osx_output_parse_channel_map(const char *device_name, if (want_number && (isdigit(*channel_map_str) || *channel_map_str == '-') ) { + char *endptr; channel_map[inserted_channels] = strtol(channel_map_str, &endptr, 10); if (channel_map[inserted_channels] < -1) throw FormatRuntimeError("%s: channel map value %d not allowed (must be -1 or greater)", @@ -296,12 +296,10 @@ osx_output_parse_channel_map(const char *device_name, static void osx_output_set_channel_map(OSXOutput *oo) { - AudioStreamBasicDescription desc; OSStatus status; - UInt32 size, num_channels; - char errormsg[1024]; - size = sizeof(desc); + AudioStreamBasicDescription desc; + UInt32 size = sizeof(desc); memset(&desc, 0, size); status = AudioUnitGetProperty(oo->au, kAudioUnitProperty_StreamFormat, @@ -310,12 +308,13 @@ osx_output_set_channel_map(OSXOutput *oo) &desc, &size); if (status != noErr) { + char errormsg[1024]; osx_os_status_to_cstring(status, errormsg, sizeof(errormsg)); throw FormatRuntimeError("%s: unable to get number of output device channels: %s", oo->device_name, errormsg); } - num_channels = desc.mChannelsPerFrame; + UInt32 num_channels = desc.mChannelsPerFrame; std::unique_ptr channel_map(new SInt32[num_channels]); osx_output_parse_channel_map(oo->device_name, oo->channel_map, @@ -330,6 +329,7 @@ osx_output_set_channel_map(OSXOutput *oo) channel_map.get(), size); if (status != noErr) { + char errormsg[1024]; osx_os_status_to_cstring(status, errormsg, sizeof(errormsg)); throw FormatRuntimeError("%s: unable to set channel map: %s", oo->device_name, errormsg); } @@ -630,9 +630,6 @@ osx_output_set_device(OSXOutput *oo) OSStatus status; UInt32 size, numdevices; CFStringRef cfname = nullptr; - char errormsg[1024]; - char name[256]; - unsigned int i; AtScopeExit(&cfname) { if (cfname) @@ -652,6 +649,7 @@ osx_output_set_device(OSXOutput *oo) status = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &aopa_hw_devices, 0, nullptr, &size); if (status != noErr) { + char errormsg[1024]; osx_os_status_to_cstring(status, errormsg, sizeof(errormsg)); throw FormatRuntimeError("Unable to determine number of OS X audio devices: %s", errormsg); @@ -664,6 +662,7 @@ osx_output_set_device(OSXOutput *oo) &aopa_hw_devices, 0, nullptr, &size, deviceids.get()); if (status != noErr) { + char errormsg[1024]; osx_os_status_to_cstring(status, errormsg, sizeof(errormsg)); throw FormatRuntimeError("Unable to determine OS X audio device IDs: %s", errormsg); @@ -676,12 +675,14 @@ osx_output_set_device(OSXOutput *oo) kAudioObjectPropertyElementMaster, }; + unsigned i; size = sizeof(CFStringRef); for (i = 0; i < numdevices; i++) { status = AudioObjectGetPropertyData(deviceids[i], &aopa_name, 0, nullptr, &size, &cfname); if (status != noErr) { + char errormsg[1024]; osx_os_status_to_cstring(status, errormsg, sizeof(errormsg)); throw FormatRuntimeError("Unable to determine OS X device name " "(device %u): %s", @@ -689,6 +690,7 @@ osx_output_set_device(OSXOutput *oo) errormsg); } + char name[256]; if (!CFStringGetCString(cfname, name, sizeof(name), kCFStringEncodingUTF8)) throw std::runtime_error("Unable to convert device name from CFStringRef to char*"); @@ -712,6 +714,7 @@ osx_output_set_device(OSXOutput *oo) &(deviceids[i]), sizeof(AudioDeviceID)); if (status != noErr) { + char errormsg[1024]; osx_os_status_to_cstring(status, errormsg, sizeof(errormsg)); throw FormatRuntimeError("Unable to set OS X audio output device: %s", errormsg); @@ -720,7 +723,7 @@ osx_output_set_device(OSXOutput *oo) oo->dev_id = deviceids[i]; FormatDebug(osx_output_domain, "set OS X audio output device ID=%u, name=%s", - (unsigned)deviceids[i], name); + (unsigned)deviceids[i], oo->device_name); if (oo->channel_map) osx_output_set_channel_map(oo); @@ -754,8 +757,6 @@ osx_render(void *vdata, void OSXOutput::Enable() { - char errormsg[1024]; - AudioComponentDescription desc; desc.componentType = kAudioUnitType_Output; desc.componentSubType = component_subtype; @@ -769,6 +770,7 @@ OSXOutput::Enable() OSStatus status = AudioComponentInstanceNew(comp, &au); if (status != noErr) { + char errormsg[1024]; osx_os_status_to_cstring(status, errormsg, sizeof(errormsg)); throw FormatRuntimeError("Unable to open OS X component: %s", errormsg); @@ -814,7 +816,6 @@ OSXOutput::Close() noexcept void OSXOutput::Open(AudioFormat &audio_format) { - char errormsg[1024]; #ifdef ENABLE_DSD PcmExport::Params params; params.alsa_channel_order = true; @@ -895,6 +896,7 @@ OSXOutput::Open(AudioFormat &audio_format) status = AudioUnitInitialize(au); if (status != noErr) { + char errormsg[1024]; osx_os_status_to_cstring(status, errormsg, sizeof(errormsg)); throw FormatRuntimeError("Unable to initialize OS X audio unit: %s", errormsg); @@ -903,6 +905,7 @@ OSXOutput::Open(AudioFormat &audio_format) UInt32 buffer_frame_size = 1; status = osx_output_set_buffer_size(au, asbd, &buffer_frame_size); if (status != noErr) { + char errormsg[1024]; osx_os_status_to_cstring(status, errormsg, sizeof(errormsg)); throw FormatRuntimeError("Unable to set frame size: %s", errormsg); @@ -923,6 +926,7 @@ OSXOutput::Open(AudioFormat &audio_format) status = AudioOutputUnitStart(au); if (status != 0) { AudioUnitUninitialize(au); + char errormsg[1024]; osx_os_status_to_cstring(status, errormsg, sizeof(errormsg)); throw FormatRuntimeError("Unable to start audio output: %s", errormsg); From 5c7243d3add84b0f11da0ebea558b31984b0a65f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 28 May 2020 13:30:52 +0200 Subject: [PATCH 7/7] output/osx: make several fields `const` --- src/output/plugins/OSXOutputPlugin.cxx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index 5b2f11e6e..7f84e6e83 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -66,8 +66,8 @@ struct OSXOutput final : AudioOutput { OSType component_subtype; /* only applicable with kAudioUnitSubType_HALOutput */ const char *device_name; - const char *channel_map; - bool hog_device; + const char *const channel_map; + const bool hog_device; bool pause; #ifdef ENABLE_DSD /** @@ -75,7 +75,7 @@ struct OSXOutput final : AudioOutput { * * @see http://dsd-guide.com/dop-open-standard */ - bool dop_setting; + const bool dop_setting; bool dop_enabled; Manual pcm_export; #endif @@ -131,7 +131,12 @@ osx_output_test_default_device() } OSXOutput::OSXOutput(const ConfigBlock &block) - :AudioOutput(FLAG_ENABLE_DISABLE|FLAG_PAUSE) + :AudioOutput(FLAG_ENABLE_DISABLE|FLAG_PAUSE), + channel_map(block.GetBlockValue("channel_map")), + hog_device(block.GetBlockValue("hog_device", false)) +#ifdef ENABLE_DSD + , dop_setting(block.GetBlockValue("dop", false)) +#endif { const char *device = block.GetBlockValue("device"); @@ -148,12 +153,6 @@ OSXOutput::OSXOutput(const ConfigBlock &block) /* XXX am I supposed to strdup() this? */ device_name = device; } - - channel_map = block.GetBlockValue("channel_map"); - hog_device = block.GetBlockValue("hog_device", false); -#ifdef ENABLE_DSD - dop_setting = block.GetBlockValue("dop", false); -#endif } AudioOutput *