fix to work with the new decoder interface
This commit is contained in:
parent
e6499bdf18
commit
24745f9d87
@ -74,13 +74,13 @@ void about(HWND hwndParent)
|
||||
|
||||
void init()
|
||||
{
|
||||
decoder = FLAC__file_decoder_get_new_instance();
|
||||
decoder = FLAC__file_decoder_new();
|
||||
}
|
||||
|
||||
void quit()
|
||||
{
|
||||
if(decoder)
|
||||
FLAC__file_decoder_free_instance(decoder);
|
||||
FLAC__file_decoder_delete(decoder);
|
||||
}
|
||||
|
||||
int isourfile(char *fn) { return 0; }
|
||||
@ -161,7 +161,7 @@ void stop()
|
||||
thread_handle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
if(decoder) {
|
||||
if(decoder->state != FLAC__FILE_DECODER_UNINITIALIZED)
|
||||
if(FLAC__file_decoder_state(decoder) != FLAC__FILE_DECODER_UNINITIALIZED)
|
||||
FLAC__file_decoder_finish(decoder);
|
||||
}
|
||||
|
||||
@ -207,20 +207,19 @@ void getfileinfo(char *filename, char *title, int *length_in_ms)
|
||||
}
|
||||
else { /* some other file */
|
||||
if (length_in_ms) {
|
||||
FLAC__FileDecoder *tmp_decoder = FLAC__file_decoder_get_new_instance();
|
||||
FLAC__FileDecoder *tmp_decoder = FLAC__file_decoder_new();
|
||||
stream_info_struct tmp_stream_info;
|
||||
tmp_decoder->check_md5 = false; /* turn off MD5 checking in the decoder */
|
||||
tmp_stream_info.abort_flag = false;
|
||||
if(FLAC__file_decoder_init(tmp_decoder, filename, write_callback, metadata_callback, error_callback, &tmp_stream_info) != FLAC__FILE_DECODER_OK)
|
||||
if(FLAC__file_decoder_init(tmp_decoder, false /*md5_check*/, filename, write_callback, metadata_callback, error_callback, &tmp_stream_info) != FLAC__FILE_DECODER_OK)
|
||||
return;
|
||||
if(!FLAC__file_decoder_process_metadata(tmp_decoder))
|
||||
return;
|
||||
|
||||
*length_in_ms = (int)tmp_stream_info.length_in_ms;
|
||||
|
||||
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);
|
||||
}
|
||||
if (title) {
|
||||
char *p=filename+strlen(filename);
|
||||
@ -262,7 +261,7 @@ DWORD WINAPI __stdcall DecodeThread(void *b)
|
||||
}
|
||||
else if (mod.outMod->CanWrite() >= ((int)(576*channels*bytes_per_sample) << (mod.dsp_isactive()?1:0))) {
|
||||
while(samples_in_reservoir < 576) {
|
||||
if(decoder->state == FLAC__FILE_DECODER_END_OF_FILE) {
|
||||
if(FLAC__file_decoder_state(decoder) == FLAC__FILE_DECODER_END_OF_FILE) {
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
@ -355,8 +354,7 @@ __declspec( dllexport ) In_Module * winampGetInModule2()
|
||||
**********************************************************************/
|
||||
bool stream_init(const char *infile)
|
||||
{
|
||||
decoder->check_md5 = false; /* turn off MD5 checking in the decoder */
|
||||
if(FLAC__file_decoder_init(decoder, infile, write_callback, metadata_callback, error_callback, &stream_info) != FLAC__FILE_DECODER_OK) {
|
||||
if(FLAC__file_decoder_init(decoder, false /*md5_check*/, infile, write_callback, metadata_callback, error_callback, &stream_info) != FLAC__FILE_DECODER_OK) {
|
||||
MessageBox(mod.hMainWindow,"ERROR initializing decoder, state = %d\n","ERROR initializing decoder",0);
|
||||
return false;
|
||||
}
|
||||
|
@ -83,14 +83,13 @@ int FLAC_Info::Open(char *url)
|
||||
(void)get_id3v1_tag_(filename, &tag_);
|
||||
|
||||
file_info_struct tmp_file_info;
|
||||
FLAC__FileDecoder *tmp_decoder = FLAC__file_decoder_get_new_instance();
|
||||
FLAC__FileDecoder *tmp_decoder = FLAC__file_decoder_new();
|
||||
if(0 == tmp_decoder) {
|
||||
length_in_msec_ = -1;
|
||||
return 1;
|
||||
}
|
||||
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 1;
|
||||
}
|
||||
@ -101,9 +100,9 @@ int FLAC_Info::Open(char *url)
|
||||
|
||||
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);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -146,7 +145,7 @@ class FLAC_Source : public WInputSource
|
||||
|
||||
FLAC_Source::FLAC_Source() : WInputSource()
|
||||
{
|
||||
decoder_ = FLAC__file_decoder_get_new_instance();
|
||||
decoder_ = FLAC__file_decoder_new();
|
||||
file_info_.length_in_msec = -1;
|
||||
audio_error_ = false;
|
||||
}
|
||||
@ -154,7 +153,7 @@ FLAC_Source::FLAC_Source() : WInputSource()
|
||||
FLAC_Source::~FLAC_Source()
|
||||
{
|
||||
if(decoder_)
|
||||
FLAC__file_decoder_free_instance(decoder_);
|
||||
FLAC__file_decoder_delete(decoder_);
|
||||
}
|
||||
|
||||
void FLAC_Source::GetTitle(char *buf, int maxlen)
|
||||
@ -214,7 +213,7 @@ int FLAC_Source::GetSamples(char *sample_buffer, int bytes, int *bps, int *nch,
|
||||
const unsigned wide_samples = bytes / channels / bytes_per_sample;
|
||||
if(bytes&0x3)fprintf(stderr,"@@@ Got odd buffer size request\n");
|
||||
while(reservoir_samples_ < wide_samples) {
|
||||
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;
|
||||
}
|
||||
@ -257,7 +256,7 @@ int FLAC_Source::SetPosition(int position)
|
||||
|
||||
void FLAC_Source::cleanup()
|
||||
{
|
||||
if(decoder_ && decoder_->state != FLAC__FILE_DECODER_UNINITIALIZED)
|
||||
if(decoder_ && FLAC__file_decoder_state(decoder_) != FLAC__FILE_DECODER_UNINITIALIZED)
|
||||
FLAC__file_decoder_finish(decoder_);
|
||||
|
||||
reservoir_samples_ = 0;
|
||||
@ -323,9 +322,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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user