output/osx: don't use variable-length arrays
This commit is contained in:
parent
2b7328b434
commit
8444c33514
@ -397,8 +397,12 @@ osx_output_set_device_format(AudioDeviceID dev_id,
|
|||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
throw FormatRuntimeError("Cannot get number of streams: %d\n", err);
|
throw FormatRuntimeError("Cannot get number of streams: %d\n", err);
|
||||||
|
|
||||||
int n_streams = property_size / sizeof(AudioStreamID);
|
const size_t n_streams = property_size / sizeof(AudioStreamID);
|
||||||
AudioStreamID streams[n_streams];
|
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);
|
err = AudioObjectGetPropertyData(dev_id, &aopa, 0, NULL, &property_size, streams);
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
throw FormatRuntimeError("Cannot get streams: %d\n", err);
|
throw FormatRuntimeError("Cannot get streams: %d\n", err);
|
||||||
@ -407,7 +411,7 @@ osx_output_set_device_format(AudioDeviceID dev_id,
|
|||||||
int output_stream;
|
int output_stream;
|
||||||
AudioStreamBasicDescription output_format;
|
AudioStreamBasicDescription output_format;
|
||||||
|
|
||||||
for (int i = 0; i < n_streams; i++) {
|
for (size_t i = 0; i < n_streams; i++) {
|
||||||
UInt32 direction;
|
UInt32 direction;
|
||||||
AudioStreamID stream = streams[i];
|
AudioStreamID stream = streams[i];
|
||||||
aopa.mSelector = kAudioStreamPropertyDirection;
|
aopa.mSelector = kAudioStreamPropertyDirection;
|
||||||
@ -433,7 +437,11 @@ osx_output_set_device_format(AudioDeviceID dev_id,
|
|||||||
streams[i], err);
|
streams[i], err);
|
||||||
|
|
||||||
const size_t format_count = property_size / sizeof(AudioStreamRangedDescription);
|
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);
|
err = AudioObjectGetPropertyData(stream, &aopa, 0, NULL, &property_size, format_list);
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
throw FormatRuntimeError("Unable to get available formats for stream %d. Error = %s",
|
throw FormatRuntimeError("Unable to get available formats for stream %d. Error = %s",
|
||||||
|
Loading…
Reference in New Issue
Block a user