Commit 43d82520 authored by Max Kellermann's avatar Max Kellermann

output/recorder, test/*: invoke encoder_read() after _open()

Make sure the file header gets written at the beginning, before _write() gets called.
parent 674b4ab6
......@@ -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
......
......@@ -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;
}
......
......@@ -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) {
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment