aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends/portaudio.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-12-26 00:02:23 -0800
committerChris Robinson <[email protected]>2023-12-26 02:21:35 -0800
commit1fddc044ac765d00e64628e59edcbcd71f0046b1 (patch)
tree9e6734e0527bd418a4775c7d41c3b6a25ca4eb41 /alc/backends/portaudio.cpp
parent095d1964feacaa4ec253db028fb1e8c04f718511 (diff)
Clean up some gotos and non-optimal casts
Diffstat (limited to 'alc/backends/portaudio.cpp')
-rw-r--r--alc/backends/portaudio.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/alc/backends/portaudio.cpp b/alc/backends/portaudio.cpp
index 2ccb1c64..a8bd00fd 100644
--- a/alc/backends/portaudio.cpp
+++ b/alc/backends/portaudio.cpp
@@ -148,7 +148,6 @@ void PortPlayback::open(std::string_view name)
break;
}
-retry_open:
static constexpr auto writeCallback = [](const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timeInfo,
const PaStreamCallbackFlags statusFlags, void *userData) noexcept
@@ -157,17 +156,13 @@ retry_open:
framesPerBuffer, timeInfo, statusFlags);
};
PaStream *stream{};
- PaError err{Pa_OpenStream(&stream, nullptr, &params, mDevice->Frequency, mDevice->UpdateSize,
- paNoFlag, writeCallback, this)};
- if(err != paNoError)
+ while(PaError err{Pa_OpenStream(&stream, nullptr, &params, mDevice->Frequency,
+ mDevice->UpdateSize, paNoFlag, writeCallback, this)})
{
- if(params.sampleFormat == paFloat32)
- {
- params.sampleFormat = paInt16;
- goto retry_open;
- }
- throw al::backend_exception{al::backend_error::NoDevice, "Failed to open stream: %s",
- Pa_GetErrorText(err)};
+ if(params.sampleFormat != paFloat32)
+ throw al::backend_exception{al::backend_error::NoDevice, "Failed to open stream: %s",
+ Pa_GetErrorText(err)};
+ params.sampleFormat = paInt16;
}
Pa_CloseStream(mStream);