--- kioslave/audiocd/audiocd.cpp 2003-05-07 21:16:47.000000000 +0930 +++ kioslave/audiocd/audiocd.cpp 2003-09-17 17:24:02.000000000 +0930 @@ -1516,43 +1516,9 @@ buffer[1][i]=buf[2*i+1]/32768.0; } + /* process chunk of data */ vorbis_analysis_wrote(&d->vd,i); - - while(vorbis_analysis_blockout(&d->vd,&d->vb)==1) { -/* Support ancient libvorbis (< RC3). */ -#if HAVE_VORBIS >= 2 - vorbis_analysis(&d->vb,NULL); - /* Non-ancient case. */ - vorbis_bitrate_addblock(&d->vb); - - while(vorbis_bitrate_flushpacket(&d->vd, &d->op)) { -#else - vorbis_analysis(&d->vb,&d->op); - /* Make a lexical block to place the #ifdef's nearby. */ - if (1) { -#endif - ogg_stream_packetin(&d->os,&d->op); - - while(int result=ogg_stream_pageout(&d->os,&d->og)) { - - if (!result) break; - - QByteArray output; - - char * oggheader = reinterpret_cast(d->og.header); - char * oggbody = reinterpret_cast(d->og.body); - - output.setRawData(oggheader, d->og.header_len); - data(output); - output.resetRawData(oggheader, d->og.header_len); - - output.setRawData(oggbody, d->og.body_len); - data(output); - output.resetRawData(oggbody, d->og.body_len); - processed += d->og.header_len + d->og.body_len; - } - } - } + processed += flush_vorbis(); } #endif @@ -1596,6 +1562,9 @@ #ifdef HAVE_VORBIS if (filetype == "ogg") { + // send end-of-stream and flush the encoder + vorbis_analysis_wrote(&d->vd,0); + processed += flush_vorbis(); ogg_stream_clear(&d->os); vorbis_block_clear(&d->vb); vorbis_dsp_clear(&d->vd); @@ -1788,4 +1757,48 @@ // Not yet. } +#ifdef HAVE_VORBIS +long AudioCDProtocol::flush_vorbis(void) +{ + long processed(0); + + while(vorbis_analysis_blockout(&d->vd,&d->vb)==1) { + /* Support ancient libvorbis (< RC3). */ +#if HAVE_VORBIS >= 2 + vorbis_analysis(&d->vb,NULL); + /* Non-ancient case. */ + vorbis_bitrate_addblock(&d->vb); + + while(vorbis_bitrate_flushpacket(&d->vd, &d->op)) { +#else + vorbis_analysis(&d->vb,&d->op); + /* Make a lexical block to place the #ifdef's nearby. */ + if (1) { +#endif + ogg_stream_packetin(&d->os,&d->op); + + while(int result=ogg_stream_pageout(&d->os,&d->og)) { + + if (!result) break; + + QByteArray output; + + char * oggheader = reinterpret_cast(d->og.header); + char * oggbody = reinterpret_cast(d->og.body); + + output.setRawData(oggheader, d->og.header_len); + data(output); + output.resetRawData(oggheader, d->og.header_len); + + output.setRawData(oggbody, d->og.body_len); + data(output); + output.resetRawData(oggbody, d->og.body_len); + processed += d->og.header_len + d->og.body_len; + } + } + } + return processed; + } +#endif + // vim:ts=2:sw=2:tw=78:et: --- kioslave/audiocd/audiocd.h 2003-05-07 21:16:47.000000000 +0930 +++ kioslave/audiocd/audiocd.h 2003-09-17 17:25:16.000000000 +0930 @@ -96,6 +96,7 @@ #endif #ifdef HAVE_VORBIS long vorbisSize(long time_secs); + long flush_vorbis(void); #endif };