pcm_*: convert to C++

This commit is contained in:
Max Kellermann 2013-01-31 20:33:26 +01:00
parent ccdf7184be
commit 1b175025fe
26 changed files with 132 additions and 129 deletions

View File

@ -333,17 +333,17 @@ libpcm_a_SOURCES = \
src/dsd2pcm/dsd2pcm.c src/dsd2pcm/dsd2pcm.h \ src/dsd2pcm/dsd2pcm.c src/dsd2pcm/dsd2pcm.h \
src/pcm_dsd.c src/pcm_dsd.h \ src/pcm_dsd.c src/pcm_dsd.h \
src/pcm_dsd_usb.c src/pcm_dsd_usb.h \ src/pcm_dsd_usb.c src/pcm_dsd_usb.h \
src/pcm_volume.c src/pcm_volume.h \ src/PcmVolume.cxx src/PcmVolume.hxx \
src/pcm_mix.c src/pcm_mix.h \ src/PcmMix.cxx src/PcmMix.hxx \
src/pcm_channels.c src/pcm_channels.h \ src/PcmChannels.cxx src/PcmChannels.hxx \
src/pcm_pack.c src/pcm_pack.h \ src/pcm_pack.c src/pcm_pack.h \
src/pcm_format.c src/pcm_format.h \ src/PcmFormat.cxx src/PcmFormat.hxx \
src/pcm_resample.c src/pcm_resample.h \ src/pcm_resample.c src/pcm_resample.h \
src/pcm_resample_fallback.c \ src/pcm_resample_fallback.c \
src/pcm_resample_internal.h \ src/pcm_resample_internal.h \
src/pcm_dither.c src/pcm_dither.h \ src/PcmDither.cxx src/PcmDither.hxx \
src/pcm_prng.h \ src/PcmPrng.hxx \
src/pcm_utils.h src/PcmUtils.hxx
libpcm_a_CPPFLAGS = $(AM_CPPFLAGS) \ libpcm_a_CPPFLAGS = $(AM_CPPFLAGS) \
$(SAMPLERATE_CFLAGS) $(SAMPLERATE_CFLAGS)

View File

