diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/recorder/pcm_record.c | 20 |
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 **/ |
45 | static bool is_initialized = false; /* Subsystem ready? */ | ||
45 | static bool is_recording; /* We are recording */ | 46 | static bool is_recording; /* We are recording */ |
46 | static bool is_paused; /* We have paused */ | 47 | static bool is_paused; /* We have paused */ |
47 | static unsigned long errors; /* An error has occured */ | 48 | static 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 */ |
1134 | static void pcmrec_init(void) | 1135 | static 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 */ |
1186 | static void pcmrec_close(void) | 1189 | static 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; |