diff options
author | Josh Coalson <jcoalson@users.sourceforce.net> | 2006-09-13 01:42:27 +0000 |
---|---|---|
committer | Josh Coalson <jcoalson@users.sourceforce.net> | 2006-09-13 01:42:27 +0000 |
commit | 6b21f66784e1bcbe075b405668712e85eac39414 (patch) | |
tree | cd1dcbb7cfd5041532ff7ba73b907c7e3af6a80d /src/share | |
parent | 461f3eb260107f60c4d7da1774075d09e5374d14 (diff) | |
download | flac-6b21f66784e1bcbe075b405668712e85eac39414.tar.gz |
merge down from merged-API-layer branch: cvs -q up -dP -j API_LAYER_MERGING_BASELINE -j API_LAYER_MERGING_BRANCH
Diffstat (limited to 'src/share')
-rw-r--r-- | src/share/grabbag/replaygain.c | 34 | ||||
-rw-r--r-- | src/share/grabbag/seektable.c | 34 |
2 files changed, 34 insertions, 34 deletions
diff --git a/src/share/grabbag/replaygain.c b/src/share/grabbag/replaygain.c index b3e30ecb..28457a6b 100644 --- a/src/share/grabbag/replaygain.c +++ b/src/share/grabbag/replaygain.c @@ -23,8 +23,8 @@ #include "share/grabbag.h" #include "share/replaygain_analysis.h" #include "FLAC/assert.h" -#include "FLAC/file_decoder.h" #include "FLAC/metadata.h" +#include "FLAC/stream_decoder.h" #include <locale.h> #include <math.h> #include <stdio.h> @@ -271,7 +271,7 @@ typedef struct { FLAC__bool error; } DecoderInstance; -static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) +static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) { DecoderInstance *instance = (DecoderInstance*)client_data; const unsigned bits_per_sample = frame->header.bits_per_sample; @@ -300,7 +300,7 @@ static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *d return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; } -static void metadata_callback_(const FLAC__FileDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) +static void metadata_callback_(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) { DecoderInstance *instance = (DecoderInstance*)client_data; @@ -323,7 +323,7 @@ static void metadata_callback_(const FLAC__FileDecoder *decoder, const FLAC__Str } } -static void error_callback_(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) +static void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) { DecoderInstance *instance = (DecoderInstance*)client_data; @@ -335,7 +335,7 @@ static void error_callback_(const FLAC__FileDecoder *decoder, FLAC__StreamDecode const char *grabbag__replaygain_analyze_file(const char *filename, float *title_gain, float *title_peak) { DecoderInstance instance; - FLAC__FileDecoder *decoder = FLAC__file_decoder_new(); + FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new(); if(0 == decoder) return "memory allocation error"; @@ -343,27 +343,21 @@ const char *grabbag__replaygain_analyze_file(const char *filename, float *title_ instance.error = false; /* It does these three by default but lets be explicit: */ - FLAC__file_decoder_set_md5_checking(decoder, false); - FLAC__file_decoder_set_metadata_ignore_all(decoder); - FLAC__file_decoder_set_metadata_respond(decoder, FLAC__METADATA_TYPE_STREAMINFO); - - FLAC__file_decoder_set_filename(decoder, filename); - FLAC__file_decoder_set_write_callback(decoder, write_callback_); - FLAC__file_decoder_set_metadata_callback(decoder, metadata_callback_); - FLAC__file_decoder_set_error_callback(decoder, error_callback_); - FLAC__file_decoder_set_client_data(decoder, &instance); - - if(FLAC__file_decoder_init(decoder) != FLAC__FILE_DECODER_OK) { - FLAC__file_decoder_delete(decoder); + FLAC__stream_decoder_set_md5_checking(decoder, false); + FLAC__stream_decoder_set_metadata_ignore_all(decoder); + FLAC__stream_decoder_set_metadata_respond(decoder, FLAC__METADATA_TYPE_STREAMINFO); + + if(FLAC__stream_decoder_init_file(decoder, filename, write_callback_, metadata_callback_, error_callback_, &instance) != FLAC__STREAM_DECODER_INIT_STATUS_OK) { + FLAC__stream_decoder_delete(decoder); return "initializing decoder"; } - if(!FLAC__file_decoder_process_until_end_of_file(decoder) || instance.error) { - FLAC__file_decoder_delete(decoder); + if(!FLAC__stream_decoder_process_until_end_of_stream(decoder) || instance.error) { + FLAC__stream_decoder_delete(decoder); return "decoding file"; } - FLAC__file_decoder_delete(decoder); + FLAC__stream_decoder_delete(decoder); grabbag__replaygain_get_title(title_gain, title_peak); diff --git a/src/share/grabbag/seektable.c b/src/share/grabbag/seektable.c index 7893eb1b..12644206 100644 --- a/src/share/grabbag/seektable.c +++ b/src/share/grabbag/seektable.c @@ -51,8 +51,10 @@ FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec if(0 != spec_has_real_points) *spec_has_real_points = true; if(!only_explicit_placeholders) { - if(!FLAC__metadata_object_seektable_template_append_spaced_points(seektable_template, atoi(pt), total_samples_to_encode)) - return false; + const int n = (unsigned)atoi(pt); + if(n > 0) + if(!FLAC__metadata_object_seektable_template_append_spaced_points(seektable_template, (unsigned)n, total_samples_to_encode)) + return false; } } } @@ -62,16 +64,14 @@ FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec if(0 != spec_has_real_points) *spec_has_real_points = true; if(!only_explicit_placeholders) { - double sec = atof(pt); + const double sec = atof(pt); if(sec > 0.0) { -#if defined _MSC_VER || defined __MINGW32__ - /* with MSVC you have to spoon feed it the casting */ - unsigned n = (unsigned)((double)(FLAC__int64)total_samples_to_encode / (sec * (double)sample_rate)); -#else - unsigned n = (unsigned)((double)total_samples_to_encode / (sec * (double)sample_rate)); -#endif - if(!FLAC__metadata_object_seektable_template_append_spaced_points(seektable_template, n, total_samples_to_encode)) - return false; + unsigned samples = (unsigned)(sec * (double)sample_rate); + if(samples > 0) { + /* +1 for the initial point at sample 0 */ + if(!FLAC__metadata_object_seektable_template_append_spaced_points_by_samples(seektable_template, samples, total_samples_to_encode)) + return false; + } } } } @@ -80,9 +80,15 @@ FLAC__bool grabbag__seektable_convert_specification_to_template(const char *spec if(0 != spec_has_real_points) *spec_has_real_points = true; if(!only_explicit_placeholders) { - FLAC__uint64 n = (unsigned)atoi(pt); - if(!FLAC__metadata_object_seektable_template_append_point(seektable_template, n)) - return false; + char *endptr; +#ifdef _MSC_VER + const FLAC__int64 n = (FLAC__int64)strtol(pt, &endptr, 10); /* [2G limit] */ +#else + const FLAC__int64 n = (FLAC__int64)strtoll(pt, &endptr, 10); +#endif + if(n > 0 || (endptr > pt && *endptr == ';')) + if(!FLAC__metadata_object_seektable_template_append_point(seektable_template, (FLAC__uint64)n)) + return false; } } } |