forked from len0rd/rockbox
Cosmetic change - correct the indenting to the standard Rockbox four spaces
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7709 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e85bbad753
commit
b08a942951
1 changed files with 129 additions and 129 deletions
|
@ -35,150 +35,150 @@ struct codec_api* ci;
|
||||||
/* this is the codec entry point */
|
/* this is the codec entry point */
|
||||||
enum codec_status codec_start(struct codec_api* api)
|
enum codec_status codec_start(struct codec_api* api)
|
||||||
{
|
{
|
||||||
size_t n;
|
size_t n;
|
||||||
static demux_res_t demux_res;
|
static demux_res_t demux_res;
|
||||||
stream_t input_stream;
|
stream_t input_stream;
|
||||||
uint32_t samplesdone;
|
uint32_t samplesdone;
|
||||||
uint32_t elapsedtime;
|
uint32_t elapsedtime;
|
||||||
uint32_t sample_duration;
|
uint32_t sample_duration;
|
||||||
uint32_t sample_byte_size;
|
uint32_t sample_byte_size;
|
||||||
int samplesdecoded;
|
int samplesdecoded;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned char* buffer;
|
unsigned char* buffer;
|
||||||
static NeAACDecFrameInfo frameInfo;
|
static NeAACDecFrameInfo frameInfo;
|
||||||
NeAACDecHandle hDecoder;
|
NeAACDecHandle hDecoder;
|
||||||
int err;
|
int err;
|
||||||
int16_t* decodedbuffer;
|
int16_t* decodedbuffer;
|
||||||
|
|
||||||
/* Generic codec initialisation */
|
/* Generic codec initialisation */
|
||||||
TEST_CODEC_API(api);
|
TEST_CODEC_API(api);
|
||||||
|
|
||||||
rb = api;
|
rb = api;
|
||||||
ci = (struct codec_api*)api;
|
ci = (struct codec_api*)api;
|
||||||
|
|
||||||
#ifndef SIMULATOR
|
#ifndef SIMULATOR
|
||||||
rb->memcpy(iramstart, iramcopy, iramend-iramstart);
|
rb->memcpy(iramstart, iramcopy, iramend-iramstart);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ci->configure(CODEC_SET_FILEBUF_LIMIT, (int *)(1024*1024*2));
|
ci->configure(CODEC_SET_FILEBUF_LIMIT, (int *)(1024*1024*2));
|
||||||
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*16));
|
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*16));
|
||||||
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512));
|
||||||
|
|
||||||
ci->configure(CODEC_DSP_ENABLE, (bool *)true);
|
ci->configure(CODEC_DSP_ENABLE, (bool *)true);
|
||||||
ci->configure(DSP_DITHER, (bool *)false);
|
ci->configure(DSP_DITHER, (bool *)false);
|
||||||
ci->configure(DSP_SET_STEREO_MODE, (int *)STEREO_INTERLEAVED);
|
ci->configure(DSP_SET_STEREO_MODE, (int *)STEREO_INTERLEAVED);
|
||||||
ci->configure(DSP_SET_SAMPLE_DEPTH, (int *)(16));
|
ci->configure(DSP_SET_SAMPLE_DEPTH, (int *)(16));
|
||||||
|
|
||||||
next_track:
|
|
||||||
|
|
||||||
if (codec_init(api)) {
|
next_track:
|
||||||
LOGF("FAAD: Error initialising codec\n");
|
|
||||||
return CODEC_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!rb->taginfo_ready)
|
if (codec_init(api)) {
|
||||||
rb->yield();
|
LOGF("FAAD: Error initialising codec\n");
|
||||||
|
return CODEC_ERROR;
|
||||||
ci->configure(DSP_SET_FREQUENCY, (long *)(rb->id3->frequency));
|
|
||||||
|
|
||||||
stream_create(&input_stream,ci);
|
|
||||||
|
|
||||||
/* if qtmovie_read returns successfully, the stream is up to
|
|
||||||
* the movie data, which can be used directly by the decoder */
|
|
||||||
if (!qtmovie_read(&input_stream, &demux_res)) {
|
|
||||||
LOGF("FAAD: Error initialising file\n");
|
|
||||||
return CODEC_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initialise the sound converter */
|
|
||||||
hDecoder = NULL;
|
|
||||||
hDecoder = NeAACDecOpen();
|
|
||||||
|
|
||||||
if (!hDecoder) {
|
|
||||||
LOGF("FAAD: Error opening decoder\n");
|
|
||||||
return CODEC_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
NeAACDecConfigurationPtr conf = NeAACDecGetCurrentConfiguration(hDecoder);
|
|
||||||
conf->outputFormat = 1; // 16-bit integers
|
|
||||||
NeAACDecSetConfiguration(hDecoder, conf);
|
|
||||||
|
|
||||||
unsigned long s=0;
|
|
||||||
unsigned char c=0;
|
|
||||||
|
|
||||||
err = NeAACDecInit2(hDecoder, demux_res.codecdata,demux_res.codecdata_len, &s, &c);
|
|
||||||
if (err) {
|
|
||||||
LOGF("FAAD: Error initialising decoder: %d, type=%d\n", err,hDecoder->object_type);
|
|
||||||
return CODEC_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
ci->id3->frequency=s;
|
|
||||||
|
|
||||||
i=0;
|
|
||||||
samplesdone=0;
|
|
||||||
/* The main decoding loop */
|
|
||||||
while (i < demux_res.num_sample_byte_sizes) {
|
|
||||||
rb->yield();
|
|
||||||
if (ci->stop_codec || ci->reload_codec) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deal with any pending seek requests */
|
while (!rb->taginfo_ready)
|
||||||
if (ci->seek_time) {
|
rb->yield();
|
||||||
if (alac_seek(&demux_res,&input_stream,
|
|
||||||
(ci->seek_time/10) * (ci->id3->frequency/100),
|
ci->configure(DSP_SET_FREQUENCY, (long *)(rb->id3->frequency));
|
||||||
&samplesdone, &i)) {
|
|
||||||
|
stream_create(&input_stream,ci);
|
||||||
|
|
||||||
|
/* if qtmovie_read returns successfully, the stream is up to
|
||||||
|
* the movie data, which can be used directly by the decoder */
|
||||||
|
if (!qtmovie_read(&input_stream, &demux_res)) {
|
||||||
|
LOGF("FAAD: Error initialising file\n");
|
||||||
|
return CODEC_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* initialise the sound converter */
|
||||||
|
hDecoder = NULL;
|
||||||
|
hDecoder = NeAACDecOpen();
|
||||||
|
|
||||||
|
if (!hDecoder) {
|
||||||
|
LOGF("FAAD: Error opening decoder\n");
|
||||||
|
return CODEC_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
NeAACDecConfigurationPtr conf = NeAACDecGetCurrentConfiguration(hDecoder);
|
||||||
|
conf->outputFormat = 1; // 16-bit integers
|
||||||
|
NeAACDecSetConfiguration(hDecoder, conf);
|
||||||
|
|
||||||
|
unsigned long s=0;
|
||||||
|
unsigned char c=0;
|
||||||
|
|
||||||
|
err = NeAACDecInit2(hDecoder, demux_res.codecdata,demux_res.codecdata_len, &s, &c);
|
||||||
|
if (err) {
|
||||||
|
LOGF("FAAD: Error initialising decoder: %d, type=%d\n", err,hDecoder->object_type);
|
||||||
|
return CODEC_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ci->id3->frequency=s;
|
||||||
|
|
||||||
|
i=0;
|
||||||
|
samplesdone=0;
|
||||||
|
/* The main decoding loop */
|
||||||
|
while (i < demux_res.num_sample_byte_sizes) {
|
||||||
|
rb->yield();
|
||||||
|
if (ci->stop_codec || ci->reload_codec) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deal with any pending seek requests */
|
||||||
|
if (ci->seek_time) {
|
||||||
|
if (alac_seek(&demux_res,&input_stream,
|
||||||
|
(ci->seek_time/10) * (ci->id3->frequency/100),
|
||||||
|
&samplesdone, &i)) {
|
||||||
|
elapsedtime=(samplesdone*10)/(ci->id3->frequency/100);
|
||||||
|
ci->set_elapsed(elapsedtime);
|
||||||
|
}
|
||||||
|
ci->seek_time = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Lookup the length (in samples and bytes) of block i */
|
||||||
|
if (!get_sample_info(&demux_res, i, &sample_duration,
|
||||||
|
&sample_byte_size)) {
|
||||||
|
LOGF("AAC: Error in get_sample_info\n");
|
||||||
|
return CODEC_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Request the required number of bytes from the input buffer */
|
||||||
|
buffer=ci->request_buffer((long*)&n,sample_byte_size);
|
||||||
|
|
||||||
|
/* Decode one block - returned samples will be host-endian */
|
||||||
|
rb->yield();
|
||||||
|
decodedbuffer = NeAACDecDecode(hDecoder, &frameInfo, buffer, n);
|
||||||
|
|
||||||
|
if (frameInfo.error > 0) {
|
||||||
|
LOGF("FAAD: decoding error \"%s\"\n", NeAACDecGetErrorMessage(frameInfo.error));
|
||||||
|
return CODEC_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the number of decoded samples */
|
||||||
|
samplesdecoded=frameInfo.samples;
|
||||||
|
|
||||||
|
/* Advance codec buffer */
|
||||||
|
ci->advance_buffer(n);
|
||||||
|
|
||||||
|
/* Output the audio */
|
||||||
|
rb->yield();
|
||||||
|
while (!rb->pcmbuf_insert((char*)decodedbuffer, frameInfo.samples << 1))
|
||||||
|
rb->yield();
|
||||||
|
|
||||||
|
/* Update the elapsed-time indicator */
|
||||||
|
samplesdone+=sample_duration;
|
||||||
elapsedtime=(samplesdone*10)/(ci->id3->frequency/100);
|
elapsedtime=(samplesdone*10)/(ci->id3->frequency/100);
|
||||||
ci->set_elapsed(elapsedtime);
|
ci->set_elapsed(elapsedtime);
|
||||||
}
|
|
||||||
ci->seek_time = 0;
|
/* Keep track of current position - for resuming */
|
||||||
|
ci->set_offset(elapsedtime);
|
||||||
|
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lookup the length (in samples and bytes) of block i */
|
LOGF("AAC: Decoded %d samples\n",samplesdone);
|
||||||
if (!get_sample_info(&demux_res, i, &sample_duration,
|
|
||||||
&sample_byte_size)) {
|
|
||||||
LOGF("AAC: Error in get_sample_info\n");
|
|
||||||
return CODEC_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Request the required number of bytes from the input buffer */
|
if (ci->request_next_track())
|
||||||
buffer=ci->request_buffer((long*)&n,sample_byte_size);
|
goto next_track;
|
||||||
|
|
||||||
/* Decode one block - returned samples will be host-endian */
|
return CODEC_OK;
|
||||||
rb->yield();
|
|
||||||
decodedbuffer = NeAACDecDecode(hDecoder, &frameInfo, buffer, n);
|
|
||||||
|
|
||||||
if (frameInfo.error > 0) {
|
|
||||||
LOGF("FAAD: decoding error \"%s\"\n", NeAACDecGetErrorMessage(frameInfo.error));
|
|
||||||
return CODEC_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the number of decoded samples */
|
|
||||||
samplesdecoded=frameInfo.samples;
|
|
||||||
|
|
||||||
/* Advance codec buffer */
|
|
||||||
ci->advance_buffer(n);
|
|
||||||
|
|
||||||
/* Output the audio */
|
|
||||||
rb->yield();
|
|
||||||
while (!rb->pcmbuf_insert((char*)decodedbuffer, frameInfo.samples << 1))
|
|
||||||
rb->yield();
|
|
||||||
|
|
||||||
/* Update the elapsed-time indicator */
|
|
||||||
samplesdone+=sample_duration;
|
|
||||||
elapsedtime=(samplesdone*10)/(ci->id3->frequency/100);
|
|
||||||
ci->set_elapsed(elapsedtime);
|
|
||||||
|
|
||||||
/* Keep track of current position - for resuming */
|
|
||||||
ci->set_offset(elapsedtime);
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOGF("AAC: Decoded %d samples\n",samplesdone);
|
|
||||||
|
|
||||||
if (ci->request_next_track())
|
|
||||||
goto next_track;
|
|
||||||
|
|
||||||
return CODEC_OK;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue