From 79eb7623efb3105094dcb77f8688e39b8288155e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 19 Mar 2012 20:37:17 +0100 Subject: event_pipe, test: explicitly ignore write() return value Some compilers are very picky, but we really aren't interested in the return value. --- test/read_tags.c | 2 +- test/run_convert.c | 2 +- test/run_decoder.c | 2 +- test/run_encoder.c | 5 +++-- test/run_normalize.c | 3 ++- test/software_volume.c | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/read_tags.c b/test/read_tags.c index 9af2bbac4..8906e1c8a 100644 --- a/test/read_tags.c +++ b/test/read_tags.c @@ -104,7 +104,7 @@ decoder_data(G_GNUC_UNUSED struct decoder *decoder, const void *data, size_t datalen, G_GNUC_UNUSED uint16_t bit_rate) { - write(1, data, datalen); + G_GNUC_UNUSED ssize_t nbytes = write(1, data, datalen); return DECODE_COMMAND_NONE; } diff --git a/test/run_convert.c b/test/run_convert.c index 415d7535c..ae76bc367 100644 --- a/test/run_convert.c +++ b/test/run_convert.c @@ -115,7 +115,7 @@ int main(int argc, char **argv) return 2; } - write(1, output, length); + G_GNUC_UNUSED ssize_t ignored = write(1, output, length); } pcm_convert_deinit(&state); diff --git a/test/run_decoder.c b/test/run_decoder.c index 4199f3c32..154b47324 100644 --- a/test/run_decoder.c +++ b/test/run_decoder.c @@ -126,7 +126,7 @@ decoder_data(G_GNUC_UNUSED struct decoder *decoder, const void *data, size_t datalen, G_GNUC_UNUSED uint16_t kbit_rate) { - write(1, data, datalen); + G_GNUC_UNUSED ssize_t nbytes = write(1, data, datalen); return DECODE_COMMAND_NONE; } diff --git a/test/run_encoder.c b/test/run_encoder.c index 4b512d46a..16e633029 100644 --- a/test/run_encoder.c +++ b/test/run_encoder.c @@ -36,8 +36,9 @@ encoder_to_stdout(struct encoder *encoder) size_t length; static char buffer[32768]; - while ((length = encoder_read(encoder, buffer, sizeof(buffer))) > 0) - write(1, buffer, length); + while ((length = encoder_read(encoder, buffer, sizeof(buffer))) > 0) { + G_GNUC_UNUSED ssize_t ignored = write(1, buffer, length); + } } int main(int argc, char **argv) diff --git a/test/run_normalize.c b/test/run_normalize.c index dd1140782..958015973 100644 --- a/test/run_normalize.c +++ b/test/run_normalize.c @@ -65,7 +65,8 @@ int main(int argc, char **argv) while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) { Compressor_Process_int16(compressor, (int16_t *)buffer, nbytes / 2); - write(1, buffer, nbytes); + + G_GNUC_UNUSED ssize_t ignored = write(1, buffer, nbytes); } Compressor_delete(compressor); diff --git a/test/software_volume.c b/test/software_volume.c index c4de69328..789fffe61 100644 --- a/test/software_volume.c +++ b/test/software_volume.c @@ -65,6 +65,6 @@ int main(int argc, char **argv) return 2; } - write(1, buffer, nbytes); + G_GNUC_UNUSED ssize_t ignored = write(1, buffer, nbytes); } } -- cgit v1.2.3 From 47c58c01d10526b3e4b4b6cff0faa17af4039916 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Apr 2012 22:56:38 +0200 Subject: test/test_vorbis_encoder: program to debug the vorbis encoder --- test/test_vorbis_encoder.c | 109 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 test/test_vorbis_encoder.c (limited to 'test') diff --git a/test/test_vorbis_encoder.c b/test/test_vorbis_encoder.c new file mode 100644 index 000000000..370a8a59e --- /dev/null +++ b/test/test_vorbis_encoder.c @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2003-2012 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" +#include "encoder_list.h" +#include "encoder_plugin.h" +#include "audio_format.h" +#include "conf.h" +#include "stdbin.h" +#include "tag.h" + +#include + +#include +#include + +static uint8_t zero[256]; + +static void +encoder_to_stdout(struct encoder *encoder) +{ + size_t length; + static char buffer[32768]; + + while ((length = encoder_read(encoder, buffer, sizeof(buffer))) > 0) { + G_GNUC_UNUSED ssize_t ignored = write(1, buffer, length); + } +} + +int +main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) +{ + G_GNUC_UNUSED bool success; + + /* create the encoder */ + + const struct encoder_plugin *plugin = encoder_plugin_get("vorbis"); + assert(plugin != NULL); + + struct config_param *param = config_new_param(NULL, -1); + config_add_block_param(param, "quality", "5.0", -1, NULL); + + struct encoder *encoder = encoder_init(plugin, param, NULL); + assert(encoder != NULL); + + /* 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); + assert(success); + + /* write a block of data */ + + success = encoder_write(encoder, zero, sizeof(zero), NULL); + assert(success); + + encoder_to_stdout(encoder); + + /* write a tag */ + + success = encoder_pre_tag(encoder, NULL); + assert(success); + + encoder_to_stdout(encoder); + + struct tag *tag = tag_new(); + tag_add_item(tag, TAG_ARTIST, "Foo"); + tag_add_item(tag, TAG_TITLE, "Bar"); + + success = encoder_tag(encoder, tag, NULL); + assert(success); + + tag_free(tag); + + encoder_to_stdout(encoder); + + /* write another block of data */ + + success = encoder_write(encoder, zero, sizeof(zero), NULL); + assert(success); + + /* finish */ + + success = encoder_flush(encoder, NULL); + assert(success); + + encoder_to_stdout(encoder); + + encoder_close(encoder); + encoder_finish(encoder); +} -- cgit v1.2.3 From 5acee73fc85e44179120a5818247fc0760038cff Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 5 Apr 2012 00:03:38 +0200 Subject: encoder/vorbis: generate end-of-stream packet when playback ends Add the encoder_plugin method end(). This is important for the recorder plugin. --- test/run_encoder.c | 2 +- test/test_vorbis_encoder.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/run_encoder.c b/test/run_encoder.c index 16e633029..4c05a06c7 100644 --- a/test/run_encoder.c +++ b/test/run_encoder.c @@ -121,7 +121,7 @@ int main(int argc, char **argv) encoder_to_stdout(encoder); } - ret = encoder_flush(encoder, &error); + ret = encoder_end(encoder, &error); if (!ret) { g_printerr("encoder_flush() failed: %s\n", error->message); diff --git a/test/test_vorbis_encoder.c b/test/test_vorbis_encoder.c index 370a8a59e..969ab7687 100644 --- a/test/test_vorbis_encoder.c +++ b/test/test_vorbis_encoder.c @@ -99,7 +99,7 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) /* finish */ - success = encoder_flush(encoder, NULL); + success = encoder_end(encoder, NULL); assert(success); encoder_to_stdout(encoder); -- cgit v1.2.3