X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=alsa_output.cpp;h=7dd10244b094d83b9f93c65af0b8e87dc4e5a5c6;hb=9e47a2f661b9d292598ef0277e507458e3dad62f;hp=a3d17a2088ca0a49ad9ababfa118363150a07147;hpb=c58345b12770f5ac730d02d9cf50af78df526acd;p=nageru diff --git a/alsa_output.cpp b/alsa_output.cpp index a3d17a2..7dd1024 100644 --- a/alsa_output.cpp +++ b/alsa_output.cpp @@ -1,5 +1,9 @@ #include "alsa_output.h" +#include +#include +#include +#include #include using namespace std; @@ -17,7 +21,7 @@ void die_on_error(const char *func_name, int err) } // namespace ALSAOutput::ALSAOutput(int sample_rate, int num_channels) - : num_channels(num_channels) + : sample_rate(sample_rate), num_channels(num_channels) { die_on_error("snd_pcm_open()", snd_pcm_open(&pcm_handle, "default", SND_PCM_STREAM_PLAYBACK, 0)); @@ -79,7 +83,8 @@ try_again: if (ret == 0) { if (buffer.size() >= period_size * num_channels * 8) { // OK, almost 100 ms. Giving up. - fprintf(stderr, "warning: ALSA overrun, dropping some audio\n"); + fprintf(stderr, "warning: ALSA overrun, dropping some audio (%d ms)\n", + int(buffer.size() * 1000 / (num_channels * sample_rate))); buffer.clear(); } } else if (ret > 0) {