diff options
author | Spencer Williams <spnw@plexwave.org> | 2025-04-14 15:25:36 -0400 |
---|---|---|
committer | Spencer Williams <spnw@plexwave.org> | 2025-04-14 15:25:36 -0400 |
commit | adaa3396edd425312065a134aec99991bd7b9cdd (patch) | |
tree | ce392fc23f14e629b9a6ba7d4277cca7d6dc243f /mpc/audio_format.c | |
parent | c85630c55c104a88d743c6dfd32bdee7189a6e47 (diff) |
Add mpc sources
Diffstat (limited to 'mpc/audio_format.c')
-rw-r--r-- | mpc/audio_format.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mpc/audio_format.c b/mpc/audio_format.c new file mode 100644 index 0000000..044a1d4 --- /dev/null +++ b/mpc/audio_format.c @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +// Copyright The Music Player Daemon Project + +#include "audio_format.h" + +#include <mpd/client.h> + +#include <assert.h> +#include <stdio.h> + +void +format_audio_format(char *buffer, size_t buffer_size, + const struct mpd_audio_format *audio_format) +{ + assert(buffer != NULL); + assert(buffer_size > 0); + assert(audio_format != NULL); + + if (audio_format->bits == MPD_SAMPLE_FORMAT_FLOAT) + snprintf(buffer, buffer_size, "%u:f:%u", audio_format->sample_rate, audio_format->channels); + else if (audio_format->bits == MPD_SAMPLE_FORMAT_DSD) + snprintf(buffer, buffer_size, "%u:dsd:%u", audio_format->sample_rate, audio_format->channels); + else + snprintf(buffer, buffer_size, "%u:%u:%u", audio_format->sample_rate, audio_format->bits, audio_format->channels); +} |