added decoder_data()
Moved all of the player-waiting code to decoder_data(), to make OutputBuffer more generic.
This commit is contained in:
@@ -165,12 +165,11 @@ MpdTag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block,
|
||||
/* keep this inlined, this is just macro but prettier :) */
|
||||
static inline int flacSendChunk(FlacData * data)
|
||||
{
|
||||
if (ob_send(data->inStream,
|
||||
1, data->chunk,
|
||||
data->chunk_length, data->time,
|
||||
data->bitRate,
|
||||
data->replayGainInfo) ==
|
||||
OUTPUT_BUFFER_DC_STOP)
|
||||
if (decoder_data(data->decoder, data->inStream,
|
||||
1, data->chunk,
|
||||
data->chunk_length, data->time,
|
||||
data->bitRate,
|
||||
data->replayGainInfo) == OUTPUT_BUFFER_DC_STOP)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -391,9 +391,9 @@ static int aac_decode(struct decoder * mpd_decoder, char *path)
|
||||
|
||||
sampleBufferLen = sampleCount * 2;
|
||||
|
||||
ob_send(NULL, 0, sampleBuffer,
|
||||
sampleBufferLen, file_time,
|
||||
bitRate, NULL);
|
||||
decoder_data(mpd_decoder, NULL, 0, sampleBuffer,
|
||||
sampleBufferLen, file_time,
|
||||
bitRate, NULL);
|
||||
if (dc.command == DECODE_COMMAND_SEEK) {
|
||||
dc.seekError = 1;
|
||||
dc_command_finished();
|
||||
|
||||
@@ -106,13 +106,13 @@ static int audiofile_decode(struct decoder * decoder, char *path)
|
||||
eof = 1;
|
||||
else {
|
||||
current += ret;
|
||||
ob_send(NULL,
|
||||
1,
|
||||
chunk, ret * fs,
|
||||
(float)current /
|
||||
(float)dc.audioFormat.
|
||||
sampleRate, bitRate,
|
||||
NULL);
|
||||
decoder_data(decoder, NULL,
|
||||
1,
|
||||
chunk, ret * fs,
|
||||
(float)current /
|
||||
(float)dc.audioFormat.
|
||||
sampleRate, bitRate,
|
||||
NULL);
|
||||
if (dc.command == DECODE_COMMAND_STOP)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -200,9 +200,9 @@ static int mod_decode(struct decoder * decoder, char *path)
|
||||
|
||||
ret = VC_WriteBytes(data->audio_buffer, MIKMOD_FRAME_SIZE);
|
||||
total_time += ret * secPerByte;
|
||||
ob_send(NULL, 0,
|
||||
(char *)data->audio_buffer, ret,
|
||||
total_time, 0, NULL);
|
||||
decoder_data(decoder, NULL, 0,
|
||||
(char *)data->audio_buffer, ret,
|
||||
total_time, 0, NULL);
|
||||
}
|
||||
|
||||
ob_flush();
|
||||
|
||||
@@ -812,7 +812,8 @@ static int openMp3FromInputStream(InputStream * inStream, mp3DecodeData * data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
|
||||
static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
|
||||
ReplayGainInfo ** replayGainInfo)
|
||||
{
|
||||
int samplesPerFrame;
|
||||
int samplesLeft;
|
||||
@@ -926,13 +927,13 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
|
||||
}
|
||||
|
||||
if (data->outputPtr >= data->outputBufferEnd) {
|
||||
ret = ob_send(data->inStream,
|
||||
data->inStream->seekable,
|
||||
data->outputBuffer,
|
||||
data->outputPtr - data->outputBuffer,
|
||||
data->elapsedTime,
|
||||
data->bitRate / 1000,
|
||||
(replayGainInfo != NULL) ? *replayGainInfo : NULL);
|
||||
ret = decoder_data(decoder, data->inStream,
|
||||
data->inStream->seekable,
|
||||
data->outputBuffer,
|
||||
data->outputPtr - data->outputBuffer,
|
||||
data->elapsedTime,
|
||||
data->bitRate / 1000,
|
||||
(replayGainInfo != NULL) ? *replayGainInfo : NULL);
|
||||
if (ret == OUTPUT_BUFFER_DC_STOP) {
|
||||
data->flush = 0;
|
||||
return DECODE_BREAK;
|
||||
@@ -1063,16 +1064,16 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream)
|
||||
|
||||
decoder_initialized(decoder);
|
||||
|
||||
while (mp3Read(&data, &replayGainInfo) != DECODE_BREAK) ;
|
||||
while (mp3Read(&data, decoder, &replayGainInfo) != DECODE_BREAK) ;
|
||||
/* send last little bit if not DECODE_COMMAND_STOP */
|
||||
if (dc.command != DECODE_COMMAND_STOP &&
|
||||
data.outputPtr != data.outputBuffer && data.flush) {
|
||||
ob_send(NULL,
|
||||
data.inStream->seekable,
|
||||
data.outputBuffer,
|
||||
data.outputPtr - data.outputBuffer,
|
||||
data.elapsedTime, data.bitRate / 1000,
|
||||
replayGainInfo);
|
||||
decoder_data(decoder, NULL,
|
||||
data.inStream->seekable,
|
||||
data.outputBuffer,
|
||||
data.outputPtr - data.outputBuffer,
|
||||
data.elapsedTime, data.bitRate / 1000,
|
||||
replayGainInfo);
|
||||
}
|
||||
|
||||
if (replayGainInfo)
|
||||
|
||||
@@ -270,9 +270,9 @@ static int mp4_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
||||
|
||||
sampleBuffer += offset * channels * 2;
|
||||
|
||||
ob_send(inStream, 1, sampleBuffer,
|
||||
sampleBufferLen, file_time,
|
||||
bitRate, NULL);
|
||||
decoder_data(mpd_decoder, inStream, 1, sampleBuffer,
|
||||
sampleBufferLen, file_time,
|
||||
bitRate, NULL);
|
||||
if (dc.command == DECODE_COMMAND_STOP) {
|
||||
eof = 1;
|
||||
break;
|
||||
|
||||
@@ -215,11 +215,11 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
||||
bitRate = vbrUpdateBits *
|
||||
dc.audioFormat.sampleRate / 1152 / 1000;
|
||||
|
||||
ob_send(inStream,
|
||||
inStream->seekable,
|
||||
chunk, chunkpos,
|
||||
total_time,
|
||||
bitRate, replayGainInfo);
|
||||
decoder_data(mpd_decoder, inStream,
|
||||
inStream->seekable,
|
||||
chunk, chunkpos,
|
||||
total_time,
|
||||
bitRate, replayGainInfo);
|
||||
|
||||
chunkpos = 0;
|
||||
s16 = (mpd_sint16 *) chunk;
|
||||
@@ -237,9 +237,9 @@ static int mpc_decode(struct decoder * mpd_decoder, InputStream * inStream)
|
||||
bitRate =
|
||||
vbrUpdateBits * dc.audioFormat.sampleRate / 1152 / 1000;
|
||||
|
||||
ob_send(NULL, inStream->seekable,
|
||||
chunk, chunkpos, total_time, bitRate,
|
||||
replayGainInfo);
|
||||
decoder_data(mpd_decoder, NULL, inStream->seekable,
|
||||
chunk, chunkpos, total_time, bitRate,
|
||||
replayGainInfo);
|
||||
}
|
||||
|
||||
ob_flush();
|
||||
|
||||
@@ -309,12 +309,11 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
|
||||
if ((test = ov_bitrate_instant(&vf)) > 0) {
|
||||
bitRate = test / 1000;
|
||||
}
|
||||
ob_send(inStream,
|
||||
inStream->seekable,
|
||||
chunk, chunkpos,
|
||||
ov_pcm_tell(&vf) /
|
||||
dc.audioFormat.sampleRate,
|
||||
bitRate, replayGainInfo);
|
||||
decoder_data(decoder, inStream,
|
||||
inStream->seekable,
|
||||
chunk, chunkpos,
|
||||
ov_pcm_tell(&vf) / dc.audioFormat.sampleRate,
|
||||
bitRate, replayGainInfo);
|
||||
chunkpos = 0;
|
||||
if (dc.command == DECODE_COMMAND_STOP)
|
||||
break;
|
||||
@@ -322,10 +321,10 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
|
||||
}
|
||||
|
||||
if (dc.command != DECODE_COMMAND_STOP && chunkpos > 0) {
|
||||
ob_send(NULL, inStream->seekable,
|
||||
chunk, chunkpos,
|
||||
ov_time_tell(&vf), bitRate,
|
||||
replayGainInfo);
|
||||
decoder_data(decoder, NULL, inStream->seekable,
|
||||
chunk, chunkpos,
|
||||
ov_time_tell(&vf), bitRate,
|
||||
replayGainInfo);
|
||||
}
|
||||
|
||||
if (replayGainInfo)
|
||||
|
||||
@@ -207,10 +207,10 @@ static void wavpack_decode(struct decoder * decoder,
|
||||
format_samples(Bps, chunk,
|
||||
samplesgot * dc.audioFormat.channels);
|
||||
|
||||
ob_send(NULL, 0, chunk,
|
||||
samplesgot * outsamplesize,
|
||||
file_time, bitrate,
|
||||
replayGainInfo);
|
||||
decoder_data(decoder, NULL, 0, chunk,
|
||||
samplesgot * outsamplesize,
|
||||
file_time, bitrate,
|
||||
replayGainInfo);
|
||||
}
|
||||
} while (samplesgot == samplesreq);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user