diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2011-03-02 08:49:38 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2011-03-02 08:49:38 +0000 |
commit | 12375d1d3aa41f7d277a9af584c7b810b636ec95 (patch) | |
tree | fc9ce8029a6910a8dac71b3bf60c71155a01eea4 /apps | |
parent | 05e180a1308a095d51d51d0e047fcd44425ea88f (diff) | |
download | rockbox-12375d1d3aa41f7d277a9af584c7b810b636ec95.tar.gz rockbox-12375d1d3aa41f7d277a9af584c7b810b636ec95.zip |
Merge functionality of wakeups and semaphores-- fewer APIs and object types. semaphore_wait takes a timeout now so codecs and plugins have to be made incompatible. Don't make semaphores for targets not using them.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29492 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/codecs.h | 6 | ||||
-rw-r--r-- | apps/codecs/mpa.c | 4 | ||||
-rw-r--r-- | apps/codecs/spc.c | 17 | ||||
-rw-r--r-- | apps/plugin.h | 6 |
4 files changed, 16 insertions, 17 deletions
diff --git a/apps/codecs.h b/apps/codecs.h index 8a40791106..028e3614ff 100644 --- a/apps/codecs.h +++ b/apps/codecs.h | |||
@@ -75,12 +75,12 @@ | |||
75 | #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ | 75 | #define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ |
76 | 76 | ||
77 | /* increase this every time the api struct changes */ | 77 | /* increase this every time the api struct changes */ |
78 | #define CODEC_API_VERSION 38 | 78 | #define CODEC_API_VERSION 39 |
79 | 79 | ||
80 | /* update this to latest version if a change to the api struct breaks | 80 | /* update this to latest version if a change to the api struct breaks |
81 | backwards compatibility (and please take the opportunity to sort in any | 81 | backwards compatibility (and please take the opportunity to sort in any |
82 | new function which are "waiting" at the end of the function table) */ | 82 | new function which are "waiting" at the end of the function table) */ |
83 | #define CODEC_MIN_API_VERSION 38 | 83 | #define CODEC_MIN_API_VERSION 39 |
84 | 84 | ||
85 | /* codec return codes */ | 85 | /* codec return codes */ |
86 | enum codec_status { | 86 | enum codec_status { |
@@ -166,7 +166,7 @@ struct codec_api { | |||
166 | void (*thread_thaw)(unsigned int thread_id); | 166 | void (*thread_thaw)(unsigned int thread_id); |
167 | void (*thread_wait)(unsigned int thread_id); | 167 | void (*thread_wait)(unsigned int thread_id); |
168 | void (*semaphore_init)(struct semaphore *s, int max, int start); | 168 | void (*semaphore_init)(struct semaphore *s, int max, int start); |
169 | void (*semaphore_wait)(struct semaphore *s); | 169 | int (*semaphore_wait)(struct semaphore *s, int timeout); |
170 | void (*semaphore_release)(struct semaphore *s); | 170 | void (*semaphore_release)(struct semaphore *s); |
171 | #endif /* NUM_CORES */ | 171 | #endif /* NUM_CORES */ |
172 | 172 | ||
diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c index d3da63b430..4d6c52f2b3 100644 --- a/apps/codecs/mpa.c +++ b/apps/codecs/mpa.c | |||
@@ -211,7 +211,7 @@ static void mad_synth_thread(void) | |||
211 | { | 211 | { |
212 | while(1) { | 212 | while(1) { |
213 | ci->semaphore_release(&synth_done_sem); | 213 | ci->semaphore_release(&synth_done_sem); |
214 | ci->semaphore_wait(&synth_pending_sem); | 214 | ci->semaphore_wait(&synth_pending_sem, TIMEOUT_BLOCK); |
215 | 215 | ||
216 | if(die) | 216 | if(die) |
217 | break; | 217 | break; |
@@ -224,7 +224,7 @@ static void mad_synth_thread(void) | |||
224 | * synthesized */ | 224 | * synthesized */ |
225 | static inline void mad_synth_thread_wait_pcm(void) | 225 | static inline void mad_synth_thread_wait_pcm(void) |
226 | { | 226 | { |
227 | ci->semaphore_wait(&synth_done_sem); | 227 | ci->semaphore_wait(&synth_done_sem, TIMEOUT_BLOCK); |
228 | } | 228 | } |
229 | 229 | ||
230 | /* increment the done semaphore - used after a wait for idle to preserve the | 230 | /* increment the done semaphore - used after a wait for idle to preserve the |
diff --git a/apps/codecs/spc.c b/apps/codecs/spc.c index d4ed741f7e..4db2878964 100644 --- a/apps/codecs/spc.c +++ b/apps/codecs/spc.c | |||
@@ -244,7 +244,7 @@ static inline void samples_release_wrbuf(void) | |||
244 | 244 | ||
245 | static inline struct sample_queue_chunk * samples_get_wrbuf(void) | 245 | static inline struct sample_queue_chunk * samples_get_wrbuf(void) |
246 | { | 246 | { |
247 | ci->semaphore_wait(&sample_queue.emu_sem_tail); | 247 | ci->semaphore_wait(&sample_queue.emu_sem_tail, TIMEOUT_BLOCK); |
248 | return &sample_queue.wav_chunk[sample_queue.tail & WAV_CHUNK_MASK]; | 248 | return &sample_queue.wav_chunk[sample_queue.tail & WAV_CHUNK_MASK]; |
249 | } | 249 | } |
250 | 250 | ||
@@ -259,7 +259,7 @@ static inline void samples_release_rdbuf(void) | |||
259 | 259 | ||
260 | static inline int32_t * samples_get_rdbuf(void) | 260 | static inline int32_t * samples_get_rdbuf(void) |
261 | { | 261 | { |
262 | ci->semaphore_wait(&sample_queue.emu_sem_head); | 262 | ci->semaphore_wait(&sample_queue.emu_sem_head, TIMEOUT_BLOCK); |
263 | 263 | ||
264 | if (ci->stop_codec || ci->new_track) | 264 | if (ci->stop_codec || ci->new_track) |
265 | { | 265 | { |
@@ -275,7 +275,7 @@ static intptr_t emu_thread_send_msg(long id, intptr_t data) | |||
275 | { | 275 | { |
276 | struct sample_queue_chunk *chunk; | 276 | struct sample_queue_chunk *chunk; |
277 | /* Grab an audio output buffer */ | 277 | /* Grab an audio output buffer */ |
278 | ci->semaphore_wait(&sample_queue.emu_sem_head); | 278 | ci->semaphore_wait(&sample_queue.emu_sem_head, TIMEOUT_BLOCK); |
279 | chunk = &sample_queue.wav_chunk[sample_queue.head & WAV_CHUNK_MASK]; | 279 | chunk = &sample_queue.wav_chunk[sample_queue.head & WAV_CHUNK_MASK]; |
280 | /* Place a message in it instead of audio */ | 280 | /* Place a message in it instead of audio */ |
281 | chunk->id = id; | 281 | chunk->id = id; |
@@ -285,7 +285,7 @@ static intptr_t emu_thread_send_msg(long id, intptr_t data) | |||
285 | 285 | ||
286 | if (id != SPC_EMU_QUIT) { | 286 | if (id != SPC_EMU_QUIT) { |
287 | /* Wait for a response */ | 287 | /* Wait for a response */ |
288 | ci->semaphore_wait(&sample_queue.emu_evt_reply); | 288 | ci->semaphore_wait(&sample_queue.emu_evt_reply, TIMEOUT_BLOCK); |
289 | } | 289 | } |
290 | 290 | ||
291 | return sample_queue.retval; | 291 | return sample_queue.retval; |
@@ -308,11 +308,10 @@ static bool emu_thread_process_msg(struct sample_queue_chunk *chunk) | |||
308 | sample_queue.retval = SPC_load_spc(&spc_emu, ld->buf, ld->size); | 308 | sample_queue.retval = SPC_load_spc(&spc_emu, ld->buf, ld->size); |
309 | 309 | ||
310 | /* Empty the audio queue */ | 310 | /* Empty the audio queue */ |
311 | /* This is a dirty hack a timeout based wait would make unnescessary but | 311 | ci->semaphore_release(&sample_queue.emu_sem_tail); |
312 | still safe because the other thread is known to be waiting for a reply | 312 | ci->semaphore_release(&sample_queue.emu_sem_tail); |
313 | and is not using the objects. */ | 313 | ci->semaphore_wait(&sample_queue.emu_sem_head, TIMEOUT_NOBLOCK); |
314 | ci->semaphore_init(&sample_queue.emu_sem_tail, 2, 2); | 314 | ci->semaphore_wait(&sample_queue.emu_sem_head, TIMEOUT_NOBLOCK); |
315 | ci->semaphore_init(&sample_queue.emu_sem_head, 2, 0); | ||
316 | sample_queue.head = sample_queue.tail = 0; | 315 | sample_queue.head = sample_queue.tail = 0; |
317 | } | 316 | } |
318 | 317 | ||
diff --git a/apps/plugin.h b/apps/plugin.h index 8c2d458c57..2275b309d7 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -145,12 +145,12 @@ void* plugin_get_buffer(size_t *buffer_size); | |||
145 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 145 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
146 | 146 | ||
147 | /* increase this every time the api struct changes */ | 147 | /* increase this every time the api struct changes */ |
148 | #define PLUGIN_API_VERSION 199 | 148 | #define PLUGIN_API_VERSION 200 |
149 | 149 | ||
150 | /* update this to latest version if a change to the api struct breaks | 150 | /* update this to latest version if a change to the api struct breaks |
151 | backwards compatibility (and please take the opportunity to sort in any | 151 | backwards compatibility (and please take the opportunity to sort in any |
152 | new function which are "waiting" at the end of the function table) */ | 152 | new function which are "waiting" at the end of the function table) */ |
153 | #define PLUGIN_MIN_API_VERSION 199 | 153 | #define PLUGIN_MIN_API_VERSION 200 |
154 | 154 | ||
155 | /* plugin return codes */ | 155 | /* plugin return codes */ |
156 | /* internal returns start at 0x100 to make exit(1..255) work */ | 156 | /* internal returns start at 0x100 to make exit(1..255) work */ |
@@ -901,7 +901,7 @@ struct plugin_api { | |||
901 | 901 | ||
902 | #ifdef HAVE_SEMAPHORE_OBJECTS | 902 | #ifdef HAVE_SEMAPHORE_OBJECTS |
903 | void (*semaphore_init)(struct semaphore *s, int max, int start); | 903 | void (*semaphore_init)(struct semaphore *s, int max, int start); |
904 | void (*semaphore_wait)(struct semaphore *s); | 904 | int (*semaphore_wait)(struct semaphore *s, int timeout); |
905 | void (*semaphore_release)(struct semaphore *s); | 905 | void (*semaphore_release)(struct semaphore *s); |
906 | #endif | 906 | #endif |
907 | 907 | ||