diff options
author | Erik de Castro Lopo <erikd@mega-nerd.com> | 2013-03-29 20:54:34 +1100 |
---|---|---|
committer | Erik de Castro Lopo <erikd@mega-nerd.com> | 2013-03-29 20:54:34 +1100 |
commit | 9b8fdafe3a4ba0b6272bdcb0161f921bf750ca49 (patch) | |
tree | bdf9d54fd190e7c2c4180ee67c92160e7dc73afe /src/test_libFLAC | |
parent | 1ec6e3a0648fc28bd754e02ee70e9ee512b75f08 (diff) | |
download | flac-9b8fdafe3a4ba0b6272bdcb0161f921bf750ca49.tar.gz |
src/test_libFLAC/decoders.c : Minor improvement.
Diffstat (limited to 'src/test_libFLAC')
-rw-r--r-- | src/test_libFLAC/decoders.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/test_libFLAC/decoders.c b/src/test_libFLAC/decoders.c index c9d2cdf3..100318e4 100644 --- a/src/test_libFLAC/decoders.c +++ b/src/test_libFLAC/decoders.c @@ -29,6 +29,7 @@ #include "FLAC/stream_decoder.h" #include "share/grabbag.h" #include "share/compat.h" +#include "share/safe_str.h" #include "test_libs_common/file_utils_flac.h" #include "test_libs_common/metadata_utils.h" @@ -49,6 +50,7 @@ static const char * const LayerString[] = { typedef struct { Layer layer; FILE *file; + char filename[512]; unsigned current_metadata_number; FLAC__bool ignore_errors; FLAC__bool error_occurred; @@ -84,6 +86,12 @@ static FLAC__bool die_s_(const char *msg, const FLAC__StreamDecoder *decoder) return false; } +static void open_test_file(StreamDecoderClientData * pdcd, int is_ogg, const char * mode) +{ + pdcd->file = fopen(flacfilename(is_ogg), mode); + safe_strncpy(pdcd->filename, flacfilename(is_ogg), sizeof (pdcd->filename)); +} + static void init_metadata_blocks_(void) { mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &picture_, &unknown_); @@ -315,7 +323,7 @@ static FLAC__bool stream_decoder_test_respond_(FLAC__StreamDecoder *decoder, Str /* for FLAC__stream_encoder_init_FILE(), the FLAC__stream_encoder_finish() closes the file so we have to keep re-opening: */ if(dcd->layer == LAYER_FILE) { printf("opening %sFLAC file... ", is_ogg? "Ogg ":""); - dcd->file = fopen(flacfilename(is_ogg), "rb"); + open_test_file(dcd, is_ogg, "rb"); if(0 == dcd->file) { printf("ERROR (%s)\n", strerror(errno)); return false; @@ -466,7 +474,7 @@ static FLAC__bool test_stream_decoder(Layer layer, FLAC__bool is_ogg) if(layer < LAYER_FILENAME) { printf("opening %sFLAC file... ", is_ogg? "Ogg ":""); - decoder_client_data.file = fopen(flacfilename(is_ogg), "rb"); + open_test_file(&decoder_client_data, is_ogg, "rb"); if(0 == decoder_client_data.file) { printf("ERROR (%s)\n", strerror(errno)); return false; |