AudioFormat: replace struct audio_format_string with class StringBuffer, return it

This commit is contained in:
Max Kellermann
2017-01-17 22:04:31 +01:00
parent 4f01387edf
commit 39114f91a7
10 changed files with 36 additions and 53 deletions

View File

@@ -18,6 +18,7 @@
*/
#include "AudioFormat.hxx"
#include "util/StringBuffer.hxx"
#include <assert.h>
#include <stdio.h>
@@ -40,15 +41,13 @@ AudioFormat::ApplyMask(AudioFormat mask)
assert(IsValid());
}
const char *
audio_format_to_string(const AudioFormat af,
struct audio_format_string *s)
StringBuffer<24>
ToString(const AudioFormat af)
{
assert(s != nullptr);
snprintf(s->buffer, sizeof(s->buffer), "%u:%s:%u",
StringBuffer<24> buffer;
snprintf(buffer.data(), buffer.capacity(), "%u:%s:%u",
af.sample_rate, sample_format_to_string(af.format),
af.channels);
return s->buffer;
return buffer;
}