summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-01-14 21:09:57 +0100
committerMax Kellermann <max@musicpd.org>2017-01-14 21:09:57 +0100
commit9f8145e590406794446cdb0e69b088dd4719e139 (patch)
treef6a7339d59ce0ded3a673ae77bb9c5d13f7fe09a
parent791efc171a35848bb062aad0aee41220cd1f62ba (diff)
input/alsa: dump buffer/period sizes
-rw-r--r--src/input/plugins/AlsaInputPlugin.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/input/plugins/AlsaInputPlugin.cxx b/src/input/plugins/AlsaInputPlugin.cxx
index c20fddf17..7d8dcca02 100644
--- a/src/input/plugins/AlsaInputPlugin.cxx
+++ b/src/input/plugins/AlsaInputPlugin.cxx
@@ -324,6 +324,26 @@ ConfigureCapture(snd_pcm_t *capture_handle,
throw FormatRuntimeError("Cannot set sample rate (%s)",
snd_strerror(err));
+ snd_pcm_uframes_t buffer_size_min, buffer_size_max;
+ snd_pcm_hw_params_get_buffer_size_min(hw_params, &buffer_size_min);
+ snd_pcm_hw_params_get_buffer_size_max(hw_params, &buffer_size_max);
+ unsigned buffer_time_min, buffer_time_max;
+ snd_pcm_hw_params_get_buffer_time_min(hw_params, &buffer_time_min, 0);
+ snd_pcm_hw_params_get_buffer_time_max(hw_params, &buffer_time_max, 0);
+ FormatDebug(alsa_input_domain, "buffer: size=%u..%u time=%u..%u",
+ (unsigned)buffer_size_min, (unsigned)buffer_size_max,
+ buffer_time_min, buffer_time_max);
+
+ snd_pcm_uframes_t period_size_min, period_size_max;
+ snd_pcm_hw_params_get_period_size_min(hw_params, &period_size_min, 0);
+ snd_pcm_hw_params_get_period_size_max(hw_params, &period_size_max, 0);
+ unsigned period_time_min, period_time_max;
+ snd_pcm_hw_params_get_period_time_min(hw_params, &period_time_min, 0);
+ snd_pcm_hw_params_get_period_time_max(hw_params, &period_time_max, 0);
+ FormatDebug(alsa_input_domain, "period: size=%u..%u time=%u..%u",
+ (unsigned)period_size_min, (unsigned)period_size_max,
+ period_time_min, period_time_max);
+
/* period needs to be big enough so that poll() doesn't fire too often,
* but small enough that buffer overruns don't occur if Read() is not
* invoked often enough.
@@ -341,6 +361,22 @@ ConfigureCapture(snd_pcm_t *capture_handle,
throw FormatRuntimeError("Cannot set parameters (%s)",
snd_strerror(err));
+ snd_pcm_uframes_t alsa_buffer_size;
+ err = snd_pcm_hw_params_get_buffer_size(hw_params, &alsa_buffer_size);
+ if (err < 0)
+ throw FormatRuntimeError("snd_pcm_hw_params_get_buffer_size() failed: %s",
+ snd_strerror(-err));
+
+ snd_pcm_uframes_t alsa_period_size;
+ err = snd_pcm_hw_params_get_period_size(hw_params, &alsa_period_size,
+ nullptr);
+ if (err < 0)
+ throw FormatRuntimeError("snd_pcm_hw_params_get_period_size() failed: %s",
+ snd_strerror(-err));
+
+ FormatDebug(alsa_input_domain, "buffer_size=%u period_size=%u",
+ (unsigned)alsa_buffer_size, (unsigned)alsa_period_size);
+
snd_pcm_sw_params_t *sw_params;
snd_pcm_sw_params_malloc(&sw_params);