audio_format: convert to C++
This commit is contained in:
@@ -51,7 +51,7 @@ my_log_func(const gchar *log_domain, G_GNUC_UNUSED GLogLevelFlags log_level,
|
||||
|
||||
void
|
||||
decoder_initialized(G_GNUC_UNUSED struct decoder *decoder,
|
||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||
G_GNUC_UNUSED const AudioFormat audio_format,
|
||||
G_GNUC_UNUSED bool seekable,
|
||||
G_GNUC_UNUSED float total_time)
|
||||
{
|
||||
|
@@ -101,7 +101,7 @@ filter_plugin_by_name(G_GNUC_UNUSED const char *name)
|
||||
|
||||
bool
|
||||
pcm_volume(G_GNUC_UNUSED void *buffer, G_GNUC_UNUSED size_t length,
|
||||
G_GNUC_UNUSED enum sample_format format,
|
||||
G_GNUC_UNUSED SampleFormat format,
|
||||
G_GNUC_UNUSED int volume)
|
||||
{
|
||||
assert(false);
|
||||
|
@@ -23,7 +23,7 @@
|
||||
#include "DecoderAPI.hxx"
|
||||
#include "InputInit.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "audio_format.h"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "TagHandler.hxx"
|
||||
#include "TagId3.hxx"
|
||||
#include "ApeTag.hxx"
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
void
|
||||
decoder_initialized(G_GNUC_UNUSED struct decoder *decoder,
|
||||
G_GNUC_UNUSED const struct audio_format *audio_format,
|
||||
G_GNUC_UNUSED const AudioFormat audio_format,
|
||||
G_GNUC_UNUSED bool seekable,
|
||||
G_GNUC_UNUSED float total_time)
|
||||
{
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "AudioParser.hxx"
|
||||
#include "audio_format.h"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "pcm/PcmConvert.hxx"
|
||||
#include "conf.h"
|
||||
#include "util/fifo_buffer.h"
|
||||
@@ -57,7 +57,7 @@ config_get_string(gcc_unused enum ConfigOption option,
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GError *error = NULL;
|
||||
struct audio_format in_audio_format, out_audio_format;
|
||||
AudioFormat in_audio_format, out_audio_format;
|
||||
const void *output;
|
||||
ssize_t nbytes;
|
||||
size_t length;
|
||||
@@ -69,15 +69,15 @@ int main(int argc, char **argv)
|
||||
|
||||
g_log_set_default_handler(my_log_func, NULL);
|
||||
|
||||
if (!audio_format_parse(&in_audio_format, argv[1],
|
||||
if (!audio_format_parse(in_audio_format, argv[1],
|
||||
false, &error)) {
|
||||
g_printerr("Failed to parse audio format: %s\n",
|
||||
error->message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct audio_format out_audio_format_mask;
|
||||
if (!audio_format_parse(&out_audio_format_mask, argv[2],
|
||||
AudioFormat out_audio_format_mask;
|
||||
if (!audio_format_parse(out_audio_format_mask, argv[2],
|
||||
true, &error)) {
|
||||
g_printerr("Failed to parse audio format: %s\n",
|
||||
error->message);
|
||||
@@ -85,9 +85,9 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
out_audio_format = in_audio_format;
|
||||
audio_format_mask_apply(&out_audio_format, &out_audio_format_mask);
|
||||
out_audio_format.ApplyMask(out_audio_format_mask);
|
||||
|
||||
const size_t in_frame_size = audio_format_frame_size(&in_audio_format);
|
||||
const size_t in_frame_size = in_audio_format.GetFrameSize();
|
||||
|
||||
PcmConvert state;
|
||||
|
||||
@@ -112,8 +112,8 @@ int main(int argc, char **argv)
|
||||
|
||||
fifo_buffer_consume(buffer, length);
|
||||
|
||||
output = state.Convert(&in_audio_format, src, length,
|
||||
&out_audio_format, &length, &error);
|
||||
output = state.Convert(in_audio_format, src, length,
|
||||
out_audio_format, &length, &error);
|
||||
if (output == NULL) {
|
||||
g_printerr("Failed to convert: %s\n", error->message);
|
||||
return 2;
|
||||
|
@@ -23,7 +23,7 @@
|
||||
#include "DecoderAPI.hxx"
|
||||
#include "InputInit.hxx"
|
||||
#include "input_stream.h"
|
||||
#include "audio_format.h"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "stdbin.h"
|
||||
|
||||
#include <glib.h>
|
||||
@@ -52,14 +52,14 @@ struct decoder {
|
||||
|
||||
void
|
||||
decoder_initialized(struct decoder *decoder,
|
||||
const struct audio_format *audio_format,
|
||||
const AudioFormat audio_format,
|
||||
G_GNUC_UNUSED bool seekable,
|
||||
G_GNUC_UNUSED float total_time)
|
||||
{
|
||||
struct audio_format_string af_string;
|
||||
|
||||
assert(!decoder->initialized);
|
||||
assert(audio_format_valid(audio_format));
|
||||
assert(audio_format.IsValid());
|
||||
|
||||
g_printerr("audio_format=%s\n",
|
||||
audio_format_to_string(audio_format, &af_string));
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include "config.h"
|
||||
#include "EncoderList.hxx"
|
||||
#include "EncoderPlugin.hxx"
|
||||
#include "audio_format.h"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "AudioParser.hxx"
|
||||
#include "conf.h"
|
||||
#include "stdbin.h"
|
||||
@@ -44,7 +44,6 @@ encoder_to_stdout(Encoder &encoder)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GError *error = NULL;
|
||||
struct audio_format audio_format;
|
||||
bool ret;
|
||||
const char *encoder_name;
|
||||
static char buffer[32768];
|
||||
@@ -61,8 +60,6 @@ int main(int argc, char **argv)
|
||||
else
|
||||
encoder_name = "vorbis";
|
||||
|
||||
audio_format_init(&audio_format, 44100, SAMPLE_FORMAT_S16, 2);
|
||||
|
||||
/* create the encoder */
|
||||
|
||||
const auto plugin = encoder_plugin_get(encoder_name);
|
||||
@@ -84,8 +81,9 @@ int main(int argc, char **argv)
|
||||
|
||||
/* open the encoder */
|
||||
|
||||
AudioFormat audio_format(44100, SampleFormat::S16, 2);
|
||||
if (argc > 2) {
|
||||
ret = audio_format_parse(&audio_format, argv[2],
|
||||
ret = audio_format_parse(audio_format, argv[2],
|
||||
false, &error);
|
||||
if (!ret) {
|
||||
g_printerr("Failed to parse audio format: %s\n",
|
||||
@@ -95,7 +93,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (!encoder_open(encoder, &audio_format, &error)) {
|
||||
if (!encoder_open(encoder, audio_format, &error)) {
|
||||
g_printerr("Failed to open encoder: %s\n",
|
||||
error->message);
|
||||
g_error_free(error);
|
||||
|
@@ -21,7 +21,7 @@
|
||||
#include "conf.h"
|
||||
#include "fs/Path.hxx"
|
||||
#include "AudioParser.hxx"
|
||||
#include "audio_format.h"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "FilterPlugin.hxx"
|
||||
#include "FilterInternal.hxx"
|
||||
#include "pcm/PcmVolume.hxx"
|
||||
@@ -91,11 +91,9 @@ load_filter(const char *name)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct audio_format audio_format;
|
||||
struct audio_format_string af_string;
|
||||
bool success;
|
||||
GError *error = NULL;
|
||||
const struct audio_format *out_audio_format;
|
||||
char buffer[4096];
|
||||
|
||||
if (argc < 3 || argc > 4) {
|
||||
@@ -105,7 +103,7 @@ int main(int argc, char **argv)
|
||||
|
||||
const Path config_path = Path::FromFS(argv[1]);
|
||||
|
||||
audio_format_init(&audio_format, 44100, SAMPLE_FORMAT_S16, 2);
|
||||
AudioFormat audio_format(44100, SampleFormat::S16, 2);
|
||||
|
||||
/* initialize GLib */
|
||||
|
||||
@@ -127,7 +125,7 @@ int main(int argc, char **argv)
|
||||
/* parse the audio format */
|
||||
|
||||
if (argc > 3) {
|
||||
success = audio_format_parse(&audio_format, argv[3],
|
||||
success = audio_format_parse(audio_format, argv[3],
|
||||
false, &error);
|
||||
if (!success) {
|
||||
g_printerr("Failed to parse audio format: %s\n",
|
||||
@@ -145,8 +143,9 @@ int main(int argc, char **argv)
|
||||
|
||||
/* open the filter */
|
||||
|
||||
out_audio_format = filter->Open(audio_format, &error);
|
||||
if (out_audio_format == NULL) {
|
||||
const AudioFormat out_audio_format =
|
||||
filter->Open(audio_format, &error);
|
||||
if (!out_audio_format.IsDefined()) {
|
||||
g_printerr("Failed to open filter: %s\n", error->message);
|
||||
g_error_free(error);
|
||||
delete filter;
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include "config.h"
|
||||
#include "AudioCompress/compress.h"
|
||||
#include "AudioParser.hxx"
|
||||
#include "audio_format.h"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "stdbin.h"
|
||||
|
||||
#include <glib.h>
|
||||
@@ -38,7 +38,6 @@
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GError *error = NULL;
|
||||
struct audio_format audio_format;
|
||||
bool ret;
|
||||
struct Compressor *compressor;
|
||||
static char buffer[4096];
|
||||
@@ -49,16 +48,16 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
AudioFormat audio_format(48000, SampleFormat::S16, 2);
|
||||
if (argc > 1) {
|
||||
ret = audio_format_parse(&audio_format, argv[1],
|
||||
ret = audio_format_parse(audio_format, argv[1],
|
||||
false, &error);
|
||||
if (!ret) {
|
||||
g_printerr("Failed to parse audio format: %s\n",
|
||||
error->message);
|
||||
return 1;
|
||||
}
|
||||
} else
|
||||
audio_format_init(&audio_format, 48000, SAMPLE_FORMAT_S16, 2);
|
||||
}
|
||||
|
||||
compressor = Compressor_new(0);
|
||||
|
||||
|
@@ -52,9 +52,9 @@ PcmConvert::PcmConvert() {}
|
||||
PcmConvert::~PcmConvert() {}
|
||||
|
||||
const void *
|
||||
PcmConvert::Convert(gcc_unused const audio_format *src_format,
|
||||
PcmConvert::Convert(gcc_unused const AudioFormat src_format,
|
||||
gcc_unused const void *src, gcc_unused size_t src_size,
|
||||
gcc_unused const audio_format *dest_format,
|
||||
gcc_unused const AudioFormat dest_format,
|
||||
gcc_unused size_t *dest_size_r,
|
||||
gcc_unused GError **error_r)
|
||||
{
|
||||
@@ -114,7 +114,7 @@ load_audio_output(const char *name)
|
||||
}
|
||||
|
||||
static bool
|
||||
run_output(struct audio_output *ao, struct audio_format *audio_format)
|
||||
run_output(struct audio_output *ao, AudioFormat audio_format)
|
||||
{
|
||||
/* open the audio output */
|
||||
|
||||
@@ -138,7 +138,7 @@ run_output(struct audio_output *ao, struct audio_format *audio_format)
|
||||
g_printerr("audio_format=%s\n",
|
||||
audio_format_to_string(audio_format, &af_string));
|
||||
|
||||
size_t frame_size = audio_format_frame_size(audio_format);
|
||||
size_t frame_size = audio_format.GetFrameSize();
|
||||
|
||||
/* play */
|
||||
|
||||
@@ -183,7 +183,6 @@ run_output(struct audio_output *ao, struct audio_format *audio_format)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct audio_format audio_format;
|
||||
bool success;
|
||||
GError *error = NULL;
|
||||
|
||||
@@ -194,7 +193,7 @@ int main(int argc, char **argv)
|
||||
|
||||
const Path config_path = Path::FromFS(argv[1]);
|
||||
|
||||
audio_format_init(&audio_format, 44100, SAMPLE_FORMAT_S16, 2);
|
||||
AudioFormat audio_format(44100, SampleFormat::S16, 2);
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2,32,0)
|
||||
g_thread_init(NULL);
|
||||
@@ -227,7 +226,7 @@ int main(int argc, char **argv)
|
||||
/* parse the audio format */
|
||||
|
||||
if (argc > 3) {
|
||||
success = audio_format_parse(&audio_format, argv[3],
|
||||
success = audio_format_parse(audio_format, argv[3],
|
||||
false, &error);
|
||||
if (!success) {
|
||||
g_printerr("Failed to parse audio format: %s\n",
|
||||
@@ -239,7 +238,7 @@ int main(int argc, char **argv)
|
||||
|
||||
/* do it */
|
||||
|
||||
success = run_output(ao, &audio_format);
|
||||
success = run_output(ao, audio_format);
|
||||
|
||||
/* cleanup and exit */
|
||||
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include "config.h"
|
||||
#include "pcm/PcmVolume.hxx"
|
||||
#include "AudioParser.hxx"
|
||||
#include "audio_format.h"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "stdbin.h"
|
||||
|
||||
#include <glib.h>
|
||||
@@ -37,7 +37,6 @@
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GError *error = NULL;
|
||||
struct audio_format audio_format;
|
||||
bool ret;
|
||||
static char buffer[4096];
|
||||
ssize_t nbytes;
|
||||
@@ -47,20 +46,20 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
AudioFormat audio_format(48000, SampleFormat::S16, 2);
|
||||
if (argc > 1) {
|
||||
ret = audio_format_parse(&audio_format, argv[1],
|
||||
ret = audio_format_parse(audio_format, argv[1],
|
||||
false, &error);
|
||||
if (!ret) {
|
||||
g_printerr("Failed to parse audio format: %s\n",
|
||||
error->message);
|
||||
return 1;
|
||||
}
|
||||
} else
|
||||
audio_format_init(&audio_format, 48000, SAMPLE_FORMAT_S16, 2);
|
||||
}
|
||||
|
||||
while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) {
|
||||
if (!pcm_volume(buffer, nbytes,
|
||||
sample_format(audio_format.format),
|
||||
audio_format.format,
|
||||
PCM_VOLUME_1 / 2)) {
|
||||
g_printerr("pcm_volume() has failed\n");
|
||||
return 2;
|
||||
|
@@ -24,7 +24,7 @@
|
||||
#include "pcm/PcmDither.hxx"
|
||||
#include "pcm/PcmUtils.hxx"
|
||||
#include "pcm/PcmBuffer.hxx"
|
||||
#include "audio_format.h"
|
||||
#include "AudioFormat.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@@ -38,7 +38,7 @@ test_pcm_format_8_to_16()
|
||||
|
||||
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, SampleFormat::S8,
|
||||
src, sizeof(src), &d_size);
|
||||
auto d_end = pcm_end_pointer(d, d_size);
|
||||
g_assert_cmpint(d_end - d, ==, N);
|
||||
@@ -56,7 +56,7 @@ test_pcm_format_16_to_24()
|
||||
PcmBuffer buffer;
|
||||
|
||||
size_t d_size;
|
||||
auto d = pcm_convert_to_24(buffer, SAMPLE_FORMAT_S16,
|
||||
auto d = pcm_convert_to_24(buffer, SampleFormat::S16,
|
||||
src, sizeof(src), &d_size);
|
||||
auto d_end = pcm_end_pointer(d, d_size);
|
||||
g_assert_cmpint(d_end - d, ==, N);
|
||||
@@ -74,7 +74,7 @@ test_pcm_format_16_to_32()
|
||||
PcmBuffer buffer;
|
||||
|
||||
size_t d_size;
|
||||
auto d = pcm_convert_to_32(buffer, SAMPLE_FORMAT_S16,
|
||||
auto d = pcm_convert_to_32(buffer, SampleFormat::S16,
|
||||
src, sizeof(src), &d_size);
|
||||
auto d_end = pcm_end_pointer(d, d_size);
|
||||
g_assert_cmpint(d_end - d, ==, N);
|
||||
@@ -92,7 +92,7 @@ test_pcm_format_float()
|
||||
PcmBuffer buffer1, buffer2;
|
||||
|
||||
size_t f_size;
|
||||
auto f = pcm_convert_to_float(buffer1, SAMPLE_FORMAT_S16,
|
||||
auto f = pcm_convert_to_float(buffer1, SampleFormat::S16,
|
||||
src, sizeof(src), &f_size);
|
||||
auto f_end = pcm_end_pointer(f, f_size);
|
||||
g_assert_cmpint(f_end - f, ==, N);
|
||||
@@ -106,7 +106,7 @@ test_pcm_format_float()
|
||||
|
||||
size_t d_size;
|
||||
auto d = pcm_convert_to_16(buffer2, dither,
|
||||
SAMPLE_FORMAT_FLOAT,
|
||||
SampleFormat::FLOAT,
|
||||
f, f_size, &d_size);
|
||||
auto d_end = pcm_end_pointer(d, d_size);
|
||||
g_assert_cmpint(d_end - d, ==, N);
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
template<typename T, sample_format format, typename G=GlibRandomInt<T>>
|
||||
template<typename T, SampleFormat format, typename G=GlibRandomInt<T>>
|
||||
void
|
||||
TestPcmMix(G g=G())
|
||||
{
|
||||
@@ -62,23 +62,23 @@ TestPcmMix(G g=G())
|
||||
void
|
||||
test_pcm_mix_8()
|
||||
{
|
||||
TestPcmMix<int8_t, SAMPLE_FORMAT_S8>();
|
||||
TestPcmMix<int8_t, SampleFormat::S8>();
|
||||
}
|
||||
|
||||
void
|
||||
test_pcm_mix_16()
|
||||
{
|
||||
TestPcmMix<int16_t, SAMPLE_FORMAT_S16>();
|
||||
TestPcmMix<int16_t, SampleFormat::S16>();
|
||||
}
|
||||
|
||||
void
|
||||
test_pcm_mix_24()
|
||||
{
|
||||
TestPcmMix<int32_t, SAMPLE_FORMAT_S24_P32>(GlibRandomInt24());
|
||||
TestPcmMix<int32_t, SampleFormat::S24_P32>(GlibRandomInt24());
|
||||
}
|
||||
|
||||
void
|
||||
test_pcm_mix_32()
|
||||
{
|
||||
TestPcmMix<int32_t, SAMPLE_FORMAT_S32>();
|
||||
TestPcmMix<int32_t, SampleFormat::S32>();
|
||||
}
|
||||
|
@@ -37,17 +37,17 @@ test_pcm_volume_8()
|
||||
int8_t dest[N];
|
||||
|
||||
std::copy(src.begin(), src.end(), dest);
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SAMPLE_FORMAT_S8,
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SampleFormat::S8,
|
||||
0), ==, true);
|
||||
g_assert_cmpint(memcmp(dest, zero, sizeof(zero)), ==, 0);
|
||||
|
||||
std::copy(src.begin(), src.end(), dest);
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SAMPLE_FORMAT_S8,
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SampleFormat::S8,
|
||||
PCM_VOLUME_1), ==, true);
|
||||
g_assert_cmpint(memcmp(dest, src, sizeof(src)), ==, 0);
|
||||
|
||||
std::copy(src.begin(), src.end(), dest);
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SAMPLE_FORMAT_S8,
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SampleFormat::S8,
|
||||
PCM_VOLUME_1 / 2), ==, true);
|
||||
|
||||
for (unsigned i = 0; i < N; ++i) {
|
||||
@@ -66,17 +66,17 @@ test_pcm_volume_16()
|
||||
int16_t dest[N];
|
||||
|
||||
std::copy(src.begin(), src.end(), dest);
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SAMPLE_FORMAT_S16,
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SampleFormat::S16,
|
||||
0), ==, true);
|
||||
g_assert_cmpint(memcmp(dest, zero, sizeof(zero)), ==, 0);
|
||||
|
||||
std::copy(src.begin(), src.end(), dest);
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SAMPLE_FORMAT_S16,
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SampleFormat::S16,
|
||||
PCM_VOLUME_1), ==, true);
|
||||
g_assert_cmpint(memcmp(dest, src, sizeof(src)), ==, 0);
|
||||
|
||||
std::copy(src.begin(), src.end(), dest);
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SAMPLE_FORMAT_S16,
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SampleFormat::S16,
|
||||
PCM_VOLUME_1 / 2), ==, true);
|
||||
|
||||
for (unsigned i = 0; i < N; ++i) {
|
||||
@@ -95,17 +95,17 @@ test_pcm_volume_24()
|
||||
int32_t dest[N];
|
||||
|
||||
std::copy(src.begin(), src.end(), dest);
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SAMPLE_FORMAT_S24_P32,
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SampleFormat::S24_P32,
|
||||
0), ==, true);
|
||||
g_assert_cmpint(memcmp(dest, zero, sizeof(zero)), ==, 0);
|
||||
|
||||
std::copy(src.begin(), src.end(), dest);
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SAMPLE_FORMAT_S24_P32,
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SampleFormat::S24_P32,
|
||||
PCM_VOLUME_1), ==, true);
|
||||
g_assert_cmpint(memcmp(dest, src, sizeof(src)), ==, 0);
|
||||
|
||||
std::copy(src.begin(), src.end(), dest);
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SAMPLE_FORMAT_S24_P32,
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SampleFormat::S24_P32,
|
||||
PCM_VOLUME_1 / 2), ==, true);
|
||||
|
||||
for (unsigned i = 0; i < N; ++i) {
|
||||
@@ -124,17 +124,17 @@ test_pcm_volume_32()
|
||||
int32_t dest[N];
|
||||
|
||||
std::copy(src.begin(), src.end(), dest);
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SAMPLE_FORMAT_S32,
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SampleFormat::S32,
|
||||
0), ==, true);
|
||||
g_assert_cmpint(memcmp(dest, zero, sizeof(zero)), ==, 0);
|
||||
|
||||
std::copy(src.begin(), src.end(), dest);
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SAMPLE_FORMAT_S32,
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SampleFormat::S32,
|
||||
PCM_VOLUME_1), ==, true);
|
||||
g_assert_cmpint(memcmp(dest, src, sizeof(src)), ==, 0);
|
||||
|
||||
std::copy(src.begin(), src.end(), dest);
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SAMPLE_FORMAT_S32,
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SampleFormat::S32,
|
||||
PCM_VOLUME_1 / 2), ==, true);
|
||||
|
||||
for (unsigned i = 0; i < N; ++i) {
|
||||
@@ -153,17 +153,17 @@ test_pcm_volume_float()
|
||||
float dest[N];
|
||||
|
||||
std::copy(src.begin(), src.end(), dest);
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SAMPLE_FORMAT_FLOAT,
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SampleFormat::FLOAT,
|
||||
0), ==, true);
|
||||
g_assert_cmpint(memcmp(dest, zero, sizeof(zero)), ==, 0);
|
||||
|
||||
std::copy(src.begin(), src.end(), dest);
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SAMPLE_FORMAT_FLOAT,
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SampleFormat::FLOAT,
|
||||
PCM_VOLUME_1), ==, true);
|
||||
g_assert_cmpint(memcmp(dest, src, sizeof(src)), ==, 0);
|
||||
|
||||
std::copy(src.begin(), src.end(), dest);
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SAMPLE_FORMAT_FLOAT,
|
||||
g_assert_cmpint(pcm_volume(dest, sizeof(dest), SampleFormat::FLOAT,
|
||||
PCM_VOLUME_1 / 2), ==, true);
|
||||
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include "config.h"
|
||||
#include "EncoderList.hxx"
|
||||
#include "EncoderPlugin.hxx"
|
||||
#include "audio_format.h"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "conf.h"
|
||||
#include "stdbin.h"
|
||||
#include "Tag.hxx"
|
||||
@@ -61,10 +61,8 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
|
||||
|
||||
/* open the encoder */
|
||||
|
||||
struct audio_format audio_format;
|
||||
|
||||
audio_format_init(&audio_format, 44100, SAMPLE_FORMAT_S16, 2);
|
||||
success = encoder_open(encoder, &audio_format, NULL);
|
||||
AudioFormat audio_format(44100, SampleFormat::S16, 2);
|
||||
success = encoder_open(encoder, audio_format, NULL);
|
||||
assert(success);
|
||||
|
||||
encoder_to_stdout(*encoder);
|
||||
|
Reference in New Issue
Block a user