[Flac-dev] [PATCH 3/5]: Change EOF warnings to errors

Joshua Kwan joshk at triplehelix.org
Mon Jan 8 17:08:32 PST 2007


This patch changes EOF warnings to errors. The reason for doing this is
that someone complained that he specified flac --delete-input-file when
encoding, received an EOF warning, and since the warning was not fatal,
the file was deleted anyway, and it was no longer possible to check the
input file.

-- 
Joshua Kwan

--- flac-1.1.2.orig/src/flac/encode.c
+++ flac-1.1.2/src/flac/encode.c
@@ -448,8 +448,8 @@
 						return EncoderSession_finish_error(&encoder_session);
 					}
 					else if(feof(infile)) {
-						flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned int)encoder_session.total_samples_to_encode, (unsigned int)encoder_session.samples_written);
-						data_bytes= 0;
+						flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned int)encoder_session.total_samples_to_encode, (unsigned int)encoder_session.samples_written);
+						return EncoderSession_finish_error(&encoder_session);
 					}
 				}
 				else {
@@ -508,7 +508,8 @@
 							return EncoderSession_finish_error(&encoder_session);
 						}
 						else if(bytes_read != (*options.common.align_reservoir_samples) * bytes_per_frame) {
-							flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; read %u bytes; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned int)bytes_read, (unsigned int)encoder_session.total_samples_to_encode, (unsigned int)encoder_session.samples_written);
+							flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF; read %u bytes; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned int)bytes_read, (unsigned int)encoder_session.total_samples_to_encode, (unsigned int)encoder_session.samples_written);
+							return EncoderSession_finish_error(&encoder_session);
 						}
 						else {
 							info_align_carry= *options.common.align_reservoir_samples;
@@ -968,8 +969,8 @@
 						return EncoderSession_finish_error(&encoder_session);
 					}
 					else if(feof(infile)) {
-						flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
-						data_bytes = 0;
+						flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
+						return EncoderSession_finish_error(&encoder_session);
 					}
 				}
 				else {
@@ -1027,7 +1028,8 @@
 							return EncoderSession_finish_error(&encoder_session);
 						}
 						else if(bytes_read != (*options.common.align_reservoir_samples) * bytes_per_wide_sample) {
-							flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; read %u bytes; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)bytes_read, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
+							flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF; read %u bytes; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)bytes_read, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
+							return EncoderSession_finish_error(&encoder_session);
 						}
 						else {
 							info_align_carry = *options.common.align_reservoir_samples;
@@ -1282,8 +1284,8 @@
 					return EncoderSession_finish_error(&encoder_session);
 				}
 				else if(feof(infile)) {
-					flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
-					total_input_bytes_read = max_input_bytes;
+					flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
+					return EncoderSession_finish_error(&encoder_session);
 				}
 			}
 			else {
@@ -1334,7 +1336,8 @@
 					return EncoderSession_finish_error(&encoder_session);
 				}
 				else if(bytes_read != (*options.common.align_reservoir_samples) * bytes_per_wide_sample) {
-					flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; read %u bytes; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)bytes_read, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
+					flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF; read %u bytes; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)bytes_read, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
+					return EncoderSession_finish_error(&encoder_session);
 				}
 				else {
 					info_align_carry = *options.common.align_reservoir_samples;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 881 bytes
Desc: Digital signature
Url : http://lists.xiph.org/pipermail/flac-dev/attachments/20070108/c2c17dac/attachment-0001.pgp


More information about the Flac-dev mailing list