summaryrefslogtreecommitdiff
path: root/src/filter
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-07-29 08:10:10 +0200
committerMax Kellermann <max@duempel.org>2013-07-30 08:31:02 +0200
commitc75cb67c4406648314ce2a15daf8b632374d7913 (patch)
tree5e27b73f2c90e878631bfac5b60070505b094717 /src/filter
parentcd1bb2bafa2653e5d4c7c9abf6f464bcdec693c5 (diff)
pcm_buffer: convert to C++
Diffstat (limited to 'src/filter')
-rw-r--r--src/filter/NormalizeFilterPlugin.cxx9
-rw-r--r--src/filter/ReplayGainFilterPlugin.cxx12
-rw-r--r--src/filter/RouteFilterPlugin.cxx13
-rw-r--r--src/filter/VolumeFilterPlugin.cxx9
4 files changed, 16 insertions, 27 deletions
diff --git a/src/filter/NormalizeFilterPlugin.cxx b/src/filter/NormalizeFilterPlugin.cxx
index 082d6fc94..f4e2963cc 100644
--- a/src/filter/NormalizeFilterPlugin.cxx
+++ b/src/filter/NormalizeFilterPlugin.cxx
@@ -21,7 +21,7 @@
#include "FilterPlugin.hxx"
#include "FilterInternal.hxx"
#include "FilterRegistry.hxx"
-#include "pcm/pcm_buffer.h"
+#include "pcm/PcmBuffer.hxx"
#include "audio_format.h"
#include "AudioCompress/compress.h"
@@ -31,7 +31,7 @@
class NormalizeFilter final : public Filter {
struct Compressor *compressor;
- struct pcm_buffer buffer;
+ PcmBuffer buffer;
public:
virtual const audio_format *Open(audio_format &af, GError **error_r);
@@ -53,7 +53,6 @@ NormalizeFilter::Open(audio_format &audio_format, gcc_unused GError **error_r)
audio_format.format = SAMPLE_FORMAT_S16;
compressor = Compressor_new(0);
- pcm_buffer_init(&buffer);
return &audio_format;
}
@@ -61,7 +60,7 @@ NormalizeFilter::Open(audio_format &audio_format, gcc_unused GError **error_r)
void
NormalizeFilter::Close()
{
- pcm_buffer_deinit(&buffer);
+ buffer.Clear();
Compressor_delete(compressor);
}
@@ -69,7 +68,7 @@ const void *
NormalizeFilter::FilterPCM(const void *src, size_t src_size,
size_t *dest_size_r, gcc_unused GError **error_r)
{
- int16_t *dest = (int16_t *)pcm_buffer_get(&buffer, src_size);
+ int16_t *dest = (int16_t *)buffer.Get(src_size);
memcpy(dest, src, src_size);
Compressor_Process_int16(compressor, dest, src_size / 2);
diff --git a/src/filter/ReplayGainFilterPlugin.cxx b/src/filter/ReplayGainFilterPlugin.cxx
index f590d57f5..d736c910f 100644
--- a/src/filter/ReplayGainFilterPlugin.cxx
+++ b/src/filter/ReplayGainFilterPlugin.cxx
@@ -27,10 +27,7 @@
#include "replay_gain_config.h"
#include "MixerControl.hxx"
#include "pcm/PcmVolume.hxx"
-
-extern "C" {
-#include "pcm/pcm_buffer.h"
-}
+#include "pcm/PcmBuffer.hxx"
#include <assert.h>
#include <string.h>
@@ -71,7 +68,7 @@ class ReplayGainFilter final : public Filter {
struct audio_format format;
- struct pcm_buffer buffer;
+ PcmBuffer buffer;
public:
ReplayGainFilter()
@@ -166,7 +163,6 @@ const audio_format *
ReplayGainFilter::Open(audio_format &af, gcc_unused GError **error_r)
{
format = af;
- pcm_buffer_init(&buffer);
return &format;
}
@@ -174,7 +170,7 @@ ReplayGainFilter::Open(audio_format &af, gcc_unused GError **error_r)
void
ReplayGainFilter::Close()
{
- pcm_buffer_deinit(&buffer);
+ buffer.Clear();
}
const void *
@@ -188,7 +184,7 @@ ReplayGainFilter::FilterPCM(const void *src, size_t src_size,
/* optimized special case: 100% volume = no-op */
return src;
- void *dest = pcm_buffer_get(&buffer, src_size);
+ void *dest = buffer.Get(src_size);
if (volume <= 0) {
/* optimized special case: 0% volume = memset(0) */
/* XXX is this valid for all sample formats? What
diff --git a/src/filter/RouteFilterPlugin.cxx b/src/filter/RouteFilterPlugin.cxx
index 85db7e9ea..3dc0991f9 100644
--- a/src/filter/RouteFilterPlugin.cxx
+++ b/src/filter/RouteFilterPlugin.cxx
@@ -47,7 +47,7 @@
#include "FilterPlugin.hxx"
#include "FilterInternal.hxx"
#include "FilterRegistry.hxx"
-#include "pcm/pcm_buffer.h"
+#include "pcm/PcmBuffer.hxx"
#include <assert.h>
#include <string.h>
@@ -101,7 +101,7 @@ class RouteFilter final : public Filter {
/**
* The output buffer used last time around, can be reused if the size doesn't differ.
*/
- struct pcm_buffer output_buffer;
+ PcmBuffer output_buffer;
public:
RouteFilter():sources(nullptr) {}
@@ -256,16 +256,13 @@ RouteFilter::Open(audio_format &audio_format, gcc_unused GError **error_r)
// Precalculate this simple value, to speed up allocation later
output_frame_size = audio_format_frame_size(&output_format);
- // This buffer grows as needed
- pcm_buffer_init(&output_buffer);
-
return &output_format;
}
void
RouteFilter::Close()
{
- pcm_buffer_deinit(&output_buffer);
+ output_buffer.Clear();
}
const void *
@@ -285,9 +282,7 @@ RouteFilter::FilterPCM(const void *src, size_t src_size,
// Grow our reusable buffer, if needed, and set the moving pointer
*dest_size_r = number_of_frames * output_frame_size;
- chan_destination = (uint8_t *)
- pcm_buffer_get(&output_buffer, *dest_size_r);
-
+ chan_destination = (uint8_t *)output_buffer.Get(*dest_size_r);
// Perform our copy operations, with N input channels and M output channels
for (unsigned int s=0; s<number_of_frames; ++s) {
diff --git a/src/filter/VolumeFilterPlugin.cxx b/src/filter/VolumeFilterPlugin.cxx
index 660ad260e..824ad0ab4 100644
--- a/src/filter/VolumeFilterPlugin.cxx
+++ b/src/filter/VolumeFilterPlugin.cxx
@@ -23,8 +23,8 @@
#include "FilterInternal.hxx"
#include "FilterRegistry.hxx"
#include "conf.h"
-#include "pcm/pcm_buffer.h"
#include "pcm/PcmVolume.hxx"
+#include "pcm/PcmBuffer.hxx"
#include "audio_format.h"
#include <assert.h>
@@ -38,7 +38,7 @@ class VolumeFilter final : public Filter {
struct audio_format format;
- struct pcm_buffer buffer;
+ PcmBuffer buffer;
public:
VolumeFilter()
@@ -79,7 +79,6 @@ const struct audio_format *
VolumeFilter::Open(audio_format &audio_format, gcc_unused GError **error_r)
{
format = audio_format;
- pcm_buffer_init(&buffer);
return &format;
}
@@ -87,7 +86,7 @@ VolumeFilter::Open(audio_format &audio_format, gcc_unused GError **error_r)
void
VolumeFilter::Close()
{
- pcm_buffer_deinit(&buffer);
+ buffer.Clear();
}
const void *
@@ -100,7 +99,7 @@ VolumeFilter::FilterPCM(const void *src, size_t src_size,
/* optimized special case: 100% volume = no-op */
return src;
- void *dest = pcm_buffer_get(&buffer, src_size);
+ void *dest = buffer.Get(src_size);
if (volume <= 0) {
/* optimized special case: 0% volume = memset(0) */