fix to work with the new decoder interface

This commit is contained in:
Josh Coalson
2001-06-13 18:21:03 +00:00
parent e6499bdf18
commit 24745f9d87
3 changed files with 29 additions and 37 deletions

View File

@@ -119,7 +119,7 @@ InputPlugin *get_iplugin_info()
void FLAC_XMMS__init()
{
decoder_ = FLAC__file_decoder_get_new_instance();
decoder_ = FLAC__file_decoder_new();
}
int FLAC_XMMS__is_our_file(char *filename)
@@ -152,7 +152,7 @@ void FLAC_XMMS__play_file(char *filename)
if (flac_ip.output->open_audio(file_info_.sample_format, file_info_.sample_rate, file_info_.channels) == 0) {
audio_error_ = true;
if(decoder_ && decoder_->state != FLAC__FILE_DECODER_UNINITIALIZED)
if(decoder_ && FLAC__file_decoder_state(decoder_) != FLAC__FILE_DECODER_UNINITIALIZED)
FLAC__file_decoder_finish(decoder_);
return;
}
@@ -170,7 +170,7 @@ void FLAC_XMMS__stop()
file_info_.is_playing = false;
pthread_join(decode_thread_, NULL);
flac_ip.output->close_audio();
if(decoder_ && decoder_->state != FLAC__FILE_DECODER_UNINITIALIZED)
if(decoder_ && FLAC__file_decoder_state(decoder_) != FLAC__FILE_DECODER_UNINITIALIZED)
FLAC__file_decoder_finish(decoder_);
}
}
@@ -202,7 +202,7 @@ int FLAC_XMMS__get_time()
void FLAC_XMMS__cleanup()
{
if(decoder_)
FLAC__file_decoder_free_instance(decoder_);
FLAC__file_decoder_delete(decoder_);
}
void FLAC_XMMS__get_song_info(char *filename, char **title, int *length_in_msec)
@@ -215,15 +215,14 @@ void FLAC_XMMS__get_song_info(char *filename, char **title, int *length_in_msec)
strcpy(*title, tag.description);
}
if(length_in_msec) {
FLAC__FileDecoder *tmp_decoder = FLAC__file_decoder_get_new_instance();
FLAC__FileDecoder *tmp_decoder = FLAC__file_decoder_new();
file_info_struct tmp_file_info;
if(0 == tmp_decoder) {
*length_in_msec = -1;
return;
}
tmp_file_info.abort_flag = false;
tmp_decoder->check_md5 = false; /* turn off MD5 checking in the decoder */
if(FLAC__file_decoder_init(tmp_decoder, filename, write_callback_, metadata_callback_, error_callback_, &tmp_file_info) != FLAC__FILE_DECODER_OK) {
if(FLAC__file_decoder_init(tmp_decoder, false /*md5_check*/, filename, write_callback_, metadata_callback_, error_callback_, &tmp_file_info) != FLAC__FILE_DECODER_OK) {
*length_in_msec = -1;
return;
}
@@ -234,9 +233,9 @@ void FLAC_XMMS__get_song_info(char *filename, char **title, int *length_in_msec)
*length_in_msec = (int)tmp_file_info.length_in_msec;
if(tmp_decoder->state != FLAC__FILE_DECODER_UNINITIALIZED)
if(FLAC__file_decoder_state(tmp_decoder) != FLAC__FILE_DECODER_UNINITIALIZED)
FLAC__file_decoder_finish(tmp_decoder);
FLAC__file_decoder_free_instance(tmp_decoder);
FLAC__file_decoder_delete(tmp_decoder);
}
}
@@ -298,7 +297,7 @@ void *play_loop_(void *arg)
while(file_info_.is_playing) {
if(!file_info_.eof) {
while(reservoir_samples_ < SAMPLES_PER_WRITE) {
if(decoder_->state == FLAC__FILE_DECODER_END_OF_FILE) {
if(FLAC__file_decoder_state(decoder_) == FLAC__FILE_DECODER_END_OF_FILE) {
file_info_.eof = true;
break;
}
@@ -343,7 +342,7 @@ void *play_loop_(void *arg)
}
}
if(decoder_ && decoder_->state != FLAC__FILE_DECODER_UNINITIALIZED)
if(decoder_ && FLAC__file_decoder_state(decoder_) != FLAC__FILE_DECODER_UNINITIALIZED)
FLAC__file_decoder_finish(decoder_);
/* are these two calls necessary? */
@@ -359,9 +358,7 @@ bool decoder_init_(const char *filename)
if(decoder_ == 0)
return false;
decoder_->check_md5 = false; /* turn off MD5 checking in the decoder */
if(FLAC__file_decoder_init(decoder_, filename, write_callback_, metadata_callback_, error_callback_, &file_info_) != FLAC__FILE_DECODER_OK)
if(FLAC__file_decoder_init(decoder_, false /*md5_check*/, filename, write_callback_, metadata_callback_, error_callback_, &file_info_) != FLAC__FILE_DECODER_OK)
return false;
file_info_.abort_flag = false;