Commit ef114ee6 authored by Max Kellermann's avatar Max Kellermann

input/alsa: improve logging in Recover()

Copy yet more code from the ALSA output plugin.
parent 667f2097
...@@ -69,6 +69,12 @@ static constexpr size_t read_buffer_size = 4096; ...@@ -69,6 +69,12 @@ static constexpr size_t read_buffer_size = 4096;
class AlsaInputStream final class AlsaInputStream final
: public AsyncInputStream, : public AsyncInputStream,
MultiSocketMonitor, DeferredMonitor { MultiSocketMonitor, DeferredMonitor {
/**
* The configured name of the ALSA device.
*/
const std::string device;
snd_pcm_t *const capture_handle; snd_pcm_t *const capture_handle;
const size_t frame_size; const size_t frame_size;
...@@ -77,11 +83,13 @@ class AlsaInputStream final ...@@ -77,11 +83,13 @@ class AlsaInputStream final
public: public:
AlsaInputStream(EventLoop &loop, AlsaInputStream(EventLoop &loop,
const char *_uri, Mutex &_mutex, Cond &_cond, const char *_uri, Mutex &_mutex, Cond &_cond,
const char *_device,
snd_pcm_t *_handle, int _frame_size) snd_pcm_t *_handle, int _frame_size)
:AsyncInputStream(_uri, _mutex, _cond, :AsyncInputStream(_uri, _mutex, _cond,
ALSA_MAX_BUFFERED, ALSA_RESUME_AT), ALSA_MAX_BUFFERED, ALSA_RESUME_AT),
MultiSocketMonitor(loop), MultiSocketMonitor(loop),
DeferredMonitor(loop), DeferredMonitor(loop),
device(_device),
capture_handle(_handle), capture_handle(_handle),
frame_size(_frame_size) frame_size(_frame_size)
{ {
...@@ -171,7 +179,7 @@ AlsaInputStream::Create(const char *uri, Mutex &mutex, Cond &cond) ...@@ -171,7 +179,7 @@ AlsaInputStream::Create(const char *uri, Mutex &mutex, Cond &cond)
int frame_size = snd_pcm_format_width(format) / 8 * channels; int frame_size = snd_pcm_format_width(format) / 8 * channels;
return new AlsaInputStream(io_thread_get(), return new AlsaInputStream(io_thread_get(),
uri, mutex, cond, uri, mutex, cond,
handle, frame_size); device, handle, frame_size);
} }
std::chrono::steady_clock::duration std::chrono::steady_clock::duration
...@@ -230,7 +238,15 @@ AlsaInputStream::Recover(int err) ...@@ -230,7 +238,15 @@ AlsaInputStream::Recover(int err)
{ {
switch(err) { switch(err) {
case -EPIPE: case -EPIPE:
LogDebug(alsa_input_domain, "Buffer Overrun"); FormatDebug(alsa_input_domain,
"Overrun on ALSA capture device \"%s\"",
device.c_str());
break;
case -ESTRPIPE:
FormatDebug(alsa_input_domain,
"ALSA capture device \"%s\" was suspended",
device.c_str());
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment