summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-05-30 18:42:59 -0400
committerMichael Sevakis <jethead71@rockbox.org>2013-05-30 18:42:59 -0400
commitdf6e1bcce5071e02b5cd46736bff87ca0dcceffe (patch)
tree1ff6f3d59896d9d9d95bfedf79d437aa8a14168f /apps
parent5a1e697e2a8ed9a53c6eed5d0c291ff0905cd5aa (diff)
downloadrockbox-df6e1bcce5071e02b5cd46736bff87ca0dcceffe.tar.gz
rockbox-df6e1bcce5071e02b5cd46736bff87ca0dcceffe.zip
pcm_record: Track initialization state
It should not access audio hardware and change settings unless it has been initialized first and given control of it. Change-Id: I5004602d7caa604ded751f6838b792d1ff24b3fb
Diffstat (limited to 'apps')
-rw-r--r--apps/recorder/pcm_record.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/apps/recorder/pcm_record.c b/apps/recorder/pcm_record.c
index d904be9a4e..fe7a54a565 100644
--- a/apps/recorder/pcm_record.c
+++ b/apps/recorder/pcm_record.c
@@ -42,6 +42,7 @@
42/***************************************************************************/ 42/***************************************************************************/
43 43
44/** General recording state **/ 44/** General recording state **/
45static bool is_initialized = false; /* Subsystem ready? */
45static bool is_recording; /* We are recording */ 46static bool is_recording; /* We are recording */
46static bool is_paused; /* We have paused */ 47static bool is_paused; /* We have paused */
47static unsigned long errors; /* An error has occured */ 48static unsigned long errors; /* An error has occured */
@@ -1133,6 +1134,8 @@ static void pcmrec_new_stream(const char *filename, /* next file name */
1133/* PCMREC_INIT */ 1134/* PCMREC_INIT */
1134static void pcmrec_init(void) 1135static void pcmrec_init(void)
1135{ 1136{
1137 is_initialized = true;
1138
1136 unsigned char *buffer; 1139 unsigned char *buffer;
1137 send_event(RECORDING_EVENT_START, NULL); 1140 send_event(RECORDING_EVENT_START, NULL);
1138 1141
@@ -1185,6 +1188,7 @@ static void pcmrec_init(void)
1185/* PCMREC_CLOSE */ 1188/* PCMREC_CLOSE */
1186static void pcmrec_close(void) 1189static void pcmrec_close(void)
1187{ 1190{
1191 is_initialized = false;
1188 dma_lock = true; 1192 dma_lock = true;
1189 pre_record_ticks = 0; /* Can't be prerecording any more */ 1193 pre_record_ticks = 0; /* Can't be prerecording any more */
1190 warnings = 0; 1194 warnings = 0;
@@ -1490,6 +1494,17 @@ static void pcmrec_thread(void)
1490 { 1494 {
1491 /* Not doing anything - sit and wait for commands */ 1495 /* Not doing anything - sit and wait for commands */
1492 queue_wait(&pcmrec_queue, &ev); 1496 queue_wait(&pcmrec_queue, &ev);
1497
1498 /* Some messages must be handled even if not initialized */
1499 switch (ev.id)
1500 {
1501 case PCMREC_INIT:
1502 case SYS_USB_CONNECTED:
1503 break;
1504 default:
1505 if (!is_initialized)
1506 continue;
1507 }
1493 } 1508 }
1494 1509
1495 switch (ev.id) 1510 switch (ev.id)
@@ -1533,7 +1548,10 @@ static void pcmrec_thread(void)
1533 case SYS_USB_CONNECTED: 1548 case SYS_USB_CONNECTED:
1534 if (is_recording) 1549 if (is_recording)
1535 break; 1550 break;
1536 pcmrec_close(); 1551
1552 if (is_initialized)
1553 pcmrec_close();
1554
1537 usb_acknowledge(SYS_USB_CONNECTED_ACK); 1555 usb_acknowledge(SYS_USB_CONNECTED_ACK);
1538 usb_wait_for_disconnect(&pcmrec_queue); 1556 usb_wait_for_disconnect(&pcmrec_queue);
1539 flush_interrupts = 0; 1557 flush_interrupts = 0;