From 1ddd9dd52a2439cc188d5372a4fc095aaebfd38d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 1 Oct 2012 23:04:40 +0200 Subject: test/run_encoder: fix encoder_open() call --- test/run_encoder.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'test') diff --git a/test/run_encoder.c b/test/run_encoder.c index 6a410862..397dd857 100644 --- a/test/run_encoder.c +++ b/test/run_encoder.c @@ -99,8 +99,7 @@ int main(int argc, char **argv) } } - ret = encoder_open(encoder, &audio_format, &error); - if (encoder == NULL) { + if (!encoder_open(encoder, &audio_format, &error)) { g_printerr("Failed to open encoder: %s\n", error->message); g_error_free(error); -- cgit v1.2.3 From 43d82520502bc0c76fbd11d6e949739235166021 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 1 Oct 2012 23:17:13 +0200 Subject: output/recorder, test/*: invoke encoder_read() after _open() Make sure the file header gets written at the beginning, before _write() gets called. --- src/encoder_plugin.h | 4 ++++ src/output/recorder_output_plugin.c | 7 +++++++ test/run_encoder.c | 2 ++ test/test_vorbis_encoder.c | 2 ++ 4 files changed, 15 insertions(+) (limited to 'test') diff --git a/src/encoder_plugin.h b/src/encoder_plugin.h index 33a37911..cae0c804 100644 --- a/src/encoder_plugin.h +++ b/src/encoder_plugin.h @@ -119,6 +119,10 @@ encoder_finish(struct encoder *encoder) * Before you free it, you must call encoder_close(). You may open * and close (reuse) one encoder any number of times. * + * After this function returns successfully and before the first + * encoder_write() call, you should invoke encoder_read() to obtain + * the file header. + * * @param encoder the encoder * @param audio_format the encoder's input audio format; the plugin * may modify the struct to adapt it to its abilities diff --git a/src/output/recorder_output_plugin.c b/src/output/recorder_output_plugin.c index ea299468..ad2d961d 100644 --- a/src/output/recorder_output_plugin.c +++ b/src/output/recorder_output_plugin.c @@ -192,6 +192,13 @@ recorder_output_open(struct audio_output *ao, return false; } + if (!recorder_output_encoder_to_file(recorder, error_r)) { + encoder_close(recorder->encoder); + close(recorder->fd); + unlink(recorder->path); + return false; + } + return true; } diff --git a/test/run_encoder.c b/test/run_encoder.c index 397dd857..db4d3af9 100644 --- a/test/run_encoder.c +++ b/test/run_encoder.c @@ -106,6 +106,8 @@ int main(int argc, char **argv) return 1; } + encoder_to_stdout(encoder); + /* do it */ while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) { diff --git a/test/test_vorbis_encoder.c b/test/test_vorbis_encoder.c index 048d26f0..61939915 100644 --- a/test/test_vorbis_encoder.c +++ b/test/test_vorbis_encoder.c @@ -67,6 +67,8 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv) success = encoder_open(encoder, &audio_format, NULL); assert(success); + encoder_to_stdout(encoder); + /* write a block of data */ success = encoder_write(encoder, zero, sizeof(zero), NULL); -- cgit v1.2.3