Skip to content

Commit

Permalink
Merge branch 'alsa_input_exception' of https://github.com/borine/MPD
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Dec 20, 2023
2 parents e2f8c9a + f61eed1 commit 7727630
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/input/plugins/AlsaInputPlugin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ AlsaInputStream::PrepareSockets() noexcept

void
AlsaInputStream::DispatchSockets() noexcept
{
try {
non_block.DispatchSockets(*this, capture_handle);

const std::scoped_lock<Mutex> protect(mutex);
Expand All @@ -238,16 +238,17 @@ AlsaInputStream::DispatchSockets() noexcept
if (n_frames == -EAGAIN)
return;

if (Recover(n_frames) < 0) {
postponed_exception = std::make_exception_ptr(std::runtime_error("PCM error - stream aborted"));
InvokeOnAvailable();
return;
}
if (Recover(n_frames) < 0)
throw std::runtime_error("PCM error - stream aborted");
}

size_t nbytes = n_frames * frame_size;
CommitWriteBuffer(nbytes);
}
catch (...) {
postponed_exception = std::current_exception();
InvokeOnAvailable();
}

inline int
AlsaInputStream::Recover(int err)
Expand Down

0 comments on commit 7727630

Please sign in to comment.