make --serial-number or the default random serial number apply only to the first...
authorJosh Coalson <jcoalson@users.sourceforce.net>
Fri, 16 Jul 2004 01:05:28 +0000 (01:05 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Fri, 16 Jul 2004 01:05:28 +0000 (01:05 +0000)
doc/html/documentation.html
man/flac.sgml
src/flac/encode.c
src/flac/encode.h
src/flac/main.c

index c8a36e1..311b1fe 100644 (file)
                                <TT>--serial-number=#</TT>
                        </TD>
                        <TD>
-                               When used with --ogg, specifies the serial number to use the for the FLAC stream.  When encoding and no serial number is given, flac uses '0'.  When decoding and no number is given, flac uses the serial number of the first page.<P>
+                               When used with --ogg, specifies the serial number to use for the first Ogg FLAC stream, which is then incremented for each additional stream.  When encoding and no serial number is given, <TT><B>flac</B></TT> uses a random number for the first stream, then increments it for each additional stream.  When decoding and no number is given, <TT><B>flac</B></TT> uses the serial number of the first page.<P>
                        </TD>
                </TR>
        </TABLE>
index 42bede3..f1741a9 100644 (file)
                <term><option>--serial-number</option>=<replaceable>#</replaceable></term>
 
                <listitem>
-                 <para>When used with --ogg, specifies the serial
-                   number to use for the FLAC stream.  When encoding and
-                   no serial number is given, flac uses '0'.  When
-                   decoding and no number is given, flac uses the serial
-                   number of the first page.</para>
+                 <para>When used with --ogg, specifies the serial number to
+                   use for the first Ogg FLAC stream, which is then
+                   incremented for each additional stream.  When encoding and
+                   no serial number is given, flac uses a random number for
+                   the first stream, then increments it for each additional
+                   stream.  When decoding and no number is given, flac uses
+                   the serial number of the first page.</para>
                </listitem>
              </varlistentry>
 
index 1f7b286..0359325 100644 (file)
@@ -28,7 +28,6 @@
 #include <stdio.h> /* for FILE etc. */
 #include <stdlib.h> /* for malloc */
 #include <string.h> /* for strcmp() */
-#include <time.h>
 #include "FLAC/all.h"
 #include "share/grabbag.h"
 #include "encode.h"
@@ -1460,18 +1459,10 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
        e->blocksize = options.blocksize;
        e->stats_mask = (options.do_exhaustive_model_search || options.do_qlp_coeff_prec_search)? 0x0f : 0x3f;
 
-       /* set a random serial number if one has not yet been specified */
-       if(!options.has_serial_number) {
-               srand(time(0));
-               options.serial_number = rand();
-               options.has_serial_number = true;
-       }
-
 #ifdef FLAC__HAS_OGG
        if(e->use_ogg) {
                if(e->is_stdout) {
-                       if(options.has_serial_number)
-                               OggFLAC__stream_encoder_set_serial_number(e->encoder.ogg.stream, options.serial_number);
+                       OggFLAC__stream_encoder_set_serial_number(e->encoder.ogg.stream, options.serial_number);
                        OggFLAC__stream_encoder_set_verify(e->encoder.ogg.stream, options.verify);
                        OggFLAC__stream_encoder_set_streamable_subset(e->encoder.ogg.stream, !options.lax);
                        OggFLAC__stream_encoder_set_do_mid_side_stereo(e->encoder.ogg.stream, options.do_mid_side);
@@ -1506,8 +1497,7 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
                        }
                }
                else {
-                       if(options.has_serial_number)
-                               OggFLAC__file_encoder_set_serial_number(e->encoder.ogg.file, options.serial_number);
+                       OggFLAC__file_encoder_set_serial_number(e->encoder.ogg.file, options.serial_number);
                        OggFLAC__file_encoder_set_filename(e->encoder.ogg.file, e->outfilename);
                        OggFLAC__file_encoder_set_verify(e->encoder.ogg.file, options.verify);
                        OggFLAC__file_encoder_set_streamable_subset(e->encoder.ogg.file, !options.lax);
index eb0fe55..1f7e5a2 100644 (file)
@@ -33,7 +33,6 @@ typedef struct {
        FLAC__bool verify;
 #ifdef FLAC__HAS_OGG
        FLAC__bool use_ogg;
-       FLAC__bool has_serial_number;
        long serial_number;
 #endif
        FLAC__bool lax;
index e520184..787ad05 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -1510,8 +1511,13 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_
        common_options.verify = option_values.verify;
 #ifdef FLAC__HAS_OGG
        common_options.use_ogg = option_values.use_ogg;
-       common_options.has_serial_number = option_values.has_serial_number;
-       common_options.serial_number = option_values.serial_number;
+       /* set a random serial number if one has not yet been specified */
+       if(!option_values.has_serial_number) {
+               srand(time(0));
+               option_values.serial_number = rand();
+               option_values.has_serial_number = true;
+       }
+       common_options.serial_number = option_values.serial_number++;
 #endif
        common_options.lax = option_values.lax;
        common_options.do_mid_side = option_values.do_mid_side;