Skip to content

Commit 679b0e9

Browse files
committed
Add missing C++ wrapper functions for new C functions
1 parent d12281e commit 679b0e9

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

include/FLAC++/decoder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,14 @@ namespace FLAC {
137137
virtual bool get_decode_chained_stream() const; ///< See FLAC__stream_decoder_get_decode_chained_stream()
138138
virtual bool get_md5_checking() const; ///< See FLAC__stream_decoder_get_md5_checking()
139139
virtual FLAC__uint64 get_total_samples() const; ///< See FLAC__stream_decoder_get_total_samples()
140+
virtual FLAC__uint64 find_total_samples(); ///< See FLAC__stream_decoder_find_total_samples()
140141
virtual uint32_t get_channels() const; ///< See FLAC__stream_decoder_get_channels()
141142
virtual ::FLAC__ChannelAssignment get_channel_assignment() const; ///< See FLAC__stream_decoder_get_channel_assignment()
142143
virtual uint32_t get_bits_per_sample() const; ///< See FLAC__stream_decoder_get_bits_per_sample()
143144
virtual uint32_t get_sample_rate() const; ///< See FLAC__stream_decoder_get_sample_rate()
144145
virtual uint32_t get_blocksize() const; ///< See FLAC__stream_decoder_get_blocksize()
145146
virtual bool get_decode_position(FLAC__uint64 *position) const; ///< See FLAC__stream_decoder_get_decode_position()
147+
virtual int32_t get_link_lengths(FLAC__uint64 **link_lengths); ///< See FLAC__stream_decoder_get_link_lengths()
146148

147149
virtual ::FLAC__StreamDecoderInitStatus init(); ///< Seek FLAC__stream_decoder_init_stream()
148150
virtual ::FLAC__StreamDecoderInitStatus init_ogg(); ///< Seek FLAC__stream_decoder_init_ogg_stream()

src/libFLAC++/stream_decoder.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ namespace FLAC {
146146
return ::FLAC__stream_decoder_get_total_samples(decoder_);
147147
}
148148

149+
FLAC__uint64 Stream::find_total_samples()
150+
{
151+
FLAC__ASSERT(is_valid());
152+
return ::FLAC__stream_decoder_find_total_samples(decoder_);
153+
}
154+
149155
uint32_t Stream::get_channels() const
150156
{
151157
FLAC__ASSERT(is_valid());
@@ -182,6 +188,12 @@ namespace FLAC {
182188
return ::FLAC__stream_decoder_get_decode_position(decoder_, position);
183189
}
184190

191+
int32_t Stream::get_link_lengths(FLAC__uint64 **link_lengths)
192+
{
193+
FLAC__ASSERT(is_valid());
194+
return ::FLAC__stream_decoder_get_link_lengths(decoder_, link_lengths);
195+
}
196+
185197
::FLAC__StreamDecoderInitStatus Stream::init()
186198
{
187199
FLAC__ASSERT(is_valid());

src/test_libFLAC++/decoders.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,20 @@ static bool test_stream_decoder(Layer layer, bool is_ogg, bool is_chained_ogg)
679679
FLAC::Decoder::Stream::State state = decoder->get_state();
680680
printf("returned state = %u (%s)... OK\n", (uint32_t)((::FLAC__StreamDecoderState)state), state.as_cstring());
681681

682+
printf("testing get_link_lengths()... ");
683+
if(decoder->get_link_lengths(NULL) != FLAC__STREAM_DECODER_GET_LINK_LENGTHS_NOT_INDEXED)
684+
return die_s_("returned incorrectly", decoder);
685+
682686
printf("progress to next chain link with finish_link()... ");
683687
if(!decoder->finish_link())
684688
return die_s_("returned false", decoder);
685689
printf("OK\n");
686690
}
691+
else {
692+
printf("testing get_link_lengths()... ");
693+
if(decoder->get_link_lengths(NULL) != FLAC__STREAM_DECODER_GET_LINK_LENGTHS_INVALID)
694+
return die_s_("returned incorrectly", decoder);
695+
}
687696

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

784+
if(is_chained_ogg) {
785+
FLAC__uint64 *link_lengths;
786+
printf("testing get_link_lengths()... ");
787+
if(decoder->get_link_lengths(NULL) != 2)
788+
return die_s_("returned incorrectly", decoder);
789+
790+
printf("testing get_link_lengths()... ");
791+
if(decoder->get_link_lengths(&link_lengths) != 2)
792+
return die_s_("returned incorrectly", decoder);
793+
free(link_lengths);
794+
}
795+
else {
796+
printf("testing get_link_lengths()... ");
797+
if(decoder->get_link_lengths(NULL) != FLAC__STREAM_DECODER_GET_LINK_LENGTHS_INVALID)
798+
return die_s_("returned incorrectly", decoder);
799+
}
800+
801+
775802
printf("testing get_channels()... ");
776803
{
777804
uint32_t channels = decoder->get_channels();

0 commit comments

Comments
 (0)