summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2005-06-29 21:36:30 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2005-06-29 21:36:30 +0000
commit7d6d122441e2900d873ca8f96c3ed8063176dd33 (patch)
tree69be846721869779a5370da2675fcbdac6a31a67
parent7f8cc3f1c62cd6e09d94b38370e5d6f0bfc625cd (diff)
downloadrockbox-7d6d122441e2900d873ca8f96c3ed8063176dd33.zip
rockbox-7d6d122441e2900d873ca8f96c3ed8063176dd33.tar.gz
rockbox-7d6d122441e2900d873ca8f96c3ed8063176dd33.tar.bz2
rockbox-7d6d122441e2900d873ca8f96c3ed8063176dd33.tar.xz
Added event handler to register track changes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6936 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/playback.c15
-rw-r--r--apps/playback.h3
2 files changed, 16 insertions, 2 deletions
diff --git a/apps/playback.c b/apps/playback.c
index 55829a0..a89441f 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -152,7 +152,7 @@ static long fill_bytesleft;
static struct track_info tracks[MAX_TRACK];
/* Pointer to track info structure about current song playing. */
-static volatile struct track_info *cur_ti;
+static struct track_info *cur_ti;
/* Codec API including function callbacks. */
extern struct codec_api ci;
@@ -161,6 +161,9 @@ extern struct codec_api ci;
variable keeps information about whether to go a next/previous track. */
static int new_track;
+/* Callback function to call when current track has really changed. */
+void (*track_changed_callback)(struct track_info *ti);
+
/* Configuration */
static int conf_bufferlimit;
static int conf_watermark;
@@ -554,10 +557,15 @@ void codec_configure_callback(int setting, void *value)
}
}
+void audio_set_track_changed_event(void (*handler)(struct track_info *ti))
+{
+ track_changed_callback = handler;
+}
+
void codec_track_changed(void)
{
track_changed = true;
- // queue_post(&audio_queue, AUDIO_TRACK_CHANGED, 0);
+ queue_post(&audio_queue, AUDIO_TRACK_CHANGED, 0);
}
void yield_codecs(void)
@@ -1174,6 +1182,8 @@ void audio_thread(void)
break ;
case AUDIO_TRACK_CHANGED:
+ if (track_changed_callback)
+ track_changed_callback(cur_ti);
break ;
case AUDIO_CODEC_DONE:
@@ -1549,6 +1559,7 @@ void audio_init(void)
paused = false;
track_changed = false;
current_fd = -1;
+ track_changed_callback = NULL;
logf("abuf:%0x", PCMBUF_SIZE);
logf("fbuf:%0x", codecbuflen);
diff --git a/apps/playback.h b/apps/playback.h
index f0ae9ea..ac37651 100644
--- a/apps/playback.h
+++ b/apps/playback.h
@@ -60,6 +60,9 @@ struct track_info {
int playlist_offset; /* File location in playlist */
};
+/* Functions */
+void audio_set_track_changed_event(void (*handler)(struct track_info *ti));
+
#endif