rendered paste bodydiff --git a/apps/buffering.c b/apps/buffering.cindex 64f522c..f6c9f31 100644--- a/apps/buffering.c+++ b/apps/buffering.c@@ -61,7 +61,7 @@ #endif /* Define LOGF_ENABLE to enable logf output in this file */-/*#define LOGF_ENABLE*/+#define LOGF_ENABLE #include "logf.h" /* macros to enable logf for queues@@ -639,6 +639,10 @@ static bool buffer_handle(int handle_id) h->available += rc; h->filerem -= rc; +#ifdef SIMULATOR+ sleep(1);+#endif+ /* If this is a large file, see if we need to break or give the codec * more time */ if (h->type == TYPE_PACKET_AUDIO &&diff --git a/apps/debug_menu.c b/apps/debug_menu.cindex 8cd1fed..7091814 100644--- a/apps/debug_menu.c+++ b/apps/debug_menu.c@@ -279,6 +279,8 @@ static bool dbg_buffering_thread(void) size_t bufsize = pcmbuf_get_bufsize(); int pcmbufdescs = pcmbuf_descs(); struct buffering_debug d;+ //extern struct codec_api ci;+ extern int wps_offset; ticks = boost_ticks = 0; @@ -288,16 +290,16 @@ static bool dbg_buffering_thread(void) lcd_setfont(FONT_SYSFIXED); while(!done) {- button = get_action(CONTEXT_STD,HZ/5);+ button = get_action(CONTEXT_WPS,HZ/5); switch(button) {- case ACTION_STD_NEXT:+ case ACTION_WPS_SKIPNEXT: audio_next(); break;- case ACTION_STD_PREV:+ case ACTION_WPS_SKIPPREV: audio_prev(); break;- case ACTION_STD_CANCEL:+ case ACTION_WPS_MENU: done = true; break; }@@ -370,6 +372,12 @@ static bool dbg_buffering_thread(void) pcmbuf_used_descs(), pcmbufdescs); lcd_puts(0, line++, buf); + //snprintf(buf, sizeof(buf), "ci.new_track: %d", ci.new_track);+ //lcd_puts(0, line++, buf);++ snprintf(buf, sizeof(buf), "wps_offset: %d", wps_offset);+ lcd_puts(0, line++, buf);+ lcd_update(); } diff --git a/apps/playback.c b/apps/playback.cindex cca5b73..73558e2 100644--- a/apps/playback.c+++ b/apps/playback.c@@ -86,7 +86,7 @@ #define AUDIO_REBUFFER_GUESS_SIZE (1024*32) /* Define LOGF_ENABLE to enable logf output in this file */-/*#define LOGF_ENABLE*/+#define LOGF_ENABLE #include "logf.h" /* macros to enable logf for queues@@ -222,6 +222,10 @@ static int track_widx = 0; /* Track being buffered (A) */ static struct track_info *prev_ti = NULL; /* Pointer to the previously played track */ +/* Set by buffering_audio_callback when the low buffer event is received, to+ avoid flodding the audio queue with fill_file_buffer messages. */+static bool lowbuffer_event_sent = false;+ /* Set by the audio thread when the current track information has updated * and the WPS may need to update its cached information */ static bool track_changed = false;@@ -239,7 +243,7 @@ static bool playlist_end = false; /* Has the current playlist ended? (A) */ static bool auto_dir_skip = false; /* Have we changed dirs automatically? */ static bool dir_skip = false; /* Is a directory skip pending? (A) */ static bool new_playlist = false; /* Are we starting a new playlist? (A) */-static int wps_offset = 0; /* Pending track change offset, to keep WPS responsive (A) */+int wps_offset = 0; /* Pending track change offset, to keep WPS responsive (A) */ static bool skipped_during_pause = false; /* Do we need to clear the PCM buffer when playback resumes (A) */ /* Callbacks which applications or plugins may set */@@ -553,7 +557,8 @@ struct mp3entry* audio_current_track(void) struct mp3entry* audio_next_track(void) {- int next_idx = track_ridx;+ int next_idx;+ int offset = ci.new_track + wps_offset; if (!audio_have_tracks()) return NULL;@@ -565,7 +570,7 @@ struct mp3entry* audio_next_track(void) return &curtrack_id3; } - next_idx = (next_idx + 1) & MAX_TRACK_MASK;+ next_idx = (track_ridx + offset + 1) & MAX_TRACK_MASK; if (next_idx == track_widx) {@@ -629,17 +634,19 @@ void audio_resume(void) queue_send(&audio_queue, Q_AUDIO_PAUSE, false); } -void audio_next(void)+static void audio_skip(int direction) {- if (playlist_check(ci.new_track + wps_offset + 1))+ if (playlist_check(ci.new_track + wps_offset + direction)) { if (global_settings.beep) pcmbuf_beep(5000, 100, 2500*global_settings.beep); - LOGFQUEUE("audio > audio Q_AUDIO_SKIP 1");- queue_post(&audio_queue, Q_AUDIO_SKIP, 1);+ LOGFQUEUE("audio > audio Q_AUDIO_SKIP %d", direction);+ queue_post(&audio_queue, Q_AUDIO_SKIP, direction); /* Update wps while our message travels inside deep playback queues. */- wps_offset++;+ playlist_next(direction);+ last_peek_offset -= direction;+ wps_offset += direction; track_changed = true; } else@@ -650,25 +657,14 @@ void audio_next(void) } } -void audio_prev(void)+void audio_next(void) {- if (playlist_check(ci.new_track + wps_offset - 1))- {- if (global_settings.beep)- pcmbuf_beep(5000, 100, 2500*global_settings.beep);+ audio_skip(1);+} - LOGFQUEUE("audio > audio Q_AUDIO_SKIP -1");- queue_post(&audio_queue, Q_AUDIO_SKIP, -1);- /* Update wps while our message travels inside deep playback queues. */- wps_offset--;- track_changed = true;- }- else- {- /* No more tracks. */- if (global_settings.beep)- pcmbuf_beep(1000, 100, 1000*global_settings.beep);- }+void audio_prev(void)+{+ audio_skip(-1); } void audio_next_dir(void)@@ -1466,8 +1462,11 @@ static void buffering_audio_callback(enum callback_event ev, int value) switch (ev) { case EVENT_BUFFER_LOW:- LOGFQUEUE("buffering > audio Q_AUDIO_FILL_BUFFER");- queue_post(&audio_queue, Q_AUDIO_FILL_BUFFER, 0);+ if (!lowbuffer_event_sent) {+ LOGFQUEUE("buffering > audio Q_AUDIO_FILL_BUFFER");+ queue_post(&audio_queue, Q_AUDIO_FILL_BUFFER, 0);+ lowbuffer_event_sent = true;+ } break; case EVENT_HANDLE_REBUFFER:@@ -1476,6 +1475,7 @@ static void buffering_audio_callback(enum callback_event ev, int value) break; case EVENT_HANDLE_FINISHED:+ logf("handle %d finished buffering", value); strip_tags(value); break; @@ -1895,6 +1895,9 @@ static void audio_fill_file_buffer(bool start_play, size_t offset) bool had_next_track = audio_next_track() != NULL; bool continue_buffering; + if (ci.new_track != 0)+ return;+ /* Must reset the buffer before use if trashed or voice only - voice file size shouldn't have changed so we can go straight from BUFFER_STATE_VOICED_ONLY to BUFFER_STATE_INITIALIZED */@@ -1902,6 +1905,9 @@ static void audio_fill_file_buffer(bool start_play, size_t offset) audio_reset_buffer(); logf("Starting buffer fill");+#ifdef SIMULATOR+ sleep(200);+#endif if (!start_play) audio_clear_track_entries(false);@@ -1930,6 +1936,7 @@ static void audio_fill_file_buffer(bool start_play, size_t offset) track_changed = true; audio_generate_postbuffer_events();+ lowbuffer_event_sent = false; } static void audio_rebuffer(void)@@ -1959,7 +1966,7 @@ static int audio_check_new_track(void) int track_count = audio_track_count(); int old_track_ridx = track_ridx; int i, idx;- int next_playlist_index;+ //int next_playlist_index; bool forward; bool end_of_playlist; /* Temporary flag, not the same as playlist_end */ @@ -2001,6 +2008,7 @@ static int audio_check_new_track(void) return Q_CODEC_REQUEST_FAILED; } }+#if 0 /* Update the playlist */ last_peek_offset -= ci.new_track; @@ -2016,6 +2024,7 @@ static int audio_check_new_track(void) return Q_CODEC_REQUEST_FAILED; } }+#endif if (new_playlist) {@@ -2063,8 +2072,6 @@ static int audio_check_new_track(void) wps_offset = -ci.new_track; } - track_changed = true;- /* If it is not safe to even skip this many track entries */ if (ci.new_track >= track_count || ci.new_track <= track_count - MAX_TRACK) {@@ -2296,8 +2303,11 @@ static void audio_new_playlist(void) audio_fill_file_buffer(false, 0); } +/* Called on manual track skip */ static void audio_initiate_track_change(long direction) {+ logf("audio_initiate_track_change(%ld)", direction);+ playlist_end = false; ci.new_track += direction; wps_offset -= direction;@@ -2305,6 +2315,7 @@ static void audio_initiate_track_change(long direction) skipped_during_pause = true; } +/* Called on manual dir skip */ static void audio_initiate_dir_change(long direction) { playlist_end = false;diff --git a/uisimulator/common/io.c b/uisimulator/common/io.cindex 822a43b..7489ff3 100644--- a/uisimulator/common/io.c+++ b/uisimulator/common/io.c@@ -342,7 +342,7 @@ int sim_open(const char *name, int o) { snprintf(buffer, sizeof(buffer), "%s%s", get_sim_rootdir(), name); - debugf("We open the real file '%s'\n", buffer);+ //debugf("We open the real file '%s'\n", buffer); if (num_openfiles < MAX_OPEN_FILES) { ret = OPEN(buffer, opts, 0666);