pcm_buffer: convert to C++

This commit is contained in:
Max Kellermann
2013-07-29 08:10:10 +02:00
parent cd1bb2bafa
commit c75cb67c44
33 changed files with 190 additions and 314 deletions

View File

@@ -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);

View File

@@ -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

View File

@@ -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) {

View File

@@ -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) */