mplay

Controllable music player
git clone https://git.sinitax.com/sinitax/mplay
Log | Files | Refs | sfeed.txt

commit 4cbb1e2c86ec6532bcf51bd8bfebbe802c45cdf9
parent 54e9f8389c8c2087ce82c4488f376b6c220ad014
Author: Louis Burda <quent.burda@gmail.com>
Date:   Thu, 12 Jan 2023 21:11:03 +0100

Add debug flag for underflow and overflow detection

Diffstat:
Mmplay.c | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/mplay.c b/mplay.c @@ -103,6 +103,7 @@ static bool term_set = false; static bool cmd_input_mode = false; static bool use_stdio = true; +static bool debug = false; uint8_t * map_file(const char *path, size_t *len) @@ -258,6 +259,18 @@ pa_stream_write_callback(pa_stream *stream, size_t requested, void *data) } void +pa_stream_underflow_callback(struct pa_stream *stream, void *data) +{ + printf("+UNDERFLOW\n"); +} + +void +pa_stream_overflow_callback(struct pa_stream *stream, void *data) +{ + printf("+OVERFLOW\n"); +} + +void update_sink_input_info_callback(struct pa_context *ctx, const pa_sink_input_info *info, int eol, void *data) { @@ -601,6 +614,13 @@ pulse_stream_init(void) pa_stream_set_write_callback(pa_strm, pa_stream_write_callback, NULL); + if (debug) { + pa_stream_set_underflow_callback(pa_strm, + pa_stream_underflow_callback, NULL); + pa_stream_set_overflow_callback(pa_strm, + pa_stream_overflow_callback, NULL); + } + ret = pa_stream_connect_playback(pa_strm, NULL, &pa_buf, pa_stream_flags, NULL, NULL); if (ret) ERRX("pa_stream_connect_playback failed"); @@ -653,6 +673,8 @@ main(int argc, const char **argv) cmd_input_mode = true; } else if (!strcmp(*arg, "-h")) { use_stdio = false; + } else if (!strcmp(*arg, "-d")) { + debug = true; } else { if (file) usage(); file = *arg;