@ -19,8 +19,8 @@
#include "config.h" #include "config.h"
#include "MixerAll.hxx" #include "MixerAll.hxx"
#include "pcm_volume.h"
#include "OutputAll.hxx" #include "OutputAll.hxx"
#include "PcmVolume.hxx"
extern "C" { extern "C" {
#include "mixer_control.h" #include "mixer_control.h"

View File

@ -20,10 +20,10 @@
#include "config.h" #include "config.h"
#include "OutputThread.hxx" #include "OutputThread.hxx"
#include "output_api.h" #include "output_api.h"
#include "PcmMix.hxx"
extern "C" { extern "C" {
#include "output_internal.h" #include "output_internal.h"
#include "pcm_mix.h"
#include "filter_plugin.h" #include "filter_plugin.h"
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,9 +18,9 @@
*/ */
#include "config.h" #include "config.h"
#include "pcm_channels.h" #include "PcmChannels.hxx"
#include "pcm_buffer.h" #include "pcm_buffer.h"
#include "pcm_utils.h" #include "PcmUtils.hxx"
#include <assert.h> #include <assert.h>
@ -84,7 +84,7 @@ pcm_convert_channels_16(struct pcm_buffer *buffer,
size_t dest_size = src_size / src_channels * dest_channels; size_t dest_size = src_size / src_channels * dest_channels;
*dest_size_r = dest_size; *dest_size_r = dest_size;
int16_t *dest = pcm_buffer_get(buffer, dest_size); int16_t *dest = (int16_t *)pcm_buffer_get(buffer, dest_size);
const int16_t *src_end = pcm_end_pointer(src, src_size); const int16_t *src_end = pcm_end_pointer(src, src_size);
if (src_channels == 1 && dest_channels == 2) if (src_channels == 1 && dest_channels == 2)
@ -160,8 +160,9 @@ pcm_convert_channels_24(struct pcm_buffer *buffer,
size_t dest_size = src_size / src_channels * dest_channels; size_t dest_size = src_size / src_channels * dest_channels;
*dest_size_r = dest_size; *dest_size_r = dest_size;
int32_t *dest = pcm_buffer_get(buffer, dest_size); int32_t *dest = (int32_t *)pcm_buffer_get(buffer, dest_size);
const int32_t *src_end = pcm_end_pointer(src, src_size); const int32_t *src_end = (const int32_t *)
pcm_end_pointer(src, src_size);
if (src_channels == 1 && dest_channels == 2) if (src_channels == 1 && dest_channels == 2)
pcm_convert_channels_24_1_to_2(dest, src, src_end); pcm_convert_channels_24_1_to_2(dest, src, src_end);
@ -229,8 +230,9 @@ pcm_convert_channels_32(struct pcm_buffer *buffer,
size_t dest_size = src_size / src_channels * dest_channels; size_t dest_size = src_size / src_channels * dest_channels;
*dest_size_r = dest_size; *dest_size_r = dest_size;
int32_t *dest = pcm_buffer_get(buffer, dest_size); int32_t *dest = (int32_t *)pcm_buffer_get(buffer, dest_size);
const int32_t *src_end = pcm_end_pointer(src, src_size); const int32_t *src_end = (const int32_t *)
pcm_end_pointer(src, src_size);
if (src_channels == 1 && dest_channels == 2) if (src_channels == 1 && dest_channels == 2)
pcm_convert_channels_32_1_to_2(dest, src, src_end); pcm_convert_channels_32_1_to_2(dest, src, src_end);
@ -300,8 +302,8 @@ pcm_convert_channels_float(struct pcm_buffer *buffer,
size_t dest_size = src_size / src_channels * dest_channels; size_t dest_size = src_size / src_channels * dest_channels;
*dest_size_r = dest_size; *dest_size_r = dest_size;
float *dest = pcm_buffer_get(buffer, dest_size); float *dest = (float *)pcm_buffer_get(buffer, dest_size);
const float *src_end = pcm_end_pointer(src, src_size); const float *src_end = (const float *)pcm_end_pointer(src, src_size);
if (src_channels == 1 && dest_channels == 2) if (src_channels == 1 && dest_channels == 2)
pcm_convert_channels_float_1_to_2(dest, src, src_end); pcm_convert_channels_float_1_to_2(dest, src, src_end);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_PCM_CHANNELS_H #ifndef MPD_PCM_CHANNELS_HXX
#define MPD_PCM_CHANNELS_H #define MPD_PCM_CHANNELS_HXX
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>

View File

@ -19,12 +19,8 @@
#include "config.h" #include "config.h"
#include "PcmConvert.hxx" #include "PcmConvert.hxx"
#include "PcmChannels.hxx"
extern "C" { #include "PcmFormat.hxx"
#include "pcm_channels.h"
#include "pcm_format.h"
}
#include "pcm_pack.h" #include "pcm_pack.h"
#include "audio_format.h" #include "audio_format.h"

View File

@ -20,10 +20,11 @@
#ifndef PCM_CONVERT_HXX #ifndef PCM_CONVERT_HXX
#define PCM_CONVERT_HXX #define PCM_CONVERT_HXX
#include "PcmDither.hxx"
extern "C" { extern "C" {
#include "pcm_dsd.h" #include "pcm_dsd.h"
#include "pcm_resample.h" #include "pcm_resample.h"
#include "pcm_dither.h"
#include "pcm_buffer.h" #include "pcm_buffer.h"
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -18,8 +18,8 @@
*/ */
#include "config.h" #include "config.h"
#include "pcm_dither.h" #include "PcmDither.hxx"
#include "pcm_prng.h" #include "PcmPrng.hxx"
static int16_t static int16_t
pcm_dither_sample_24_to_16(int32_t sample, struct pcm_dither *dither) pcm_dither_sample_24_to_16(int32_t sample, struct pcm_dither *dither)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef MPD_PCM_DITHER_H #ifndef MPD_PCM_DITHER_HXX
#define MPD_PCM_DITHER_H #define MPD_PCM_DITHER_HXX
#include <stdint.h> #include <stdint.h>

View File

@ -18,11 +18,11 @@
*/ */
#include "config.h" #include "config.h"
#include "pcm_format.h" #include "PcmFormat.hxx"
#include "pcm_dither.h" #include "PcmDither.hxx"
#include "pcm_buffer.h" #include "pcm_buffer.h"
#include "pcm_pack.h" #include "pcm_pack.h"
#include "pcm_utils.h" #include "PcmUtils.hxx"
static void static void
pcm_convert_8_to_16(int16_t *out, const int8_t *in, const int8_t *in_end) pcm_convert_8_to_16(int16_t *out, const int8_t *in, const int8_t *in_end)
@ -64,7 +64,7 @@ pcm_allocate_8_to_16(struct pcm_buffer *buffer,
{ {
int16_t *dest; int16_t *dest;
*dest_size_r = src_size / sizeof(*src) * sizeof(*dest); *dest_size_r = src_size / sizeof(*src) * sizeof(*dest);
dest = pcm_buffer_get(buffer, *dest_size_r); dest = (int16_t *)pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_8_to_16(dest, src, pcm_end_pointer(src, src_size)); pcm_convert_8_to_16(dest, src, pcm_end_pointer(src, src_size));
return dest; return dest;
} }
@ -77,7 +77,7 @@ pcm_allocate_24p32_to_16(struct pcm_buffer *buffer, struct pcm_dither *dither,
int16_t *dest; int16_t *dest;
*dest_size_r = src_size / 2; *dest_size_r = src_size / 2;
assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest)); assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest));
dest = pcm_buffer_get(buffer, *dest_size_r); dest = (int16_t *)pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_24_to_16(dither, dest, src, pcm_convert_24_to_16(dither, dest, src,
pcm_end_pointer(src, src_size)); pcm_end_pointer(src, src_size));
return dest; return dest;
@ -91,7 +91,7 @@ pcm_allocate_32_to_16(struct pcm_buffer *buffer, struct pcm_dither *dither,
int16_t *dest; int16_t *dest;
*dest_size_r = src_size / 2; *dest_size_r = src_size / 2;
assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest)); assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest));
dest = pcm_buffer_get(buffer, *dest_size_r); dest = (int16_t *)pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_32_to_16(dither, dest, src, pcm_convert_32_to_16(dither, dest, src,
pcm_end_pointer(src, src_size)); pcm_end_pointer(src, src_size));
return dest; return dest;
@ -105,7 +105,7 @@ pcm_allocate_float_to_16(struct pcm_buffer *buffer,
int16_t *dest; int16_t *dest;
*dest_size_r = src_size / 2; *dest_size_r = src_size / 2;
assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest)); assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest));
dest = pcm_buffer_get(buffer, *dest_size_r); dest = (int16_t *)pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_float_to_16(dest, src, pcm_convert_float_to_16(dest, src,
pcm_end_pointer(src, src_size)); pcm_end_pointer(src, src_size));
return dest; return dest;
@ -125,22 +125,26 @@ pcm_convert_to_16(struct pcm_buffer *buffer, struct pcm_dither *dither,
case SAMPLE_FORMAT_S8: case SAMPLE_FORMAT_S8:
return pcm_allocate_8_to_16(buffer, return pcm_allocate_8_to_16(buffer,
src, src_size, dest_size_r); (const int8_t *)src, src_size,
dest_size_r);
case SAMPLE_FORMAT_S16: case SAMPLE_FORMAT_S16:
*dest_size_r = src_size; *dest_size_r = src_size;
return src; return (const int16_t *)src;
case SAMPLE_FORMAT_S24_P32: case SAMPLE_FORMAT_S24_P32:
return pcm_allocate_24p32_to_16(buffer, dither, src, src_size, return pcm_allocate_24p32_to_16(buffer, dither,
(const int32_t *)src, src_size,
dest_size_r); dest_size_r);
case SAMPLE_FORMAT_S32: case SAMPLE_FORMAT_S32:
return pcm_allocate_32_to_16(buffer, dither, src, src_size, return pcm_allocate_32_to_16(buffer, dither,
(const int32_t *)src, src_size,
dest_size_r); dest_size_r);
case SAMPLE_FORMAT_FLOAT: case SAMPLE_FORMAT_FLOAT:
return pcm_allocate_float_to_16(buffer, src, src_size, return pcm_allocate_float_to_16(buffer,
(const float *)src, src_size,
dest_size_r); dest_size_r);
} }
@ -188,7 +192,7 @@ pcm_allocate_8_to_24(struct pcm_buffer *buffer,
{ {
int32_t *dest; int32_t *dest;
*dest_size_r = src_size / sizeof(*src) * sizeof(*dest); *dest_size_r = src_size / sizeof(*src) * sizeof(*dest);
dest = pcm_buffer_get(buffer, *dest_size_r); dest = (int32_t *)pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_8_to_24(dest, src, pcm_end_pointer(src, src_size)); pcm_convert_8_to_24(dest, src, pcm_end_pointer(src, src_size));
return dest; return dest;
} }
@ -200,7 +204,7 @@ pcm_allocate_16_to_24(struct pcm_buffer *buffer,
int32_t *dest; int32_t *dest;
*dest_size_r = src_size * 2; *dest_size_r = src_size * 2;
assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest)); assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest));
dest = pcm_buffer_get(buffer, *dest_size_r); dest = (int32_t *)pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_16_to_24(dest, src, pcm_end_pointer(src, src_size)); pcm_convert_16_to_24(dest, src, pcm_end_pointer(src, src_size));
return dest; return dest;
} }
@ -210,7 +214,7 @@ pcm_allocate_32_to_24(struct pcm_buffer *buffer,
const int32_t *src, size_t src_size, size_t *dest_size_r) const int32_t *src, size_t src_size, size_t *dest_size_r)
{ {
*dest_size_r = src_size; *dest_size_r = src_size;
int32_t *dest = pcm_buffer_get(buffer, *dest_size_r); int32_t *dest = (int32_t *)pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_32_to_24(dest, src, pcm_end_pointer(src, src_size)); pcm_convert_32_to_24(dest, src, pcm_end_pointer(src, src_size));
return dest; return dest;
} }
@ -221,7 +225,7 @@ pcm_allocate_float_to_24(struct pcm_buffer *buffer,
size_t *dest_size_r) size_t *dest_size_r)
{ {
*dest_size_r = src_size; *dest_size_r = src_size;
int32_t *dest = pcm_buffer_get(buffer, *dest_size_r); int32_t *dest = (int32_t *)pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_float_to_24(dest, src, pcm_end_pointer(src, src_size)); pcm_convert_float_to_24(dest, src, pcm_end_pointer(src, src_size));
return dest; return dest;
} }
@ -240,22 +244,26 @@ pcm_convert_to_24(struct pcm_buffer *buffer,
case SAMPLE_FORMAT_S8: case SAMPLE_FORMAT_S8:
return pcm_allocate_8_to_24(buffer, return pcm_allocate_8_to_24(buffer,
src, src_size, dest_size_r); (const int8_t *)src, src_size,
dest_size_r);
case SAMPLE_FORMAT_S16: case SAMPLE_FORMAT_S16:
return pcm_allocate_16_to_24(buffer, return pcm_allocate_16_to_24(buffer,
src, src_size, dest_size_r); (const int16_t *)src, src_size,
dest_size_r);
case SAMPLE_FORMAT_S24_P32: case SAMPLE_FORMAT_S24_P32:
*dest_size_r = src_size; *dest_size_r = src_size;
return src; return (const int32_t *)src;
case SAMPLE_FORMAT_S32: case SAMPLE_FORMAT_S32:
return pcm_allocate_32_to_24(buffer, src, src_size, return pcm_allocate_32_to_24(buffer,
(const int32_t *)src, src_size,
dest_size_r); dest_size_r);
case SAMPLE_FORMAT_FLOAT: case SAMPLE_FORMAT_FLOAT:
return pcm_allocate_float_to_24(buffer, src, src_size, return pcm_allocate_float_to_24(buffer,
(const float *)src, src_size,
dest_size_r); dest_size_r);
} }
@ -291,7 +299,7 @@ pcm_allocate_8_to_32(struct pcm_buffer *buffer,
{ {
int32_t *dest; int32_t *dest;
*dest_size_r = src_size / sizeof(*src) * sizeof(*dest); *dest_size_r = src_size / sizeof(*src) * sizeof(*dest);
dest = pcm_buffer_get(buffer, *dest_size_r); dest = (int32_t *)pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_8_to_32(dest, src, pcm_end_pointer(src, src_size)); pcm_convert_8_to_32(dest, src, pcm_end_pointer(src, src_size));
return dest; return dest;
} }
@ -303,7 +311,7 @@ pcm_allocate_16_to_32(struct pcm_buffer *buffer,
int32_t *dest; int32_t *dest;
*dest_size_r = src_size * 2; *dest_size_r = src_size * 2;
assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest)); assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest));
dest = pcm_buffer_get(buffer, *dest_size_r); dest = (int32_t *)pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_16_to_32(dest, src, pcm_end_pointer(src, src_size)); pcm_convert_16_to_32(dest, src, pcm_end_pointer(src, src_size));
return dest; return dest;
} }
@ -314,7 +322,7 @@ pcm_allocate_24p32_to_32(struct pcm_buffer *buffer,
size_t *dest_size_r) size_t *dest_size_r)
{ {
*dest_size_r = src_size; *dest_size_r = src_size;
int32_t *dest = pcm_buffer_get(buffer, *dest_size_r); int32_t *dest = (int32_t *)pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_24_to_32(dest, src, pcm_end_pointer(src, src_size)); pcm_convert_24_to_32(dest, src, pcm_end_pointer(src, src_size));
return dest; return dest;
} }
@ -346,23 +354,27 @@ pcm_convert_to_32(struct pcm_buffer *buffer,
break; break;
case SAMPLE_FORMAT_S8: case SAMPLE_FORMAT_S8:
return pcm_allocate_8_to_32(buffer, src, src_size, return pcm_allocate_8_to_32(buffer,
(const int8_t *)src, src_size,
dest_size_r); dest_size_r);
case SAMPLE_FORMAT_S16: case SAMPLE_FORMAT_S16:
return pcm_allocate_16_to_32(buffer, src, src_size, return pcm_allocate_16_to_32(buffer,
(const int16_t *)src, src_size,
dest_size_r); dest_size_r);
case SAMPLE_FORMAT_S24_P32: case SAMPLE_FORMAT_S24_P32:
return pcm_allocate_24p32_to_32(buffer, src, src_size, return pcm_allocate_24p32_to_32(buffer,
(const int32_t *)src, src_size,
dest_size_r); dest_size_r);
case SAMPLE_FORMAT_S32: case SAMPLE_FORMAT_S32:
*dest_size_r = src_size; *dest_size_r = src_size;
return src; return (const int32_t *)src;
case SAMPLE_FORMAT_FLOAT: case SAMPLE_FORMAT_FLOAT:
return pcm_allocate_float_to_32(buffer, src, src_size, return pcm_allocate_float_to_32(buffer,
(const float *)src, src_size,
dest_size_r); dest_size_r);
} }
@ -412,7 +424,7 @@ pcm_allocate_8_to_float(struct pcm_buffer *buffer,
{ {
float *dest; float *dest;
*dest_size_r = src_size / sizeof(*src) * sizeof(*dest); *dest_size_r = src_size / sizeof(*src) * sizeof(*dest);
dest = pcm_buffer_get(buffer, *dest_size_r); dest = (float *)pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_8_to_float(dest, src, pcm_end_pointer(src, src_size)); pcm_convert_8_to_float(dest, src, pcm_end_pointer(src, src_size));
return dest; return dest;
} }
@ -425,7 +437,7 @@ pcm_allocate_16_to_float(struct pcm_buffer *buffer,
float *dest; float *dest;
*dest_size_r = src_size * 2; *dest_size_r = src_size * 2;
assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest)); assert(*dest_size_r == src_size / sizeof(*src) * sizeof(*dest));
dest = pcm_buffer_get(buffer, *dest_size_r); dest = (float *)pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_16_to_float(dest, src, pcm_end_pointer(src, src_size)); pcm_convert_16_to_float(dest, src, pcm_end_pointer(src, src_size));
return dest; return dest;
} }
@ -436,7 +448,7 @@ pcm_allocate_24p32_to_float(struct pcm_buffer *buffer,
size_t *dest_size_r) size_t *dest_size_r)
{ {
*dest_size_r = src_size; *dest_size_r = src_size;
float *dest = pcm_buffer_get(buffer, *dest_size_r); float *dest = (float *)pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_24_to_float(dest, src, pcm_end_pointer(src, src_size)); pcm_convert_24_to_float(dest, src, pcm_end_pointer(src, src_size));
return dest; return dest;
} }
@ -447,7 +459,7 @@ pcm_allocate_32_to_float(struct pcm_buffer *buffer,
size_t *dest_size_r) size_t *dest_size_r)
{ {
*dest_size_r = src_size; *dest_size_r = src_size;
float *dest = pcm_buffer_get(buffer, *dest_size_r); float *dest = (float *)pcm_buffer_get(buffer, *dest_size_r);
pcm_convert_32_to_float(dest, src, pcm_end_pointer(src, src_size)); pcm_convert_32_to_float(dest, src, pcm_end_pointer(src, src_size));
return dest; return dest;
} }
@ -464,23 +476,27 @@ pcm_convert_to_float(struct pcm_buffer *buffer,
case SAMPLE_FORMAT_S8: case SAMPLE_FORMAT_S8:
return pcm_allocate_8_to_float(buffer, return pcm_allocate_8_to_float(buffer,
src, src_size, dest_size_r); (const int8_t *)src, src_size,
dest_size_r);
case SAMPLE_FORMAT_S16: case SAMPLE_FORMAT_S16:
return pcm_allocate_16_to_float(buffer, return pcm_allocate_16_to_float(buffer,
src, src_size, dest_size_r); (const int16_t *)src, src_size,
dest_size_r);
case SAMPLE_FORMAT_S24_P32: case SAMPLE_FORMAT_S24_P32:
return pcm_allocate_24p32_to_float(buffer, return pcm_allocate_24p32_to_float(buffer,
src, src_size, dest_size_r); (const int32_t *)src, src_size,
dest_size_r);
case SAMPLE_FORMAT_S32: case SAMPLE_FORMAT_S32:
return pcm_allocate_32_to_float(buffer, return pcm_allocate_32_to_float(buffer,
src, src_size, dest_size_r); (const int32_t *)src, src_size,
dest_size_r);
case SAMPLE_FORMAT_FLOAT: case SAMPLE_FORMAT_FLOAT:
*dest_size_r = src_size; *dest_size_r = src_size;
return src; return (const float *)src;
} }
return NULL; return NULL;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef PCM_FORMAT_H #ifndef MPD_PCM_FORMAT_HXX
#define PCM_FORMAT_H #define MPD_PCM_FORMAT_HXX
#include "audio_format.h" #include "audio_format.h"

