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/mp3_enc.c | 59 ++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) (limited to 'apps/codecs/mp3_enc.c') diff --git a/apps/codecs/mp3_enc.c b/apps/codecs/mp3_enc.c index e7893fd14a..2f5528f74c 100644 --- a/apps/codecs/mp3_enc.c +++ b/apps/codecs/mp3_enc.c @@ -2584,45 +2584,46 @@ static bool enc_init(void) return true; } /* enc_init */ -enum codec_status codec_main(void) +/* this is the codec entry point */ +enum codec_status codec_main(enum codec_entry_call_reason reason) { - /* Generic codec initialisation */ - if (!enc_init()) - return CODEC_ERROR; + if (reason == CODEC_LOAD) { + if (!enc_init()) + return CODEC_ERROR; + } + else if (reason == CODEC_UNLOAD) { + /* reset parameters to initial state */ + ci->enc_set_parameters(NULL); + } + + return CODEC_OK; +} +/* this is called for each file to process */ +enum codec_status codec_run(void) +{ /* main encoding loop */ - while (!ci->stop_codec) + while(ci->get_command(NULL) != CODEC_ACTION_HALT) { - char *buffer; - - while ((buffer = ci->enc_get_pcm_data(pcm_chunk_size)) != NULL) - { - struct enc_chunk_hdr *chunk; - - if (ci->stop_codec) - break; + char *buffer = buffer = ci->enc_get_pcm_data(pcm_chunk_size); + struct enc_chunk_hdr *chunk; - chunk = ci->enc_get_chunk(); - chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk); + if(buffer == NULL) + continue; - encode_frame(buffer, chunk); + chunk = ci->enc_get_chunk(); + chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk); - if (chunk->num_pcm < samp_per_frame) - { - ci->enc_unget_pcm_data(pcm_chunk_size - chunk->num_pcm*4); - chunk->num_pcm = samp_per_frame; - } + encode_frame(buffer, chunk); - ci->enc_finish_chunk(); - - ci->yield(); + if (chunk->num_pcm < samp_per_frame) + { + ci->enc_unget_pcm_data(pcm_chunk_size - chunk->num_pcm*4); + chunk->num_pcm = samp_per_frame; } - ci->yield(); + ci->enc_finish_chunk(); } - /* reset parameters to initial state */ - ci->enc_set_parameters(NULL); - return CODEC_OK; -} /* codec_start */ +} -- cgit v1.2.3