From adaa3396edd425312065a134aec99991bd7b9cdd Mon Sep 17 00:00:00 2001 From: Spencer Williams Date: Mon, 14 Apr 2025 15:25:36 -0400 Subject: Add mpc sources --- mpc/audio_format.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 mpc/audio_format.c (limited to 'mpc/audio_format.c') 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 + +#include +#include + +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); +} -- cgit v1.2.3