View File

@ -18,18 +18,13 @@
*/ */
#include "config.h" #include "config.h"
#include "pcm_mix.h" #include "PcmMix.hxx"
#include "pcm_volume.h" #include "PcmVolume.hxx"
#include "pcm_utils.h" #include "PcmUtils.hxx"
#include "audio_format.h" #include "audio_format.h"
#include <glib.h>
#include <math.h> #include <math.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "pcm"
static void static void
pcm_add_vol_8(int8_t *buffer1, const int8_t *buffer2, pcm_add_vol_8(int8_t *buffer1, const int8_t *buffer2,
unsigned num_samples, int volume1, int volume2) unsigned num_samples, int volume1, int volume2)
@ -144,7 +139,8 @@ pcm_add_vol(void *buffer1, const void *buffer2, size_t size,
return true; return true;
case SAMPLE_FORMAT_FLOAT: case SAMPLE_FORMAT_FLOAT:
pcm_add_vol_float(buffer1, buffer2, size / 4, pcm_add_vol_float((float *)buffer1, (const float *)buffer2,
size / 4,
pcm_volume_to_float(vol1), pcm_volume_to_float(vol1),
pcm_volume_to_float(vol2)); pcm_volume_to_float(vol2));
return true; return true;
@ -249,7 +245,8 @@ pcm_add(void *buffer1, const void *buffer2, size_t size,
return true; return true;
case SAMPLE_FORMAT_FLOAT: case SAMPLE_FORMAT_FLOAT:
pcm_add_float(buffer1, buffer2, size / 4); pcm_add_float((float *)buffer1, (const float *)buffer2,
size / 4);
return true; return true;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,13 +17,12 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef PCM_MIX_H #ifndef MPD_PCM_MIX_HXX
#define PCM_MIX_H #define MPD_PCM_MIX_HXX
#include "audio_format.h" #include "audio_format.h"
#include "gcc.h" #include "gcc.h"
#include <stdbool.h>
#include <stddef.h> #include <stddef.h>
/* /*

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef PCM_PRNG_H #ifndef MPD_PCM_PRNG_HXX
#define PCM_PRNG_H #define MPD_PCM_PRNG_HXX
/** /**
* A very simple linear congruential PRNG. It's good enough for PCM * A very simple linear congruential PRNG. It's good enough for PCM

View File

@ -29,10 +29,11 @@
* function to convert a source pointer and a byte count to an "end" * function to convert a source pointer and a byte count to an "end"
* pointer for use in loops. * pointer for use in loops.
*/ */
static inline const void * template<typename T>
pcm_end_pointer(const void *p, size_t size) static inline const T *
pcm_end_pointer(const T *p, size_t size)
{ {
return (const char *)p + size; return (const T *)((const uint8_t *)p + size);
} }
/** /**

View File

@ -18,8 +18,8 @@
*/ */
#include "config.h" #include "config.h"
#include "pcm_volume.h" #include "PcmVolume.hxx"
#include "pcm_utils.h" #include "PcmUtils.hxx"
#include "audio_format.h" #include "audio_format.h"
#include <glib.h> #include <glib.h>
@ -163,23 +163,27 @@ pcm_volume(void *buffer, size_t length,
return false; return false;
case SAMPLE_FORMAT_S8: case SAMPLE_FORMAT_S8:
pcm_volume_change_8(buffer, end, volume); pcm_volume_change_8((int8_t *)buffer, (const int8_t *)end,
volume);
return true; return true;
case SAMPLE_FORMAT_S16: case SAMPLE_FORMAT_S16:
pcm_volume_change_16(buffer, end, volume); pcm_volume_change_16((int16_t *)buffer, (const int16_t *)end,
volume);
return true; return true;
case SAMPLE_FORMAT_S24_P32: case SAMPLE_FORMAT_S24_P32:
pcm_volume_change_24(buffer, end, volume); pcm_volume_change_24((int32_t *)buffer, (const int32_t *)end,
volume);
return true; return true;
case SAMPLE_FORMAT_S32: case SAMPLE_FORMAT_S32:
pcm_volume_change_32(buffer, end, volume); pcm_volume_change_32((int32_t *)buffer, (const int32_t *)end,
volume);
return true; return true;
case SAMPLE_FORMAT_FLOAT: case SAMPLE_FORMAT_FLOAT:
pcm_volume_change_float(buffer, end, pcm_volume_change_float((float *)buffer, (const float *)end,
pcm_volume_to_float(volume)); pcm_volume_to_float(volume));
return true; return true;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -17,10 +17,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef PCM_VOLUME_H #ifndef MPD_PCM_VOLUME_HXX
#define PCM_VOLUME_H #define MPD_PCM_VOLUME_HXX
#include "pcm_prng.h" #include "PcmPrng.hxx"
#include "audio_format.h" #include "audio_format.h"
#include <stdint.h> #include <stdint.h>
@ -65,10 +65,6 @@ pcm_volume_dither(void)
return (r & 511) - ((r >> 9) & 511); return (r & 511) - ((r >> 9) & 511);
} }
#ifdef __cplusplus
extern "C" {
#endif
/** /**
* Adjust the volume of the specified PCM buffer. * Adjust the volume of the specified PCM buffer.
* *
@ -83,8 +79,4 @@ pcm_volume(void *buffer, size_t length,
enum sample_format format, enum sample_format format,
int volume); int volume);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@ -26,10 +26,10 @@
#include "replay_gain_info.h" #include "replay_gain_info.h"
#include "replay_gain_config.h" #include "replay_gain_config.h"
#include "mixer_control.h" #include "mixer_control.h"
#include "PcmVolume.hxx"
extern "C" { extern "C" {
#include "pcm_buffer.h" #include "pcm_buffer.h"
#include "pcm_volume.h"
} }
#include <assert.h> #include <assert.h>

View File

@ -24,7 +24,7 @@
#include "filter_registry.h" #include "filter_registry.h"
#include "conf.h" #include "conf.h"
#include "pcm_buffer.h" #include "pcm_buffer.h"
#include "pcm_volume.h" #include "PcmVolume.hxx"
#include "audio_format.h" #include "audio_format.h"
#include <assert.h> #include <assert.h>

View File

@ -23,7 +23,7 @@
#include "filter_plugin.h" #include "filter_plugin.h"
#include "filter_registry.h" #include "filter_registry.h"
#include "filter/VolumeFilterPlugin.hxx" #include "filter/VolumeFilterPlugin.hxx"
#include "pcm_volume.h" #include "PcmVolume.hxx"
#include <assert.h> #include <assert.h>
#include <math.h> #include <math.h>

View File

@ -25,7 +25,7 @@ extern "C" {
#include "filter_registry.h" #include "filter_registry.h"
} }
#include "pcm_volume.h" #include "PcmVolume.hxx"
#include "GlobalEvents.hxx" #include "GlobalEvents.hxx"
#include "Main.hxx" #include "Main.hxx"
#include "event/Loop.hxx" #include "event/Loop.hxx"

View File

@ -23,7 +23,7 @@
#include "AudioParser.hxx" #include "AudioParser.hxx"
#include "audio_format.h" #include "audio_format.h"
#include "filter_plugin.h" #include "filter_plugin.h"
#include "pcm_volume.h" #include "PcmVolume.hxx"
#include "mixer_control.h" #include "mixer_control.h"
#include "stdbin.h" #include "stdbin.h"

View File

@ -24,7 +24,7 @@
*/ */
#include "config.h" #include "config.h"
#include "pcm_volume.h" #include "PcmVolume.hxx"
#include "AudioParser.hxx" #include "AudioParser.hxx"
#include "audio_format.h" #include "audio_format.h"
#include "stdbin.h" #include "stdbin.h"

View File

@ -19,9 +19,7 @@
#include "config.h" #include "config.h"
#include "test_pcm_all.hxx" #include "test_pcm_all.hxx"
extern "C" { #include "PcmChannels.hxx"
#include "pcm_channels.h"
}
#include "pcm_buffer.h" #include "pcm_buffer.h"
#include <glib.h> #include <glib.h>

View File

@ -18,10 +18,7 @@
*/ */
#include "test_pcm_all.hxx" #include "test_pcm_all.hxx"
#include "PcmDither.hxx"
extern "C" {
#include "pcm_dither.h"
}
#include <glib.h> #include <glib.h>

View File

@ -18,7 +18,7 @@
*/ */
#include "test_pcm_all.hxx" #include "test_pcm_all.hxx"
#include "pcm_volume.h" #include "PcmVolume.hxx"
#include <glib.h> #include <glib.h>