📄 decoders.cpp
字号:
printf("OK\n");
printf("testing process_until_end_of_file()... ");
if(!decoder->process_until_end_of_file())
return decoder->die("returned false");
printf("OK\n");
printf("testing get_channels()... ");
{
unsigned channels = decoder->get_channels();
if(channels != streaminfo_.data.stream_info.channels) {
printf("FAILED, returned %u, expected %u\n", channels, streaminfo_.data.stream_info.channels);
return false;
}
}
printf("OK\n");
printf("testing get_bits_per_sample()... ");
{
unsigned bits_per_sample = decoder->get_bits_per_sample();
if(bits_per_sample != streaminfo_.data.stream_info.bits_per_sample) {
printf("FAILED, returned %u, expected %u\n", bits_per_sample, streaminfo_.data.stream_info.bits_per_sample);
return false;
}
}
printf("OK\n");
printf("testing get_sample_rate()... ");
{
unsigned sample_rate = decoder->get_sample_rate();
if(sample_rate != streaminfo_.data.stream_info.sample_rate) {
printf("FAILED, returned %u, expected %u\n", sample_rate, streaminfo_.data.stream_info.sample_rate);
return false;
}
}
printf("OK\n");
printf("testing get_blocksize()... ");
{
unsigned blocksize = decoder->get_blocksize();
/* value could be anything since we're at the last block, so accept any answer */
printf("returned %u... OK\n", blocksize);
}
printf("testing get_channel_assignment()... ");
{
::FLAC__ChannelAssignment ca = decoder->get_channel_assignment();
printf("returned %u (%s)... OK\n", (unsigned)ca, ::FLAC__ChannelAssignmentString[ca]);
}
printf("testing finish()... ");
decoder->finish();
printf("OK\n");
/*
* respond all
*/
printf("testing set_metadata_respond_all()... ");
if(!decoder->set_metadata_respond_all()) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
num_expected_ = 0;
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
expected_metadata_sequence_[num_expected_++] = &padding_;
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
/*
* ignore all
*/
printf("testing set_metadata_ignore_all()... ");
if(!decoder->set_metadata_ignore_all()) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
num_expected_ = 0;
if(!decoder->test_respond())
return false;
/*
* respond all, ignore VORBIS_COMMENT
*/
printf("testing set_metadata_respond_all()... ");
if(!decoder->set_metadata_respond_all()) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
printf("testing set_metadata_ignore(VORBIS_COMMENT)... ");
if(!decoder->set_metadata_ignore(FLAC__METADATA_TYPE_VORBIS_COMMENT)) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
num_expected_ = 0;
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
expected_metadata_sequence_[num_expected_++] = &padding_;
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
/*
* respond all, ignore APPLICATION
*/
printf("testing set_metadata_respond_all()... ");
if(!decoder->set_metadata_respond_all()) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
printf("testing set_metadata_ignore(APPLICATION)... ");
if(!decoder->set_metadata_ignore(FLAC__METADATA_TYPE_APPLICATION)) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
num_expected_ = 0;
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
expected_metadata_sequence_[num_expected_++] = &padding_;
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
/*
* respond all, ignore APPLICATION id of app#1
*/
printf("testing set_metadata_respond_all()... ");
if(!decoder->set_metadata_respond_all()) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
printf("testing set_metadata_ignore_application(of app block #1)... ");
if(!decoder->set_metadata_ignore_application(application1_.data.application.id)) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
num_expected_ = 0;
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
expected_metadata_sequence_[num_expected_++] = &padding_;
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
/*
* respond all, ignore APPLICATION id of app#1 & app#2
*/
printf("testing set_metadata_respond_all()... ");
if(!decoder->set_metadata_respond_all()) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
printf("testing set_metadata_ignore_application(of app block #1)... ");
if(!decoder->set_metadata_ignore_application(application1_.data.application.id)) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
printf("testing set_metadata_ignore_application(of app block #2)... ");
if(!decoder->set_metadata_ignore_application(application2_.data.application.id)) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
num_expected_ = 0;
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
expected_metadata_sequence_[num_expected_++] = &padding_;
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
/*
* ignore all, respond VORBIS_COMMENT
*/
printf("testing set_metadata_ignore_all()... ");
if(!decoder->set_metadata_ignore_all()) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
printf("testing set_metadata_respond(VORBIS_COMMENT)... ");
if(!decoder->set_metadata_respond(FLAC__METADATA_TYPE_VORBIS_COMMENT)) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
num_expected_ = 0;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
if(!decoder->test_respond())
return false;
/*
* ignore all, respond APPLICATION
*/
printf("testing set_metadata_ignore_all()... ");
if(!decoder->set_metadata_ignore_all()) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
printf("testing set_metadata_respond(APPLICATION)... ");
if(!decoder->set_metadata_respond(FLAC__METADATA_TYPE_APPLICATION)) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
num_expected_ = 0;
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &application2_;
if(!decoder->test_respond())
return false;
/*
* ignore all, respond APPLICATION id of app#1
*/
printf("testing set_metadata_ignore_all()... ");
if(!decoder->set_metadata_ignore_all()) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
printf("testing set_metadata_respond_application(of app block #1)... ");
if(!decoder->set_metadata_respond_application(application1_.data.application.id)) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
num_expected_ = 0;
expected_metadata_sequence_[num_expected_++] = &application1_;
if(!decoder->test_respond())
return false;
/*
* ignore all, respond APPLICATION id of app#1 & app#2
*/
printf("testing set_metadata_ignore_all()... ");
if(!decoder->set_metadata_ignore_all()) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
printf("testing set_metadata_respond_application(of app block #1)... ");
if(!decoder->set_metadata_respond_application(application1_.data.application.id)) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
printf("testing set_metadata_respond_application(of app block #2)... ");
if(!decoder->set_metadata_respond_application(application2_.data.application.id)) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
num_expected_ = 0;
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &application2_;
if(!decoder->test_respond())
return false;
/*
* respond all, ignore APPLICATION, respond APPLICATION id of app#1
*/
printf("testing set_metadata_respond_all()... ");
if(!decoder->set_metadata_respond_all()) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
printf("testing set_metadata_ignore(APPLICATION)... ");
if(!decoder->set_metadata_ignore(FLAC__METADATA_TYPE_APPLICATION)) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
printf("testing set_metadata_respond_application(of app block #1)... ");
if(!decoder->set_metadata_respond_application(application1_.data.application.id)) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
num_expected_ = 0;
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
expected_metadata_sequence_[num_expected_++] = &padding_;
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
/*
* ignore all, respond APPLICATION, ignore APPLICATION id of app#1
*/
printf("testing set_metadata_ignore_all()... ");
if(!decoder->set_metadata_ignore_all()) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
printf("testing set_metadata_respond(APPLICATION)... ");
if(!decoder->set_metadata_respond(FLAC__METADATA_TYPE_APPLICATION)) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
printf("testing set_metadata_ignore_application(of app block #1)... ");
if(!decoder->set_metadata_ignore_application(application1_.data.application.id)) {
printf("FAILED, returned false\n");
return false;
}
printf("OK\n");
num_expected_ = 0;
expected_metadata_sequence_[num_expected_++] = &application2_;
if(!decoder->test_respond())
return false;
/* done, now leave the sequence the way we found it... */
num_expected_ = 0;
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
expected_metadata_sequence_[num_expected_++] = &padding_;
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
printf("freeing decoder instance... ");
delete decoder;
printf("OK\n");
printf("\nPASSED!\n");
return true;
}
bool test_decoders()
{
init_metadata_blocks_();
if(!generate_file_())
return false;
if(!test_stream_decoder())
return false;
if(!test_seekable_stream_decoder())
return false;
if(!test_file_decoder())
return false;
(void) grabbag__file_remove_file(flacfilename_);
free_metadata_blocks_();
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -