summaryrefslogtreecommitdiffstats
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
parent5a1e697e2a8ed9a53c6eed5d0c291ff0905cd5aa (diff)
downloadrockbox-df6e1bc.tar.gz
rockbox-df6e1bc.tar.bz2
rockbox-df6e1bc.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
-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 @@
/***************************************************************************/
/** General recording state **/
+static bool is_initialized = false; /* Subsystem ready? */
static bool is_recording; /* We are recording */
static bool is_paused; /* We have paused */
static unsigned long errors; /* An error has occured */
@@ -1133,6 +1134,8 @@ static void pcmrec_new_stream(const char *filename, /* next file name */
/* PCMREC_INIT */
static void pcmrec_init(void)
{
+ is_initialized = true;
+
unsigned char *buffer;
send_event(RECORDING_EVENT_START, NULL);
@@ -1185,6 +1188,7 @@ static void pcmrec_init(void)
/* PCMREC_CLOSE */
static void pcmrec_close(void)
{
+ is_initialized = false;
dma_lock = true;
pre_record_ticks = 0; /* Can't be prerecording any more */
warnings = 0;
@@ -1490,6 +1494,17 @@ static void pcmrec_thread(void)
{
/* Not doing anything - sit and wait for commands */
queue_wait(&pcmrec_queue, &ev);
+
+ /* Some messages must be handled even if not initialized */
+ switch (ev.id)
+ {
+ case PCMREC_INIT:
+ case SYS_USB_CONNECTED:
+ break;
+ default:
+ if (!is_initialized)
+ continue;
+ }
}
switch (ev.id)
@@ -1533,7 +1548,10 @@ static void pcmrec_thread(void)
case SYS_USB_CONNECTED:
if (is_recording)
break;
- pcmrec_close();
+
+ if (is_initialized)
+ pcmrec_close();
+
usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_wait_for_disconnect(&pcmrec_queue);
flush_interrupts = 0;