mpc-bar

macOS menu bar client for the Music Player Daemon
Log | Files | Refs | README | LICENSE

audio_format.c (801B)


      1 // SPDX-License-Identifier: GPL-2.0-or-later
      2 // Copyright The Music Player Daemon Project
      3 
      4 #include "audio_format.h"
      5 
      6 #include <mpd/client.h>
      7 
      8 #include <assert.h>
      9 #include <stdio.h>
     10 
     11 void
     12 format_audio_format(char *buffer, size_t buffer_size,
     13 		    const struct mpd_audio_format *audio_format)
     14 {
     15 	assert(buffer != NULL);
     16 	assert(buffer_size > 0);
     17 	assert(audio_format != NULL);
     18 
     19 	if (audio_format->bits == MPD_SAMPLE_FORMAT_FLOAT)
     20 		snprintf(buffer, buffer_size, "%u:f:%u", audio_format->sample_rate, audio_format->channels);
     21 	else if (audio_format->bits == MPD_SAMPLE_FORMAT_DSD)
     22 		snprintf(buffer, buffer_size, "%u:dsd:%u", audio_format->sample_rate, audio_format->channels);
     23 	else
     24 		snprintf(buffer, buffer_size, "%u:%u:%u", audio_format->sample_rate, audio_format->bits, audio_format->channels);
     25 }