aboutsummaryrefslogtreecommitdiffstats
path: root/test
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 /test
parentcd1bb2bafa2653e5d4c7c9abf6f464bcdec693c5 (diff)
downloadmpd-c75cb67c4406648314ce2a15daf8b632374d7913.tar.gz
mpd-c75cb67c4406648314ce2a15daf8b632374d7913.tar.xz
mpd-c75cb67c4406648314ce2a15daf8b632374d7913.zip
pcm_buffer: convert to C++
Diffstat (limited to 'test')
-rw-r--r--test/test_pcm_channels.cxx20
-rw-r--r--test/test_pcm_format.cxx34
2 files changed, 17 insertions, 37 deletions
diff --git a/test/test_pcm_channels.cxx b/test/test_pcm_channels.cxx
index 1f9d02daf..6642ed3d4 100644
--- a/test/test_pcm_channels.cxx
+++ b/test/test_pcm_channels.cxx
@@ -21,7 +21,7 @@
#include "test_pcm_all.hxx"
#include "test_pcm_util.hxx"
#include "pcm/PcmChannels.hxx"
-#include "pcm/pcm_buffer.h"
+#include "pcm/PcmBuffer.hxx"
#include <glib.h>
@@ -31,14 +31,13 @@ test_pcm_channels_16()
constexpr unsigned N = 256;
const auto src = TestDataBuffer<int16_t, N * 2>();
- struct pcm_buffer buffer;
- pcm_buffer_init(&buffer);
+ PcmBuffer buffer;
/* stereo to mono */
size_t dest_size;
const int16_t *dest =
- pcm_convert_channels_16(&buffer, 1, 2, src, sizeof(src),
+ pcm_convert_channels_16(buffer, 1, 2, src, sizeof(src),
&dest_size);
g_assert(dest != NULL);
g_assert_cmpint(dest_size, ==, sizeof(src) / 2);
@@ -48,7 +47,7 @@ test_pcm_channels_16()
/* mono to stereo */
- dest = pcm_convert_channels_16(&buffer, 2, 1, src, sizeof(src),
+ dest = pcm_convert_channels_16(buffer, 2, 1, src, sizeof(src),
&dest_size);
g_assert(dest != NULL);
g_assert_cmpint(dest_size, ==, sizeof(src) * 2);
@@ -56,8 +55,6 @@ test_pcm_channels_16()
g_assert_cmpint(dest[i * 2], ==, src[i]);
g_assert_cmpint(dest[i * 2 + 1], ==, src[i]);
}
-
- pcm_buffer_deinit(&buffer);
}
void
@@ -66,14 +63,13 @@ test_pcm_channels_32()
constexpr unsigned N = 256;
const auto src = TestDataBuffer<int32_t, N * 2>();
- struct pcm_buffer buffer;
- pcm_buffer_init(&buffer);
+ PcmBuffer buffer;
/* stereo to mono */
size_t dest_size;
const int32_t *dest =
- pcm_convert_channels_32(&buffer, 1, 2, src, sizeof(src),
+ pcm_convert_channels_32(buffer, 1, 2, src, sizeof(src),
&dest_size);
g_assert(dest != NULL);
g_assert_cmpint(dest_size, ==, sizeof(src) / 2);
@@ -83,7 +79,7 @@ test_pcm_channels_32()
/* mono to stereo */
- dest = pcm_convert_channels_32(&buffer, 2, 1, src, sizeof(src),
+ dest = pcm_convert_channels_32(buffer, 2, 1, src, sizeof(src),
&dest_size);
g_assert(dest != NULL);
g_assert_cmpint(dest_size, ==, sizeof(src) * 2);
@@ -91,6 +87,4 @@ test_pcm_channels_32()
g_assert_cmpint(dest[i * 2], ==, src[i]);
g_assert_cmpint(dest[i * 2 + 1], ==, src[i]);
}
-
- pcm_buffer_deinit(&buffer);
}
diff --git a/test/test_pcm_format.cxx b/test/test_pcm_format.cxx
index f9b9516c9..d7a0a2698 100644
--- a/test/test_pcm_format.cxx
+++ b/test/test_pcm_format.cxx
@@ -23,7 +23,7 @@
#include "pcm/PcmFormat.hxx"
#include "pcm/PcmDither.hxx"
#include "pcm/PcmUtils.hxx"
-#include "pcm/pcm_buffer.h"
+#include "pcm/PcmBuffer.hxx"
#include "audio_format.h"
#include <glib.h>
@@ -34,20 +34,17 @@ test_pcm_format_8_to_16()
constexpr unsigned N = 256;
const auto src = TestDataBuffer<int8_t, N>();
- struct pcm_buffer buffer;
- pcm_buffer_init(&buffer);
+ PcmBuffer buffer;
size_t d_size;
PcmDither dither;
- auto d = pcm_convert_to_16(&buffer, dither, SAMPLE_FORMAT_S8,
+ auto d = pcm_convert_to_16(buffer, dither, SAMPLE_FORMAT_S8,
src, sizeof(src), &d_size);
auto d_end = pcm_end_pointer(d, d_size);
g_assert_cmpint(d_end - d, ==, N);
for (size_t i = 0; i < N; ++i)
g_assert_cmpint(src[i], ==, d[i] >> 8);
-
- pcm_buffer_deinit(&buffer);
}
void
@@ -56,19 +53,16 @@ test_pcm_format_16_to_24()
constexpr unsigned N = 256;
const auto src = TestDataBuffer<int16_t, N>();
- struct pcm_buffer buffer;
- pcm_buffer_init(&buffer);
+ PcmBuffer buffer;
size_t d_size;
- auto d = pcm_convert_to_24(&buffer, SAMPLE_FORMAT_S16,
+ auto d = pcm_convert_to_24(buffer, SAMPLE_FORMAT_S16,
src, sizeof(src), &d_size);
auto d_end = pcm_end_pointer(d, d_size);
g_assert_cmpint(d_end - d, ==, N);
for (size_t i = 0; i < N; ++i)
g_assert_cmpint(src[i], ==, d[i] >> 8);
-
- pcm_buffer_deinit(&buffer);
}
void
@@ -77,19 +71,16 @@ test_pcm_format_16_to_32()
constexpr unsigned N = 256;
const auto src = TestDataBuffer<int16_t, N>();
- struct pcm_buffer buffer;
- pcm_buffer_init(&buffer);
+ PcmBuffer buffer;
size_t d_size;
- auto d = pcm_convert_to_32(&buffer, SAMPLE_FORMAT_S16,
+ auto d = pcm_convert_to_32(buffer, SAMPLE_FORMAT_S16,
src, sizeof(src), &d_size);
auto d_end = pcm_end_pointer(d, d_size);
g_assert_cmpint(d_end - d, ==, N);
for (size_t i = 0; i < N; ++i)
g_assert_cmpint(src[i], ==, d[i] >> 16);
-
- pcm_buffer_deinit(&buffer);
}
void
@@ -98,12 +89,10 @@ test_pcm_format_float()
constexpr unsigned N = 256;
const auto src = TestDataBuffer<int16_t, N>();
- struct pcm_buffer buffer1, buffer2;
- pcm_buffer_init(&buffer1);
- pcm_buffer_init(&buffer2);
+ PcmBuffer buffer1, buffer2;
size_t f_size;
- auto f = pcm_convert_to_float(&buffer1, SAMPLE_FORMAT_S16,
+ auto f = pcm_convert_to_float(buffer1, SAMPLE_FORMAT_S16,
src, sizeof(src), &f_size);
auto f_end = pcm_end_pointer(f, f_size);
g_assert_cmpint(f_end - f, ==, N);
@@ -116,7 +105,7 @@ test_pcm_format_float()
PcmDither dither;
size_t d_size;
- auto d = pcm_convert_to_16(&buffer2, dither,
+ auto d = pcm_convert_to_16(buffer2, dither,
SAMPLE_FORMAT_FLOAT,
f, f_size, &d_size);
auto d_end = pcm_end_pointer(d, d_size);
@@ -124,7 +113,4 @@ test_pcm_format_float()
for (size_t i = 0; i < N; ++i)
g_assert_cmpint(src[i], ==, d[i]);
-
- pcm_buffer_deinit(&buffer1);
- pcm_buffer_deinit(&buffer2);
}