summaryrefslogtreecommitdiff
path: root/src/AudioFormat.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-01-24 12:52:43 +0100
committerMax Kellermann <max@musicpd.org>2018-07-06 19:07:02 +0200
commit60d5bf0240dea58419edb05198906349e81abbe8 (patch)
tree3811d24f1ec17257b14d7dd8759a6948ac676399 /src/AudioFormat.cxx
parent41cdc4e14b3d36d70039a7ac1578fe7c898a0bac (diff)
util/StringFormat: new utility library
Diffstat (limited to 'src/AudioFormat.cxx')
-rw-r--r--src/AudioFormat.cxx19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/AudioFormat.cxx b/src/AudioFormat.cxx
index f317d8abe..13d3709f9 100644
--- a/src/AudioFormat.cxx
+++ b/src/AudioFormat.cxx
@@ -19,9 +19,9 @@
#include "AudioFormat.hxx"
#include "util/StringBuffer.hxx"
+#include "util/StringFormat.hxx"
#include <assert.h>
-#include <stdio.h>
void
AudioFormat::ApplyMask(AudioFormat mask) noexcept
@@ -44,21 +44,16 @@ AudioFormat::ApplyMask(AudioFormat mask) noexcept
StringBuffer<24>
ToString(const AudioFormat af) noexcept
{
- StringBuffer<24> buffer;
-
if (af.format == SampleFormat::DSD && af.sample_rate > 0 &&
af.sample_rate % 44100 == 0) {
/* use shortcuts such as "dsd64" which implies the
sample rate */
- snprintf(buffer.data(), buffer.capacity(), "dsd%u:%u",
- af.sample_rate * 8 / 44100,
- af.channels);
- return buffer;
+ return StringFormat<24>("dsd%u:%u",
+ af.sample_rate * 8 / 44100,
+ af.channels);
}
- snprintf(buffer.data(), buffer.capacity(), "%u:%s:%u",
- af.sample_rate, sample_format_to_string(af.format),
- af.channels);
-
- return buffer;
+ return StringFormat<24>("%u:%s:%u",
+ af.sample_rate, sample_format_to_string(af.format),
+ af.channels);
}