Browse Source

Adjust when exceptions are thrown in RtAudioDevice.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
2879e5eb61
1 changed files with 12 additions and 11 deletions
  1. +12
    -11
      src/rtaudio.cpp

+ 12
- 11
src/rtaudio.cpp View File

@@ -47,8 +47,14 @@ struct RtAudioDevice : audio::Device {
}

~RtAudioDevice() {
closeStream();
delete rtAudio;
try {
closeStream();
delete rtAudio;
}
catch (Exception& e) {
WARN("Failed to destroy RtAudioDevice: %s", e.what());
// Ignore exceptions
}
}

void openStream() {
@@ -87,7 +93,7 @@ struct RtAudioDevice : audio::Device {
blockSize = 256;
}

INFO("Opening audio RtAudio device %d with %d in %d out, %f sample rate %d block size", deviceId, inputParameters.nChannels, outputParameters.nChannels, closestSampleRate, blockSize);
INFO("Opening audio RtAudio device %d with %d in %d out, %g sample rate %d block size", deviceId, inputParameters.nChannels, outputParameters.nChannels, closestSampleRate, blockSize);
try {
rtAudio->openStream(
outputParameters.nChannels > 0 ? &outputParameters : NULL,
@@ -255,14 +261,9 @@ struct RtAudioDriver : audio::Driver {
RtAudioDevice* device;
auto it = devices.find(deviceId);
if (it == devices.end()) {
try {
device = new RtAudioDevice(rtAudio->getCurrentApi(), deviceId);
devices[deviceId] = device;
}
catch (Exception& e) {
WARN("Could not subscribe to audio device: %s", e.what());
return NULL;
}
// Can throw Exception
device = new RtAudioDevice(rtAudio->getCurrentApi(), deviceId);
devices[deviceId] = device;
}
else {
device = it->second;


Loading…
Cancel
Save