diff options
author | Max Kellermann <max@duempel.org> | 2013-11-11 16:15:38 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-11-13 21:06:33 +0100 |
commit | d2679f59c5a6c8df7a2140d40ab65a17b8e5c023 (patch) | |
tree | 803edccbb6c7d383199eba5f91a8610ee3c63c96 /src/pcm/PcmConvert.hxx | |
parent | 4ee147ea34057c0bcef31afed55f98b025b997dc (diff) | |
download | mpd-d2679f59c5a6c8df7a2140d40ab65a17b8e5c023.tar.gz mpd-d2679f59c5a6c8df7a2140d40ab65a17b8e5c023.tar.xz mpd-d2679f59c5a6c8df7a2140d40ab65a17b8e5c023.zip |
PcmConvert: add methods Open(), Close()
Replaces Reset() and eliminates the AudioFormat parameters from the
Convert() method.
Diffstat (limited to '')
-rw-r--r-- | src/pcm/PcmConvert.hxx | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/src/pcm/PcmConvert.hxx b/src/pcm/PcmConvert.hxx index 40f785179..4bace1d36 100644 --- a/src/pcm/PcmConvert.hxx +++ b/src/pcm/PcmConvert.hxx @@ -24,10 +24,10 @@ #include "PcmDsd.hxx" #include "PcmResample.hxx" #include "PcmBuffer.hxx" +#include "AudioFormat.hxx" #include <stddef.h> -struct AudioFormat; class Error; /** @@ -48,17 +48,23 @@ class PcmConvert { /** the buffer for converting the channel count */ PcmBuffer channels_buffer; + AudioFormat src_format, dest_format; + public: PcmConvert(); ~PcmConvert(); + /** + * Prepare the object. Call Close() when done. + */ + bool Open(AudioFormat _src_format, AudioFormat _dest_format, + Error &error); /** - * Reset the pcm_convert_state object. Use this at the - * boundary between two distinct songs and each time the - * format changes. + * Close the object after it was prepared with Open(). After + * that, it may be reused by calling Open() again. */ - void Reset(); + void Close(); /** * Converts PCM data between two audio formats. @@ -72,34 +78,24 @@ public: * ignore errors * @return the destination buffer, or NULL on error */ - const void *Convert(AudioFormat src_format, - const void *src, size_t src_size, - AudioFormat dest_format, + const void *Convert(const void *src, size_t src_size, size_t *dest_size_r, Error &error); private: - const int16_t *Convert16(AudioFormat src_format, - const void *src_buffer, size_t src_size, - AudioFormat dest_format, + const int16_t *Convert16(const void *src_buffer, size_t src_size, size_t *dest_size_r, Error &error); - const int32_t *Convert24(AudioFormat src_format, - const void *src_buffer, size_t src_size, - AudioFormat dest_format, + const int32_t *Convert24(const void *src_buffer, size_t src_size, size_t *dest_size_r, Error &error); - const int32_t *Convert32(AudioFormat src_format, - const void *src_buffer, size_t src_size, - AudioFormat dest_format, + const int32_t *Convert32(const void *src_buffer, size_t src_size, size_t *dest_size_r, Error &error); - const float *ConvertFloat(AudioFormat src_format, - const void *src_buffer, size_t src_size, - AudioFormat dest_format, + const float *ConvertFloat(const void *src_buffer, size_t src_size, size_t *dest_size_r, Error &error); }; |