Source: grandorgue Version: 3.12.3-1 Followup-For: Bug #1051559 Control: tags -1 patch
Dear Maintainer, the attached patch fixes the FTBFS (no debdiff for now, sorry). I haven't really done any functional tests though, so use it with care.
Description: Fix FTBFS with RtAudio6 Use return codes instead of catching exceptions Author: IOhannes m zmölnig Origin: Debian Forwarded: no Last-Update: 2023-09-09 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ Index: grandorgue-3.12.3/src/grandorgue/sound/ports/GOSoundRtPort.cpp =================================================================== --- grandorgue-3.12.3.orig/src/grandorgue/sound/ports/GOSoundRtPort.cpp +++ grandorgue-3.12.3/src/grandorgue/sound/ports/GOSoundRtPort.cpp @@ -24,26 +24,21 @@ GOSoundRtPort::GOSoundRtPort( GOSoundRtPort::~GOSoundRtPort() { Close(); - try { if (m_rtApi) { const RtAudio *rtApi = m_rtApi; m_rtApi = NULL; delete rtApi; } - } catch (RtAudioError &e) { - wxString error = wxString::FromAscii(e.getMessage().c_str()); - wxLogError(_("RtAudio error: %s"), error.c_str()); - } } void GOSoundRtPort::Open() { Close(); - if (!m_rtApi) + if (!m_rtApi) { throw wxString::Format( _("Audio device %s not initialised"), m_Name.c_str()); + } - try { RtAudio::StreamParameters aOutputParam; RtAudio::StreamOptions aOptions; @@ -58,7 +53,7 @@ void GOSoundRtPort::Open() { unsigned samples_per_buffer = m_SamplesPerBuffer; - m_rtApi->openStream( + if (m_rtApi->openStream( &aOutputParam, NULL, RTAUDIO_FLOAT32, @@ -66,7 +61,10 @@ void GOSoundRtPort::Open() { &samples_per_buffer, &Callback, this, - &aOptions); + &aOptions)) { + wxString error = wxString::FromAscii(m_rtApi->getErrorText().c_str()); + throw wxString::Format(_("RtAudio error: %s"), error.c_str()); + } m_nBuffers = aOptions.numberOfBuffers; if (samples_per_buffer != m_SamplesPerBuffer) { if (samples_per_buffer != m_SamplesPerBuffer) @@ -77,18 +75,17 @@ void GOSoundRtPort::Open() { samples_per_buffer); } m_IsOpen = true; - } catch (RtAudioError &e) { - wxString error = wxString::FromAscii(e.getMessage().c_str()); - throw wxString::Format(_("RtAudio error: %s"), error.c_str()); - } } void GOSoundRtPort::StartStream() { - if (!m_rtApi || !m_IsOpen) + if (!m_rtApi || !m_IsOpen) { throw wxString::Format(_("Audio device %s not open"), m_Name.c_str()); + } - try { - m_rtApi->startStream(); + if (m_rtApi->startStream()) { + wxString error = wxString::FromAscii(m_rtApi->getErrorText().c_str()); + throw wxString::Format(_("RtAudio error: %s"), error.c_str()); + } double actual_latency = m_rtApi->getStreamLatency(); /* getStreamLatency returns zero if not supported by the API, in which @@ -98,10 +95,6 @@ void GOSoundRtPort::StartStream() { actual_latency = m_SamplesPerBuffer * m_nBuffers; SetActualLatency(actual_latency / m_SampleRate); - } catch (RtAudioError &e) { - wxString error = wxString::FromAscii(e.getMessage().c_str()); - throw wxString::Format(_("RtAudio error: %s"), error.c_str()); - } if (m_rtApi->getStreamSampleRate() != m_SampleRate) throw wxString::Format( @@ -111,18 +104,11 @@ void GOSoundRtPort::StartStream() { void GOSoundRtPort::Close() { if (!m_rtApi || !m_IsOpen) return; - try { - m_rtApi->abortStream(); - } catch (RtAudioError &e) { - wxString error = wxString::FromAscii(e.getMessage().c_str()); - wxLogError(_("RtAudio error: %s"), error.c_str()); - } - try { - m_rtApi->closeStream(); - } catch (RtAudioError &e) { - wxString error = wxString::FromAscii(e.getMessage().c_str()); + if(m_rtApi->abortStream()) { + wxString error = wxString::FromAscii(m_rtApi->getErrorText().c_str()); wxLogError(_("RtAudio error: %s"), error.c_str()); } + m_rtApi->closeStream(); m_IsOpen = false; } @@ -209,8 +195,7 @@ GOSoundPort *GOSoundRtPort::create( const GOPortsConfig &portsConfig, GOSound *sound, wxString name) { GOSoundRtPort *port = NULL; - if (portsConfig.IsEnabled(PORT_NAME)) - try { + if (portsConfig.IsEnabled(PORT_NAME)) { GOSoundPortFactory::NameParser parser(name); const wxString subsysName = parser.nextComp(); wxString apiName @@ -230,7 +215,6 @@ GOSoundPort *GOSoundRtPort::create( && (apiName == rtApiName || apiName.IsEmpty())) { RtAudio *rtApi = NULL; - try { rtApi = new RtAudio(apiIndex); for (unsigned l = rtApi->getDeviceCount(), i = 0; i < l; i++) { const RtAudio::DeviceInfo info = rtApi->getDeviceInfo(i); @@ -247,10 +231,6 @@ GOSoundPort *GOSoundRtPort::create( break; } } - } catch (RtAudioError &e) { - wxString error = wxString::FromAscii(e.getMessage().c_str()); - wxLogError(_("RtAudio error: %s"), error.c_str()); - } if (port) break; // here audioApi is not used by port @@ -258,17 +238,14 @@ GOSoundPort *GOSoundRtPort::create( delete rtApi; } } - } catch (RtAudioError &e) { - wxString error = wxString::FromAscii(e.getMessage().c_str()); - wxLogError(_("RtAudio error: %s"), error.c_str()); - } + } return port; } void GOSoundRtPort::addDevices( const GOPortsConfig &portsConfig, std::vector<GOSoundDevInfo> &result) { if (portsConfig.IsEnabled(PORT_NAME)) - try { + { std::vector<RtAudio::Api> rtaudio_apis; RtAudio::getCompiledApi(rtaudio_apis); @@ -278,11 +255,10 @@ void GOSoundRtPort::addDevices( if (portsConfig.IsEnabled(PORT_NAME, RtAudio::getApiName(apiIndex))) { RtAudio *rtApi = nullptr; - try { rtApi = new RtAudio(apiIndex); for (unsigned i = 0; i < rtApi->getDeviceCount(); i++) { RtAudio::DeviceInfo dev_info = rtApi->getDeviceInfo(i); - if (!dev_info.probed) + if (!dev_info.ID) continue; if (dev_info.outputChannels < 1) continue; @@ -292,16 +268,9 @@ void GOSoundRtPort::addDevices( info.name = getName(rtApi, dev_info); result.push_back(info); } - } catch (RtAudioError &e) { - wxString error = wxString::FromAscii(e.getMessage().c_str()); - wxLogError(_("RtAudio error: %s"), error.c_str()); - } if (rtApi) delete rtApi; } } - } catch (RtAudioError &e) { - wxString error = wxString::FromAscii(e.getMessage().c_str()); - wxLogError(_("RtAudio error: %s"), error.c_str()); } }

