Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docs, add C++ wrapper functions and update ABI dumps #799

Merged
merged 4 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 101 additions & 101 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions include/FLAC++/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,14 @@ namespace FLAC {
virtual bool get_decode_chained_stream() const; ///< See FLAC__stream_decoder_get_decode_chained_stream()
virtual bool get_md5_checking() const; ///< See FLAC__stream_decoder_get_md5_checking()
virtual FLAC__uint64 get_total_samples() const; ///< See FLAC__stream_decoder_get_total_samples()
virtual FLAC__uint64 find_total_samples(); ///< See FLAC__stream_decoder_find_total_samples()
virtual uint32_t get_channels() const; ///< See FLAC__stream_decoder_get_channels()
virtual ::FLAC__ChannelAssignment get_channel_assignment() const; ///< See FLAC__stream_decoder_get_channel_assignment()
virtual uint32_t get_bits_per_sample() const; ///< See FLAC__stream_decoder_get_bits_per_sample()
virtual uint32_t get_sample_rate() const; ///< See FLAC__stream_decoder_get_sample_rate()
virtual uint32_t get_blocksize() const; ///< See FLAC__stream_decoder_get_blocksize()
virtual bool get_decode_position(FLAC__uint64 *position) const; ///< See FLAC__stream_decoder_get_decode_position()
virtual int32_t get_link_lengths(FLAC__uint64 **link_lengths); ///< See FLAC__stream_decoder_get_link_lengths()

virtual ::FLAC__StreamDecoderInitStatus init(); ///< Seek FLAC__stream_decoder_init_stream()
virtual ::FLAC__StreamDecoderInitStatus init_ogg(); ///< Seek FLAC__stream_decoder_init_ogg_stream()
Expand Down
7 changes: 6 additions & 1 deletion include/FLAC/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@
* \section porting_1_4_3_to_1_5_0_summary Summary
*
* Between FLAC 1.4.3 and FLAC 1.5.0, there have been changes to
* existing functions and enums:
* existing C functions and enums:
* - the functions FLAC__metadata_get_streaminfo,
* FLAC__metadata_get_tags and FLAC__metadata_get_cuesheet can now
* read from Ogg FLAC files
Expand Down Expand Up @@ -478,6 +478,11 @@
* - the function FLAC__stream_decoder_find_total_samples was added,
* which seeks to the end of a file to find the total number of
* samples
* - the function FLAC__stream_encoder_set_num_threads and
* FLAC__stream_encoder_get_num_threads have been added, which
* can be used to enable multithreading in the encoder
*
* For the C++ API, changes are the same, but in C++ nomenclature
*
*/

Expand Down
12 changes: 12 additions & 0 deletions src/libFLAC++/stream_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ namespace FLAC {
return ::FLAC__stream_decoder_get_total_samples(decoder_);
}

FLAC__uint64 Stream::find_total_samples()
{
FLAC__ASSERT(is_valid());
return ::FLAC__stream_decoder_find_total_samples(decoder_);
}

uint32_t Stream::get_channels() const
{
FLAC__ASSERT(is_valid());
Expand Down Expand Up @@ -182,6 +188,12 @@ namespace FLAC {
return ::FLAC__stream_decoder_get_decode_position(decoder_, position);
}

int32_t Stream::get_link_lengths(FLAC__uint64 **link_lengths)
{
FLAC__ASSERT(is_valid());
return ::FLAC__stream_decoder_get_link_lengths(decoder_, link_lengths);
}

::FLAC__StreamDecoderInitStatus Stream::init()
{
FLAC__ASSERT(is_valid());
Expand Down
27 changes: 27 additions & 0 deletions src/test_libFLAC++/decoders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,11 +679,20 @@ static bool test_stream_decoder(Layer layer, bool is_ogg, bool is_chained_ogg)
FLAC::Decoder::Stream::State state = decoder->get_state();
printf("returned state = %u (%s)... OK\n", (uint32_t)((::FLAC__StreamDecoderState)state), state.as_cstring());

printf("testing get_link_lengths()... ");
if(decoder->get_link_lengths(NULL) != FLAC__STREAM_DECODER_GET_LINK_LENGTHS_NOT_INDEXED)
return die_s_("returned incorrectly", decoder);

printf("progress to next chain link with finish_link()... ");
if(!decoder->finish_link())
return die_s_("returned false", decoder);
printf("OK\n");
}
else {
printf("testing get_link_lengths()... ");
if(decoder->get_link_lengths(NULL) != FLAC__STREAM_DECODER_GET_LINK_LENGTHS_INVALID)
return die_s_("returned incorrectly", decoder);
}

printf("testing get_state()... ");
FLAC::Decoder::Stream::State state = decoder->get_state();
Expand Down Expand Up @@ -772,6 +781,24 @@ static bool test_stream_decoder(Layer layer, bool is_ogg, bool is_chained_ogg)
return die_s_(expect? "returned false" : "returned true", decoder);
printf("OK\n");

if(is_chained_ogg) {
FLAC__uint64 *link_lengths;
printf("testing get_link_lengths()... ");
if(decoder->get_link_lengths(NULL) != 2)
return die_s_("returned incorrectly", decoder);

printf("testing get_link_lengths()... ");
if(decoder->get_link_lengths(&link_lengths) != 2)
return die_s_("returned incorrectly", decoder);
free(link_lengths);
}
else {
printf("testing get_link_lengths()... ");
if(decoder->get_link_lengths(NULL) != FLAC__STREAM_DECODER_GET_LINK_LENGTHS_INVALID)
return die_s_("returned incorrectly", decoder);
}


printf("testing get_channels()... ");
{
uint32_t channels = decoder->get_channels();
Expand Down
Binary file modified test/abi/abi-libFLAC++-1.5.0.dump.xz
Binary file not shown.
Binary file modified test/abi/abi-libFLAC-1.5.0.dump.xz
Binary file not shown.
Loading