From effceea22915a087c1c85ff30d2e62110413edaf Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Thu, 23 Oct 2008 13:13:00 +0000 Subject: Remove the event object in the kernel since it's rather extraneous at the moment. This makes the codecs and the plugins incompatible, so update fully. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18867 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs.c | 3 --- apps/codecs.h | 7 ++----- apps/codecs/spc.c | 9 ++++----- apps/plugin.c | 6 +----- apps/plugin.h | 9 ++------- apps/plugins/test_codec.c | 3 --- apps/voice_thread.c | 12 ++++++------ 7 files changed, 15 insertions(+), 34 deletions(-) (limited to 'apps') diff --git a/apps/codecs.c b/apps/codecs.c index 8e9e55a5d4..53fa6755a8 100644 --- a/apps/codecs.c +++ b/apps/codecs.c @@ -105,9 +105,6 @@ struct codec_api ci = { semaphore_init, semaphore_wait, semaphore_release, - event_init, - event_wait, - event_set_state, #endif #ifdef CACHE_FUNCTIONS_AS_CALL diff --git a/apps/codecs.h b/apps/codecs.h index 6d8c1016a8..4194524e6d 100644 --- a/apps/codecs.h +++ b/apps/codecs.h @@ -82,12 +82,12 @@ #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ /* increase this every time the api struct changes */ -#define CODEC_API_VERSION 26 +#define CODEC_API_VERSION 27 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define CODEC_MIN_API_VERSION 26 +#define CODEC_MIN_API_VERSION 27 /* codec return codes */ enum codec_status { @@ -175,9 +175,6 @@ struct codec_api { void (*semaphore_init)(struct semaphore *s, int max, int start); void (*semaphore_wait)(struct semaphore *s); void (*semaphore_release)(struct semaphore *s); - void (*event_init)(struct event *e, unsigned int flags); - void (*event_wait)(struct event *e, unsigned int for_state); - void (*event_set_state)(struct event *e, unsigned int state); #endif /* NUM_CORES */ #ifdef CACHE_FUNCTIONS_AS_CALL diff --git a/apps/codecs/spc.c b/apps/codecs/spc.c index da91eb0391..a2b6fabf99 100644 --- a/apps/codecs/spc.c +++ b/apps/codecs/spc.c @@ -230,7 +230,7 @@ static struct int head, tail; struct semaphore emu_sem_head; struct semaphore emu_sem_tail; - struct event emu_evt_reply; + struct semaphore emu_evt_reply; intptr_t retval; struct sample_queue_chunk wav_chunk[WAV_NUM_CHUNKS]; } sample_queue SHAREDBSS_ATTR; @@ -284,7 +284,7 @@ static intptr_t emu_thread_send_msg(long id, intptr_t data) if (id != SPC_EMU_QUIT) { /* Wait for a response */ - ci->event_wait(&sample_queue.emu_evt_reply, STATE_SIGNALED); + ci->semaphore_wait(&sample_queue.emu_evt_reply); } return sample_queue.retval; @@ -316,7 +316,7 @@ static bool emu_thread_process_msg(struct sample_queue_chunk *chunk) } if (id != SPC_EMU_QUIT) { - ci->event_set_state(&sample_queue.emu_evt_reply, STATE_SIGNALED); + ci->semaphore_release(&sample_queue.emu_evt_reply); } return ret; @@ -361,8 +361,7 @@ static bool spc_emu_start(void) /* Initialize audio queue as full to prevent emu thread from trying to run the emulator before loading something */ - ci->event_init(&sample_queue.emu_evt_reply, - EVENT_AUTOMATIC | STATE_NONSIGNALED); + ci->semaphore_init(&sample_queue.emu_evt_reply, 1, 0); ci->semaphore_init(&sample_queue.emu_sem_tail, 2, 0); ci->semaphore_init(&sample_queue.emu_sem_head, 2, 2); sample_queue.head = 0; diff --git a/apps/plugin.c b/apps/plugin.c index 4ba1396085..a9c9a6c3f8 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -614,11 +614,7 @@ static const struct plugin_api rockbox_api = { semaphore_wait, semaphore_release, #endif -#ifdef HAVE_EVENT_OBJECTS - event_init, - event_wait, - event_set_state, -#endif + appsversion, /* new stuff at the end, sort into place next time the API gets incompatible */ diff --git a/apps/plugin.h b/apps/plugin.h index 1029431cd1..9544b3851c 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -130,12 +130,12 @@ void* plugin_get_buffer(size_t *buffer_size); #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 124 +#define PLUGIN_API_VERSION 125 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define PLUGIN_MIN_API_VERSION 123 +#define PLUGIN_MIN_API_VERSION 125 /* plugin return codes */ enum plugin_status { @@ -770,11 +770,6 @@ struct plugin_api { void (*semaphore_wait)(struct semaphore *s); void (*semaphore_release)(struct semaphore *s); #endif -#ifdef HAVE_EVENT_OBJECTS - void (*event_init)(struct event *e, unsigned int flags); - void (*event_wait)(struct event *e, unsigned int for_state); - void (*event_set_state)(struct event *e, unsigned int state); -#endif const char *appsversion; /* new stuff at the end, sort into place next time diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index 448b512c83..3c54610a94 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c @@ -493,9 +493,6 @@ static void init_ci(void) ci.semaphore_init = rb->semaphore_init; ci.semaphore_wait = rb->semaphore_wait; ci.semaphore_release = rb->semaphore_release; - ci.event_init = rb->event_init; - ci.event_wait = rb->event_wait; - ci.event_set_state = rb->event_set_state; #endif } diff --git a/apps/voice_thread.c b/apps/voice_thread.c index aeffa5bd7c..084c3872c6 100644 --- a/apps/voice_thread.c +++ b/apps/voice_thread.c @@ -61,8 +61,8 @@ static const char voice_thread_name[] = "voice"; /* Voice thread synchronization objects */ static struct event_queue voice_queue SHAREDBSS_ATTR; static struct mutex voice_mutex SHAREDBSS_ATTR; -static struct event voice_event SHAREDBSS_ATTR; static struct queue_sender_list voice_queue_sender_list SHAREDBSS_ATTR; +static bool voice_done SHAREDDATA_ATTR = true; /* Buffer for decoded samples */ static spx_int16_t voice_output_buf[VOICE_FRAME_SIZE] CACHEALIGN_ATTR; @@ -189,9 +189,9 @@ void voice_wait(void) /* NOTE: One problem here is that we can't tell if another thread started a * new clip by the time we wait. This should be resolvable if conditions * ever require knowing the very clip you requested has finished. */ - event_wait(&voice_event, STATE_SIGNALED); + /* Wait for PCM buffer to be exhausted. Works only if not playing. */ - while(!playback_is_playing() && pcm_is_playing()) + while(!voice_done || (!playback_is_playing() && pcm_is_playing())) sleep(1); } @@ -219,7 +219,7 @@ static void voice_message(struct voice_thread_data *td) case Q_VOICE_PLAY: LOGFQUEUE("voice < Q_VOICE_PLAY"); /* Put up a block for completion signal */ - event_set_state(&voice_event, STATE_NONSIGNALED); + voice_done = false; /* Copy the clip info */ td->vi = *(struct voice_info *)td->ev.data; @@ -264,7 +264,7 @@ static void voice_message(struct voice_thread_data *td) cancel_cpu_boost(); td->state = TSTATE_STOPPED; - event_set_state(&voice_event, STATE_SIGNALED); + voice_done = true; break; case Q_VOICE_STATE: @@ -433,7 +433,7 @@ void voice_thread_init(void) logf("Starting voice thread"); queue_init(&voice_queue, false); mutex_init(&voice_mutex); - event_init(&voice_event, STATE_SIGNALED | EVENT_MANUAL); + voice_thread_p = create_thread(voice_thread, voice_stack, sizeof(voice_stack), CREATE_THREAD_FROZEN, voice_thread_name IF_PRIO(, PRIORITY_PLAYBACK) IF_COP(, CPU)); -- cgit v1.2.3