summaryrefslogtreecommitdiffstats
path: root/apps/codecs/mp3_enc.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-04-27 03:08:23 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-04-27 03:08:23 +0000
commitc537d5958e8b421ac4f9bef6c8b9e7425a6cf167 (patch)
tree7ed36518fb6524da7bbd913ba7619b85b5d15d23 /apps/codecs/mp3_enc.c
parentdcf0f8de4a37ff1d2ea510aef75fa67977a8bdcc (diff)
downloadrockbox-c537d5958e8b421ac4f9bef6c8b9e7425a6cf167.tar.gz
rockbox-c537d5958e8b421ac4f9bef6c8b9e7425a6cf167.zip
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
Diffstat (limited to 'apps/codecs/mp3_enc.c')
-rw-r--r--apps/codecs/mp3_enc.c59
1 files changed, 30 insertions, 29 deletions
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 */
+}