aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am4
-rw-r--r--src/pcm/PcmConvert.cxx11
-rw-r--r--src/pcm/PcmConvert.hxx4
-rw-r--r--src/pcm/PcmDsd.cxx (renamed from src/pcm/pcm_dsd.c)56
-rw-r--r--src/pcm/PcmDsd.hxx (renamed from src/pcm/pcm_dsd.h)28
-rw-r--r--src/pcm/PcmDsdUsb.cxx (renamed from src/pcm/pcm_dsd_usb.c)6
-rw-r--r--src/pcm/PcmDsdUsb.hxx (renamed from src/pcm/pcm_dsd_usb.h)7
-rw-r--r--src/pcm/PcmExport.cxx2
8 files changed, 54 insertions, 64 deletions
diff --git a/Makefile.am b/Makefile.am
index 7b10163fd..0185f8e5e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -307,8 +307,8 @@ libpcm_a_SOURCES = \
src/pcm/PcmExport.cxx src/pcm/PcmExport.hxx \
src/pcm/PcmConvert.cxx src/pcm/PcmConvert.hxx \
src/pcm/dsd2pcm/dsd2pcm.c src/pcm/dsd2pcm/dsd2pcm.h \
- src/pcm/pcm_dsd.c src/pcm/pcm_dsd.h \
- src/pcm/pcm_dsd_usb.c src/pcm/pcm_dsd_usb.h \
+ src/pcm/PcmDsd.cxx src/pcm/PcmDsd.hxx \
+ src/pcm/PcmDsdUsb.cxx src/pcm/PcmDsdUsb.hxx \
src/pcm/PcmVolume.cxx src/pcm/PcmVolume.hxx \
src/pcm/PcmMix.cxx src/pcm/PcmMix.hxx \
src/pcm/PcmChannels.cxx src/pcm/PcmChannels.hxx \
diff --git a/src/pcm/PcmConvert.cxx b/src/pcm/PcmConvert.cxx
index 9618b9642..383df9156 100644
--- a/src/pcm/PcmConvert.cxx
+++ b/src/pcm/PcmConvert.cxx
@@ -36,7 +36,6 @@ PcmConvert::PcmConvert()
{
memset(this, 0, sizeof(*this));
- pcm_dsd_init(&dsd);
pcm_resample_init(&resample);
pcm_buffer_init(&format_buffer);
@@ -45,7 +44,6 @@ PcmConvert::PcmConvert()
PcmConvert::~PcmConvert()
{
- pcm_dsd_deinit(&dsd);
pcm_resample_deinit(&resample);
pcm_buffer_deinit(&format_buffer);
@@ -55,7 +53,7 @@ PcmConvert::~PcmConvert()
void
PcmConvert::Reset()
{
- pcm_dsd_reset(&dsd);
+ dsd.Reset();
pcm_resample_reset(&resample);
}
@@ -278,10 +276,9 @@ PcmConvert::Convert(const audio_format *src_format,
struct audio_format float_format;
if (src_format->format == SAMPLE_FORMAT_DSD) {
size_t f_size;
- const float *f = pcm_dsd_to_float(&dsd,
- src_format->channels,
- false, (const uint8_t *)src,
- src_size, &f_size);
+ const float *f = dsd.ToFloat(src_format->channels,
+ false, (const uint8_t *)src,
+ src_size, &f_size);
if (f == NULL) {
g_set_error_literal(error_r, pcm_convert_quark(), 0,
"DSD to PCM conversion failed");
diff --git a/src/pcm/PcmConvert.hxx b/src/pcm/PcmConvert.hxx
index f08188a9c..62f67ed8e 100644
--- a/src/pcm/PcmConvert.hxx
+++ b/src/pcm/PcmConvert.hxx
@@ -21,9 +21,9 @@
#define PCM_CONVERT_HXX
#include "PcmDither.hxx"
+#include "PcmDsd.hxx"
extern "C" {
-#include "pcm_dsd.h"
#include "pcm_resample.h"
#include "pcm_buffer.h"
}
@@ -38,7 +38,7 @@ struct audio_format;
* conversions.
*/
class PcmConvert {
- struct pcm_dsd dsd;
+ PcmDsd dsd;
struct pcm_resample_state resample;
diff --git a/src/pcm/pcm_dsd.c b/src/pcm/PcmDsd.cxx
index 76266b4cc..fb2dfd033 100644
--- a/src/pcm/pcm_dsd.c
+++ b/src/pcm/PcmDsd.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2012 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,48 +18,48 @@
*/
#include "config.h"
-#include "pcm_dsd.h"
+#include "PcmDsd.hxx"
#include "dsd2pcm/dsd2pcm.h"
#include <glib.h>
+
+#include <algorithm>
+
#include <string.h>
-void
-pcm_dsd_init(struct pcm_dsd *dsd)
+PcmDsd::PcmDsd()
{
- pcm_buffer_init(&dsd->buffer);
+ pcm_buffer_init(&buffer);
- memset(dsd->dsd2pcm, 0, sizeof(dsd->dsd2pcm));
+ std::fill_n(dsd2pcm, G_N_ELEMENTS(dsd2pcm), nullptr);
}
-void
-pcm_dsd_deinit(struct pcm_dsd *dsd)
+PcmDsd::~PcmDsd()
{
- pcm_buffer_deinit(&dsd->buffer);
+ pcm_buffer_deinit(&buffer);
- for (unsigned i = 0; i < G_N_ELEMENTS(dsd->dsd2pcm); ++i)
- if (dsd->dsd2pcm[i] != NULL)
- dsd2pcm_destroy(dsd->dsd2pcm[i]);
+ for (unsigned i = 0; i < G_N_ELEMENTS(dsd2pcm); ++i)
+ if (dsd2pcm[i] != nullptr)
+ dsd2pcm_destroy(dsd2pcm[i]);
}
void
-pcm_dsd_reset(struct pcm_dsd *dsd)
+PcmDsd::Reset()
{
- for (unsigned i = 0; i < G_N_ELEMENTS(dsd->dsd2pcm); ++i)
- if (dsd->dsd2pcm[i] != NULL)
- dsd2pcm_reset(dsd->dsd2pcm[i]);
+ for (unsigned i = 0; i < G_N_ELEMENTS(dsd2pcm); ++i)
+ if (dsd2pcm[i] != nullptr)
+ dsd2pcm_reset(dsd2pcm[i]);
}
const float *
-pcm_dsd_to_float(struct pcm_dsd *dsd, unsigned channels, bool lsbfirst,
- const uint8_t *src, size_t src_size,
- size_t *dest_size_r)
+PcmDsd::ToFloat(unsigned channels, bool lsbfirst,
+ const uint8_t *src, size_t src_size,
+ size_t *dest_size_r)
{
- assert(dsd != NULL);
- assert(src != NULL);
+ assert(src != nullptr);
assert(src_size > 0);
assert(src_size % channels == 0);
- assert(channels <= G_N_ELEMENTS(dsd->dsd2pcm));
+ assert(channels <= G_N_ELEMENTS(dsd2pcm));
const unsigned num_samples = src_size;
const unsigned num_frames = src_size / channels;
@@ -67,16 +67,16 @@ pcm_dsd_to_float(struct pcm_dsd *dsd, unsigned channels, bool lsbfirst,
float *dest;
const size_t dest_size = num_samples * sizeof(*dest);
*dest_size_r = dest_size;
- dest = pcm_buffer_get(&dsd->buffer, dest_size);
+ dest = (float *)pcm_buffer_get(&buffer, dest_size);
for (unsigned c = 0; c < channels; ++c) {
- if (dsd->dsd2pcm[c] == NULL) {
- dsd->dsd2pcm[c] = dsd2pcm_init();
- if (dsd->dsd2pcm[c] == NULL)
- return NULL;
+ if (dsd2pcm[c] == nullptr) {
+ dsd2pcm[c] = dsd2pcm_init();
+ if (dsd2pcm[c] == nullptr)
+ return nullptr;
}
- dsd2pcm_translate(dsd->dsd2pcm[c], num_frames,
+ dsd2pcm_translate(dsd2pcm[c], num_frames,
src + c, channels,
lsbfirst, dest + c, channels);
}
diff --git a/src/pcm/pcm_dsd.h b/src/pcm/PcmDsd.hxx
index 85c2455aa..ef71411e9 100644
--- a/src/pcm/pcm_dsd.h
+++ b/src/pcm/PcmDsd.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2012 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,36 +17,30 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_PCM_DSD_H
-#define MPD_PCM_DSD_H
+#ifndef MPD_PCM_DSD_HXX
+#define MPD_PCM_DSD_HXX
#include "check.h"
#include "pcm_buffer.h"
-#include <stdbool.h>
#include <stdint.h>
/**
* Wrapper for the dsd2pcm library.
*/
-struct pcm_dsd {
+struct PcmDsd {
struct pcm_buffer buffer;
struct dsd2pcm_ctx_s *dsd2pcm[32];
-};
-
-void
-pcm_dsd_init(struct pcm_dsd *dsd);
-void
-pcm_dsd_deinit(struct pcm_dsd *dsd);
+ PcmDsd();
+ ~PcmDsd();
-void
-pcm_dsd_reset(struct pcm_dsd *dsd);
+ void Reset();
-const float *
-pcm_dsd_to_float(struct pcm_dsd *dsd, unsigned channels, bool lsbfirst,
- const uint8_t *src, size_t src_size,
- size_t *dest_size_r);
+ const float *ToFloat(unsigned channels, bool lsbfirst,
+ const uint8_t *src, size_t src_size,
+ size_t *dest_size_r);
+};
#endif
diff --git a/src/pcm/pcm_dsd_usb.c b/src/pcm/PcmDsdUsb.cxx
index 4b5e39f39..30231e144 100644
--- a/src/pcm/pcm_dsd_usb.c
+++ b/src/pcm/PcmDsdUsb.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2012 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -18,7 +18,7 @@
*/
#include "config.h"
-#include "pcm_dsd_usb.h"
+#include "PcmDsdUsb.hxx"
#include "pcm_buffer.h"
#include "audio_format.h"
@@ -58,7 +58,7 @@ pcm_dsd_to_usb(struct pcm_buffer *buffer, unsigned channels,
const size_t dest_size = num_samples * 4;
*dest_size_r = dest_size;
- uint32_t *const dest0 = pcm_buffer_get(buffer, dest_size),
+ uint32_t *const dest0 = (uint32_t *)pcm_buffer_get(buffer, dest_size),
*dest = dest0;
for (unsigned i = num_frames / 2; i > 0; --i) {
diff --git a/src/pcm/pcm_dsd_usb.h b/src/pcm/PcmDsdUsb.hxx
index 389358459..d4b414324 100644
--- a/src/pcm/pcm_dsd_usb.h
+++ b/src/pcm/PcmDsdUsb.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2012 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,12 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_PCM_DSD_USB_H
-#define MPD_PCM_DSD_USB_H
+#ifndef MPD_PCM_DSD_USB_HXX
+#define MPD_PCM_DSD_USB_HXX
#include "check.h"
-#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
diff --git a/src/pcm/PcmExport.cxx b/src/pcm/PcmExport.cxx
index 288b59ab4..a148e2873 100644
--- a/src/pcm/PcmExport.cxx
+++ b/src/pcm/PcmExport.cxx
@@ -19,9 +19,9 @@
#include "config.h"
#include "PcmExport.hxx"
+#include "PcmDsdUsb.hxx"
extern "C" {
-#include "pcm_dsd_usb.h"
#include "pcm_pack.h"
#include "util/byte_reverse.h"
}