diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2011-04-27 03:08:23 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2011-04-27 03:08:23 +0000 |
commit | c537d5958e8b421ac4f9bef6c8b9e7425a6cf167 (patch) | |
tree | 7ed36518fb6524da7bbd913ba7619b85b5d15d23 /apps/codecs/mp3_enc.c | |
parent | dcf0f8de4a37ff1d2ea510aef75fa67977a8bdcc (diff) | |
download | rockbox-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.c | 59 |
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) | |||
2584 | return true; | 2584 | return true; |
2585 | } /* enc_init */ | 2585 | } /* enc_init */ |
2586 | 2586 | ||
2587 | enum codec_status codec_main(void) | 2587 | /* this is the codec entry point */ |
2588 | enum codec_status codec_main(enum codec_entry_call_reason reason) | ||
2588 | { | 2589 | { |
2589 | /* Generic codec initialisation */ | 2590 | if (reason == CODEC_LOAD) { |
2590 | if (!enc_init()) | 2591 | if (!enc_init()) |
2591 | return CODEC_ERROR; | 2592 | return CODEC_ERROR; |
2593 | } | ||
2594 | else if (reason == CODEC_UNLOAD) { | ||
2595 | /* reset parameters to initial state */ | ||
2596 | ci->enc_set_parameters(NULL); | ||
2597 | } | ||
2598 | |||
2599 | return CODEC_OK; | ||
2600 | } | ||
2592 | 2601 | ||
2602 | /* this is called for each file to process */ | ||
2603 | enum codec_status codec_run(void) | ||
2604 | { | ||
2593 | /* main encoding loop */ | 2605 | /* main encoding loop */ |
2594 | while (!ci->stop_codec) | 2606 | while(ci->get_command(NULL) != CODEC_ACTION_HALT) |
2595 | { | 2607 | { |
2596 | char *buffer; | 2608 | char *buffer = buffer = ci->enc_get_pcm_data(pcm_chunk_size); |
2597 | 2609 | struct enc_chunk_hdr *chunk; | |
2598 | while ((buffer = ci->enc_get_pcm_data(pcm_chunk_size)) != NULL) | ||
2599 | { | ||
2600 | struct enc_chunk_hdr *chunk; | ||
2601 | |||
2602 | if (ci->stop_codec) | ||
2603 | break; | ||
2604 | 2610 | ||
2605 | chunk = ci->enc_get_chunk(); | 2611 | if(buffer == NULL) |
2606 | chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk); | 2612 | continue; |
2607 | 2613 | ||
2608 | encode_frame(buffer, chunk); | 2614 | chunk = ci->enc_get_chunk(); |
2615 | chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk); | ||
2609 | 2616 | ||
2610 | if (chunk->num_pcm < samp_per_frame) | 2617 | encode_frame(buffer, chunk); |
2611 | { | ||
2612 | ci->enc_unget_pcm_data(pcm_chunk_size - chunk->num_pcm*4); | ||
2613 | chunk->num_pcm = samp_per_frame; | ||
2614 | } | ||
2615 | 2618 | ||
2616 | ci->enc_finish_chunk(); | 2619 | if (chunk->num_pcm < samp_per_frame) |
2617 | 2620 | { | |
2618 | ci->yield(); | 2621 | ci->enc_unget_pcm_data(pcm_chunk_size - chunk->num_pcm*4); |
2622 | chunk->num_pcm = samp_per_frame; | ||
2619 | } | 2623 | } |
2620 | 2624 | ||
2621 | ci->yield(); | 2625 | ci->enc_finish_chunk(); |
2622 | } | 2626 | } |
2623 | 2627 | ||
2624 | /* reset parameters to initial state */ | ||
2625 | ci->enc_set_parameters(NULL); | ||
2626 | |||
2627 | return CODEC_OK; | 2628 | return CODEC_OK; |
2628 | } /* codec_start */ | 2629 | } |