diff options
author | Brandon Low <lostlogic@rockbox.org> | 2006-04-22 14:40:13 +0000 |
---|---|---|
committer | Brandon Low <lostlogic@rockbox.org> | 2006-04-22 14:40:13 +0000 |
commit | f3bc1efc49826454a895c1c1f46fbe2cfd23f492 (patch) | |
tree | 676d501a9e75a9420f07a13f1d7fc1c5820b432a /apps/codecs | |
parent | b5991b27cafa8cc8bd2e86e04110beec34a587e0 (diff) | |
download | rockbox-f3bc1efc49826454a895c1c1f46fbe2cfd23f492.tar.gz rockbox-f3bc1efc49826454a895c1c1f46fbe2cfd23f492.zip |
First commit of reworking voice to be mroe stable on swcodec
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9758 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs')
-rw-r--r-- | apps/codecs/a52.c | 5 | ||||
-rw-r--r-- | apps/codecs/aac.c | 14 | ||||
-rw-r--r-- | apps/codecs/aiff.c | 24 | ||||
-rw-r--r-- | apps/codecs/alac.c | 10 | ||||
-rw-r--r-- | apps/codecs/flac.c | 11 | ||||
-rw-r--r-- | apps/codecs/mpa.c | 8 | ||||
-rw-r--r-- | apps/codecs/mpc.c | 14 | ||||
-rw-r--r-- | apps/codecs/shorten.c | 3 | ||||
-rw-r--r-- | apps/codecs/vorbis.c | 8 | ||||
-rw-r--r-- | apps/codecs/wav.c | 34 | ||||
-rw-r--r-- | apps/codecs/wavpack.c | 6 |
11 files changed, 69 insertions, 68 deletions
diff --git a/apps/codecs/a52.c b/apps/codecs/a52.c index 8ad9d37d33..71e0fda432 100644 --- a/apps/codecs/a52.c +++ b/apps/codecs/a52.c @@ -141,7 +141,6 @@ enum codec_status codec_start(struct codec_api *api) ci->memset(iedata, 0, iend - iedata); #endif - ci->configure(CODEC_DSP_ENABLE, (bool *)true); ci->configure(DSP_DITHER, (bool *)false); ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_NONINTERLEAVED); ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)28); @@ -185,9 +184,11 @@ next_track: a52_decode_data(filebuf, filebuf + n); ci->advance_buffer(n); } + retval = CODEC_OK; + if (ci->request_next_track()) goto next_track; - retval = CODEC_OK; + exit: a52_free(state); return retval; diff --git a/apps/codecs/aac.c b/apps/codecs/aac.c index 02d460651c..532082ff05 100644 --- a/apps/codecs/aac.c +++ b/apps/codecs/aac.c @@ -63,7 +63,6 @@ enum codec_status codec_start(struct codec_api* api) ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*16)); ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); - ci->configure(CODEC_DSP_ENABLE, (bool *)true); ci->configure(DSP_DITHER, (bool *)false); ci->configure(DSP_SET_STEREO_MODE, (int *)STEREO_NONINTERLEAVED); ci->configure(DSP_SET_SAMPLE_DEPTH, (int *)(29)); @@ -88,7 +87,7 @@ next_track: if (!qtmovie_read(&input_stream, &demux_res)) { LOGF("FAAD: Error initialising file\n"); err = CODEC_ERROR; - goto exit; + goto done; } /* initialise the sound converter */ @@ -98,7 +97,7 @@ next_track: if (!hDecoder) { LOGF("FAAD: Error opening decoder\n"); err = CODEC_ERROR; - goto exit; + goto done; } NeAACDecConfigurationPtr conf = NeAACDecGetCurrentConfiguration(hDecoder); @@ -112,7 +111,7 @@ next_track: if (err) { LOGF("FAAD: Error initialising decoder: %d, type=%d\n", err,hDecoder->object_type); err = CODEC_ERROR; - goto exit; + goto done; } ci->id3->frequency=s; @@ -142,7 +141,7 @@ next_track: &sample_byte_size)) { LOGF("AAC: Error in get_sample_info\n"); err = CODEC_ERROR; - goto exit; + goto done; } /* Request the required number of bytes from the input buffer */ @@ -156,7 +155,7 @@ next_track: if (frameInfo.error > 0) { LOGF("FAAD: decoding error \"%s\"\n", NeAACDecGetErrorMessage(frameInfo.error)); err = CODEC_ERROR; - goto exit; + goto done; } /* Get the number of decoded samples */ @@ -182,13 +181,14 @@ next_track: i++; } + err = CODEC_OK; +done: LOGF("AAC: Decoded %d samples\n",samplesdone); if (ci->request_next_track()) goto next_track; - err = CODEC_OK; exit: return err; } diff --git a/apps/codecs/aiff.c b/apps/codecs/aiff.c index 20d2dd3aa0..1e7adca220 100644 --- a/apps/codecs/aiff.c +++ b/apps/codecs/aiff.c @@ -98,11 +98,11 @@ next_track: buf = ci->request_buffer(&n, 1024); if (n < 44) { i = CODEC_ERROR; - goto exit; + goto done; } if ((memcmp(buf, "FORM", 4) != 0) || (memcmp(&buf[8], "AIFF", 4) != 0)) { i = CODEC_ERROR; - goto exit; + goto done; } buf += 12; @@ -117,7 +117,7 @@ next_track: if (i != 18) { DEBUGF("CODEC_ERROR: 'COMM' chunk size=%lu != 18\n", i); i = CODEC_ERROR; - goto exit; + goto done; } /* num_channels */ num_channels = ((buf[8]<<8)|buf[9]); @@ -130,7 +130,7 @@ next_track: if (buf[16] != 0x40) { DEBUGF("CODEC_ERROR: weird sampling rate (no @)\n", i); i = CODEC_ERROR; - goto exit; + goto done; } sample_rate = ((buf[18]<<24)|(buf[19]<<16)|(buf[20]<<8)|buf[21])+1; sample_rate = sample_rate >> (16 + 14 - buf[17]); @@ -140,7 +140,7 @@ next_track: if (sample_size == 0) { DEBUGF("CODEC_ERROR: unsupported chunk order\n"); i = CODEC_ERROR; - goto exit; + goto done; } /* offset2snd */ offset2snd = ((buf[8]<<8)|buf[9]); @@ -161,7 +161,7 @@ next_track: if (n < (i + 8)) { DEBUGF("CODEC_ERROR: AIFF header size > 1024\n"); i = CODEC_ERROR; - goto exit; + goto done; } n -= i + 8; } /* while 'SSND' */ @@ -169,21 +169,20 @@ next_track: if (num_channels == 0) { DEBUGF("CODEC_ERROR: 'COMM' chunk not found or 0-channels file\n"); i = CODEC_ERROR; - goto exit; + goto done; } if (numbytes == 0) { DEBUGF("CODEC_ERROR: 'SSND' chunk not found or has zero length\n"); i = CODEC_ERROR; - goto exit; + goto done; } if (sample_size > 24) { DEBUGF("CODEC_ERROR: PCM with more than 24 bits per sample " "is unsupported\n"); i = CODEC_ERROR; - goto exit; + goto done; } - ci->configure(CODEC_DSP_ENABLE, (bool *)true); ci->configure(DSP_SET_FREQUENCY, (long *)(ci->id3->frequency)); ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)28); @@ -194,7 +193,7 @@ next_track: } else { DEBUGF("CODEC_ERROR: more than 2 channels unsupported\n"); i = CODEC_ERROR; - goto exit; + goto done; } firstblockposn = 1024 - n; @@ -277,11 +276,12 @@ next_track: ci->set_elapsed(bytesdone*1000LL/avgbytespersec); } + i = CODEC_OK; +done: if (ci->request_next_track()) goto next_track; - i = CODEC_OK; exit: return i; } diff --git a/apps/codecs/alac.c b/apps/codecs/alac.c index 73f45fc213..01172eed2b 100644 --- a/apps/codecs/alac.c +++ b/apps/codecs/alac.c @@ -64,7 +64,6 @@ enum codec_status codec_start(struct codec_api* api) ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128)); - ci->configure(CODEC_DSP_ENABLE, (bool *)true); ci->configure(DSP_DITHER, (bool *)false); ci->configure(DSP_SET_STEREO_MODE, (int *)STEREO_NONINTERLEAVED); ci->configure(DSP_SET_SAMPLE_DEPTH, (int *)(ALAC_OUTPUT_DEPTH-1)); @@ -89,7 +88,7 @@ enum codec_status codec_start(struct codec_api* api) if (!qtmovie_read(&input_stream, &demux_res)) { LOGF("ALAC: Error initialising file\n"); retval = CODEC_ERROR; - goto exit; + goto done; } /* initialise the sound converter */ @@ -121,7 +120,7 @@ enum codec_status codec_start(struct codec_api* api) &sample_byte_size)) { LOGF("ALAC: Error in get_sample_info\n"); retval = CODEC_ERROR; - goto exit; + goto done; } /* Request the required number of bytes from the input buffer */ @@ -129,7 +128,7 @@ enum codec_status codec_start(struct codec_api* api) buffer=ci->request_buffer(&n,sample_byte_size); if (n!=sample_byte_size) { retval = CODEC_ERROR; - goto exit; + goto done; } /* Decode one block - returned samples will be host-endian */ @@ -156,13 +155,14 @@ enum codec_status codec_start(struct codec_api* api) i++; } + retval = CODEC_OK; +done: LOGF("ALAC: Decoded %d samples\n",samplesdone); if (ci->request_next_track()) goto next_track; - retval = CODEC_OK; exit: return retval; } diff --git a/apps/codecs/flac.c b/apps/codecs/flac.c index cc2ce636ab..5e392da8e7 100644 --- a/apps/codecs/flac.c +++ b/apps/codecs/flac.c @@ -224,7 +224,7 @@ enum codec_status codec_start(struct codec_api* api) { int8_t *buf; FLACContext fc; - uint32_t samplesdone; + uint32_t samplesdone = 0; uint32_t elapsedtime; size_t bytesleft; int consumed; @@ -244,7 +244,6 @@ enum codec_status codec_start(struct codec_api* api) ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128)); - ci->configure(CODEC_DSP_ENABLE, (bool *)true); ci->configure(DSP_DITHER, (bool *)false); ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_NONINTERLEAVED); ci->configure(DSP_SET_SAMPLE_DEPTH, (int *)(FLAC_OUTPUT_DEPTH-1)); @@ -260,7 +259,7 @@ enum codec_status codec_start(struct codec_api* api) if (!flac_init(&fc,ci->id3->first_frame_offset)) { LOGF("FLAC: Error initialising codec\n"); retval = CODEC_ERROR; - goto exit; + goto done; } while (!*ci->taginfo_ready) @@ -292,7 +291,7 @@ enum codec_status codec_start(struct codec_api* api) bytesleft,ci->yield)) < 0) { LOGF("FLAC: Frame %d, error %d\n",frame,res); retval = CODEC_ERROR; - goto exit; + goto done; } consumed=fc.gb.index/8; frame++; @@ -312,12 +311,14 @@ enum codec_status codec_start(struct codec_api* api) buf = ci->request_buffer(&bytesleft, MAX_FRAMESIZE); } + retval = CODEC_OK; + +done: LOGF("FLAC: Decoded %d samples\n",samplesdone); if (ci->request_next_track()) goto next_track; - retval = CODEC_OK; exit: return retval; } diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c index 7219095591..51038c5244 100644 --- a/apps/codecs/mpa.c +++ b/apps/codecs/mpa.c @@ -91,7 +91,7 @@ void init_mad(void) /* this is the codec entry point */ enum codec_status codec_start(struct codec_api *api) { - int status = CODEC_OK; + int status; size_t size; int file_end; int frame_skip; /* samples to skip current frame */ @@ -110,7 +110,6 @@ enum codec_status codec_start(struct codec_api *api) /* Create a decoder instance */ - ci->configure(CODEC_DSP_ENABLE, (bool *)true); ci->configure(DSP_DITHER, (bool *)false); ci->configure(DSP_SET_SAMPLE_DEPTH, (int *)(MAD_F_FRACBITS)); ci->configure(DSP_SET_CLIP_MIN, (int *)-MAD_F_ONE); @@ -122,6 +121,7 @@ enum codec_status codec_start(struct codec_api *api) * for gapless playback. * Reinitializing seems to be necessary to avoid playback quircks when seeking. */ next_track: + status = CODEC_OK; init_mad(); @@ -171,7 +171,7 @@ enum codec_status codec_start(struct codec_api *api) ci->id3->first_frame_offset; if (!ci->seek_buffer(newpos)) - goto next_track; + break; ci->seek_complete(); init_mad(); } @@ -192,7 +192,7 @@ enum codec_status codec_start(struct codec_api *api) break; /* Fill the buffer */ - if (stream.next_frame) + if (stream.next_frame && stream.next_frame != stream.this_frame) ci->advance_buffer_loc((void *)stream.next_frame); else ci->advance_buffer(size); diff --git a/apps/codecs/mpc.c b/apps/codecs/mpc.c index 4201b2591c..ee639012b9 100644 --- a/apps/codecs/mpc.c +++ b/apps/codecs/mpc.c @@ -90,7 +90,6 @@ enum codec_status codec_start(struct codec_api *api) ci->memset(iedata, 0, iend - iedata); #endif - ci->configure(CODEC_DSP_ENABLE, (bool *)true); ci->configure(DSP_DITHER, (bool *)false); ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)(28)); ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*16)); @@ -113,7 +112,7 @@ next_track: mpc_streaminfo_init(&info); if (mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) { retval = CODEC_ERROR; - goto exit; + goto done; } frequency = info.sample_freq; ci->configure(DSP_SET_FREQUENCY, (long *)(long)info.sample_freq); @@ -127,7 +126,7 @@ next_track: ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_MONO); else { retval = CODEC_ERROR; - goto exit; + goto done; } codec_set_replaygain(ci->id3); @@ -135,7 +134,7 @@ next_track: mpc_decoder_setup(&decoder, &reader); if (!mpc_decoder_initialize(&decoder, &info)) { retval = CODEC_ERROR; - goto exit; + goto done; } /* This is the decoding loop. */ @@ -171,7 +170,7 @@ next_track: ci->yield(); if (status == (unsigned)(-1)) { /* decode error */ retval = CODEC_ERROR; - goto exit; + goto done; } else { while (!ci->pcmbuf_insert_split(sample_buffer, sample_buffer + MPC_FRAME_LENGTH, @@ -181,11 +180,12 @@ next_track: ci->set_elapsed(samplesdone/(frequency/1000)); } } while (status != 0); - + retval = CODEC_OK; + +done: if (ci->request_next_track()) goto next_track; - retval = CODEC_OK; exit: return retval; } diff --git a/apps/codecs/shorten.c b/apps/codecs/shorten.c index 03a08021a7..8d62a12f03 100644 --- a/apps/codecs/shorten.c +++ b/apps/codecs/shorten.c @@ -63,7 +63,6 @@ enum codec_status codec_start(struct codec_api* api) ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*128)); - ci->configure(CODEC_DSP_ENABLE, (bool *)true); ci->configure(DSP_DITHER, (bool *)false); ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_NONINTERLEAVED); ci->configure(DSP_SET_SAMPLE_DEPTH, (int *)(SHN_OUTPUT_DEPTH-1)); @@ -146,7 +145,7 @@ seek_start: if (res == FN_ERROR) { LOGF("Shorten: shorten_decode_frames error (%d)\n", samplesdone); - return CODEC_ERROR; + break; } else { /* Insert decoded samples in pcmbuf */ if (nsamples) { diff --git a/apps/codecs/vorbis.c b/apps/codecs/vorbis.c index a9a274500c..1900364a89 100644 --- a/apps/codecs/vorbis.c +++ b/apps/codecs/vorbis.c @@ -129,7 +129,6 @@ enum codec_status codec_start(struct codec_api *api) rb->memset(iedata, 0, iend - iedata); #endif - rb->configure(CODEC_DSP_ENABLE, (bool *)true); rb->configure(DSP_DITHER, (bool *)false); rb->configure(DSP_SET_SAMPLE_DEPTH, (long *)24); rb->configure(DSP_SET_CLIP_MAX, (long *)((1 << 24) - 1)); @@ -194,7 +193,7 @@ next_track: } else { //rb->logf("ov_open: %d", error); error = CODEC_ERROR; - goto exit; + goto done; } if (rb->id3->offset) { @@ -224,7 +223,7 @@ next_track: if (current_section != previous_section) { if (!vorbis_set_codec_parameters(&vf)) { error = CODEC_ERROR; - goto exit; + goto done; } else { previous_section = current_section; } @@ -243,7 +242,9 @@ next_track: rb->set_elapsed(ov_time_tell(&vf)); } } + error = CODEC_OK; +done: if (rb->request_next_track()) { /* Clean things up for the next track */ vf.dataoffsets = NULL; @@ -255,7 +256,6 @@ next_track: goto next_track; } - error = CODEC_OK; exit: return error; } diff --git a/apps/codecs/wav.c b/apps/codecs/wav.c index c89d121c6a..d9be0a3420 100644 --- a/apps/codecs/wav.c +++ b/apps/codecs/wav.c @@ -242,7 +242,6 @@ enum codec_status codec_start(struct codec_api *api) ci->memset(iedata, 0, iend - iedata); #endif - ci->configure(CODEC_DSP_ENABLE, (bool *)true); ci->configure(DSP_SET_SAMPLE_DEPTH, (long *)28); ci->configure(CODEC_SET_FILEBUF_WATERMARK, (int *)(1024*512)); ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*256)); @@ -261,11 +260,11 @@ next_track: buf = ci->request_buffer(&n, 1024); if (n < 44) { i = CODEC_ERROR; - goto exit; + goto done; } if ((memcmp(buf, "RIFF", 4) != 0) || (memcmp(&buf[8], "WAVE", 4) != 0)) { i = CODEC_ERROR; - goto exit; + goto done; } buf += 12; @@ -281,7 +280,7 @@ next_track: if (i < 16) { DEBUGF("CODEC_ERROR: 'fmt ' chunk size=%lu < 16\n", i); i = CODEC_ERROR; - goto exit; + goto done; } /* wFormatTag */ formattag=buf[8]|(buf[9]<<8); @@ -309,7 +308,7 @@ next_track: DEBUGF("CODEC_ERROR: dvi_adpcm is missing " "SamplesPerBlock value\n"); i = CODEC_ERROR; - goto exit; + goto done; } samplesperblock = buf[26]|(buf[27]<<8); } else if (formattag == WAVE_FORMAT_EXTENSIBLE) { @@ -317,7 +316,7 @@ next_track: DEBUGF("CODEC_ERROR: WAVE_FORMAT_EXTENSIBLE is " "missing extension\n"); i = CODEC_ERROR; - goto exit; + goto done; } /* wValidBitsPerSample */ bitspersample = buf[26]|(buf[27]<<8); @@ -344,7 +343,7 @@ next_track: if (n < (i + 8)) { DEBUGF("CODEC_ERROR: WAVE header size > 1024\n"); i = CODEC_ERROR; - goto exit; + goto done; } n -= i + 8; } @@ -352,12 +351,12 @@ next_track: if (channels == 0) { DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-channels file\n"); i = CODEC_ERROR; - goto exit; + goto done; } if (numbytes == 0) { DEBUGF("CODEC_ERROR: 'data' chunk not found or has zero-length\n"); i = CODEC_ERROR; - goto exit; + goto done; } if (formattag != WAVE_FORMAT_PCM && totalsamples == 0) { /* This is non-fatal for some formats */ @@ -368,7 +367,7 @@ next_track: if (bitspersample != 8) { DEBUGF("CODEC_ERROR: alaw and mulaw must have 8 bitspersample\n"); i = CODEC_ERROR; - goto exit; + goto done; } bytespersample = channels; } @@ -376,13 +375,13 @@ next_track: && bitspersample != 4 && bitspersample != 3) { DEBUGF("CODEC_ERROR: dvi_adpcm must have 3 or 4 bitspersample\n"); i = CODEC_ERROR; - goto exit; + goto done; } if (formattag == WAVE_FORMAT_PCM && bitspersample > 32) { DEBUGF("CODEC_ERROR: pcm with more than 32 bitspersample " "is unsupported\n"); i = CODEC_ERROR; - goto exit; + goto done; } ci->configure(DSP_SET_FREQUENCY, (long *)(ci->id3->frequency)); @@ -393,7 +392,7 @@ next_track: } else { DEBUGF("CODEC_ERROR: more than 2 channels\n"); i = CODEC_ERROR; - goto exit; + goto done; } if (totalsamples == 0) { @@ -406,7 +405,7 @@ next_track: } else { DEBUGF("CODEC_ERROR: cannot compute totalsamples\n"); i = CODEC_ERROR; - goto exit; + goto done; } } @@ -505,14 +504,14 @@ next_track: samples + i*samplesperblock*channels, &decodedsize) != CODEC_OK) { i = CODEC_ERROR; - goto exit; + goto done; } } bufsize = nblocks*samplesperblock*channels*4; } else { DEBUGF("CODEC_ERROR: unsupported format %x\n", formattag); i = CODEC_ERROR; - goto exit; + goto done; } while (!ci->pcmbuf_insert((char *)samples, bufsize)) @@ -524,11 +523,12 @@ next_track: endofstream = 1; ci->set_elapsed(bytesdone*1000LL/avgbytespersec); } + i = CODEC_OK; +done: if (ci->request_next_track()) goto next_track; - i = CODEC_OK; exit: return i; } diff --git a/apps/codecs/wavpack.c b/apps/codecs/wavpack.c index f864aa3ec6..1871b46f67 100644 --- a/apps/codecs/wavpack.c +++ b/apps/codecs/wavpack.c @@ -75,7 +75,6 @@ enum codec_status codec_start(struct codec_api* api) while (!*ci->taginfo_ready && !ci->stop_codec) ci->sleep(1); - ci->configure(CODEC_DSP_ENABLE, (bool *)true); ci->configure(DSP_SET_FREQUENCY, (long *)(ci->id3->frequency)); codec_set_replaygain(ci->id3); @@ -84,7 +83,7 @@ enum codec_status codec_start(struct codec_api* api) if (!wpc) { retval = CODEC_ERROR; - goto exit; + goto done; } bps = WavpackGetBytesPerSample (wpc); @@ -143,11 +142,12 @@ enum codec_status codec_start(struct codec_api* api) ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10); ci->yield (); } + retval = CODEC_OK; +done: if (ci->request_next_track()) goto next_track; - retval = CODEC_OK; exit: return retval; } |