diff --git a/client/decoder/pcmDecoder.cpp b/client/decoder/pcmDecoder.cpp index a48278c4..e3010fc2 100644 --- a/client/decoder/pcmDecoder.cpp +++ b/client/decoder/pcmDecoder.cpp @@ -60,19 +60,7 @@ PcmDecoder::PcmDecoder() : Decoder() bool PcmDecoder::decode(msg::PcmChunk* chunk) { -/* int16_t* bufferT = (int16_t*)chunk->payload; - for (size_t n=0; ngetSampleCount(); ++n) - { - bufferT[n] = SWAP_16(bufferT[n]); - } - - if (sampleFormat.bits == 8) - adjustVolume(buffer, frames*sampleFormat.channels, volume); - else if (sampleFormat.bits == 16) - adjustVolume(buffer, frames*sampleFormat.channels, volume); - else if (sampleFormat.bits == 32) - adjustVolume(buffer, frames*sampleFormat.channels, volume); -*/ return true; + return true; } diff --git a/client/player/player.h b/client/player/player.h index e7372442..b36b15f3 100644 --- a/client/player/player.h +++ b/client/player/player.h @@ -52,21 +52,8 @@ protected: void adjustVolume(char *buffer, size_t count, double volume) { T* bufferT = (T*)buffer; - if (sizeof(T) == 1) - { - for (size_t n=0; n(endian::swap(bufferT[n]) * volume); } void adjustVolume(char* buffer, size_t frames); diff --git a/common/endian.h b/common/endian.h index 53300f80..3cf5f07b 100644 --- a/common/endian.h +++ b/common/endian.h @@ -11,6 +11,37 @@ # define SWAP_64(x) x #endif +namespace endian +{ + +template +T swap(const T&); + +template <> +inline int8_t swap(const int8_t& val) +{ + return val; +} + +template <> +inline int16_t swap(const int16_t& val) +{ + return SWAP_16(val); +} + +template <> +inline int32_t swap(const int32_t& val) +{ + return SWAP_32(val); +} + +template <> +inline int64_t swap(const int64_t& val) +{ + return SWAP_64(val); +} + +} #endif