From ebc1d3516c0334a093d8426e52402febb3dd6b00 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 5 May 2009 22:40:51 +0200 Subject: vorbis_encoder: start a new stream in tag() When a new tag is set, end the current stream and begin a new one. Use vorbis_analysis_headerout() to write a full ogg header. This fixes a problem with icecast: after a song change in MPD, icecast stops forwarding ogg packets to its clients. --- src/encoder/vorbis_encoder.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/encoder/vorbis_encoder.c') diff --git a/src/encoder/vorbis_encoder.c b/src/encoder/vorbis_encoder.c index 0332f1106..a5f6387f6 100644 --- a/src/encoder/vorbis_encoder.c +++ b/src/encoder/vorbis_encoder.c @@ -295,22 +295,25 @@ vorbis_encoder_tag(struct encoder *_encoder, const struct tag *tag, { struct vorbis_encoder *encoder = (struct vorbis_encoder *)_encoder; vorbis_comment comment; - ogg_packet packet; /* write the vorbis_comment object */ vorbis_comment_init(&comment); copy_tag_to_vorbis_comment(&comment, tag); - /* convert that vorbis_comment into a ogg_packet */ + /* reset ogg_stream_state and begin a new stream */ - vorbis_commentheader_out(&comment, &packet); + ogg_stream_reset_serialno(&encoder->os, g_random_int()); + + /* send that vorbis_comment to the ogg_stream_state */ + + vorbis_encoder_headerout(encoder, &comment); vorbis_comment_clear(&comment); - /* .. and send it into the ogg_stream_state */ + /* the next vorbis_encoder_read() call should flush the + ogg_stream_state */ - ogg_stream_packetin(&encoder->os, &packet); - ogg_packet_clear(&packet); + encoder->flush = true; return true; } -- cgit v1.2.3