summaryrefslogtreecommitdiff
path: root/apps/recorder/pcm_record.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/recorder/pcm_record.c')
-rw-r--r--apps/recorder/pcm_record.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c
index 3b3211afab..6b9adda8bd 100644
--- a/apps/recorder/pcm_record.c
+++ b/apps/recorder/pcm_record.c
@@ -99,7 +99,7 @@ static int num_channels; /* Current number of channels */
99static int rec_mono_mode; /* how mono is created */ 99static int rec_mono_mode; /* how mono is created */
100static struct encoder_config enc_config; /* Current encoder configuration */ 100static struct encoder_config enc_config; /* Current encoder configuration */
101static unsigned long pre_record_ticks; /* pre-record time in ticks */ 101static unsigned long pre_record_ticks; /* pre-record time in ticks */
102 102
103/**************************************************************************** 103/****************************************************************************
104 use 2 circular buffers: 104 use 2 circular buffers:
105 pcm_buffer=DMA output buffer: chunks (8192 Bytes) of raw pcm audio data 105 pcm_buffer=DMA output buffer: chunks (8192 Bytes) of raw pcm audio data
@@ -166,7 +166,7 @@ static size_t enc_chunk_size; /* maximum encoder chunk size */
166static unsigned long enc_sample_rate; /* sample rate used by encoder */ 166static unsigned long enc_sample_rate; /* sample rate used by encoder */
167static bool pcmrec_context = false; /* called by pcmrec thread? */ 167static bool pcmrec_context = false; /* called by pcmrec thread? */
168static bool pcm_buffer_empty; /* all pcm chunks processed? */ 168static bool pcm_buffer_empty; /* all pcm chunks processed? */
169 169
170/** file flushing **/ 170/** file flushing **/
171static int low_watermark; /* Low watermark to stop flush */ 171static int low_watermark; /* Low watermark to stop flush */
172static int high_watermark; /* max chunk limit for data flush */ 172static int high_watermark; /* max chunk limit for data flush */
@@ -259,7 +259,7 @@ static void pcmrec_raise_warning_status(unsigned long w)
259{ 259{
260 warnings |= w; 260 warnings |= w;
261} 261}
262 262
263/* Callback for when more data is ready - called in interrupt context */ 263/* Callback for when more data is ready - called in interrupt context */
264static void pcm_rec_have_more(void **start, size_t *size) 264static void pcm_rec_have_more(void **start, size_t *size)
265{ 265{
@@ -457,7 +457,7 @@ void audio_pause_recording(void)
457 457
458/** 458/**
459 * Resume current recording if paused 459 * Resume current recording if paused
460 */ 460 */
461void audio_resume_recording(void) 461void audio_resume_recording(void)
462{ 462{
463 logf("audio_resume_recording"); 463 logf("audio_resume_recording");
@@ -466,11 +466,11 @@ void audio_resume_recording(void)
466} /* audio_resume_recording */ 466} /* audio_resume_recording */
467 467
468/** 468/**
469 * Note that microphone is mono, only left value is used 469 * Note that microphone is mono, only left value is used
470 * See audiohw_set_recvol() for exact ranges. 470 * See audiohw_set_recvol() for exact ranges.
471 * 471 *
472 * @param type AUDIO_GAIN_MIC, AUDIO_GAIN_LINEIN 472 * @param type AUDIO_GAIN_MIC, AUDIO_GAIN_LINEIN
473 * 473 *
474 */ 474 */
475void audio_set_recording_gain(int left, int right, int type) 475void audio_set_recording_gain(int left, int right, int type)
476{ 476{
@@ -503,7 +503,7 @@ unsigned long audio_num_recorded_bytes(void)
503 503
504 return num_rec_bytes; 504 return num_rec_bytes;
505} /* audio_num_recorded_bytes */ 505} /* audio_num_recorded_bytes */
506 506
507/***************************************************************************/ 507/***************************************************************************/
508/* */ 508/* */
509/* Functions that execute in the context of audio thread */ 509/* Functions that execute in the context of audio thread */
@@ -559,14 +559,14 @@ static inline void pcmrec_fnq_set_empty(void)
559{ 559{
560 fnq_rd_pos = fnq_wr_pos; 560 fnq_rd_pos = fnq_wr_pos;
561} /* pcmrec_fnq_set_empty */ 561} /* pcmrec_fnq_set_empty */
562 562
563/* returns true if the queue is full */ 563/* returns true if the queue is full */
564static bool pcmrec_fnq_is_full(void) 564static bool pcmrec_fnq_is_full(void)
565{ 565{
566 ssize_t size = fnq_wr_pos - fnq_rd_pos; 566 ssize_t size = fnq_wr_pos - fnq_rd_pos;
567 if (size < 0) 567 if (size < 0)
568 size += fnq_size; 568 size += fnq_size;
569 569
570 return size >= fnq_size - MAX_PATH; 570 return size >= fnq_size - MAX_PATH;
571} /* pcmrec_fnq_is_full */ 571} /* pcmrec_fnq_is_full */
572 572
@@ -575,7 +575,7 @@ static bool pcmrec_fnq_add_filename(const char *filename)
575{ 575{
576 strlcpy(fn_queue + fnq_wr_pos, filename, MAX_PATH); 576 strlcpy(fn_queue + fnq_wr_pos, filename, MAX_PATH);
577 fnq_wr_pos = FNQ_NEXT(fnq_wr_pos); 577 fnq_wr_pos = FNQ_NEXT(fnq_wr_pos);
578 578
579 if (fnq_rd_pos != fnq_wr_pos) 579 if (fnq_rd_pos != fnq_wr_pos)
580 return true; 580 return true;
581 581
@@ -607,7 +607,7 @@ static bool pcmrec_fnq_get_filename(char *filename)
607 607
608 if (filename) 608 if (filename)
609 strlcpy(filename, fn_queue + fnq_rd_pos, MAX_PATH); 609 strlcpy(filename, fn_queue + fnq_rd_pos, MAX_PATH);
610 610
611 fnq_rd_pos = FNQ_NEXT(fnq_rd_pos); 611 fnq_rd_pos = FNQ_NEXT(fnq_rd_pos);
612 return true; 612 return true;
613} /* pcmrec_fnq_get_filename */ 613} /* pcmrec_fnq_get_filename */
@@ -683,7 +683,7 @@ static void pcmrec_start_file(void)
683 logf("start file: file already open"); 683 logf("start file: file already open");
684 pcmrec_raise_error_status(PCMREC_E_FNQ_DESYNC); 684 pcmrec_raise_error_status(PCMREC_E_FNQ_DESYNC);
685 } 685 }
686 686
687 if (errors != 0) 687 if (errors != 0)
688 rec_fdata.chunk->flags |= CHUNKF_ERROR; 688 rec_fdata.chunk->flags |= CHUNKF_ERROR;
689 689
@@ -709,7 +709,7 @@ static void pcmrec_start_file(void)
709 { 709 {
710 pcmrec_update_sizes(enc_size, num_pcm); 710 pcmrec_update_sizes(enc_size, num_pcm);
711 } 711 }
712 712
713 rec_fdata.chunk->flags &= ~CHUNKF_START_FILE; 713 rec_fdata.chunk->flags &= ~CHUNKF_START_FILE;
714} /* pcmrec_start_file */ 714} /* pcmrec_start_file */
715 715
@@ -893,7 +893,7 @@ static void pcmrec_flush(unsigned flush_num)
893 logf("writing:%d(%d):%s%s", num_ready, flush_num, 893 logf("writing:%d(%d):%s%s", num_ready, flush_num,
894 interruptable ? "i" : "", 894 interruptable ? "i" : "",
895 flush_num == PCMREC_FLUSH_MINI ? "m" : ""); 895 flush_num == PCMREC_FLUSH_MINI ? "m" : "");
896 896
897 cpu_boost(true); 897 cpu_boost(true);
898 898
899 remaining = flush_num; 899 remaining = flush_num;
@@ -1077,7 +1077,7 @@ static void pcmrec_new_stream(const char *filename, /* next file name */
1077 logf("stream prerecord start"); 1077 logf("stream prerecord start");
1078 start = data.pre_chunk = GET_ENC_CHUNK(pre_index); 1078 start = data.pre_chunk = GET_ENC_CHUNK(pre_index);
1079 start->flags &= CHUNKF_START_FILE | CHUNKF_PRERECORD; 1079 start->flags &= CHUNKF_START_FILE | CHUNKF_PRERECORD;
1080 } 1080 }
1081 else 1081 else
1082 { 1082 {
1083 logf("stream normal start"); 1083 logf("stream normal start");
@@ -1145,7 +1145,7 @@ static void pcmrec_new_stream(const char *filename, /* next file name */
1145 pcmrec_flush(PCMREC_FLUSH_ALL); 1145 pcmrec_flush(PCMREC_FLUSH_ALL);
1146 did_flush = true; 1146 did_flush = true;
1147 } 1147 }
1148 1148
1149 fnq_add_fn(path); 1149 fnq_add_fn(path);
1150 } 1150 }
1151 1151
@@ -1271,7 +1271,7 @@ static void pcmrec_record(const char *filename)
1271 num_rec_bytes = 0; 1271 num_rec_bytes = 0;
1272 num_rec_samples = 0; 1272 num_rec_samples = 0;
1273 1273
1274 if (!is_recording) 1274 if (!is_recording)
1275 { 1275 {
1276#if 0 1276#if 0
1277 accum_rec_bytes = 0; 1277 accum_rec_bytes = 0;
@@ -1371,7 +1371,7 @@ static void pcmrec_record(const char *filename)
1371static void pcmrec_stop(void) 1371static void pcmrec_stop(void)
1372{ 1372{
1373 logf("pcmrec_stop"); 1373 logf("pcmrec_stop");
1374 1374
1375 if (is_recording) 1375 if (is_recording)
1376 { 1376 {
1377 dma_lock = true; /* lock dma write position */ 1377 dma_lock = true; /* lock dma write position */
@@ -1401,7 +1401,7 @@ static void pcmrec_stop(void)
1401 { 1401 {
1402 logf("fnq: not empty!"); 1402 logf("fnq: not empty!");
1403 pcmrec_fnq_set_empty(); 1403 pcmrec_fnq_set_empty();
1404 } 1404 }
1405 1405
1406 /* be absolutely sure the file is closed */ 1406 /* be absolutely sure the file is closed */
1407 if (errors != 0) 1407 if (errors != 0)
@@ -1446,7 +1446,7 @@ static void pcmrec_pause(void)
1446static void pcmrec_resume(void) 1446static void pcmrec_resume(void)
1447{ 1447{
1448 logf("pcmrec_resume"); 1448 logf("pcmrec_resume");
1449 1449
1450 if (!is_recording) 1450 if (!is_recording)
1451 { 1451 {
1452 logf("not recording"); 1452 logf("not recording");
@@ -1593,7 +1593,7 @@ void enc_set_parameters(struct enc_parameters *params)
1593 1593
1594 enc_num_chunks = bufsize / enc_chunk_size; 1594 enc_num_chunks = bufsize / enc_chunk_size;
1595 logf("num chunks:%d", enc_num_chunks); 1595 logf("num chunks:%d", enc_num_chunks);
1596 1596
1597 /* get real amount used by encoder chunks */ 1597 /* get real amount used by encoder chunks */
1598 bufsize = enc_num_chunks*enc_chunk_size; 1598 bufsize = enc_num_chunks*enc_chunk_size;
1599 logf("enc size:%lu", bufsize); 1599 logf("enc size:%lu", bufsize);
@@ -1674,7 +1674,7 @@ struct enc_chunk_hdr * enc_get_chunk(void)
1674 return chunk; 1674 return chunk;
1675} /* enc_get_chunk */ 1675} /* enc_get_chunk */
1676 1676
1677/* releases the current chunk into the available chunks - 1677/* releases the current chunk into the available chunks -
1678 NOTE: can be called by pcmrec thread when splitting streams */ 1678 NOTE: can be called by pcmrec thread when splitting streams */
1679void enc_finish_chunk(void) 1679void enc_finish_chunk(void)
1680{ 1680{