added audio_format parameter to decoder_initialized()
dc->audioFormat is set once by the decoder plugins before invoking decoder_initialized(); hide dc->audioFormat and let the decoder pass an AudioFormat pointer to decoder_initialized().
This commit is contained in:
parent
0d45870cea
commit
4590a98f0e
@ -24,10 +24,17 @@
|
|||||||
#include "playerData.h"
|
#include "playerData.h"
|
||||||
#include "gcc.h"
|
#include "gcc.h"
|
||||||
|
|
||||||
void decoder_initialized(mpd_unused struct decoder * decoder)
|
void decoder_initialized(mpd_unused struct decoder * decoder,
|
||||||
|
const AudioFormat * audio_format)
|
||||||
{
|
{
|
||||||
assert(dc.state == DECODE_STATE_START);
|
assert(dc.state == DECODE_STATE_START);
|
||||||
|
|
||||||
|
if (audio_format != NULL) {
|
||||||
|
dc.audioFormat = *audio_format;
|
||||||
|
getOutputAudioFormat(audio_format,
|
||||||
|
&(ob.audioFormat));
|
||||||
|
}
|
||||||
|
|
||||||
dc.state = DECODE_STATE_DECODE;
|
dc.state = DECODE_STATE_DECODE;
|
||||||
notify_signal(&pc.notify);
|
notify_signal(&pc.notify);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,8 @@ struct decoder;
|
|||||||
* Notify the player thread that it has finished initialization and
|
* Notify the player thread that it has finished initialization and
|
||||||
* that it has read the song's meta data.
|
* that it has read the song's meta data.
|
||||||
*/
|
*/
|
||||||
void decoder_initialized(struct decoder * decoder);
|
void decoder_initialized(struct decoder * decoder,
|
||||||
|
const AudioFormat * audio_format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is called by the decoder plugin when it has
|
* This function is called by the decoder plugin when it has
|
||||||
|
@ -162,11 +162,10 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
|
|||||||
|
|
||||||
switch (block->type) {
|
switch (block->type) {
|
||||||
case FLAC__METADATA_TYPE_STREAMINFO:
|
case FLAC__METADATA_TYPE_STREAMINFO:
|
||||||
dc.audioFormat.bits = (mpd_sint8)si->bits_per_sample;
|
data->audio_format.bits = (mpd_sint8)si->bits_per_sample;
|
||||||
dc.audioFormat.sampleRate = si->sample_rate;
|
data->audio_format.sampleRate = si->sample_rate;
|
||||||
dc.audioFormat.channels = (mpd_sint8)si->channels;
|
data->audio_format.channels = (mpd_sint8)si->channels;
|
||||||
dc.totalTime = ((float)si->total_samples) / (si->sample_rate);
|
dc.totalTime = ((float)si->total_samples) / (si->sample_rate);
|
||||||
getOutputAudioFormat(&(dc.audioFormat), &(ob.audioFormat));
|
|
||||||
break;
|
break;
|
||||||
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
|
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
|
||||||
flacParseReplayGain(block, data);
|
flacParseReplayGain(block, data);
|
||||||
|
@ -143,6 +143,7 @@ typedef struct {
|
|||||||
size_t chunk_length;
|
size_t chunk_length;
|
||||||
float time;
|
float time;
|
||||||
unsigned int bitRate;
|
unsigned int bitRate;
|
||||||
|
AudioFormat audio_format;
|
||||||
FLAC__uint64 position;
|
FLAC__uint64 position;
|
||||||
struct decoder *decoder;
|
struct decoder *decoder;
|
||||||
InputStream *inStream;
|
InputStream *inStream;
|
||||||
|
@ -286,6 +286,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
|
|||||||
faacDecFrameInfo frameInfo;
|
faacDecFrameInfo frameInfo;
|
||||||
faacDecConfigurationPtr config;
|
faacDecConfigurationPtr config;
|
||||||
long bread;
|
long bread;
|
||||||
|
AudioFormat audio_format;
|
||||||
uint32_t sampleRate;
|
uint32_t sampleRate;
|
||||||
unsigned char channels;
|
unsigned char channels;
|
||||||
int eof = 0;
|
int eof = 0;
|
||||||
@ -335,7 +336,7 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.audioFormat.bits = 16;
|
audio_format.bits = 16;
|
||||||
|
|
||||||
dc.totalTime = totalTime;
|
dc.totalTime = totalTime;
|
||||||
|
|
||||||
@ -369,11 +370,9 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (dc.state != DECODE_STATE_DECODE) {
|
if (dc.state != DECODE_STATE_DECODE) {
|
||||||
dc.audioFormat.channels = frameInfo.channels;
|
audio_format.channels = frameInfo.channels;
|
||||||
dc.audioFormat.sampleRate = sampleRate;
|
audio_format.sampleRate = sampleRate;
|
||||||
getOutputAudioFormat(&(dc.audioFormat),
|
decoder_initialized(mpd_decoder, &audio_format);
|
||||||
&(ob.audioFormat));
|
|
||||||
decoder_initialized(mpd_decoder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
advanceAacBuffer(&b, frameInfo.bytesconsumed);
|
advanceAacBuffer(&b, frameInfo.bytesconsumed);
|
||||||
|
@ -45,6 +45,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
|
|||||||
int fs, frame_count;
|
int fs, frame_count;
|
||||||
AFfilehandle af_fp;
|
AFfilehandle af_fp;
|
||||||
int bits;
|
int bits;
|
||||||
|
AudioFormat audio_format;
|
||||||
mpd_uint16 bitRate;
|
mpd_uint16 bitRate;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
@ -62,30 +63,30 @@ static int audiofile_decode(struct decoder * decoder, char *path)
|
|||||||
afSetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK,
|
afSetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK,
|
||||||
AF_SAMPFMT_TWOSCOMP, 16);
|
AF_SAMPFMT_TWOSCOMP, 16);
|
||||||
afGetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
|
afGetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
|
||||||
dc.audioFormat.bits = (mpd_uint8)bits;
|
audio_format.bits = (mpd_uint8)bits;
|
||||||
dc.audioFormat.sampleRate =
|
audio_format.sampleRate =
|
||||||
(unsigned int)afGetRate(af_fp, AF_DEFAULT_TRACK);
|
(unsigned int)afGetRate(af_fp, AF_DEFAULT_TRACK);
|
||||||
dc.audioFormat.channels =
|
audio_format.channels =
|
||||||
(mpd_uint8)afGetVirtualChannels(af_fp, AF_DEFAULT_TRACK);
|
(mpd_uint8)afGetVirtualChannels(af_fp, AF_DEFAULT_TRACK);
|
||||||
getOutputAudioFormat(&(dc.audioFormat), &(ob.audioFormat));
|
|
||||||
|
|
||||||
frame_count = afGetFrameCount(af_fp, AF_DEFAULT_TRACK);
|
frame_count = afGetFrameCount(af_fp, AF_DEFAULT_TRACK);
|
||||||
|
|
||||||
dc.totalTime =
|
dc.totalTime =
|
||||||
((float)frame_count / (float)dc.audioFormat.sampleRate);
|
((float)frame_count / (float)audio_format.sampleRate);
|
||||||
|
|
||||||
bitRate = (mpd_uint16)(st.st_size * 8.0 / dc.totalTime / 1000.0 + 0.5);
|
bitRate = (mpd_uint16)(st.st_size * 8.0 / dc.totalTime / 1000.0 + 0.5);
|
||||||
|
|
||||||
if (dc.audioFormat.bits != 8 && dc.audioFormat.bits != 16) {
|
if (audio_format.bits != 8 && audio_format.bits != 16) {
|
||||||
ERROR("Only 8 and 16-bit files are supported. %s is %i-bit\n",
|
ERROR("Only 8 and 16-bit files are supported. %s is %i-bit\n",
|
||||||
path, dc.audioFormat.bits);
|
path, audio_format.bits);
|
||||||
afCloseFile(af_fp);
|
afCloseFile(af_fp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs = (int)afGetVirtualFrameSize(af_fp, AF_DEFAULT_TRACK, 1);
|
fs = (int)afGetVirtualFrameSize(af_fp, AF_DEFAULT_TRACK, 1);
|
||||||
|
|
||||||
decoder_initialized(decoder);
|
decoder_initialized(decoder, &audio_format);
|
||||||
|
|
||||||
{
|
{
|
||||||
int ret, eof = 0, current = 0;
|
int ret, eof = 0, current = 0;
|
||||||
char chunk[CHUNK_SIZE];
|
char chunk[CHUNK_SIZE];
|
||||||
@ -94,7 +95,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
|
|||||||
if (dc.command == DECODE_COMMAND_SEEK) {
|
if (dc.command == DECODE_COMMAND_SEEK) {
|
||||||
decoder_clear(decoder);
|
decoder_clear(decoder);
|
||||||
current = dc.seekWhere *
|
current = dc.seekWhere *
|
||||||
dc.audioFormat.sampleRate;
|
audio_format.sampleRate;
|
||||||
afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
|
afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
|
||||||
dc_command_finished();
|
dc_command_finished();
|
||||||
}
|
}
|
||||||
@ -110,7 +111,7 @@ static int audiofile_decode(struct decoder * decoder, char *path)
|
|||||||
1,
|
1,
|
||||||
chunk, ret * fs,
|
chunk, ret * fs,
|
||||||
(float)current /
|
(float)current /
|
||||||
(float)dc.audioFormat.
|
(float)audio_format.
|
||||||
sampleRate, bitRate,
|
sampleRate, bitRate,
|
||||||
NULL);
|
NULL);
|
||||||
if (dc.command == DECODE_COMMAND_STOP)
|
if (dc.command == DECODE_COMMAND_STOP)
|
||||||
|
@ -242,7 +242,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec,
|
|||||||
FLAC__uint32 samples = frame->header.blocksize;
|
FLAC__uint32 samples = frame->header.blocksize;
|
||||||
unsigned int c_samp;
|
unsigned int c_samp;
|
||||||
const unsigned int num_channels = frame->header.channels;
|
const unsigned int num_channels = frame->header.channels;
|
||||||
const unsigned int bytes_per_sample = (dc.audioFormat.bits / 8);
|
const unsigned int bytes_per_sample = (data->audio_format.bits / 8);
|
||||||
const unsigned int bytes_per_channel =
|
const unsigned int bytes_per_channel =
|
||||||
bytes_per_sample * frame->header.channels;
|
bytes_per_sample * frame->header.channels;
|
||||||
const unsigned int max_samples = FLAC_CHUNK_SIZE / bytes_per_channel;
|
const unsigned int max_samples = FLAC_CHUNK_SIZE / bytes_per_channel;
|
||||||
@ -250,7 +250,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec,
|
|||||||
float timeChange;
|
float timeChange;
|
||||||
FLAC__uint64 newPosition = 0;
|
FLAC__uint64 newPosition = 0;
|
||||||
|
|
||||||
assert(dc.audioFormat.bits > 0);
|
assert(data->audio_format.bits > 0);
|
||||||
|
|
||||||
timeChange = ((float)samples) / frame->header.sample_rate;
|
timeChange = ((float)samples) / frame->header.sample_rate;
|
||||||
data->time += timeChange;
|
data->time += timeChange;
|
||||||
@ -415,7 +415,7 @@ static int flac_decode_internal(struct decoder * decoder,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
decoder_initialized(decoder);
|
decoder_initialized(decoder, &data.audio_format);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (!flac_process_single(flacDec))
|
if (!flac_process_single(flacDec))
|
||||||
@ -424,11 +424,11 @@ static int flac_decode_internal(struct decoder * decoder,
|
|||||||
break;
|
break;
|
||||||
if (dc.command == DECODE_COMMAND_SEEK) {
|
if (dc.command == DECODE_COMMAND_SEEK) {
|
||||||
FLAC__uint64 sampleToSeek = dc.seekWhere *
|
FLAC__uint64 sampleToSeek = dc.seekWhere *
|
||||||
dc.audioFormat.sampleRate + 0.5;
|
data.audio_format.sampleRate + 0.5;
|
||||||
if (flac_seek_absolute(flacDec, sampleToSeek)) {
|
if (flac_seek_absolute(flacDec, sampleToSeek)) {
|
||||||
decoder_clear(decoder);
|
decoder_clear(decoder);
|
||||||
data.time = ((float)sampleToSeek) /
|
data.time = ((float)sampleToSeek) /
|
||||||
dc.audioFormat.sampleRate;
|
data.audio_format.sampleRate;
|
||||||
data.position = 0;
|
data.position = 0;
|
||||||
} else
|
} else
|
||||||
dc.seekError = 1;
|
dc.seekError = 1;
|
||||||
|
@ -162,6 +162,7 @@ static void mod_close(mod_Data * data)
|
|||||||
static int mod_decode(struct decoder * decoder, char *path)
|
static int mod_decode(struct decoder * decoder, char *path)
|
||||||
{
|
{
|
||||||
mod_Data *data;
|
mod_Data *data;
|
||||||
|
AudioFormat audio_format;
|
||||||
float total_time = 0.0;
|
float total_time = 0.0;
|
||||||
int ret;
|
int ret;
|
||||||
float secPerByte;
|
float secPerByte;
|
||||||
@ -176,16 +177,16 @@ static int mod_decode(struct decoder * decoder, char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dc.totalTime = 0;
|
dc.totalTime = 0;
|
||||||
dc.audioFormat.bits = 16;
|
audio_format.bits = 16;
|
||||||
dc.audioFormat.sampleRate = 44100;
|
audio_format.sampleRate = 44100;
|
||||||
dc.audioFormat.channels = 2;
|
audio_format.channels = 2;
|
||||||
getOutputAudioFormat(&(dc.audioFormat), &(ob.audioFormat));
|
|
||||||
|
|
||||||
secPerByte =
|
secPerByte =
|
||||||
1.0 / ((dc.audioFormat.bits * dc.audioFormat.channels / 8.0) *
|
1.0 / ((audio_format.bits * audio_format.channels / 8.0) *
|
||||||
(float)dc.audioFormat.sampleRate);
|
(float)audio_format.sampleRate);
|
||||||
|
|
||||||
|
decoder_initialized(decoder, &audio_format);
|
||||||
|
|
||||||
decoder_initialized(decoder);
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (dc.command == DECODE_COMMAND_SEEK) {
|
if (dc.command == DECODE_COMMAND_SEEK) {
|
||||||
dc.seekError = 1;
|
dc.seekError = 1;
|
||||||
|
@ -1021,6 +1021,7 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream)
|
|||||||
mp3DecodeData data;
|
mp3DecodeData data;
|
||||||
MpdTag *tag = NULL;
|
MpdTag *tag = NULL;
|
||||||
ReplayGainInfo *replayGainInfo = NULL;
|
ReplayGainInfo *replayGainInfo = NULL;
|
||||||
|
AudioFormat audio_format;
|
||||||
|
|
||||||
if (openMp3FromInputStream(inStream, &data, &tag, &replayGainInfo) <
|
if (openMp3FromInputStream(inStream, &data, &tag, &replayGainInfo) <
|
||||||
0) {
|
0) {
|
||||||
@ -1032,8 +1033,7 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
initAudioFormatFromMp3DecodeData(&data, &(dc.audioFormat));
|
initAudioFormatFromMp3DecodeData(&data, &audio_format);
|
||||||
getOutputAudioFormat(&(dc.audioFormat), &(ob.audioFormat));
|
|
||||||
|
|
||||||
dc.totalTime = data.totalTime;
|
dc.totalTime = data.totalTime;
|
||||||
|
|
||||||
@ -1062,7 +1062,7 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream)
|
|||||||
freeMpdTag(tag);
|
freeMpdTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
decoder_initialized(decoder);
|
decoder_initialized(decoder, &audio_format);
|
||||||
|
|
||||||
while (mp3Read(&data, decoder, &replayGainInfo) != DECODE_BREAK) ;
|
while (mp3Read(&data, decoder, &replayGainInfo) != DECODE_BREAK) ;
|
||||||
/* send last little bit if not DECODE_COMMAND_STOP */
|
/* send last little bit if not DECODE_COMMAND_STOP */
|
||||||
|
@ -88,6 +88,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
faacDecHandle decoder;
|
faacDecHandle decoder;
|
||||||
faacDecFrameInfo frameInfo;
|
faacDecFrameInfo frameInfo;
|
||||||
faacDecConfigurationPtr config;
|
faacDecConfigurationPtr config;
|
||||||
|
AudioFormat audio_format;
|
||||||
unsigned char *mp4Buffer;
|
unsigned char *mp4Buffer;
|
||||||
unsigned int mp4BufferSize;
|
unsigned int mp4BufferSize;
|
||||||
uint32_t sampleRate;
|
uint32_t sampleRate;
|
||||||
@ -139,7 +140,7 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
#endif
|
#endif
|
||||||
faacDecSetConfiguration(decoder, config);
|
faacDecSetConfiguration(decoder, config);
|
||||||
|
|
||||||
dc.audioFormat.bits = 16;
|
audio_format.bits = 16;
|
||||||
|
|
||||||
mp4Buffer = NULL;
|
mp4Buffer = NULL;
|
||||||
mp4BufferSize = 0;
|
mp4BufferSize = 0;
|
||||||
@ -154,8 +155,8 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.audioFormat.sampleRate = sampleRate;
|
audio_format.sampleRate = sampleRate;
|
||||||
dc.audioFormat.channels = channels;
|
audio_format.channels = channels;
|
||||||
file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track);
|
file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track);
|
||||||
scale = mp4ff_time_scale(mp4fh, track);
|
scale = mp4ff_time_scale(mp4fh, track);
|
||||||
|
|
||||||
@ -245,11 +246,9 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE
|
#ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE
|
||||||
scale = frameInfo.samplerate;
|
scale = frameInfo.samplerate;
|
||||||
#endif
|
#endif
|
||||||
dc.audioFormat.sampleRate = scale;
|
audio_format.sampleRate = scale;
|
||||||
dc.audioFormat.channels = frameInfo.channels;
|
audio_format.channels = frameInfo.channels;
|
||||||
getOutputAudioFormat(&(dc.audioFormat),
|
decoder_initialized(mpd_decoder, &audio_format);
|
||||||
&(ob.audioFormat));
|
|
||||||
decoder_initialized(mpd_decoder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channels * (unsigned long)(dur + offset) > frameInfo.samples) {
|
if (channels * (unsigned long)(dur + offset) > frameInfo.samples) {
|
||||||
|
@ -111,6 +111,7 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
mpc_decoder decoder;
|
mpc_decoder decoder;
|
||||||
mpc_reader reader;
|
mpc_reader reader;
|
||||||
mpc_streaminfo info;
|
mpc_streaminfo info;
|
||||||
|
AudioFormat audio_format;
|
||||||
|
|
||||||
MpcCallbackData data;
|
MpcCallbackData data;
|
||||||
|
|
||||||
@ -161,11 +162,9 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
|
|
||||||
dc.totalTime = mpc_streaminfo_get_length(&info);
|
dc.totalTime = mpc_streaminfo_get_length(&info);
|
||||||
|
|
||||||
dc.audioFormat.bits = 16;
|
audio_format.bits = 16;
|
||||||
dc.audioFormat.channels = info.channels;
|
audio_format.channels = info.channels;
|
||||||
dc.audioFormat.sampleRate = info.sample_freq;
|
audio_format.sampleRate = info.sample_freq;
|
||||||
|
|
||||||
getOutputAudioFormat(&(dc.audioFormat), &(ob.audioFormat));
|
|
||||||
|
|
||||||
replayGainInfo = newReplayGainInfo();
|
replayGainInfo = newReplayGainInfo();
|
||||||
replayGainInfo->albumGain = info.gain_album * 0.01;
|
replayGainInfo->albumGain = info.gain_album * 0.01;
|
||||||
@ -173,11 +172,11 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
replayGainInfo->trackGain = info.gain_title * 0.01;
|
replayGainInfo->trackGain = info.gain_title * 0.01;
|
||||||
replayGainInfo->trackPeak = info.peak_title / 32767.0;
|
replayGainInfo->trackPeak = info.peak_title / 32767.0;
|
||||||
|
|
||||||
decoder_initialized(mpd_decoder);
|
decoder_initialized(mpd_decoder, &audio_format);
|
||||||
|
|
||||||
while (!eof) {
|
while (!eof) {
|
||||||
if (dc.command == DECODE_COMMAND_SEEK) {
|
if (dc.command == DECODE_COMMAND_SEEK) {
|
||||||
samplePos = dc.seekWhere * dc.audioFormat.sampleRate;
|
samplePos = dc.seekWhere * audio_format.sampleRate;
|
||||||
if (mpc_decoder_seek_sample(&decoder, samplePos)) {
|
if (mpc_decoder_seek_sample(&decoder, samplePos)) {
|
||||||
decoder_clear(mpd_decoder);
|
decoder_clear(mpd_decoder);
|
||||||
s16 = (mpd_sint16 *) chunk;
|
s16 = (mpd_sint16 *) chunk;
|
||||||
@ -210,10 +209,10 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
|
|
||||||
if (chunkpos >= MPC_CHUNK_SIZE) {
|
if (chunkpos >= MPC_CHUNK_SIZE) {
|
||||||
total_time = ((float)samplePos) /
|
total_time = ((float)samplePos) /
|
||||||
dc.audioFormat.sampleRate;
|
audio_format.sampleRate;
|
||||||
|
|
||||||
bitRate = vbrUpdateBits *
|
bitRate = vbrUpdateBits *
|
||||||
dc.audioFormat.sampleRate / 1152 / 1000;
|
audio_format.sampleRate / 1152 / 1000;
|
||||||
|
|
||||||
decoder_data(mpd_decoder, inStream,
|
decoder_data(mpd_decoder, inStream,
|
||||||
inStream->seekable,
|
inStream->seekable,
|
||||||
@ -232,10 +231,10 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dc.command != DECODE_COMMAND_STOP && chunkpos > 0) {
|
if (dc.command != DECODE_COMMAND_STOP && chunkpos > 0) {
|
||||||
total_time = ((float)samplePos) / dc.audioFormat.sampleRate;
|
total_time = ((float)samplePos) / audio_format.sampleRate;
|
||||||
|
|
||||||
bitRate =
|
bitRate =
|
||||||
vbrUpdateBits * dc.audioFormat.sampleRate / 1152 / 1000;
|
vbrUpdateBits * audio_format.sampleRate / 1152 / 1000;
|
||||||
|
|
||||||
decoder_data(mpd_decoder, NULL, inStream->seekable,
|
decoder_data(mpd_decoder, NULL, inStream->seekable,
|
||||||
chunk, chunkpos, total_time, bitRate,
|
chunk, chunkpos, total_time, bitRate,
|
||||||
|
@ -188,7 +188,7 @@ static FLAC__StreamDecoderWriteStatus oggflacWrite(const
|
|||||||
c_chan++) {
|
c_chan++) {
|
||||||
u16 = buf[c_chan][c_samp];
|
u16 = buf[c_chan][c_samp];
|
||||||
uc = (unsigned char *)&u16;
|
uc = (unsigned char *)&u16;
|
||||||
for (i = 0; i < (dc.audioFormat.bits / 8); i++) {
|
for (i = 0; i < (data->audio_format.bits / 8); i++) {
|
||||||
if (data->chunk_length >= FLAC_CHUNK_SIZE) {
|
if (data->chunk_length >= FLAC_CHUNK_SIZE) {
|
||||||
if (flacSendChunk(data) < 0) {
|
if (flacSendChunk(data) < 0) {
|
||||||
return
|
return
|
||||||
@ -345,7 +345,7 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
decoder_initialized(mpd_decoder);
|
decoder_initialized(mpd_decoder, &data.audio_format);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
OggFLAC__seekable_stream_decoder_process_single(decoder);
|
OggFLAC__seekable_stream_decoder_process_single(decoder);
|
||||||
@ -353,14 +353,14 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
|||||||
OggFLAC__SEEKABLE_STREAM_DECODER_OK) {
|
OggFLAC__SEEKABLE_STREAM_DECODER_OK) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (dc.command == DECODE_COMMAND_SEEK) {
|
if (dc->command == DECODE_COMMAND_SEEK) {
|
||||||
FLAC__uint64 sampleToSeek = dc.seekWhere *
|
FLAC__uint64 sampleToSeek = dc->seekWhere *
|
||||||
dc.audioFormat.sampleRate + 0.5;
|
data.audio_format.sampleRate + 0.5;
|
||||||
if (OggFLAC__seekable_stream_decoder_seek_absolute
|
if (OggFLAC__seekable_stream_decoder_seek_absolute
|
||||||
(decoder, sampleToSeek)) {
|
(decoder, sampleToSeek)) {
|
||||||
decoder_clear(mpd_decoder);
|
decoder_clear(mpd_decoder);
|
||||||
data.time = ((float)sampleToSeek) /
|
data.time = ((float)sampleToSeek) /
|
||||||
dc.audioFormat.sampleRate;
|
data.audio_format.sampleRate;
|
||||||
data.position = 0;
|
data.position = 0;
|
||||||
} else
|
} else
|
||||||
dc.seekError = 1;
|
dc.seekError = 1;
|
||||||
|
@ -215,6 +215,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
|
|||||||
OggVorbis_File vf;
|
OggVorbis_File vf;
|
||||||
ov_callbacks callbacks;
|
ov_callbacks callbacks;
|
||||||
OggCallbackData data;
|
OggCallbackData data;
|
||||||
|
AudioFormat audio_format;
|
||||||
int current_section;
|
int current_section;
|
||||||
int prev_section = -1;
|
int prev_section = -1;
|
||||||
long ret;
|
long ret;
|
||||||
@ -264,7 +265,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
|
|||||||
dc.totalTime = ov_time_total(&vf, -1);
|
dc.totalTime = ov_time_total(&vf, -1);
|
||||||
if (dc.totalTime < 0)
|
if (dc.totalTime < 0)
|
||||||
dc.totalTime = 0;
|
dc.totalTime = 0;
|
||||||
dc.audioFormat.bits = 16;
|
audio_format.bits = 16;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (dc.command == DECODE_COMMAND_SEEK) {
|
if (dc.command == DECODE_COMMAND_SEEK) {
|
||||||
@ -281,12 +282,10 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
|
|||||||
if (current_section != prev_section) {
|
if (current_section != prev_section) {
|
||||||
/*printf("new song!\n"); */
|
/*printf("new song!\n"); */
|
||||||
vorbis_info *vi = ov_info(&vf, -1);
|
vorbis_info *vi = ov_info(&vf, -1);
|
||||||
dc.audioFormat.channels = vi->channels;
|
audio_format.channels = vi->channels;
|
||||||
dc.audioFormat.sampleRate = vi->rate;
|
audio_format.sampleRate = vi->rate;
|
||||||
if (dc.state == DECODE_STATE_START) {
|
if (dc.state == DECODE_STATE_START) {
|
||||||
getOutputAudioFormat(&(dc.audioFormat),
|
decoder_initialized(decoder, &audio_format);
|
||||||
&(ob.audioFormat));
|
|
||||||
decoder_initialized(decoder);
|
|
||||||
}
|
}
|
||||||
comments = ov_comment(&vf, -1)->user_comments;
|
comments = ov_comment(&vf, -1)->user_comments;
|
||||||
putOggCommentsIntoOutputBuffer(inStream->metaName,
|
putOggCommentsIntoOutputBuffer(inStream->metaName,
|
||||||
@ -312,7 +311,7 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
|
|||||||
decoder_data(decoder, inStream,
|
decoder_data(decoder, inStream,
|
||||||
inStream->seekable,
|
inStream->seekable,
|
||||||
chunk, chunkpos,
|
chunk, chunkpos,
|
||||||
ov_pcm_tell(&vf) / dc.audioFormat.sampleRate,
|
ov_pcm_tell(&vf) / audio_format.sampleRate,
|
||||||
bitRate, replayGainInfo);
|
bitRate, replayGainInfo);
|
||||||
chunkpos = 0;
|
chunkpos = 0;
|
||||||
if (dc.command == DECODE_COMMAND_STOP)
|
if (dc.command == DECODE_COMMAND_STOP)
|
||||||
|
@ -128,6 +128,7 @@ static void wavpack_decode(struct decoder * decoder,
|
|||||||
WavpackContext *wpc, int canseek,
|
WavpackContext *wpc, int canseek,
|
||||||
ReplayGainInfo *replayGainInfo)
|
ReplayGainInfo *replayGainInfo)
|
||||||
{
|
{
|
||||||
|
AudioFormat audio_format;
|
||||||
void (*format_samples)(int Bps, void *buffer, uint32_t samcnt);
|
void (*format_samples)(int Bps, void *buffer, uint32_t samcnt);
|
||||||
char chunk[CHUNK_SIZE];
|
char chunk[CHUNK_SIZE];
|
||||||
float file_time;
|
float file_time;
|
||||||
@ -136,12 +137,12 @@ static void wavpack_decode(struct decoder * decoder,
|
|||||||
int position, outsamplesize;
|
int position, outsamplesize;
|
||||||
int Bps;
|
int Bps;
|
||||||
|
|
||||||
dc.audioFormat.sampleRate = WavpackGetSampleRate(wpc);
|
audio_format.sampleRate = WavpackGetSampleRate(wpc);
|
||||||
dc.audioFormat.channels = WavpackGetReducedChannels(wpc);
|
audio_format.channels = WavpackGetReducedChannels(wpc);
|
||||||
dc.audioFormat.bits = WavpackGetBitsPerSample(wpc);
|
audio_format.bits = WavpackGetBitsPerSample(wpc);
|
||||||
|
|
||||||
if (dc.audioFormat.bits > 16)
|
if (audio_format.bits > 16)
|
||||||
dc.audioFormat.bits = 16;
|
audio_format.bits = 16;
|
||||||
|
|
||||||
if ((WavpackGetMode(wpc) & MODE_FLOAT) == MODE_FLOAT)
|
if ((WavpackGetMode(wpc) & MODE_FLOAT) == MODE_FLOAT)
|
||||||
format_samples = format_samples_float;
|
format_samples = format_samples_float;
|
||||||
@ -159,16 +160,14 @@ static void wavpack_decode(struct decoder * decoder,
|
|||||||
outsamplesize = Bps;
|
outsamplesize = Bps;
|
||||||
if (outsamplesize > 2)
|
if (outsamplesize > 2)
|
||||||
outsamplesize = 2;
|
outsamplesize = 2;
|
||||||
outsamplesize *= dc.audioFormat.channels;
|
outsamplesize *= audio_format.channels;
|
||||||
|
|
||||||
samplesreq = sizeof(chunk) / (4 * dc.audioFormat.channels);
|
samplesreq = sizeof(chunk) / (4 * audio_format.channels);
|
||||||
|
|
||||||
getOutputAudioFormat(&(dc.audioFormat), &(ob.audioFormat));
|
dc.totalTime = (float)allsamples / audio_format.sampleRate;
|
||||||
|
|
||||||
dc.totalTime = (float)allsamples / dc.audioFormat.sampleRate;
|
|
||||||
dc.seekable = canseek;
|
dc.seekable = canseek;
|
||||||
|
|
||||||
decoder_initialized(decoder);
|
decoder_initialized(decoder, &audio_format);
|
||||||
|
|
||||||
position = 0;
|
position = 0;
|
||||||
|
|
||||||
@ -180,7 +179,7 @@ static void wavpack_decode(struct decoder * decoder,
|
|||||||
decoder_clear(decoder);
|
decoder_clear(decoder);
|
||||||
|
|
||||||
where = dc.seekWhere *
|
where = dc.seekWhere *
|
||||||
dc.audioFormat.sampleRate;
|
audio_format.sampleRate;
|
||||||
if (WavpackSeekSample(wpc, where))
|
if (WavpackSeekSample(wpc, where))
|
||||||
position = where;
|
position = where;
|
||||||
else
|
else
|
||||||
@ -202,10 +201,10 @@ static void wavpack_decode(struct decoder * decoder,
|
|||||||
1000 + 0.5);
|
1000 + 0.5);
|
||||||
position += samplesgot;
|
position += samplesgot;
|
||||||
file_time = (float)position /
|
file_time = (float)position /
|
||||||
dc.audioFormat.sampleRate;
|
audio_format.sampleRate;
|
||||||
|
|
||||||
format_samples(Bps, chunk,
|
format_samples(Bps, chunk,
|
||||||
samplesgot * dc.audioFormat.channels);
|
samplesgot * audio_format.channels);
|
||||||
|
|
||||||
decoder_data(decoder, NULL, 0, chunk,
|
decoder_data(decoder, NULL, 0, chunk,
|
||||||
samplesgot * outsamplesize,
|
samplesgot * outsamplesize,
|
||||||
|
Loading…
Reference in New Issue
Block a user