diff options
Diffstat (limited to 'apps/codecs/wav_enc.c')
-rw-r--r-- | apps/codecs/wav_enc.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/apps/codecs/wav_enc.c b/apps/codecs/wav_enc.c index ff49238303..083465ab54 100644 --- a/apps/codecs/wav_enc.c +++ b/apps/codecs/wav_enc.c | |||
@@ -46,7 +46,7 @@ struct riff_header | |||
46 | uint8_t data_id[4]; /* 24h - "data" */ | 46 | uint8_t data_id[4]; /* 24h - "data" */ |
47 | uint32_t data_size; /* 28h - num_samples*num_channels*bits_per_sample/8 */ | 47 | uint32_t data_size; /* 28h - num_samples*num_channels*bits_per_sample/8 */ |
48 | /* unsigned char *data; 2ch - actual sound data */ | 48 | /* unsigned char *data; 2ch - actual sound data */ |
49 | }; | 49 | } __attribute__((packed)); |
50 | 50 | ||
51 | #define RIFF_FMT_HEADER_SIZE 12 /* format -> format_size */ | 51 | #define RIFF_FMT_HEADER_SIZE 12 /* format -> format_size */ |
52 | #define RIFF_FMT_DATA_SIZE 16 /* audio_format -> bits_per_sample */ | 52 | #define RIFF_FMT_DATA_SIZE 16 /* audio_format -> bits_per_sample */ |
@@ -287,7 +287,9 @@ static bool init_encoder(void) | |||
287 | ci->enc_set_parameters == NULL || | 287 | ci->enc_set_parameters == NULL || |
288 | ci->enc_get_chunk == NULL || | 288 | ci->enc_get_chunk == NULL || |
289 | ci->enc_finish_chunk == NULL || | 289 | ci->enc_finish_chunk == NULL || |
290 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
290 | ci->enc_pcm_buf_near_empty == NULL || | 291 | ci->enc_pcm_buf_near_empty == NULL || |
292 | #endif | ||
291 | ci->enc_get_pcm_data == NULL ) | 293 | ci->enc_get_pcm_data == NULL ) |
292 | return false; | 294 | return false; |
293 | 295 | ||
@@ -314,7 +316,9 @@ static bool init_encoder(void) | |||
314 | /* main codec entry point */ | 316 | /* main codec entry point */ |
315 | enum codec_status codec_main(void) | 317 | enum codec_status codec_main(void) |
316 | { | 318 | { |
319 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
317 | bool cpu_boosted; | 320 | bool cpu_boosted; |
321 | #endif | ||
318 | 322 | ||
319 | if (!init_encoder()) | 323 | if (!init_encoder()) |
320 | { | 324 | { |
@@ -325,8 +329,10 @@ enum codec_status codec_main(void) | |||
325 | /* main application waits for this flag during encoder loading */ | 329 | /* main application waits for this flag during encoder loading */ |
326 | ci->enc_codec_loaded = 1; | 330 | ci->enc_codec_loaded = 1; |
327 | 331 | ||
332 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
328 | ci->cpu_boost(true); | 333 | ci->cpu_boost(true); |
329 | cpu_boosted = true; | 334 | cpu_boosted = true; |
335 | #endif | ||
330 | 336 | ||
331 | /* main encoding loop */ | 337 | /* main encoding loop */ |
332 | while(!ci->stop_codec) | 338 | while(!ci->stop_codec) |
@@ -340,12 +346,13 @@ enum codec_status codec_main(void) | |||
340 | if (ci->stop_codec) | 346 | if (ci->stop_codec) |
341 | break; | 347 | break; |
342 | 348 | ||
349 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
343 | if (!cpu_boosted && ci->enc_pcm_buf_near_empty() == 0) | 350 | if (!cpu_boosted && ci->enc_pcm_buf_near_empty() == 0) |
344 | { | 351 | { |
345 | ci->cpu_boost(true); | 352 | ci->cpu_boost(true); |
346 | cpu_boosted = true; | 353 | cpu_boosted = true; |
347 | } | 354 | } |
348 | 355 | #endif | |
349 | chunk = ci->enc_get_chunk(); | 356 | chunk = ci->enc_get_chunk(); |
350 | chunk->enc_size = enc_size; | 357 | chunk->enc_size = enc_size; |
351 | chunk->num_pcm = PCM_SAMP_PER_CHUNK; | 358 | chunk->num_pcm = PCM_SAMP_PER_CHUNK; |
@@ -357,17 +364,20 @@ enum codec_status codec_main(void) | |||
357 | ci->yield(); | 364 | ci->yield(); |
358 | } | 365 | } |
359 | 366 | ||
367 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
360 | if (cpu_boosted && ci->enc_pcm_buf_near_empty() != 0) | 368 | if (cpu_boosted && ci->enc_pcm_buf_near_empty() != 0) |
361 | { | 369 | { |
362 | ci->cpu_boost(false); | 370 | ci->cpu_boost(false); |
363 | cpu_boosted = false; | 371 | cpu_boosted = false; |
364 | } | 372 | } |
365 | 373 | #endif | |
366 | ci->yield(); | 374 | ci->yield(); |
367 | } | 375 | } |
368 | 376 | ||
369 | if(cpu_boosted) /* set initial boost state */ | 377 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
378 | if (cpu_boosted) /* set initial boost state */ | ||
370 | ci->cpu_boost(false); | 379 | ci->cpu_boost(false); |
380 | #endif | ||
371 | 381 | ||
372 | /* reset parameters to initial state */ | 382 | /* reset parameters to initial state */ |
373 | ci->enc_set_parameters(NULL); | 383 | ci->enc_set_parameters(NULL); |