diff options
| author | Brandon Low <lostlogic@rockbox.org> | 2006-01-18 20:22:03 +0000 |
|---|---|---|
| committer | Brandon Low <lostlogic@rockbox.org> | 2006-01-18 20:22:03 +0000 |
| commit | 1060e447f83128a78dfaa8d59ba0baa642d15a4d (patch) | |
| tree | 9af0876f9c5d0ad5cb8bfc2adc7b1653c43013ff /apps/codecs/mpc.c | |
| parent | 3ded3cea756d8290372b808884837931a7e8cf1a (diff) | |
| download | rockbox-1060e447f83128a78dfaa8d59ba0baa642d15a4d.zip rockbox-1060e447f83128a78dfaa8d59ba0baa642d15a4d.tar.gz rockbox-1060e447f83128a78dfaa8d59ba0baa642d15a4d.tar.bz2 rockbox-1060e447f83128a78dfaa8d59ba0baa642d15a4d.tar.xz | |
Part of the profiling patch to use a consistent return path in all codecs to facilitate 'on exit' functionality
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8374 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/mpc.c')
| -rw-r--r-- | apps/codecs/mpc.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/apps/codecs/mpc.c b/apps/codecs/mpc.c index 1d1ed3a..67c0eaa 100644 --- a/apps/codecs/mpc.c +++ b/apps/codecs/mpc.c @@ -83,6 +83,7 @@ enum codec_status codec_start(struct codec_api *api) unsigned status; mpc_reader reader; mpc_streaminfo info; + int retval; #ifdef USE_IRAM ci->memcpy(iramstart, iramcopy, iramend - iramstart); @@ -111,13 +112,17 @@ enum codec_status codec_start(struct codec_api *api) reader.data = ci; next_track: - if (codec_init(api)) - return CODEC_ERROR; + if (codec_init(api)) { + retval = CODEC_ERROR; + goto exit; + } /* read file's streaminfo data */ mpc_streaminfo_init(&info); - if (mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) - return CODEC_ERROR; + if (mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) { + retval = CODEC_ERROR; + goto exit; + } frequency = info.sample_freq; ci->configure(DSP_SET_FREQUENCY, (long *)info.sample_freq); @@ -128,14 +133,18 @@ next_track: ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_NONINTERLEAVED); else if (info.channels == 1) ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_MONO); - else - return CODEC_ERROR; + else { + retval = CODEC_ERROR; + goto exit; + } codec_set_replaygain(ci->id3); /* instantiate a decoder with our file reader */ mpc_decoder_setup(&decoder, &reader); - if (!mpc_decoder_initialize(&decoder, &info)) - return CODEC_ERROR; + if (!mpc_decoder_initialize(&decoder, &info)) { + retval = CODEC_ERROR; + goto exit; + } /* This is the decoding loop. */ samplesdone = 0; @@ -169,7 +178,8 @@ next_track: status = mpc_decoder_decode(&decoder, sample_buffer, NULL, NULL); ci->yield(); if (status == (unsigned)(-1)) { /* decode error */ - return CODEC_ERROR; + retval = CODEC_ERROR; + goto exit; } else { while (!ci->pcmbuf_insert_split(sample_buffer, sample_buffer + MPC_FRAME_LENGTH, @@ -182,6 +192,9 @@ next_track: if (ci->request_next_track()) goto next_track; - return CODEC_OK; + + retval = CODEC_OK; +exit: + return retval; } |