aboutsummaryrefslogtreecommitdiffstats
path: root/src/pcm
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-03 21:00:50 +0200
committerMax Kellermann <max@duempel.org>2013-08-03 21:37:56 +0200
commitd1e7b4e38136f9342aad76c685a13adf0e69f869 (patch)
tree49643b937ddfe735511b566a71398da5a945d7aa /src/pcm
parent67f591a9ce60651da41afc499bd9a22e25314e35 (diff)
downloadmpd-d1e7b4e38136f9342aad76c685a13adf0e69f869.tar.gz
mpd-d1e7b4e38136f9342aad76c685a13adf0e69f869.tar.xz
mpd-d1e7b4e38136f9342aad76c685a13adf0e69f869.zip
audio_format: convert to C++
Diffstat (limited to 'src/pcm')
-rw-r--r--src/pcm/PcmConvert.cxx142
-rw-r--r--src/pcm/PcmConvert.hxx22
-rw-r--r--src/pcm/PcmDsdUsb.cxx2
-rw-r--r--src/pcm/PcmExport.cxx14
-rw-r--r--src/pcm/PcmExport.hxx12
-rw-r--r--src/pcm/PcmFormat.cxx64
-rw-r--r--src/pcm/PcmFormat.hxx10
-rw-r--r--src/pcm/PcmMix.cxx36
-rw-r--r--src/pcm/PcmMix.hxx4
-rw-r--r--src/pcm/PcmVolume.cxx18
-rw-r--r--src/pcm/PcmVolume.hxx6
11 files changed, 165 insertions, 165 deletions
diff --git a/src/pcm/PcmConvert.cxx b/src/pcm/PcmConvert.cxx
index 69e1c5d04..7e71da283 100644
--- a/src/pcm/PcmConvert.cxx
+++ b/src/pcm/PcmConvert.cxx
@@ -22,7 +22,7 @@
#include "PcmChannels.hxx"
#include "PcmFormat.hxx"
#include "pcm_pack.h"
-#include "audio_format.h"
+#include "AudioFormat.hxx"
#include <glib.h>
@@ -48,46 +48,46 @@ PcmConvert::Reset()
}
inline const int16_t *
-PcmConvert::Convert16(const audio_format *src_format,
+PcmConvert::Convert16(const AudioFormat src_format,
const void *src_buffer, size_t src_size,
- const audio_format *dest_format, size_t *dest_size_r,
+ const AudioFormat dest_format, size_t *dest_size_r,
GError **error_r)
{
const int16_t *buf;
size_t len;
- assert(dest_format->format == SAMPLE_FORMAT_S16);
+ assert(dest_format.format == SampleFormat::S16);
buf = pcm_convert_to_16(format_buffer, dither,
- sample_format(src_format->format),
+ src_format.format,
src_buffer, src_size,
&len);
if (buf == NULL) {
g_set_error(error_r, pcm_convert_quark(), 0,
"Conversion from %s to 16 bit is not implemented",
- sample_format_to_string(sample_format(src_format->format)));
+ sample_format_to_string(src_format.format));
return NULL;
}
- if (src_format->channels != dest_format->channels) {
+ if (src_format.channels != dest_format.channels) {
buf = pcm_convert_channels_16(channels_buffer,
- dest_format->channels,
- src_format->channels,
+ dest_format.channels,
+ src_format.channels,
buf, len, &len);
if (buf == NULL) {
g_set_error(error_r, pcm_convert_quark(), 0,
"Conversion from %u to %u channels "
"is not implemented",
- src_format->channels,
- dest_format->channels);
+ src_format.channels,
+ dest_format.channels);
return NULL;
}
}
- if (src_format->sample_rate != dest_format->sample_rate) {
- buf = resampler.Resample16(dest_format->channels,
- src_format->sample_rate, buf, len,
- dest_format->sample_rate, &len,
+ if (src_format.sample_rate != dest_format.sample_rate) {
+ buf = resampler.Resample16(dest_format.channels,
+ src_format.sample_rate, buf, len,
+ dest_format.sample_rate, &len,
error_r);
if (buf == NULL)
return NULL;
@@ -98,45 +98,45 @@ PcmConvert::Convert16(const audio_format *src_format,
}
inline const int32_t *
-PcmConvert::Convert24(const audio_format *src_format,
+PcmConvert::Convert24(const AudioFormat src_format,
const void *src_buffer, size_t src_size,
- const audio_format *dest_format, size_t *dest_size_r,
+ const AudioFormat dest_format, size_t *dest_size_r,
GError **error_r)
{
const int32_t *buf;
size_t len;
- assert(dest_format->format == SAMPLE_FORMAT_S24_P32);
+ assert(dest_format.format == SampleFormat::S24_P32);
buf = pcm_convert_to_24(format_buffer,
- sample_format(src_format->format),
+ src_format.format,
src_buffer, src_size, &len);
if (buf == NULL) {
g_set_error(error_r, pcm_convert_quark(), 0,
"Conversion from %s to 24 bit is not implemented",
- sample_format_to_string(sample_format(src_format->format)));
+ sample_format_to_string(src_format.format));
return NULL;
}
- if (src_format->channels != dest_format->channels) {
+ if (src_format.channels != dest_format.channels) {
buf = pcm_convert_channels_24(channels_buffer,
- dest_format->channels,
- src_format->channels,
+ dest_format.channels,
+ src_format.channels,
buf, len, &len);
if (buf == NULL) {
g_set_error(error_r, pcm_convert_quark(), 0,
"Conversion from %u to %u channels "
"is not implemented",
- src_format->channels,
- dest_format->channels);
+ src_format.channels,
+ dest_format.channels);
return NULL;
}
}
- if (src_format->sample_rate != dest_format->sample_rate) {
- buf = resampler.Resample24(dest_format->channels,
- src_format->sample_rate, buf, len,
- dest_format->sample_rate, &len,
+ if (src_format.sample_rate != dest_format.sample_rate) {
+ buf = resampler.Resample24(dest_format.channels,
+ src_format.sample_rate, buf, len,
+ dest_format.sample_rate, &len,
error_r);
if (buf == NULL)
return NULL;
@@ -147,45 +147,45 @@ PcmConvert::Convert24(const audio_format *src_format,
}
inline const int32_t *
-PcmConvert::Convert32(const audio_format *src_format,
+PcmConvert::Convert32(const AudioFormat src_format,
const void *src_buffer, size_t src_size,
- const audio_format *dest_format, size_t *dest_size_r,
+ const AudioFormat dest_format, size_t *dest_size_r,
GError **error_r)
{
const int32_t *buf;
size_t len;
- assert(dest_format->format == SAMPLE_FORMAT_S32);
+ assert(dest_format.format == SampleFormat::S32);
buf = pcm_convert_to_32(format_buffer,
- sample_format(src_format->format),
+ src_format.format,
src_buffer, src_size, &len);
if (buf == NULL) {
g_set_error(error_r, pcm_convert_quark(), 0,
"Conversion from %s to 32 bit is not implemented",
- sample_format_to_string(sample_format(src_format->format)));
+ sample_format_to_string(src_format.format));
return NULL;
}
- if (src_format->channels != dest_format->channels) {
+ if (src_format.channels != dest_format.channels) {
buf = pcm_convert_channels_32(channels_buffer,
- dest_format->channels,
- src_format->channels,
+ dest_format.channels,
+ src_format.channels,
buf, len, &len);
if (buf == NULL) {
g_set_error(error_r, pcm_convert_quark(), 0,
"Conversion from %u to %u channels "
"is not implemented",
- src_format->channels,
- dest_format->channels);
+ src_format.channels,
+ dest_format.channels);
return NULL;
}
}
- if (src_format->sample_rate != dest_format->sample_rate) {
- buf = resampler.Resample32(dest_format->channels,
- src_format->sample_rate, buf, len,
- dest_format->sample_rate, &len,
+ if (src_format.sample_rate != dest_format.sample_rate) {
+ buf = resampler.Resample32(dest_format.channels,
+ src_format.sample_rate, buf, len,
+ dest_format.sample_rate, &len,
error_r);
if (buf == NULL)
return buf;
@@ -196,41 +196,41 @@ PcmConvert::Convert32(const audio_format *src_format,
}
inline const float *
-PcmConvert::ConvertFloat(const audio_format *src_format,
+PcmConvert::ConvertFloat(const AudioFormat src_format,
const void *src_buffer, size_t src_size,
- const audio_format *dest_format, size_t *dest_size_r,
+ const AudioFormat dest_format, size_t *dest_size_r,
GError **error_r)
{
const float *buffer = (const float *)src_buffer;
size_t size = src_size;
- assert(dest_format->format == SAMPLE_FORMAT_FLOAT);
+ assert(dest_format.format == SampleFormat::FLOAT);
/* convert to float now */
buffer = pcm_convert_to_float(format_buffer,
- sample_format(src_format->format),
+ src_format.format,
buffer, size, &size);
if (buffer == NULL) {
g_set_error(error_r, pcm_convert_quark(), 0,
"Conversion from %s to float is not implemented",
- sample_format_to_string(sample_format(src_format->format)));
+ sample_format_to_string(src_format.format));
return NULL;
}
/* convert channels */
- if (src_format->channels != dest_format->channels) {
+ if (src_format.channels != dest_format.channels) {
buffer = pcm_convert_channels_float(channels_buffer,
- dest_format->channels,
- src_format->channels,
+ dest_format.channels,
+ src_format.channels,
buffer, size, &size);
if (buffer == NULL) {
g_set_error(error_r, pcm_convert_quark(), 0,
"Conversion from %u to %u channels "
"is not implemented",
- src_format->channels,
- dest_format->channels);
+ src_format.channels,
+ dest_format.channels);
return NULL;
}
}
@@ -238,11 +238,11 @@ PcmConvert::ConvertFloat(const audio_format *src_format,
/* resample with float, because this is the best format for
libsamplerate */
- if (src_format->sample_rate != dest_format->sample_rate) {
- buffer = resampler.ResampleFloat(dest_format->channels,
- src_format->sample_rate,
+ if (src_format.sample_rate != dest_format.sample_rate) {
+ buffer = resampler.ResampleFloat(dest_format.channels,
+ src_format.sample_rate,
buffer, size,
- dest_format->sample_rate,
+ dest_format.sample_rate,
&size, error_r);
if (buffer == NULL)
return NULL;
@@ -253,16 +253,16 @@ PcmConvert::ConvertFloat(const audio_format *src_format,
}
const void *
-PcmConvert::Convert(const audio_format *src_format,
+PcmConvert::Convert(AudioFormat src_format,
const void *src, size_t src_size,
- const audio_format *dest_format,
+ const AudioFormat dest_format,
size_t *dest_size_r,
GError **error_r)
{
- struct audio_format float_format;
- if (src_format->format == SAMPLE_FORMAT_DSD) {
+ AudioFormat float_format;
+ if (src_format.format == SampleFormat::DSD) {
size_t f_size;
- const float *f = dsd.ToFloat(src_format->channels,
+ const float *f = dsd.ToFloat(src_format.channels,
false, (const uint8_t *)src,
src_size, &f_size);
if (f == NULL) {
@@ -271,31 +271,31 @@ PcmConvert::Convert(const audio_format *src_format,
return NULL;
}
- float_format = *src_format;
- float_format.format = SAMPLE_FORMAT_FLOAT;
+ float_format = src_format;
+ float_format.format = SampleFormat::FLOAT;
- src_format = &float_format;
+ src_format = float_format;
src = f;
src_size = f_size;
}
- switch (sample_format(dest_format->format)) {
- case SAMPLE_FORMAT_S16:
+ switch (dest_format.format) {
+ case SampleFormat::S16:
return Convert16(src_format, src, src_size,
dest_format, dest_size_r,
error_r);
- case SAMPLE_FORMAT_S24_P32:
+ case SampleFormat::S24_P32:
return Convert24(src_format, src, src_size,
dest_format, dest_size_r,
error_r);
- case SAMPLE_FORMAT_S32:
+ case SampleFormat::S32:
return Convert32(src_format, src, src_size,
dest_format, dest_size_r,
error_r);
- case SAMPLE_FORMAT_FLOAT:
+ case SampleFormat::FLOAT:
return ConvertFloat(src_format, src, src_size,
dest_format, dest_size_r,
error_r);
@@ -303,7 +303,7 @@ PcmConvert::Convert(const audio_format *src_format,
default:
g_set_error(error_r, pcm_convert_quark(), 0,
"PCM conversion to %s is not implemented",
- sample_format_to_string(sample_format(dest_format->format)));
+ sample_format_to_string(dest_format.format));
return NULL;
}
}
diff --git a/src/pcm/PcmConvert.hxx b/src/pcm/PcmConvert.hxx
index f4503f5aa..42b59e407 100644
--- a/src/pcm/PcmConvert.hxx
+++ b/src/pcm/PcmConvert.hxx
@@ -27,7 +27,7 @@
#include <glib.h>
-struct audio_format;
+struct AudioFormat;
/**
* This object is statically allocated (within another struct), and
@@ -71,34 +71,34 @@ public:
* ignore errors
* @return the destination buffer, or NULL on error
*/
- const void *Convert(const audio_format *src_format,
+ const void *Convert(AudioFormat src_format,
const void *src, size_t src_size,
- const audio_format *dest_format,
+ AudioFormat dest_format,
size_t *dest_size_r,
GError **error_r);
private:
- const int16_t *Convert16(const audio_format *src_format,
+ const int16_t *Convert16(AudioFormat src_format,
const void *src_buffer, size_t src_size,
- const audio_format *dest_format,
+ AudioFormat dest_format,
size_t *dest_size_r,
GError **error_r);
- const int32_t *Convert24(const audio_format *src_format,
+ const int32_t *Convert24(AudioFormat src_format,
const void *src_buffer, size_t src_size,
- const audio_format *dest_format,
+ AudioFormat dest_format,
size_t *dest_size_r,
GError **error_r);
- const int32_t *Convert32(const audio_format *src_format,
+ const int32_t *Convert32(AudioFormat src_format,
const void *src_buffer, size_t src_size,
- const audio_format *dest_format,
+ AudioFormat dest_format,
size_t *dest_size_r,
GError **error_r);
- const float *ConvertFloat(const audio_format *src_format,
+ const float *ConvertFloat(AudioFormat src_format,
const void *src_buffer, size_t src_size,
- const audio_format *dest_format,
+ AudioFormat dest_format,
size_t *dest_size_r,
GError **error_r);
};
diff --git a/src/pcm/PcmDsdUsb.cxx b/src/pcm/PcmDsdUsb.cxx
index ef267e724..7d58dec4d 100644
--- a/src/pcm/PcmDsdUsb.cxx
+++ b/src/pcm/PcmDsdUsb.cxx
@@ -20,7 +20,7 @@
#include "config.h"
#include "PcmDsdUsb.hxx"
#include "PcmBuffer.hxx"
-#include "audio_format.h"
+#include "AudioFormat.hxx"
G_GNUC_CONST
static inline uint32_t
diff --git a/src/pcm/PcmExport.cxx b/src/pcm/PcmExport.cxx
index 8840dc865..762411f59 100644
--- a/src/pcm/PcmExport.cxx
+++ b/src/pcm/PcmExport.cxx
@@ -27,21 +27,21 @@ extern "C" {
}
void
-PcmExport::Open(enum sample_format sample_format, unsigned _channels,
+PcmExport::Open(SampleFormat sample_format, unsigned _channels,
bool _dsd_usb, bool _shift8, bool _pack, bool _reverse_endian)
{
assert(audio_valid_sample_format(sample_format));
assert(!_dsd_usb || audio_valid_channel_count(_channels));
channels = _channels;
- dsd_usb = _dsd_usb && sample_format == SAMPLE_FORMAT_DSD;
+ dsd_usb = _dsd_usb && sample_format == SampleFormat::DSD;
if (dsd_usb)
/* after the conversion to DSD-over-USB, the DSD
samples are stuffed inside fake 24 bit samples */
- sample_format = SAMPLE_FORMAT_S24_P32;
+ sample_format = SampleFormat::S24_P32;
- shift8 = _shift8 && sample_format == SAMPLE_FORMAT_S24_P32;
- pack24 = _pack && sample_format == SAMPLE_FORMAT_S24_P32;
+ shift8 = _shift8 && sample_format == SampleFormat::S24_P32;
+ pack24 = _pack && sample_format == SampleFormat::S24_P32;
assert(!shift8 || !pack24);
@@ -58,7 +58,7 @@ PcmExport::Open(enum sample_format sample_format, unsigned _channels,
}
size_t
-PcmExport::GetFrameSize(const struct audio_format &audio_format) const
+PcmExport::GetFrameSize(const AudioFormat &audio_format) const
{
if (pack24)
/* packed 24 bit samples (3 bytes per sample) */
@@ -71,7 +71,7 @@ PcmExport::GetFrameSize(const struct audio_format &audio_format) const
bytes per sample) */
return channels * 4;
- return audio_format_frame_size(&audio_format);
+ return audio_format.GetFrameSize();
}
const void *
diff --git a/src/pcm/PcmExport.hxx b/src/pcm/PcmExport.hxx
index e420493f0..bd18c0534 100644
--- a/src/pcm/PcmExport.hxx
+++ b/src/pcm/PcmExport.hxx
@@ -22,9 +22,9 @@
#include "check.h"
#include "PcmBuffer.hxx"
-#include "audio_format.h"
+#include "AudioFormat.hxx"
-struct audio_format;
+struct AudioFormat;
/**
* An object that handles export of PCM samples to some instance
@@ -61,8 +61,8 @@ struct PcmExport {
/**
* Convert DSD to DSD-over-USB? Input format must be
- * SAMPLE_FORMAT_DSD and output format must be
- * SAMPLE_FORMAT_S24_P32.
+ * SampleFormat::DSD and output format must be
+ * SampleFormat::S24_P32.
*/
bool dsd_usb;
@@ -94,14 +94,14 @@ struct PcmExport {
*
* @param channels the number of channels; ignored unless dsd_usb is set
*/
- void Open(enum sample_format sample_format, unsigned channels,
+ void Open(SampleFormat sample_format, unsigned channels,
bool dsd_usb, bool shift8, bool pack, bool reverse_endian);
/**
* Calculate the size of one output frame.
*/
gcc_pure
- size_t GetFrameSize(const struct audio_format &audio_format) const;
+ size_t GetFrameSize(const AudioFormat &audio_format) const;
/**
* Export a PCM buffer.
diff --git a/src/pcm/PcmFormat.cxx b/src/pcm/PcmFormat.cxx
index 2dea09d2c..6425c7cfd 100644
--- a/src/pcm/PcmFormat.cxx
+++ b/src/pcm/PcmFormat.cxx
@@ -142,36 +142,36 @@ pcm_allocate_float_to_16(PcmBuffer &buffer,
const int16_t *
pcm_convert_to_16(PcmBuffer &buffer, PcmDither &dither,
- enum sample_format src_format, const void *src,
+ SampleFormat src_format, const void *src,
size_t src_size, size_t *dest_size_r)
{
assert(src_size % sample_format_size(src_format) == 0);
switch (src_format) {
- case SAMPLE_FORMAT_UNDEFINED:
- case SAMPLE_FORMAT_DSD:
+ case SampleFormat::UNDEFINED:
+ case SampleFormat::DSD:
break;
- case SAMPLE_FORMAT_S8:
+ case SampleFormat::S8:
return pcm_allocate_8_to_16(buffer,
(const int8_t *)src, src_size,
dest_size_r);
- case SAMPLE_FORMAT_S16:
+ case SampleFormat::S16:
*dest_size_r = src_size;
return (const int16_t *)src;
- case SAMPLE_FORMAT_S24_P32:
+ case SampleFormat::S24_P32:
return pcm_allocate_24p32_to_16(buffer, dither,
(const int32_t *)src, src_size,
dest_size_r);
- case SAMPLE_FORMAT_S32:
+ case SampleFormat::S32:
return pcm_allocate_32_to_16(buffer, dither,
(const int32_t *)src, src_size,
dest_size_r);
- case SAMPLE_FORMAT_FLOAT:
+ case SampleFormat::FLOAT:
return pcm_allocate_float_to_16(buffer,
(const float *)src, src_size,
dest_size_r);
@@ -247,36 +247,36 @@ pcm_allocate_float_to_24(PcmBuffer &buffer,
const int32_t *
pcm_convert_to_24(PcmBuffer &buffer,
- enum sample_format src_format, const void *src,
+ SampleFormat src_format, const void *src,
size_t src_size, size_t *dest_size_r)
{
assert(src_size % sample_format_size(src_format) == 0);
switch (src_format) {
- case SAMPLE_FORMAT_UNDEFINED:
- case SAMPLE_FORMAT_DSD:
+ case SampleFormat::UNDEFINED:
+ case SampleFormat::DSD:
break;
- case SAMPLE_FORMAT_S8:
+ case SampleFormat::S8:
return pcm_allocate_8_to_24(buffer,
(const int8_t *)src, src_size,
dest_size_r);
- case SAMPLE_FORMAT_S16:
+ case SampleFormat::S16:
return pcm_allocate_16_to_24(buffer,
(const int16_t *)src, src_size,
dest_size_r);
- case SAMPLE_FORMAT_S24_P32:
+ case SampleFormat::S24_P32:
*dest_size_r = src_size;
return (const int32_t *)src;
- case SAMPLE_FORMAT_S32:
+ case SampleFormat::S32:
return pcm_allocate_32_to_24(buffer,
(const int32_t *)src, src_size,
dest_size_r);
- case SAMPLE_FORMAT_FLOAT:
+ case SampleFormat::FLOAT:
return pcm_allocate_float_to_24(buffer,
(const float *)src, src_size,
dest_size_r);
@@ -358,36 +358,36 @@ pcm_allocate_float_to_32(PcmBuffer &buffer,
const int32_t *
pcm_convert_to_32(PcmBuffer &buffer,
- enum sample_format src_format, const void *src,
+ SampleFormat src_format, const void *src,
size_t src_size, size_t *dest_size_r)
{
assert(src_size % sample_format_size(src_format) == 0);
switch (src_format) {
- case SAMPLE_FORMAT_UNDEFINED:
- case SAMPLE_FORMAT_DSD:
+ case SampleFormat::UNDEFINED:
+ case SampleFormat::DSD:
break;
- case SAMPLE_FORMAT_S8:
+ case SampleFormat::S8:
return pcm_allocate_8_to_32(buffer,
(const int8_t *)src, src_size,
dest_size_r);
- case SAMPLE_FORMAT_S16:
+ case SampleFormat::S16:
return pcm_allocate_16_to_32(buffer,
(const int16_t *)src, src_size,
dest_size_r);
- case SAMPLE_FORMAT_S24_P32:
+ case SampleFormat::S24_P32:
return pcm_allocate_24p32_to_32(buffer,
(const int32_t *)src, src_size,
dest_size_r);
- case SAMPLE_FORMAT_S32:
+ case SampleFormat::S32:
*dest_size_r = src_size;
return (const int32_t *)src;
- case SAMPLE_FORMAT_FLOAT:
+ case SampleFormat::FLOAT:
return pcm_allocate_float_to_32(buffer,
(const float *)src, src_size,
dest_size_r);
@@ -463,35 +463,35 @@ pcm_allocate_32_to_float(PcmBuffer &buffer,
const float *
pcm_convert_to_float(PcmBuffer &buffer,
- enum sample_format src_format, const void *src,
+ SampleFormat src_format, const void *src,
size_t src_size, size_t *dest_size_r)
{
switch (src_format) {
- case SAMPLE_FORMAT_UNDEFINED:
- case SAMPLE_FORMAT_DSD:
+ case SampleFormat::UNDEFINED:
+ case SampleFormat::DSD:
break;
- case SAMPLE_FORMAT_S8:
+ case SampleFormat::S8:
return pcm_allocate_8_to_float(buffer,
(const int8_t *)src, src_size,
dest_size_r);
- case SAMPLE_FORMAT_S16:
+ case SampleFormat::S16:
return pcm_allocate_16_to_float(buffer,
(const int16_t *)src, src_size,
dest_size_r);
- case SAMPLE_FORMAT_S24_P32:
+ case SampleFormat::S24_P32:
return pcm_allocate_24p32_to_float(buffer,
(const int32_t *)src, src_size,
dest_size_r);
- case SAMPLE_FORMAT_S32:
+ case SampleFormat::S32:
return pcm_allocate_32_to_float(buffer,
(const int32_t *)src, src_size,
dest_size_r);
- case SAMPLE_FORMAT_FLOAT:
+ case SampleFormat::FLOAT:
*dest_size_r = src_size;
return (const float *)src;
}
diff --git a/src/pcm/PcmFormat.hxx b/src/pcm/PcmFormat.hxx
index bb5ad49ae..b18b4f932 100644
--- a/src/pcm/PcmFormat.hxx
+++ b/src/pcm/PcmFormat.hxx
@@ -20,7 +20,7 @@
#ifndef MPD_PCM_FORMAT_HXX
#define MPD_PCM_FORMAT_HXX
-#include "audio_format.h"
+#include "AudioFormat.hxx"
#include <stdint.h>
#include <stddef.h>
@@ -42,7 +42,7 @@ class PcmDither;
*/
const int16_t *
pcm_convert_to_16(PcmBuffer &buffer, PcmDither &dither,
- enum sample_format src_format, const void *src,
+ SampleFormat src_format, const void *src,
size_t src_size, size_t *dest_size_r);
/**
@@ -57,7 +57,7 @@ pcm_convert_to_16(PcmBuffer &buffer, PcmDither &dither,
*/
const int32_t *
pcm_convert_to_24(PcmBuffer &buffer,
- enum sample_format src_format, const void *src,
+ SampleFormat src_format, const void *src,
size_t src_size, size_t *dest_size_r);
/**
@@ -72,7 +72,7 @@ pcm_convert_to_24(PcmBuffer &buffer,
*/
const int32_t *
pcm_convert_to_32(PcmBuffer &buffer,
- enum sample_format src_format, const void *src,
+ SampleFormat src_format, const void *src,
size_t src_size, size_t *dest_size_r);
/**
@@ -87,7 +87,7 @@ pcm_convert_to_32(PcmBuffer &buffer,
*/
const float *
pcm_convert_to_float(PcmBuffer &buffer,
- enum sample_format src_format, const void *src,
+ SampleFormat src_format, const void *src,
size_t src_size, size_t *dest_size_r);
#endif
diff --git a/src/pcm/PcmMix.cxx b/src/pcm/PcmMix.cxx
index b92258a83..f4a02fc47 100644
--- a/src/pcm/PcmMix.cxx
+++ b/src/pcm/PcmMix.cxx
@@ -21,7 +21,7 @@
#include "PcmMix.hxx"
#include "PcmVolume.hxx"
#include "PcmUtils.hxx"
-#include "audio_format.h"
+#include "AudioFormat.hxx"
#include <math.h>
@@ -74,35 +74,35 @@ pcm_add_vol_float(float *buffer1, const float *buffer2,
static bool
pcm_add_vol(void *buffer1, const void *buffer2, size_t size,
int vol1, int vol2,
- enum sample_format format)
+ SampleFormat format)
{
switch (format) {
- case SAMPLE_FORMAT_UNDEFINED:
- case SAMPLE_FORMAT_DSD:
+ case SampleFormat::UNDEFINED:
+ case SampleFormat::DSD:
/* not implemented */
return false;
- case SAMPLE_FORMAT_S8:
+ case SampleFormat::S8:
PcmAddVolumeVoid<int8_t, int32_t, 8>(buffer1, buffer2, size,
vol1, vol2);
return true;
- case SAMPLE_FORMAT_S16:
+ case SampleFormat::S16:
PcmAddVolumeVoid<int16_t, int32_t, 16>(buffer1, buffer2, size,
vol1, vol2);
return true;
- case SAMPLE_FORMAT_S24_P32:
+ case SampleFormat::S24_P32:
PcmAddVolumeVoid<int32_t, int64_t, 24>(buffer1, buffer2, size,
vol1, vol2);
return true;
- case SAMPLE_FORMAT_S32:
+ case SampleFormat::S32:
PcmAddVolumeVoid<int32_t, int64_t, 32>(buffer1, buffer2, size,
vol1, vol2);
return true;
- case SAMPLE_FORMAT_FLOAT:
+ case SampleFormat::FLOAT:
pcm_add_vol_float((float *)buffer1, (const float *)buffer2,
size / 4,
pcm_volume_to_float(vol1),
@@ -153,31 +153,31 @@ pcm_add_float(float *buffer1, const float *buffer2, unsigned num_samples)
static bool
pcm_add(void *buffer1, const void *buffer2, size_t size,
- enum sample_format format)
+ SampleFormat format)
{
switch (format) {
- case SAMPLE_FORMAT_UNDEFINED:
- case SAMPLE_FORMAT_DSD:
+ case SampleFormat::UNDEFINED:
+ case SampleFormat::DSD:
/* not implemented */
return false;
- case SAMPLE_FORMAT_S8:
+ case SampleFormat::S8:
PcmAddVoid<int8_t, int32_t, 8>(buffer1, buffer2, size);
return true;
- case SAMPLE_FORMAT_S16:
+ case SampleFormat::S16:
PcmAddVoid<int16_t, int32_t, 16>(buffer1, buffer2, size);
return true;
- case SAMPLE_FORMAT_S24_P32:
+ case SampleFormat::S24_P32:
PcmAddVoid<int32_t, int64_t, 24>(buffer1, buffer2, size);
return true;
- case SAMPLE_FORMAT_S32:
+ case SampleFormat::S32:
PcmAddVoid<int32_t, int64_t, 32>(buffer1, buffer2, size);
return true;
- case SAMPLE_FORMAT_FLOAT:
+ case SampleFormat::FLOAT:
pcm_add_float((float *)buffer1, (const float *)buffer2,
size / 4);
return true;
@@ -189,7 +189,7 @@ pcm_add(void *buffer1, const void *buffer2, size_t size,
bool
pcm_mix(void *buffer1, const void *buffer2, size_t size,
- enum sample_format format, float portion1)
+ SampleFormat format, float portion1)
{
int vol1;
float s;
diff --git a/src/pcm/PcmMix.hxx b/src/pcm/PcmMix.hxx
index bb7110d04..b50a163fd 100644
--- a/src/pcm/PcmMix.hxx
+++ b/src/pcm/PcmMix.hxx
@@ -20,7 +20,7 @@
#ifndef MPD_PCM_MIX_HXX
#define MPD_PCM_MIX_HXX
-#include "audio_format.h"
+#include "AudioFormat.hxx"
#include "gcc.h"
#include <stddef.h>
@@ -44,6 +44,6 @@
gcc_warn_unused_result
bool
pcm_mix(void *buffer1, const void *buffer2, size_t size,
- enum sample_format format, float portion1);
+ SampleFormat format, float portion1);
#endif
diff --git a/src/pcm/PcmVolume.cxx b/src/pcm/PcmVolume.cxx
index c22017ddd..2a8027400 100644
--- a/src/pcm/PcmVolume.cxx
+++ b/src/pcm/PcmVolume.cxx
@@ -20,7 +20,7 @@
#include "config.h"
#include "PcmVolume.hxx"
#include "PcmUtils.hxx"
-#include "audio_format.h"
+#include "AudioFormat.hxx"
#include <glib.h>
@@ -144,7 +144,7 @@ pcm_volume_change_float(float *buffer, const float *end, float volume)
bool
pcm_volume(void *buffer, size_t length,
- enum sample_format format,
+ SampleFormat format,
int volume)
{
if (volume == PCM_VOLUME_1)
@@ -157,32 +157,32 @@ pcm_volume(void *buffer, size_t length,
const void *end = pcm_end_pointer(buffer, length);
switch (format) {
- case SAMPLE_FORMAT_UNDEFINED:
- case SAMPLE_FORMAT_DSD:
+ case SampleFormat::UNDEFINED:
+ case SampleFormat::DSD:
/* not implemented */
return false;
- case SAMPLE_FORMAT_S8:
+ case SampleFormat::S8:
pcm_volume_change_8((int8_t *)buffer, (const int8_t *)end,
volume);
return true;
- case SAMPLE_FORMAT_S16:
+ case SampleFormat::S16:
pcm_volume_change_16((int16_t *)buffer, (const int16_t *)end,
volume);
return true;
- case SAMPLE_FORMAT_S24_P32:
+ case SampleFormat::S24_P32:
pcm_volume_change_24((int32_t *)buffer, (const int32_t *)end,
volume);
return true;
- case SAMPLE_FORMAT_S32:
+ case SampleFormat::S32:
pcm_volume_change_32((int32_t *)buffer, (const int32_t *)end,
volume);
return true;
- case SAMPLE_FORMAT_FLOAT:
+ case SampleFormat::FLOAT:
pcm_volume_change_float((float *)buffer, (const float *)end,
pcm_volume_to_float(volume));
return true;
diff --git a/src/pcm/PcmVolume.hxx b/src/pcm/PcmVolume.hxx
index ed660b22a..8cd82acf7 100644
--- a/src/pcm/PcmVolume.hxx
+++ b/src/pcm/PcmVolume.hxx
@@ -21,7 +21,7 @@
#define MPD_PCM_VOLUME_HXX
#include "PcmPrng.hxx"
-#include "audio_format.h"
+#include "AudioFormat.hxx"
#include <stdint.h>
#include <stddef.h>
@@ -31,7 +31,7 @@ enum {
PCM_VOLUME_1 = 1024,
};
-struct audio_format;
+struct AudioFormat;
/**
* Converts a float value (0.0 = silence, 1.0 = 100% volume) to an
@@ -75,7 +75,7 @@ pcm_volume_dither(void)
*/
bool
pcm_volume(void *buffer, size_t length,
- enum sample_format format,
+ SampleFormat format,
int volume);
#endif