diff options
author | Max Kellermann <max@musicpd.org> | 2017-01-19 11:57:01 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-01-20 15:57:09 +0100 |
commit | df9a665994a90c69f1a7eff708d8d9eaff3c8f42 (patch) | |
tree | c18ce8e5188b6df9ad48bfaef56b2b5d8fe43d14 /src/pcm | |
parent | 7a098ca0ed68f1a790fe45226db05869301b7fa0 (diff) |
pcm/Traits: add "SILENCE" attribute
Diffstat (limited to 'src/pcm')
-rw-r--r-- | src/pcm/Silence.cxx | 3 | ||||
-rw-r--r-- | src/pcm/Traits.hxx | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/pcm/Silence.cxx b/src/pcm/Silence.cxx index b1883ab61..babcb2408 100644 --- a/src/pcm/Silence.cxx +++ b/src/pcm/Silence.cxx @@ -19,6 +19,7 @@ #include "config.h" #include "Silence.hxx" +#include "Traits.hxx" #include "SampleFormat.hxx" #include "util/WritableBuffer.hxx" @@ -29,7 +30,7 @@ PcmSilence(WritableBuffer<void> dest, SampleFormat format) { uint8_t pattern = 0; if (format == SampleFormat::DSD) - pattern = 0x69; + pattern = SampleTraits<SampleFormat::DSD>::SILENCE; memset(dest.data, pattern, dest.size); } diff --git a/src/pcm/Traits.hxx b/src/pcm/Traits.hxx index 6d7bcc6ea..1ed74ffbf 100644 --- a/src/pcm/Traits.hxx +++ b/src/pcm/Traits.hxx @@ -85,6 +85,11 @@ struct SampleTraits<SampleFormat::S8> { * The maximum sample value. */ static constexpr value_type MAX = (sum_type(1) << (BITS - 1)) - 1; + + /** + * A value which represents "silence". + */ + static constexpr value_type SILENCE = 0; }; template<> @@ -101,6 +106,7 @@ struct SampleTraits<SampleFormat::S16> { static constexpr value_type MIN = -(sum_type(1) << (BITS - 1)); static constexpr value_type MAX = (sum_type(1) << (BITS - 1)) - 1; + static constexpr value_type SILENCE = 0; }; template<> @@ -117,6 +123,7 @@ struct SampleTraits<SampleFormat::S32> { static constexpr value_type MIN = -(sum_type(1) << (BITS - 1)); static constexpr value_type MAX = (sum_type(1) << (BITS - 1)) - 1; + static constexpr value_type SILENCE = 0; }; template<> @@ -133,6 +140,7 @@ struct SampleTraits<SampleFormat::S24_P32> { static constexpr value_type MIN = -(sum_type(1) << (BITS - 1)); static constexpr value_type MAX = (sum_type(1) << (BITS - 1)) - 1; + static constexpr value_type SILENCE = 0; }; template<> @@ -148,6 +156,7 @@ struct SampleTraits<SampleFormat::FLOAT> { static constexpr value_type MIN = -1; static constexpr value_type MAX = 1; + static constexpr value_type SILENCE = 0; }; template<> @@ -157,6 +166,8 @@ struct SampleTraits<SampleFormat::DSD> { typedef const value_type *const_pointer_type; static constexpr size_t SAMPLE_SIZE = sizeof(value_type); + + static constexpr value_type SILENCE = 0x69; }; #endif |