summaryrefslogtreecommitdiff
path: root/apps/codecs/mp3_enc.c
diff options
context:
space:
mode:
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)
2584 return true; 2584 return true;
2585} /* enc_init */ 2585} /* enc_init */
2586 2586
2587enum codec_status codec_main(void) 2587/* this is the codec entry point */
2588enum 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 */
2603enum 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}