summaryrefslogtreecommitdiff
path: root/apps/codecs/wav_enc.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/wav_enc.c')
-rw-r--r--apps/codecs/wav_enc.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/apps/codecs/wav_enc.c b/apps/codecs/wav_enc.c
index ef1a88ec23..e4afeaf93c 100644
--- a/apps/codecs/wav_enc.c
+++ b/apps/codecs/wav_enc.c
@@ -345,40 +345,42 @@ static bool init_encoder(void)
345 return true; 345 return true;
346} /* init_encoder */ 346} /* init_encoder */
347 347
348/* main codec entry point */ 348/* this is the codec entry point */
349enum codec_status codec_main(void) 349enum codec_status codec_main(enum codec_entry_call_reason reason)
350{ 350{
351 if (!init_encoder()) 351 if (reason == CODEC_LOAD) {
352 return CODEC_ERROR; 352 if (!init_encoder())
353 return CODEC_ERROR;
354 }
355 else if (reason == CODEC_UNLOAD) {
356 /* reset parameters to initial state */
357 ci->enc_set_parameters(NULL);
358 }
353 359
360 return CODEC_OK;
361}
362
363/* this is called for each file to process */
364enum codec_status codec_run(void)
365{
354 /* main encoding loop */ 366 /* main encoding loop */
355 while(!ci->stop_codec) 367 while(ci->get_command(NULL) != CODEC_ACTION_HALT)
356 { 368 {
357 uint32_t *src; 369 uint32_t *src = (uint32_t *)ci->enc_get_pcm_data(PCM_CHUNK_SIZE);
370 struct enc_chunk_hdr *chunk;
358 371
359 while ((src = (uint32_t *)ci->enc_get_pcm_data(PCM_CHUNK_SIZE)) != NULL) 372 if(src == NULL)
360 { 373 continue;
361 struct enc_chunk_hdr *chunk;
362
363 if (ci->stop_codec)
364 break;
365 374
366 chunk = ci->enc_get_chunk(); 375 chunk = ci->enc_get_chunk();
367 chunk->enc_size = enc_size; 376 chunk->enc_size = enc_size;
368 chunk->num_pcm = PCM_SAMP_PER_CHUNK; 377 chunk->num_pcm = PCM_SAMP_PER_CHUNK;
369 chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk); 378 chunk->enc_data = ENC_CHUNK_SKIP_HDR(chunk->enc_data, chunk);
370 379
371 chunk_to_wav_format(src, (uint32_t *)chunk->enc_data); 380 chunk_to_wav_format(src, (uint32_t *)chunk->enc_data);
372 381
373 ci->enc_finish_chunk(); 382 ci->enc_finish_chunk();
374 ci->yield();
375 }
376
377 ci->yield();
378 } 383 }
379 384
380 /* reset parameters to initial state */
381 ci->enc_set_parameters(NULL);
382
383 return CODEC_OK; 385 return CODEC_OK;
384} /* codec_start */ 386}