Flush page after the header (in order to follow the Ogg spec)
authorjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Sun, 21 Mar 2004 06:22:48 +0000 (06:22 +0000)
committerjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Sun, 21 Mar 2004 06:22:48 +0000 (06:22 +0000)
git-svn-id: http://svn.xiph.org/trunk/speex@6146 0101bb08-14d6-0310-b084-bc0e0c8e3800

src/speexenc.c

index 7a43a88..9016891 100644 (file)
@@ -562,7 +562,7 @@ int main(int argc, char **argv)
    }
 
 
-   /*Write header (format will change)*/
+   /*Write header*/
    {
 
       op.packet = (unsigned char *)speex_header_to_packet(&header, (int*)&(op.bytes));
@@ -573,6 +573,19 @@ int main(int argc, char **argv)
       ogg_stream_packetin(&os, &op);
       free(op.packet);
 
+      while((result = ogg_stream_flush(&os, &og)))
+      {
+         if(!result) break;
+         ret = oe_write_page(&og, fout);
+         if(ret != og.header_len + og.body_len)
+         {
+            fprintf (stderr,"Error: failed writing header to output stream\n");
+            exit(1);
+         }
+         else
+            bytes_written += ret;
+      }
+
       op.packet = (unsigned char *)comments;
       op.bytes = comments_length;
       op.b_o_s = 0;