From 0d768a37f970b40575ef2be169e670fd6b5d424a Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Thu, 7 Dec 2006 19:34:26 +0000 Subject: SWCODEC Recording: 1) Fix minor bug of not subtracting line aligment adjustment from buffer size. 2) Handle stop and pause better and let pcmrec thread lock the DMA as that could cause prerecording to get disabled internally 3) Make sure to snapshot DMA write index to ensure compiler doesn't perform multiple access when calculating available data (probably just paranoia on my part) 4) Handle USB connect in recording thread a little better by resetting hardware to defaults after closing 5) Make power managment stop recording properly when powering off (ie. no yield() from interrupt handler! :) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11685 a1c6a512-1295-4272-9138-f99709370657 --- apps/misc.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/misc.c b/apps/misc.c index 2f3251431b..4ea8568018 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -578,6 +578,9 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter) if(!charger_inserted()) #endif { + bool batt_crit = battery_level_critical(); + int audio_stat = audio_status(); + FOR_NB_SCREENS(i) screens[i].clear_display(); #ifdef X5_BACKLIGHT_SHUTDOWN @@ -604,11 +607,23 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter) } if (global_settings.fade_on_stop - && (audio_status() & AUDIO_STATUS_PLAY)) + && (audio_stat & AUDIO_STATUS_PLAY)) { fade(0); } - + +#if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC + if (!batt_crit && (audio_stat & AUDIO_STATUS_RECORD)) + { + audio_stop_recording(); + while(audio_status() & AUDIO_STATUS_RECORD) + sleep(1); + } + + audio_close_recording(); +#endif + /* audio_stop_recording == audio_stop for HWCODEC */ + audio_stop(); while (audio_status()) sleep(1); @@ -616,7 +631,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter) if (callback != NULL) callback(parameter); - if (!battery_level_critical()) /* do not save on critical battery */ + if (!batt_crit) /* do not save on critical battery */ system_flush(); #ifdef HAVE_EEPROM_SETTINGS if (firmware_settings.initialized) -- cgit v1.2.3