using std::string;
using std::vector;
+using boost::optional;
+
+
AudioBackend* AudioBackend::_instance = nullptr;
}
+optional<int>
+AudioBackend::device_output_channels(string name)
+{
+#if (RTAUDIO_VERSION_MAJOR >= 6)
+ for (auto device_id: _rtaudio.getDeviceIds()) {
+ auto info = audio.getDeviceInfo(device_id);
+ if (info.name == name) {
+ return info.outputChannels;
+ }
+ }
+#else
+ for (unsigned int i = 0; i < _rtaudio.getDeviceCount(); ++i) {
+ try {
+ auto info = _rtaudio.getDeviceInfo(i);
+ if (info.name == name) {
+ return info.outputChannels;
+ }
+ } catch (RtAudioError&) {
+ /* Never mind */
+ }
+ }
+#endif
+
+ return {};
+}
+
+
void
AudioBackend::abort_stream_if_running()
{
std::vector<std::string> output_device_names();
boost::optional<std::string> default_device_name();
+ boost::optional<int> device_output_channels(std::string name);
+
void abort_stream_if_running();
boost::optional<std::string> start_stream();
apis[RtAudio::LINUX_OSS] = _("OSS");
apis[RtAudio::RTAUDIO_DUMMY] = _("Dummy");
- int channels = 0;
- if (configured_so) {
-#if (RTAUDIO_VERSION_MAJOR >= 6)
- for (auto device_id: audio.getDeviceIds()) {
- auto info = audio.getDeviceInfo(device_id);
- if (info.name == *configured_so && info.outputChannels > 0) {
- channels = info.outputChannels;
- }
- }
-#else
- for (unsigned int i = 0; i < audio.getDeviceCount(); ++i) {
- try {
- auto info = audio.getDeviceInfo(i);
- if (info.name == *configured_so && info.outputChannels > 0) {
- channels = info.outputChannels;
- }
- } catch (RtAudioError&) {
- /* Never mind */
- }
- }
-#endif
- }
+ int const channels = configured_so ? AudioBackend::instance()->device_output_channels(*configured_so).get_value_or(0) : 0;
_sound_output_details->SetLabel (
wxString::Format(_("%d channels on %s"), channels, apis[audio.getCurrentApi()])