1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Michael Sevakis 2008-10-23 13:13:00 +00:00
parent 188e898e3c
commit effceea229
10 changed files with 15 additions and 170 deletions

View file

@ -105,9 +105,6 @@ struct codec_api ci = {
semaphore_init, semaphore_init,
semaphore_wait, semaphore_wait,
semaphore_release, semaphore_release,
event_init,
event_wait,
event_set_state,
#endif #endif
#ifdef CACHE_FUNCTIONS_AS_CALL #ifdef CACHE_FUNCTIONS_AS_CALL

View file

@ -82,12 +82,12 @@
#define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */
/* increase this every time the api struct changes */ /* 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 /* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */ 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 */ /* codec return codes */
enum codec_status { enum codec_status {
@ -175,9 +175,6 @@ struct codec_api {
void (*semaphore_init)(struct semaphore *s, int max, int start); void (*semaphore_init)(struct semaphore *s, int max, int start);
void (*semaphore_wait)(struct semaphore *s); void (*semaphore_wait)(struct semaphore *s);
void (*semaphore_release)(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 */ #endif /* NUM_CORES */
#ifdef CACHE_FUNCTIONS_AS_CALL #ifdef CACHE_FUNCTIONS_AS_CALL

View file

@ -230,7 +230,7 @@ static struct
int head, tail; int head, tail;
struct semaphore emu_sem_head; struct semaphore emu_sem_head;
struct semaphore emu_sem_tail; struct semaphore emu_sem_tail;
struct event emu_evt_reply; struct semaphore emu_evt_reply;
intptr_t retval; intptr_t retval;
struct sample_queue_chunk wav_chunk[WAV_NUM_CHUNKS]; struct sample_queue_chunk wav_chunk[WAV_NUM_CHUNKS];
} sample_queue SHAREDBSS_ATTR; } 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) { if (id != SPC_EMU_QUIT) {
/* Wait for a response */ /* 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; return sample_queue.retval;
@ -316,7 +316,7 @@ static bool emu_thread_process_msg(struct sample_queue_chunk *chunk)
} }
if (id != SPC_EMU_QUIT) { 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; 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 /* Initialize audio queue as full to prevent emu thread from trying to run the
emulator before loading something */ emulator before loading something */
ci->event_init(&sample_queue.emu_evt_reply, ci->semaphore_init(&sample_queue.emu_evt_reply, 1, 0);
EVENT_AUTOMATIC | STATE_NONSIGNALED);
ci->semaphore_init(&sample_queue.emu_sem_tail, 2, 0); ci->semaphore_init(&sample_queue.emu_sem_tail, 2, 0);
ci->semaphore_init(&sample_queue.emu_sem_head, 2, 2); ci->semaphore_init(&sample_queue.emu_sem_head, 2, 2);
sample_queue.head = 0; sample_queue.head = 0;

View file

@ -614,11 +614,7 @@ static const struct plugin_api rockbox_api = {
semaphore_wait, semaphore_wait,
semaphore_release, semaphore_release,
#endif #endif
#ifdef HAVE_EVENT_OBJECTS
event_init,
event_wait,
event_set_state,
#endif
appsversion, appsversion,
/* new stuff at the end, sort into place next time /* new stuff at the end, sort into place next time
the API gets incompatible */ the API gets incompatible */

View file

@ -130,12 +130,12 @@ void* plugin_get_buffer(size_t *buffer_size);
#define PLUGIN_MAGIC 0x526F634B /* RocK */ #define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */ /* 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 /* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */ 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 */ /* plugin return codes */
enum plugin_status { enum plugin_status {
@ -770,11 +770,6 @@ struct plugin_api {
void (*semaphore_wait)(struct semaphore *s); void (*semaphore_wait)(struct semaphore *s);
void (*semaphore_release)(struct semaphore *s); void (*semaphore_release)(struct semaphore *s);
#endif #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; const char *appsversion;
/* new stuff at the end, sort into place next time /* new stuff at the end, sort into place next time

View file

@ -493,9 +493,6 @@ static void init_ci(void)
ci.semaphore_init = rb->semaphore_init; ci.semaphore_init = rb->semaphore_init;
ci.semaphore_wait = rb->semaphore_wait; ci.semaphore_wait = rb->semaphore_wait;
ci.semaphore_release = rb->semaphore_release; 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 #endif
} }

View file

@ -61,8 +61,8 @@ static const char voice_thread_name[] = "voice";
/* Voice thread synchronization objects */ /* Voice thread synchronization objects */
static struct event_queue voice_queue SHAREDBSS_ATTR; static struct event_queue voice_queue SHAREDBSS_ATTR;
static struct mutex voice_mutex 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 struct queue_sender_list voice_queue_sender_list SHAREDBSS_ATTR;
static bool voice_done SHAREDDATA_ATTR = true;
/* Buffer for decoded samples */ /* Buffer for decoded samples */
static spx_int16_t voice_output_buf[VOICE_FRAME_SIZE] CACHEALIGN_ATTR; 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 /* 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 * new clip by the time we wait. This should be resolvable if conditions
* ever require knowing the very clip you requested has finished. */ * 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. */ /* 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); sleep(1);
} }
@ -219,7 +219,7 @@ static void voice_message(struct voice_thread_data *td)
case Q_VOICE_PLAY: case Q_VOICE_PLAY:
LOGFQUEUE("voice < Q_VOICE_PLAY"); LOGFQUEUE("voice < Q_VOICE_PLAY");
/* Put up a block for completion signal */ /* Put up a block for completion signal */
event_set_state(&voice_event, STATE_NONSIGNALED); voice_done = false;
/* Copy the clip info */ /* Copy the clip info */
td->vi = *(struct voice_info *)td->ev.data; td->vi = *(struct voice_info *)td->ev.data;
@ -264,7 +264,7 @@ static void voice_message(struct voice_thread_data *td)
cancel_cpu_boost(); cancel_cpu_boost();
td->state = TSTATE_STOPPED; td->state = TSTATE_STOPPED;
event_set_state(&voice_event, STATE_SIGNALED); voice_done = true;
break; break;
case Q_VOICE_STATE: case Q_VOICE_STATE:
@ -433,7 +433,7 @@ void voice_thread_init(void)
logf("Starting voice thread"); logf("Starting voice thread");
queue_init(&voice_queue, false); queue_init(&voice_queue, false);
mutex_init(&voice_mutex); mutex_init(&voice_mutex);
event_init(&voice_event, STATE_SIGNALED | EVENT_MANUAL);
voice_thread_p = create_thread(voice_thread, voice_stack, voice_thread_p = create_thread(voice_thread, voice_stack,
sizeof(voice_stack), CREATE_THREAD_FROZEN, sizeof(voice_stack), CREATE_THREAD_FROZEN,
voice_thread_name IF_PRIO(, PRIORITY_PLAYBACK) IF_COP(, CPU)); voice_thread_name IF_PRIO(, PRIORITY_PLAYBACK) IF_COP(, CPU));

View file

@ -409,7 +409,6 @@
#endif /* SIMULATOR */ #endif /* SIMULATOR */
#define HAVE_SEMAPHORE_OBJECTS #define HAVE_SEMAPHORE_OBJECTS
#define HAVE_EVENT_OBJECTS
#ifdef TOSHIBA_GIGABEAT_F #ifdef TOSHIBA_GIGABEAT_F
#define HAVE_WAKEUP_OBJECTS #define HAVE_WAKEUP_OBJECTS

View file

@ -176,17 +176,6 @@ struct semaphore
}; };
#endif #endif
#ifdef HAVE_EVENT_OBJECTS
struct event
{
struct thread_entry *queues[2]; /* waiters for each state */
unsigned char automatic; /* event performs auto-reset */
unsigned char state; /* state: 1 = signaled */
IF_COP( struct corelock cl; ) /* multiprocessor sync */
};
#endif
#ifdef HAVE_WAKEUP_OBJECTS #ifdef HAVE_WAKEUP_OBJECTS
struct wakeup struct wakeup
{ {
@ -286,13 +275,6 @@ extern void semaphore_init(struct semaphore *s, int max, int start);
extern void semaphore_wait(struct semaphore *s); extern void semaphore_wait(struct semaphore *s);
extern void semaphore_release(struct semaphore *s); extern void semaphore_release(struct semaphore *s);
#endif /* HAVE_SEMAPHORE_OBJECTS */ #endif /* HAVE_SEMAPHORE_OBJECTS */
#ifdef HAVE_EVENT_OBJECTS
#define EVENT_AUTOMATIC 0x10
#define EVENT_MANUAL 0x00
extern void event_init(struct event *e, unsigned int flags);
extern void event_wait(struct event *e, unsigned int for_state);
extern void event_set_state(struct event *e, unsigned int state);
#endif /* HAVE_EVENT_OBJECTS */
#ifdef HAVE_WAKEUP_OBJECTS #ifdef HAVE_WAKEUP_OBJECTS
extern void wakeup_init(struct wakeup *w); extern void wakeup_init(struct wakeup *w);

View file

@ -1264,122 +1264,6 @@ void semaphore_release(struct semaphore *s)
} }
#endif /* HAVE_SEMAPHORE_OBJECTS */ #endif /* HAVE_SEMAPHORE_OBJECTS */
/****************************************************************************
* Simple event functions ;)
****************************************************************************/
#ifdef HAVE_EVENT_OBJECTS
void event_init(struct event *e, unsigned int flags)
{
e->queues[STATE_NONSIGNALED] = NULL;
e->queues[STATE_SIGNALED] = NULL;
e->state = flags & STATE_SIGNALED;
e->automatic = (flags & EVENT_AUTOMATIC) ? 1 : 0;
corelock_init(&e->cl);
}
void event_wait(struct event *e, unsigned int for_state)
{
struct thread_entry *current;
corelock_lock(&e->cl);
if(e->automatic != 0)
{
/* wait for false always satisfied by definition
or if it just changed to false */
if(e->state == STATE_SIGNALED || for_state == STATE_NONSIGNALED)
{
/* automatic - unsignal */
e->state = STATE_NONSIGNALED;
corelock_unlock(&e->cl);
return;
}
/* block until state matches */
}
else if(for_state == e->state)
{
/* the state being waited for is the current state */
corelock_unlock(&e->cl);
return;
}
/* block until state matches what callers requests */
current = cores[CURRENT_CORE].running;
IF_COP( current->obj_cl = &e->cl; )
current->bqp = &e->queues[for_state];
disable_irq();
block_thread(current);
corelock_unlock(&e->cl);
/* turn control over to next thread */
switch_thread();
}
void event_set_state(struct event *e, unsigned int state)
{
unsigned int result;
int oldlevel;
corelock_lock(&e->cl);
if(e->state == state)
{
/* no change */
corelock_unlock(&e->cl);
return;
}
IF_PRIO( result = THREAD_OK; )
oldlevel = disable_irq_save();
if(state == STATE_SIGNALED)
{
if(e->automatic != 0)
{
/* no thread should have ever blocked for nonsignaled */
KERNEL_ASSERT(e->queues[STATE_NONSIGNALED] == NULL,
"set_event_state->queue[NS]:S\n");
/* pass to next thread and keep unsignaled - "pulse" */
result = wakeup_thread(&e->queues[STATE_SIGNALED]);
e->state = (result & THREAD_OK) ? STATE_NONSIGNALED : STATE_SIGNALED;
}
else
{
/* release all threads waiting for signaled */
e->state = STATE_SIGNALED;
IF_PRIO( result = )
thread_queue_wake(&e->queues[STATE_SIGNALED]);
}
}
else
{
/* release all threads waiting for nonsignaled */
/* no thread should have ever blocked if automatic */
KERNEL_ASSERT(e->queues[STATE_NONSIGNALED] == NULL ||
e->automatic == 0, "set_event_state->queue[NS]:NS\n");
e->state = STATE_NONSIGNALED;
IF_PRIO( result = )
thread_queue_wake(&e->queues[STATE_NONSIGNALED]);
}
restore_irq(oldlevel);
corelock_unlock(&e->cl);
#ifdef HAVE_PRIORITY_SCHEDULING
if(result & THREAD_SWITCH)
switch_thread();
#endif
}
#endif /* HAVE_EVENT_OBJECTS */
#ifdef HAVE_WAKEUP_OBJECTS #ifdef HAVE_WAKEUP_OBJECTS
/**************************************************************************** /****************************************************************************
* Lightweight IRQ-compatible wakeup object * Lightweight IRQ-compatible wakeup object
@ -1456,4 +1340,3 @@ int wakeup_signal(struct wakeup *w)
return ret; return ret;
} }
#endif /* HAVE_WAKEUP_OBJECTS */ #endif /* HAVE_WAKEUP_OBJECTS */