From c537d5958e8b421ac4f9bef6c8b9e7425a6cf167 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Wed, 27 Apr 2011 03:08:23 +0000 Subject: Commit FS#12069 - Playback rework - first stages. Gives as thorough as possible a treatment of codec management, track change and metadata logic as possible while maintaining fairly narrow focus and not rewriting everything all at once. Please see the rockbox-dev mail archive on 2011-04-25 (Playback engine rework) for a more thorough manifest of what was addressed. Plugins and codecs become incompatible. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29785 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/tta.c | 61 +++++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 33 deletions(-) (limited to 'apps/codecs/tta.c') diff --git a/apps/codecs/tta.c b/apps/codecs/tta.c index 1d0846ea61..c75f2b0a57 100644 --- a/apps/codecs/tta.c +++ b/apps/codecs/tta.c @@ -34,36 +34,36 @@ CODEC_HEADER static int32_t samples[PCM_BUFFER_LENGTH * 2] IBSS_ATTR; /* this is the codec entry point */ -enum codec_status codec_main(void) +enum codec_status codec_main(enum codec_entry_call_reason reason) +{ + if (reason == CODEC_LOAD) { + /* Generic codec initialisation */ + ci->configure(DSP_SET_SAMPLE_DEPTH, TTA_OUTPUT_DEPTH - 1); + } + + return CODEC_OK; +} + +/* this is called for each file to process */ +enum codec_status codec_run(void) { tta_info info; - int status; unsigned int decodedsamples; int endofstream; int new_pos = 0; int sample_count; - - /* Generic codec initialisation */ - ci->configure(DSP_SET_SAMPLE_DEPTH, TTA_OUTPUT_DEPTH - 1); + intptr_t param; -next_track: - status = CODEC_OK; - if (codec_init()) { DEBUGF("codec_init() error\n"); - status = CODEC_ERROR; - goto exit; + return CODEC_ERROR; } - if (codec_wait_taginfo() != 0) - goto done; + ci->seek_buffer(0); if (set_tta_info(&info) < 0 || player_init(&info) < 0) - { - status = CODEC_ERROR; - goto exit; - } + return CODEC_ERROR; codec_set_replaygain(ci->id3); @@ -74,8 +74,8 @@ next_track: ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); } else { DEBUGF("CODEC_ERROR: more than 2 channels\n"); - status = CODEC_ERROR; - goto done; + player_stop(); + return CODEC_ERROR; } /* The main decoder loop */ @@ -88,31 +88,31 @@ next_track: new_pos = set_position(ci->id3->offset, TTA_SEEK_POS); if (new_pos >= 0) decodedsamples = new_pos; - ci->seek_complete(); } while (!endofstream) { - ci->yield(); - if (ci->stop_codec || ci->new_track) + enum codec_command_action action = ci->get_command(¶m); + + if (action == CODEC_ACTION_HALT) break; - if (ci->seek_time) + if (action == CODEC_ACTION_SEEK_TIME) { - new_pos = set_position(ci->seek_time / SEEK_STEP, TTA_SEEK_TIME); + new_pos = set_position(param / SEEK_STEP, TTA_SEEK_TIME); if (new_pos >= 0) { decodedsamples = new_pos; - ci->seek_complete(); } + + ci->set_elapsed((uint64_t)info.LENGTH * 1000 * decodedsamples / info.DATALENGTH); + ci->seek_complete(); } sample_count = get_samples(samples); if (sample_count < 0) - { - status = CODEC_ERROR; break; - } + ci->pcmbuf_insert(samples, NULL, sample_count); decodedsamples += sample_count; if (decodedsamples >= info.DATALENGTH) @@ -120,11 +120,6 @@ next_track: ci->set_elapsed((uint64_t)info.LENGTH * 1000 * decodedsamples / info.DATALENGTH); } -done: player_stop(); - if (ci->request_next_track()) - goto next_track; - -exit: - return status; + return CODEC_OK; } -- cgit v1.2.3