summaryrefslogtreecommitdiff
path: root/firmware/pcm_record.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/pcm_record.c')
-rw-r--r--firmware/pcm_record.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/firmware/pcm_record.c b/firmware/pcm_record.c
index 0c10ea7b2e..d26a4d303a 100644
--- a/firmware/pcm_record.c
+++ b/firmware/pcm_record.c
@@ -342,12 +342,6 @@ void audio_resume_recording(void)
342 342
343void pcm_rec_get_peaks(int *left, int *right) 343void pcm_rec_get_peaks(int *left, int *right)
344{ 344{
345 if (!is_recording)
346 {
347 peak_left = 0;
348 peak_right = 0;
349 }
350
351 if (left) 345 if (left)
352 *left = peak_left; 346 *left = peak_left;
353 if (right) 347 if (right)
@@ -412,9 +406,6 @@ static void pcmrec_callback(bool flush)
412 unsigned short *ptr; 406 unsigned short *ptr;
413 int i, j, w; 407 int i, j, w;
414 408
415 if ((!is_recording || is_paused) && !flush)
416 return;
417
418 w = write_index; 409 w = write_index;
419 410
420 num_new = w - read2_index; 411 num_new = w - read2_index;
@@ -430,6 +421,12 @@ static void pcmrec_callback(bool flush)
430 pcmrec_find_peaks(j); 421 pcmrec_find_peaks(j);
431 } 422 }
432 423
424 if ((!is_recording || is_paused) && !flush)
425 {
426 read_index = write_index;
427 return;
428 }
429
433 for (i=0; i<num_new; i++) 430 for (i=0; i<num_new; i++)
434 { 431 {
435 /* Convert the samples to little-endian so we only have to write later 432 /* Convert the samples to little-endian so we only have to write later
@@ -531,7 +528,7 @@ void DMA1(void)
531 if (write_index >= num_chunks) 528 if (write_index >= num_chunks)
532 write_index = 0; 529 write_index = 0;
533 530
534 if (is_stopping || !is_recording) 531 if (is_stopping)
535 { 532 {
536 DCR1 = 0; /* Stop DMA transfer */ 533 DCR1 = 0; /* Stop DMA transfer */
537 is_stopping = false; 534 is_stopping = false;
@@ -644,8 +641,6 @@ static void pcmrec_start(void)
644 is_paused = false; 641 is_paused = false;
645 is_recording = true; 642 is_recording = true;
646 643
647 pcmrec_dma_start();
648
649 record_done = true; 644 record_done = true;
650} 645}
651 646
@@ -680,6 +675,9 @@ static void pcmrec_stop(void)
680 675
681 stop_done = true; 676 stop_done = true;
682 677
678 /* Finally start dma again for peakmeters and pre-recoding to work. */
679 pcmrec_dma_start();
680
683 logf("pcmrec_stop done"); 681 logf("pcmrec_stop done");
684} 682}
685 683
@@ -829,6 +827,8 @@ static void pcmrec_init(void)
829 ICR7 = 0x1c; /* Enable interrupt at level 7, priority 0 */ 827 ICR7 = 0x1c; /* Enable interrupt at level 7, priority 0 */
830 IMR &= ~(1<<15); /* bit 15 is DMA1 */ 828 IMR &= ~(1<<15); /* bit 15 is DMA1 */
831 829
830 pcmrec_dma_start();
831
832 init_done = 1; 832 init_done = 1;
833} 833}
834 834