static FLAC__bool safe_decoder_init_(const char *infilename, FLAC__FileDecoder *decoder);
static void safe_decoder_finish_(FLAC__FileDecoder *decoder);
static void safe_decoder_delete_(FLAC__FileDecoder *decoder);
-static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data);
+static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
static void metadata_callback_(const FLAC__FileDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
static void error_callback_(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
static FLAC__bool get_id3v1_tag_(const char *filename, id3v1_struct *tag);
strcpy(title, tag.description);
}
if(length_in_msec)
- *length_in_msec = streaminfo.total_samples * 10 / (streaminfo.sample_rate / 100);
+ *length_in_msec = streaminfo.data.stream_info.total_samples * 10 / (streaminfo.data.stream_info.sample_rate / 100);
}
void eq_set(int on, char data[10], int preamp)
}
}
-FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data)
+FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
{
file_info_struct *file_info_ = (file_info_struct *)client_data;
const unsigned bps = file_info_->bits_per_sample, channels = file_info_->channels, wide_samples = frame->header.blocksize;
if(!reader) return 0;\r
\r
//@@@ to be really "clean" we should go through the reader instead of directly to the file...\r
- if(!FLAC__metadata_get_streaminfo(infos->getFilename(), &stream_info))\r
+ if(!FLAC__metadata_get_streaminfo(infos->getFilename(), &streaminfo))\r
return 1;\r
\r
id3v1_struct tag;\r
infos->setLength(lengthInMsec());\r
//@@@ infos->setTitle(Std::filename(infos->getFilename()));\r
infos->setTitle(tag.description);\r
- infos->setInfo(StringPrintf("FLAC:<%ihz:%ibps:%dch>", stream_info.sample_rate, stream_info.bits_per_sample, stream_info.channels)); //@@@ fix later\r
+ infos->setInfo(StringPrintf("FLAC:<%ihz:%ibps:%dch>", streaminfo.data.stream_info.sample_rate, streaminfo.data.stream_info.bits_per_sample, streaminfo.data.stream_info.channels)); //@@@ fix later\r
if(has_tag) {\r
infos->setData("Title", tag.title);\r
infos->setData("Artist", tag.artist);\r
eof = true;\r
}\r
else {\r
- const unsigned channels = stream_info.channels;\r
- const unsigned bits_per_sample = stream_info.bits_per_sample;\r
+ const unsigned channels = streaminfo.data.stream_info.channels;\r
+ const unsigned bits_per_sample = streaminfo.data.stream_info.bits_per_sample;\r
const unsigned bytes_per_sample = (bits_per_sample+7)/8;\r
- const unsigned sample_rate = stream_info.sample_rate;\r
+ const unsigned sample_rate = streaminfo.data.stream_info.sample_rate;\r
unsigned i, n = min(samples_in_reservoir, 576), delta;\r
signed short *ssbuffer = (signed short*)output;\r
\r
\r
int FlacPcm::corecb_onSeeked(int newpos)\r
{\r
- if(stream_info.total_samples == 0 || newpos < 0)\r
+ if(streaminfo.data.stream_info.total_samples == 0 || newpos < 0)\r
return 1;\r
\r
needs_seek = true;\r
- seek_sample = (FLAC__uint64)((double)newpos / (double)lengthInMsec() * (double)(FLAC__int64)stream_info.total_samples);\r
+ seek_sample = (FLAC__uint64)((double)newpos / (double)lengthInMsec() * (double)(FLAC__int64)streaminfo.data.stream_info.total_samples);\r
return 0;\r
}\r
\r
FLAC__StreamDecoderWriteStatus FlacPcm::writeCallback_(const FLAC__SeekableStreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data)\r
{\r
FlacPcm *instance = (FlacPcm*)client_data;\r
- const unsigned bps = instance->stream_info.bits_per_sample, channels = instance->stream_info.channels, wide_samples = frame->header.blocksize;\r
+ const unsigned bps = instance->streaminfo.data.stream_info.bits_per_sample, channels = instance->streaminfo.data.stream_info.channels, wide_samples = frame->header.blocksize;\r
unsigned wide_sample, sample, channel;\r
\r
(void)decoder;\r
FlacPcm *instance = (FlacPcm*)client_data;\r
(void)decoder;\r
if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO) {\r
- instance->stream_info = metadata->data.stream_info;\r
+ instance->streaminfo.data.stream_info = *metadata;\r
\r
- if(instance->stream_info.bits_per_sample != 16) {\r
+ if(instance->streaminfo.data.stream_info.bits_per_sample != 16) {\r
//@@@ how to do this? MessageBox(mod.hMainWindow, "ERROR: plugin can only handle 16-bit samples\n", "ERROR: plugin can only handle 16-bit samples", 0);\r
instance->abort_flag = true;\r
return;\r
bool abort_flag;\r
svc_fileReader *reader;\r
FLAC__SeekableStreamDecoder *decoder;\r
- FLAC__StreamMetadata_StreamInfo stream_info;\r
+ FLAC__StreamMetadata streaminfo;\r
FLAC__int16 reservoir[FLAC__MAX_BLOCK_SIZE * 2 * 2]; // *2 for max channels, another *2 for overflow\r
unsigned char output[576 * 2 * (16/8)]; // *2 for max channels, (16/8) for max bytes per sample\r
\r
- unsigned lengthInMsec() { return (unsigned)((FLAC__uint64)1000 * stream_info.total_samples / stream_info.sample_rate); }\r
+ unsigned lengthInMsec() { return (unsigned)((FLAC__uint64)1000 * streaminfo.data.stream_info.total_samples / streaminfo.data.stream_info.sample_rate); }\r
private:\r
void cleanup();\r
static FLAC__SeekableStreamDecoderReadStatus readCallback_(const FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);\r
static FLAC__bool get_id3v1_tag_(const char *filename, id3v1_struct *tag);
static void *play_loop_(void *arg);
static FLAC__bool safe_decoder_init_(const char *filename, FLAC__FileDecoder *decoder);
-static FLAC__bool safe_decoder_finish_(FLAC__FileDecoder *decoder);
-static FLAC__bool safe_decoder_delete_(FLAC__FileDecoder *decoder);
-static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data);
+static void safe_decoder_finish_(FLAC__FileDecoder *decoder);
+static void safe_decoder_delete_(FLAC__FileDecoder *decoder);
+static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
static void metadata_callback_(const FLAC__FileDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
static void error_callback_(const FLAC__FileDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
void FLAC_XMMS__cleanup()
{
- safe_decoder_delete(decoder_);
+ safe_decoder_delete_(decoder_);
decoder_ = 0;
}
if(!FLAC__metadata_get_streaminfo(filename, &streaminfo)) {
/* @@@ how to report the error? */
if(title) {
- static const char *errtitle = "Invalid FLAC File: ");
+ static const char *errtitle = "Invalid FLAC File: ";
*title = g_malloc(strlen(errtitle) + 1 + strlen(filename) + 1 + 1);
sprintf(*title, "%s\"%s\"", errtitle, filename);
}
strcpy(*title, tag.description);
}
if(length_in_msec)
- *length_in_msec = streaminfo.total_samples * 10 / (streaminfo.sample_rate / 100);
+ *length_in_msec = streaminfo.data.stream_info.total_samples * 10 / (streaminfo.data.stream_info.sample_rate / 100);
}
/***********************************************************************
}
}
-FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *buffer[], void *client_data)
+FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__FileDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
{
file_info_struct *file_info = (file_info_struct *)client_data;
const unsigned bps = file_info->bits_per_sample, channels = file_info->channels, wide_samples = frame->header.blocksize;