Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport "Merge PR #6702: FIX(client): Infinite loop and log spam on ALSA input device disconnection" to 1.5.x #6706

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions src/mumble/ALSAAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ ALSAAudioInput::~ALSAAudioInput() {

void ALSAAudioInput::run() {
QMutexLocker qml(&qmALSA);
snd_pcm_sframes_t readblapp;

QByteArray device_name = Global::get().s.qsALSAInput.toLatin1();
snd_pcm_hw_params_t *hw_params = nullptr;
Expand Down Expand Up @@ -379,21 +378,27 @@ void ALSAAudioInput::run() {
snd_pcm_status_dump(status, log);
snd_pcm_status_free(status);
#endif
readblapp = snd_pcm_readi(capture_handle, inbuff.data(), static_cast< snd_pcm_uframes_t >(wantPeriod));
if (readblapp == -ESTRPIPE) {
qWarning("ALSAAudioInput: PCM suspended, trying to resume");
while (bRunning && snd_pcm_resume(capture_handle) == -EAGAIN)
msleep(1000);
if ((err = snd_pcm_prepare(capture_handle)) < 0)
qWarning("ALSAAudioInput: %s: %s", snd_strerror(static_cast< int >(readblapp)), snd_strerror(err));
} else if (readblapp == -EPIPE) {
err = snd_pcm_prepare(capture_handle);
qWarning("ALSAAudioInput: %s: %s", snd_strerror(static_cast< int >(readblapp)), snd_strerror(err));
} else if (readblapp < 0) {
err = snd_pcm_prepare(capture_handle);
qWarning("ALSAAudioInput: %s: %s", snd_strerror(static_cast< int >(readblapp)), snd_strerror(err));
} else if (wantPeriod == static_cast< unsigned int >(readblapp)) {
addMic(inbuff.data(), static_cast< unsigned int >(readblapp));
const snd_pcm_sframes_t ret = snd_pcm_readi(capture_handle, inbuff.data(), wantPeriod);
if (ret >= 0) {
if (static_cast< snd_pcm_uframes_t >(ret) == wantPeriod) {
addMic(inbuff.data(), static_cast< unsigned int >(ret));
}
} else {
err = static_cast< decltype(err) >(ret);
switch (err) {
case -EINTR:
case -EPIPE:
case -ESTRPIPE:
qWarning("ALSAAudioInput encountered unrecoverable error: %s -> exiting...", snd_strerror(err));
while (bRunning && snd_pcm_recover(capture_handle, err, 1) == -EAGAIN) {
msleep(1000);
}

break;
default:
qWarning("ALSAAudioInput: %s, breaking the loop...", snd_strerror(err));
bRunning = false;
}
}
}

Expand Down
Loading