AudioFormat: split the printf() calls in ToString()
Prepare for formatting masks.
This commit is contained in:
parent
4b16a8bf84
commit
603ce87ac2
@ -44,16 +44,21 @@ AudioFormat::ApplyMask(AudioFormat mask) noexcept
|
|||||||
StringBuffer<24>
|
StringBuffer<24>
|
||||||
ToString(const AudioFormat af) noexcept
|
ToString(const AudioFormat af) noexcept
|
||||||
{
|
{
|
||||||
|
StringBuffer<24> buffer;
|
||||||
|
char *p = buffer.data();
|
||||||
|
|
||||||
if (af.format == SampleFormat::DSD && af.sample_rate > 0 &&
|
if (af.format == SampleFormat::DSD && af.sample_rate > 0 &&
|
||||||
af.sample_rate % 44100 == 0) {
|
af.sample_rate % 44100 == 0) {
|
||||||
/* use shortcuts such as "dsd64" which implies the
|
/* use shortcuts such as "dsd64" which implies the
|
||||||
sample rate */
|
sample rate */
|
||||||
return StringFormat<24>("dsd%u:%u",
|
p += sprintf(p, "dsd%u:", af.sample_rate * 8 / 44100);
|
||||||
af.sample_rate * 8 / 44100,
|
} else {
|
||||||
af.channels);
|
p += sprintf(p, "%u:%s:",
|
||||||
|
af.sample_rate,
|
||||||
|
sample_format_to_string(af.format));
|
||||||
}
|
}
|
||||||
|
|
||||||
return StringFormat<24>("%u:%s:%u",
|
p += sprintf(p, "%u", af.channels);
|
||||||
af.sample_rate, sample_format_to_string(af.format),
|
|
||||||
af.channels);
|
return buffer;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user