diff options
Diffstat (limited to 'apps/playback.c')
-rw-r--r-- | apps/playback.c | 58 |
1 files changed, 3 insertions, 55 deletions
diff --git a/apps/playback.c b/apps/playback.c index b36f68f135..ee1787e612 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -245,13 +245,6 @@ static bool skipped_during_pause = false; /* Do we need to clear the PCM buffer | |||
245 | */ | 245 | */ |
246 | static bool codec_requested_stop = false; | 246 | static bool codec_requested_stop = false; |
247 | 247 | ||
248 | struct playback_event { | ||
249 | enum PLAYBACK_EVENT_TYPE type; | ||
250 | void (*callback)(void *data); | ||
251 | }; | ||
252 | |||
253 | struct playback_event events[PLAYBACK_MAX_EVENTS]; | ||
254 | |||
255 | static size_t buffer_margin = 0; /* Buffer margin aka anti-skip buffer (A/C-) */ | 248 | static size_t buffer_margin = 0; /* Buffer margin aka anti-skip buffer (A/C-) */ |
256 | 249 | ||
257 | /* Multiple threads */ | 250 | /* Multiple threads */ |
@@ -1447,51 +1440,6 @@ static void codec_thread(void) | |||
1447 | 1440 | ||
1448 | /* --- Audio thread --- */ | 1441 | /* --- Audio thread --- */ |
1449 | 1442 | ||
1450 | void playback_add_event(enum PLAYBACK_EVENT_TYPE type, void (*handler)) | ||
1451 | { | ||
1452 | int i; | ||
1453 | |||
1454 | /* Try to find a free slot. */ | ||
1455 | for (i = 0; i < PLAYBACK_MAX_EVENTS; i++) | ||
1456 | { | ||
1457 | if (events[i].callback == NULL) | ||
1458 | { | ||
1459 | events[i].type = type; | ||
1460 | events[i].callback = handler; | ||
1461 | return; | ||
1462 | } | ||
1463 | } | ||
1464 | |||
1465 | panicf("playback event line full"); | ||
1466 | } | ||
1467 | |||
1468 | void playback_remove_event(enum PLAYBACK_EVENT_TYPE type, void (*handler)) | ||
1469 | { | ||
1470 | int i; | ||
1471 | |||
1472 | for (i = 0; i < PLAYBACK_MAX_EVENTS; i++) | ||
1473 | { | ||
1474 | if (events[i].type == type && events[i].callback == handler) | ||
1475 | { | ||
1476 | events[i].callback = NULL; | ||
1477 | return; | ||
1478 | } | ||
1479 | } | ||
1480 | |||
1481 | panicf("playback event not found"); | ||
1482 | } | ||
1483 | |||
1484 | static void send_event(enum PLAYBACK_EVENT_TYPE type, void *data) | ||
1485 | { | ||
1486 | int i; | ||
1487 | |||
1488 | for (i = 0; i < PLAYBACK_MAX_EVENTS; i++) | ||
1489 | { | ||
1490 | if (events[i].type == type && events[i].callback != NULL) | ||
1491 | events[i].callback(data); | ||
1492 | } | ||
1493 | } | ||
1494 | |||
1495 | static bool audio_have_tracks(void) | 1443 | static bool audio_have_tracks(void) |
1496 | { | 1444 | { |
1497 | return (audio_track_count() != 0); | 1445 | return (audio_track_count() != 0); |
@@ -1783,7 +1731,7 @@ static bool audio_load_track(int offset, bool start_play) | |||
1783 | { | 1731 | { |
1784 | if (get_metadata(&id3, fd, trackname)) | 1732 | if (get_metadata(&id3, fd, trackname)) |
1785 | { | 1733 | { |
1786 | send_event(PLAYBACK_EVENT_TRACK_BUFFER, &id3); | 1734 | send_event(PLAYBACK_EVENT_TRACK_BUFFER, false, &id3); |
1787 | 1735 | ||
1788 | tracks[track_widx].id3_hid = | 1736 | tracks[track_widx].id3_hid = |
1789 | bufalloc(&id3, sizeof(struct mp3entry), TYPE_ID3); | 1737 | bufalloc(&id3, sizeof(struct mp3entry), TYPE_ID3); |
@@ -2020,7 +1968,7 @@ static int audio_check_new_track(void) | |||
2020 | bool end_of_playlist; /* Temporary flag, not the same as playlist_end */ | 1968 | bool end_of_playlist; /* Temporary flag, not the same as playlist_end */ |
2021 | 1969 | ||
2022 | /* Now it's good time to send track unbuffer events. */ | 1970 | /* Now it's good time to send track unbuffer events. */ |
2023 | send_event(PLAYBACK_EVENT_TRACK_FINISH, &curtrack_id3); | 1971 | send_event(PLAYBACK_EVENT_TRACK_FINISH, false, &curtrack_id3); |
2024 | 1972 | ||
2025 | if (dir_skip) | 1973 | if (dir_skip) |
2026 | { | 1974 | { |
@@ -2391,7 +2339,7 @@ static void audio_finalise_track_change(void) | |||
2391 | bufgetid3(prev_ti->id3_hid)->elapsed = 0; | 2339 | bufgetid3(prev_ti->id3_hid)->elapsed = 0; |
2392 | } | 2340 | } |
2393 | 2341 | ||
2394 | send_event(PLAYBACK_EVENT_TRACK_CHANGE, &curtrack_id3); | 2342 | send_event(PLAYBACK_EVENT_TRACK_CHANGE, false, &curtrack_id3); |
2395 | 2343 | ||
2396 | track_changed = true; | 2344 | track_changed = true; |
2397 | playlist_update_resume_info(audio_current_track()); | 2345 | playlist_update_resume_info(audio_current_track()); |