diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2006-12-17 01:24:51 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2006-12-17 01:24:51 +0000 |
commit | 98fa14bfd178df48a82897da87902c112ecafd50 (patch) | |
tree | 4ff23724e6cbdb89492567381037c5824c73f402 | |
parent | 02aeacbafaf1d30eeb07ae831714d25642901903 (diff) | |
download | rockbox-98fa14bfd178df48a82897da87902c112ecafd50.tar.gz rockbox-98fa14bfd178df48a82897da87902c112ecafd50.zip |
SWCODEC: More recording simplifications and less UI hanging in some cases using queue_send.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11781 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/pcm_record.c | 53 |
1 files changed, 16 insertions, 37 deletions
diff --git a/firmware/pcm_record.c b/firmware/pcm_record.c index 4ec5fc3256..7aa81f35a0 100644 --- a/firmware/pcm_record.c +++ b/firmware/pcm_record.c | |||
@@ -62,7 +62,6 @@ volatile bool pcm_recording = false; | |||
62 | /** General recording state **/ | 62 | /** General recording state **/ |
63 | static bool is_recording; /* We are recording */ | 63 | static bool is_recording; /* We are recording */ |
64 | static bool is_paused; /* We have paused */ | 64 | static bool is_paused; /* We have paused */ |
65 | static bool is_stopping; /* We are currently stopping */ | ||
66 | static unsigned long errors; /* An error has occured */ | 65 | static unsigned long errors; /* An error has occured */ |
67 | static unsigned long warnings; /* Warning */ | 66 | static unsigned long warnings; /* Warning */ |
68 | 67 | ||
@@ -237,7 +236,6 @@ enum | |||
237 | PCMREC_OPTIONS, /* set recording options */ | 236 | PCMREC_OPTIONS, /* set recording options */ |
238 | PCMREC_START, /* start recording */ | 237 | PCMREC_START, /* start recording */ |
239 | PCMREC_STOP, /* stop the current recording */ | 238 | PCMREC_STOP, /* stop the current recording */ |
240 | PCMREC_FINISH_STOP, /* finish the stopping recording */ | ||
241 | PCMREC_PAUSE, /* pause the current recording */ | 239 | PCMREC_PAUSE, /* pause the current recording */ |
242 | PCMREC_RESUME, /* resume the current recording */ | 240 | PCMREC_RESUME, /* resume the current recording */ |
243 | PCMREC_NEW_FILE, /* start new file */ | 241 | PCMREC_NEW_FILE, /* start new file */ |
@@ -1038,6 +1036,8 @@ static void pcmrec_new_stream(const char *filename, /* next file name */ | |||
1038 | 1036 | ||
1039 | if (start) | 1037 | if (start) |
1040 | { | 1038 | { |
1039 | char buf[MAX_PATH]; /* place to copy in case we're full */ | ||
1040 | |||
1041 | if (!(flags & CHUNKF_PRERECORD)) | 1041 | if (!(flags & CHUNKF_PRERECORD)) |
1042 | { | 1042 | { |
1043 | /* get stats on data added to start - sort of a prerecord operation */ | 1043 | /* get stats on data added to start - sort of a prerecord operation */ |
@@ -1070,6 +1070,11 @@ static void pcmrec_new_stream(const char *filename, /* next file name */ | |||
1070 | if (fnq_add_fn == pcmrec_fnq_add_filename && pcmrec_fnq_is_full()) | 1070 | if (fnq_add_fn == pcmrec_fnq_add_filename && pcmrec_fnq_is_full()) |
1071 | { | 1071 | { |
1072 | logf("fnq full"); | 1072 | logf("fnq full"); |
1073 | /* make a local copy of filename and let sender go as this | ||
1074 | flush will hang the screen for a bit otherwise */ | ||
1075 | strncpy(buf, filename, MAX_PATH); | ||
1076 | filename = buf; | ||
1077 | queue_reply(&pcmrec_queue, NULL); | ||
1073 | pcmrec_flush(-1); | 1078 | pcmrec_flush(-1); |
1074 | } | 1079 | } |
1075 | 1080 | ||
@@ -1115,7 +1120,6 @@ static void pcmrec_init(void) | |||
1115 | 1120 | ||
1116 | is_recording = false; | 1121 | is_recording = false; |
1117 | is_paused = false; | 1122 | is_paused = false; |
1118 | is_stopping = false; | ||
1119 | 1123 | ||
1120 | buffer = audio_get_recording_buffer(&rec_buffer_size); | 1124 | buffer = audio_get_recording_buffer(&rec_buffer_size); |
1121 | 1125 | ||
@@ -1183,6 +1187,8 @@ static void pcmrec_set_recording_options(struct audio_recording_options *options | |||
1183 | /* apply pcm settings to hardware */ | 1187 | /* apply pcm settings to hardware */ |
1184 | pcm_apply_settings(true); | 1188 | pcm_apply_settings(true); |
1185 | 1189 | ||
1190 | queue_reply(&pcmrec_queue, NULL); /* Release sender */ | ||
1191 | |||
1186 | if (audio_load_encoder(enc_config.afmt)) | 1192 | if (audio_load_encoder(enc_config.afmt)) |
1187 | { | 1193 | { |
1188 | /* start DMA transfer */ | 1194 | /* start DMA transfer */ |
@@ -1195,7 +1201,6 @@ static void pcmrec_set_recording_options(struct audio_recording_options *options | |||
1195 | logf("set rec opt: enc load failed"); | 1201 | logf("set rec opt: enc load failed"); |
1196 | errors |= PCMREC_E_LOAD_ENCODER; | 1202 | errors |= PCMREC_E_LOAD_ENCODER; |
1197 | } | 1203 | } |
1198 | |||
1199 | } /* pcmrec_set_recording_options */ | 1204 | } /* pcmrec_set_recording_options */ |
1200 | 1205 | ||
1201 | /* PCMREC_START/PCMREC_NEW_FILE - start recording (not gapless) | 1206 | /* PCMREC_START/PCMREC_NEW_FILE - start recording (not gapless) |
@@ -1306,33 +1311,12 @@ static void pcmrec_stop(void) | |||
1306 | if (!is_recording) | 1311 | if (!is_recording) |
1307 | { | 1312 | { |
1308 | logf("not recording"); | 1313 | logf("not recording"); |
1309 | goto not_recording_or_stopping; | 1314 | goto not_recording; |
1310 | } | ||
1311 | else if (is_stopping) | ||
1312 | { | ||
1313 | logf("already stopping"); | ||
1314 | goto not_recording_or_stopping; | ||
1315 | } | 1315 | } |
1316 | 1316 | ||
1317 | is_stopping = true; | 1317 | dma_lock = true; /* lock dma write position */ |
1318 | dma_lock = true; /* lock dma write position */ | 1318 | queue_reply(&pcmrec_queue, NULL); |
1319 | queue_post(&pcmrec_queue, PCMREC_FINISH_STOP, NULL); | ||
1320 | 1319 | ||
1321 | not_recording_or_stopping: | ||
1322 | logf("pcmrec_stop done"); | ||
1323 | } /* pcmrec_stop */ | ||
1324 | |||
1325 | /* PCMREC_FINISH_STOP */ | ||
1326 | static void pcmrec_finish_stop(void) | ||
1327 | { | ||
1328 | logf("pcmrec_finish_stop"); | ||
1329 | |||
1330 | if (!is_stopping) | ||
1331 | { | ||
1332 | logf("not stopping"); | ||
1333 | goto not_stopping; | ||
1334 | } | ||
1335 | |||
1336 | /* flush all available data first to avoid overflow while waiting | 1320 | /* flush all available data first to avoid overflow while waiting |
1337 | for encoding to finish */ | 1321 | for encoding to finish */ |
1338 | pcmrec_flush(-1); | 1322 | pcmrec_flush(-1); |
@@ -1367,12 +1351,11 @@ static void pcmrec_finish_stop(void) | |||
1367 | 1351 | ||
1368 | is_recording = false; | 1352 | is_recording = false; |
1369 | is_paused = false; | 1353 | is_paused = false; |
1370 | is_stopping = false; | ||
1371 | dma_lock = pre_record_ticks == 0; | 1354 | dma_lock = pre_record_ticks == 0; |
1372 | 1355 | ||
1373 | not_stopping: | 1356 | not_recording: |
1374 | logf("pcmrec_finish_stop done"); | 1357 | logf("pcmrec_stop done"); |
1375 | } /* pcmrec_finish_stop */ | 1358 | } /* pcmrec_stop */ |
1376 | 1359 | ||
1377 | /* PCMREC_PAUSE */ | 1360 | /* PCMREC_PAUSE */ |
1378 | static void pcmrec_pause(void) | 1361 | static void pcmrec_pause(void) |
@@ -1430,7 +1413,7 @@ static void pcmrec_thread(void) | |||
1430 | 1413 | ||
1431 | while(1) | 1414 | while(1) |
1432 | { | 1415 | { |
1433 | if (is_recording && !is_stopping) | 1416 | if (is_recording) |
1434 | { | 1417 | { |
1435 | /* Poll periodically to flush data */ | 1418 | /* Poll periodically to flush data */ |
1436 | queue_wait_w_tmo(&pcmrec_queue, &ev, HZ/5); | 1419 | queue_wait_w_tmo(&pcmrec_queue, &ev, HZ/5); |
@@ -1471,10 +1454,6 @@ static void pcmrec_thread(void) | |||
1471 | pcmrec_stop(); | 1454 | pcmrec_stop(); |
1472 | break; | 1455 | break; |
1473 | 1456 | ||
1474 | case PCMREC_FINISH_STOP: | ||
1475 | pcmrec_finish_stop(); | ||
1476 | break; | ||
1477 | |||
1478 | case PCMREC_PAUSE: | 1457 | case PCMREC_PAUSE: |
1479 | pcmrec_pause(); | 1458 | pcmrec_pause(); |
1480 | break; | 1459 | break; |