diff options
-rw-r--r-- | apps/playlist.c | 33 | ||||
-rw-r--r-- | firmware/export/ata.h | 4 |
2 files changed, 24 insertions, 13 deletions
diff --git a/apps/playlist.c b/apps/playlist.c index 756680c336..c3072ddfd2 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -70,6 +70,7 @@ | |||
70 | #include <string.h> | 70 | #include <string.h> |
71 | #include <ctype.h> | 71 | #include <ctype.h> |
72 | #include "playlist.h" | 72 | #include "playlist.h" |
73 | #include "ata_idle_notify.h" | ||
73 | #include "file.h" | 74 | #include "file.h" |
74 | #include "action.h" | 75 | #include "action.h" |
75 | #include "dir.h" | 76 | #include "dir.h" |
@@ -1255,6 +1256,23 @@ static int compare(const void* p1, const void* p2) | |||
1255 | * without affecting playlist load up performance. This thread also flushes | 1256 | * without affecting playlist load up performance. This thread also flushes |
1256 | * any pending control commands when the disk spins up. | 1257 | * any pending control commands when the disk spins up. |
1257 | */ | 1258 | */ |
1259 | static bool playlist_flush_callback(void) | ||
1260 | { | ||
1261 | struct playlist_info *playlist; | ||
1262 | playlist = ¤t_playlist; | ||
1263 | if (playlist->control_fd >= 0) | ||
1264 | { | ||
1265 | if (playlist->num_cached > 0) | ||
1266 | { | ||
1267 | mutex_lock(&playlist->control_mutex); | ||
1268 | flush_cached_control(playlist); | ||
1269 | mutex_unlock(&playlist->control_mutex); | ||
1270 | } | ||
1271 | sync_control(playlist, true); | ||
1272 | } | ||
1273 | return true; | ||
1274 | } | ||
1275 | |||
1258 | static void playlist_thread(void) | 1276 | static void playlist_thread(void) |
1259 | { | 1277 | { |
1260 | struct queue_event ev; | 1278 | struct queue_event ev; |
@@ -1288,21 +1306,10 @@ static void playlist_thread(void) | |||
1288 | timeout or 5s, whichever is less */ | 1306 | timeout or 5s, whichever is less */ |
1289 | case SYS_TIMEOUT: | 1307 | case SYS_TIMEOUT: |
1290 | playlist = ¤t_playlist; | 1308 | playlist = ¤t_playlist; |
1291 | 1309 | if (playlist->control_fd >= 0) | |
1292 | if (playlist->control_fd >= 0 | ||
1293 | # ifndef SIMULATOR | ||
1294 | && ata_disk_is_active() | ||
1295 | # endif | ||
1296 | ) | ||
1297 | { | 1310 | { |
1298 | if (playlist->num_cached > 0) | 1311 | if (playlist->num_cached > 0) |
1299 | { | 1312 | register_ata_idle_func(playlist_flush_callback); |
1300 | mutex_lock(&playlist->control_mutex); | ||
1301 | flush_cached_control(playlist); | ||
1302 | mutex_unlock(&playlist->control_mutex); | ||
1303 | } | ||
1304 | |||
1305 | sync_control(playlist, true); | ||
1306 | } | 1313 | } |
1307 | 1314 | ||
1308 | if (!dirty_pointers) | 1315 | if (!dirty_pointers) |
diff --git a/firmware/export/ata.h b/firmware/export/ata.h index d3323308e8..35538f6354 100644 --- a/firmware/export/ata.h +++ b/firmware/export/ata.h | |||
@@ -40,6 +40,10 @@ extern void ata_enable(bool on); | |||
40 | extern void ata_spindown(int seconds); | 40 | extern void ata_spindown(int seconds); |
41 | extern void ata_sleep(void); | 41 | extern void ata_sleep(void); |
42 | extern void ata_sleepnow(void); | 42 | extern void ata_sleepnow(void); |
43 | /* NOTE: DO NOT use this to poll for disk activity. | ||
44 | If you are waiting for the disk to become active before | ||
45 | doing something use ata_idle_notify.h | ||
46 | */ | ||
43 | extern bool ata_disk_is_active(void); | 47 | extern bool ata_disk_is_active(void); |
44 | extern int ata_hard_reset(void); | 48 | extern int ata_hard_reset(void); |
45 | extern int ata_soft_reset(void); | 49 | extern int ata_soft_reset(void); |