From 838f7cd210dbd3f071d48d54c168c123c3d20c58 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 20 Jul 2011 20:54:34 +0200 Subject: encoder_plugin: add method pre_tag() In the "vorbis" plugin, this is a copy of the old flush() method, while flush() gets a lot of code remove, it just sets the "flush" flag and nothing else. It doesn't start a new stream now, which should fix a few problems in some players. --- src/encoder_plugin.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/encoder_plugin.h') diff --git a/src/encoder_plugin.h b/src/encoder_plugin.h index 13fb231f..fb00413e 100644 --- a/src/encoder_plugin.h +++ b/src/encoder_plugin.h @@ -50,6 +50,8 @@ struct encoder_plugin { bool (*flush)(struct encoder *encoder, GError **error); + bool (*pre_tag)(struct encoder *encoder, GError **error); + bool (*tag)(struct encoder *encoder, const struct tag *tag, GError **error); @@ -147,9 +149,31 @@ encoder_flush(struct encoder *encoder, GError **error) : true; } +/** + * Prepare for sending a tag to the encoder. This is used by some + * encoders to flush the previous sub-stream, in preparation to begin + * a new one. + * + * @param encoder the encoder + * @param tag the tag object + * @param error location to store the error occuring, or NULL to ignore errors. + * @return true on success + */ +static inline bool +encoder_pre_tag(struct encoder *encoder, GError **error) +{ + /* this method is optional */ + return encoder->plugin->pre_tag != NULL + ? encoder->plugin->pre_tag(encoder, error) + : true; +} + /** * Sends a tag to the encoder. * + * Instructions: call encoder_pre_tag(); then obtain flushed data with + * encoder_read(); finally call encoder_tag(). + * * @param encoder the encoder * @param tag the tag object * @param error location to store the error occuring, or NULL to ignore errors. -- cgit v1.2.3