Skip to content

Commit

Permalink
Check whether libFLAC throws error when reading chained ogg
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmf01 committed Jan 17, 2025
1 parent aa414e4 commit 0676503
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/test_libFLAC/metadata_manip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1503,14 +1503,14 @@ static FLAC__bool test_level_2_(FLAC__bool filename_based, FLAC__bool is_ogg, FL
if(!test_file_(is_ogg, decoder_metadata_callback_compare_, false))
return false;

if(is_ogg)
goto end;

printf("switch file to read-write\n");

if(!change_stats_(flacfilename(is_ogg, false), /*read-only=*/false))
return false;

if(is_ogg)
goto end;

printf("create iterator\n");
if(0 == (iterator = FLAC__metadata_iterator_new()))
return die_("allocating memory for iterator");
Expand Down Expand Up @@ -1966,13 +1966,29 @@ static FLAC__bool test_level_2_(FLAC__bool filename_based, FLAC__bool is_ogg, FL
return false;

end:
printf("delete chain\n");

FLAC__metadata_chain_delete(chain);
if(is_ogg) {
/* Check whether opening a chained file fails */
printf("create chained Ogg FLAC file\n");

if(0 != flac_rename(flacfilename(is_ogg, false),flacfilename(is_ogg, true)))
return false;
file_utils__ogg_serial_number++;
if(!generate_file_(/*include_extras=*/false, is_ogg))
return false;
if(!file_utils__append_file(flacfilename(is_ogg, false), flacfilename(is_ogg, true)))
return false;
if(read_chain_(chain, flacfilename(is_ogg, false), filename_based, is_ogg))
return die_c_("read chained Ogg instead of throwing error", FLAC__metadata_chain_status(chain));
}

if(!remove_file_(flacfilename(is_ogg, false)))
return false;

printf("delete chain\n");

FLAC__metadata_chain_delete(chain);

return true;
}

Expand Down
24 changes: 24 additions & 0 deletions test/test_metaflac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -544,3 +544,27 @@ check_flac
metaflac_test_nofilter case67 "-o --append --block-number=0" "--list"

rm -f metaflac-test-files/out.meta metaflac-test-files/out1.meta

echo $ECHO_N "Checking for --ogg support in flac ... " $ECHO_C
if flac${EXE} --ogg --no-error-on-compression-fail --silent --force-raw-format --endian=little --sign=signed --channels=1 --bps=8 --sample-rate=44100 -c $0 1>/dev/null 2>&1 ; then
has_ogg=yes;
else
has_ogg=no;
fi
echo ${has_ogg}

if [ $has_ogg = "yes" ] ; then
if command -v oggz > /dev/null ; then
if command -v oggenc > /dev/null ; then
echo $ECHO_N "Creating merged and chained-merged files" $ECHO_C
run_flac --ogg metaflac1.flac -o small.oga
run_flac --ogg metaflac1.flac -o small2.oga
oggenc -Q --skeleton -o small-vorbis.oga metaflac1.flac
oggenc -Q --skeleton -o small2-vorbis.oga metaflac1.flac
oggz merge -o small-merged.oga small-vorbis.oga small.oga
oggz merge -o small2-merged.oga small2-vorbis.oga small2.oga
cat small2-merged.oga small-merged.oga > chained-merged.oga

fi
fi
fi

0 comments on commit 0676503

Please sign in to comment.