Address review comments.

This commit is contained in:
Henner Zeller 2024-01-21 15:23:45 -08:00
parent f197cf6bd9
commit 5a003e99d2
2 changed files with 14 additions and 8 deletions

View File

@ -32,7 +32,7 @@ public:
stereoPacker.init(_stream->sinkOut, 512); stereoPacker.init(_stream->sinkOut, 512);
#if RTAUDIO_VERSION_MAJOR >= 6 #if RTAUDIO_VERSION_MAJOR >= 6
audio.setErrorCallback(&reportErrorsAsException); audio.setErrorCallback(&errorCallback);
#endif #endif
bool created = false; bool created = false;
@ -55,6 +55,9 @@ public:
#endif #endif
try { try {
info = audio.getDeviceInfo(i); info = audio.getDeviceInfo(i);
#if !defined(RTAUDIO_VERSION_MAJOR) || RTAUDIO_VERSION_MAJOR < 6
if (!info.probed) { continue; }
#endif
if (info.outputChannels == 0) { continue; } if (info.outputChannels == 0) { continue; }
if (info.isDefaultOutput) { defaultDevId = devList.size(); } if (info.isDefaultOutput) { defaultDevId = devList.size(); }
devList.push_back(info); devList.push_back(info);
@ -63,7 +66,7 @@ public:
txtDevList += '\0'; txtDevList += '\0';
} }
catch (const std::exception& e) { catch (const std::exception& e) {
flog::error("AudioSinkModule Error getting audio device info: id={0}: {1}", i, e.what()); flog::error("AudioSinkModule Error getting audio device ({}) info: {}", i, e.what());
} }
} }
selectByName(device); selectByName(device);
@ -164,14 +167,14 @@ public:
} }
#if RTAUDIO_VERSION_MAJOR >= 6 #if RTAUDIO_VERSION_MAJOR >= 6
static void reportErrorsAsException(RtAudioErrorType type, const std::string& errorText) { static void errorCallback(RtAudioErrorType type, const std::string& errorText) {
switch (type) { switch (type) {
case RtAudioErrorType::RTAUDIO_NO_ERROR: case RtAudioErrorType::RTAUDIO_NO_ERROR:
return; return;
case RtAudioErrorType::RTAUDIO_WARNING: case RtAudioErrorType::RTAUDIO_WARNING:
case RtAudioErrorType::RTAUDIO_NO_DEVICES_FOUND: case RtAudioErrorType::RTAUDIO_NO_DEVICES_FOUND:
case RtAudioErrorType::RTAUDIO_DEVICE_DISCONNECT: case RtAudioErrorType::RTAUDIO_DEVICE_DISCONNECT:
flog::warn("AudioSink: {0} ({1})", errorText, (int)type); flog::warn("AudioSinkModule Warning: {} ({})", errorText, (int)type);
break; break;
default: default:
throw std::runtime_error(errorText); throw std::runtime_error(errorText);

View File

@ -36,7 +36,7 @@ public:
this->name = name; this->name = name;
#if RTAUDIO_VERSION_MAJOR >= 6 #if RTAUDIO_VERSION_MAJOR >= 6
audio.setErrorCallback(&reportErrorsAsException); audio.setErrorCallback(&errorCallback);
#endif #endif
sampleRate = 48000.0; sampleRate = 48000.0;
@ -97,6 +97,9 @@ public:
// Get info // Get info
auto info = audio.getDeviceInfo(i); auto info = audio.getDeviceInfo(i);
#if !defined(RTAUDIO_VERSION_MAJOR) || RTAUDIO_VERSION_MAJOR < 6
if (!info.probed) { continue; }
#endif
// Check that it has a stereo input // Check that it has a stereo input
if (info.inputChannels < 2) { continue; } if (info.inputChannels < 2) { continue; }
@ -105,7 +108,7 @@ public:
devices.define(info.name, info.name, dinfo); devices.define(info.name, info.name, dinfo);
} }
catch (const std::exception& e) { catch (const std::exception& e) {
flog::error("Error getting audio device info: id={0}: {1}", i, e.what()); flog::error("Error getting audio device ({}) info: {}", i, e.what());
} }
} }
} }
@ -263,14 +266,14 @@ private:
} }
#if RTAUDIO_VERSION_MAJOR >= 6 #if RTAUDIO_VERSION_MAJOR >= 6
static void reportErrorsAsException(RtAudioErrorType type, const std::string& errorText) { static void errorCallback(RtAudioErrorType type, const std::string& errorText) {
switch (type) { switch (type) {
case RtAudioErrorType::RTAUDIO_NO_ERROR: case RtAudioErrorType::RTAUDIO_NO_ERROR:
return; return;
case RtAudioErrorType::RTAUDIO_WARNING: case RtAudioErrorType::RTAUDIO_WARNING:
case RtAudioErrorType::RTAUDIO_NO_DEVICES_FOUND: case RtAudioErrorType::RTAUDIO_NO_DEVICES_FOUND:
case RtAudioErrorType::RTAUDIO_DEVICE_DISCONNECT: case RtAudioErrorType::RTAUDIO_DEVICE_DISCONNECT:
flog::warn("AudioSource: {0} ({1})", errorText, (int)type); flog::warn("AudioSourceModule Warning: {} ({})", errorText, (int)type);
break; break;
default: default:
throw std::runtime_error(errorText); throw std::runtime_error(errorText);