Make buffering initialization versus reset separate functions to avoid double initializing threads or mutexes more easily

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15327 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Brandon Low 2007-10-27 04:16:41 +00:00
parent 404c6fbdb2
commit 14b6f437bb
3 changed files with 24 additions and 19 deletions

View file

@ -1189,8 +1189,23 @@ void buffering_thread(void)
}
}
void buffering_init(void) {
mutex_init(&llist_mutex);
conf_filechunk = BUFFERING_DEFAULT_FILECHUNK;
conf_watermark = BUFFERING_DEFAULT_WATERMARK;
buffering_thread_p = create_thread( buffering_thread, buffering_stack,
sizeof(buffering_stack), 0,
buffering_thread_name IF_PRIO(, PRIORITY_BUFFERING)
IF_COP(, CPU));
queue_init(&buffering_queue, true);
queue_enable_queue_send(&buffering_queue, &buffering_queue_sender_list);
}
/* Initialise the buffering subsystem */
bool buffering_init(char *buf, size_t buflen)
bool buffering_reset(char *buf, size_t buflen)
{
if (!buf || !buflen)
return false;
@ -1211,27 +1226,11 @@ bool buffering_init(char *buf, size_t buflen)
buffer_callback_count = 0;
memset(buffer_low_callback_funcs, 0, sizeof(buffer_low_callback_funcs));
mutex_init(&llist_mutex);
conf_filechunk = BUFFERING_DEFAULT_FILECHUNK;
conf_watermark = BUFFERING_DEFAULT_WATERMARK;
/* Set the high watermark as 75% full...or 25% empty :) */
#if MEM > 8
high_watermark = 3*buflen / 4;
#endif
if (buffering_thread_p == NULL)
{
buffering_thread_p = create_thread( buffering_thread, buffering_stack,
sizeof(buffering_stack), 0,
buffering_thread_name IF_PRIO(, PRIORITY_BUFFERING)
IF_COP(, CPU));
queue_init(&buffering_queue, true);
queue_enable_queue_send(&buffering_queue, &buffering_queue_sender_list);
}
return true;
}

View file

@ -37,7 +37,10 @@ enum data_type {
/* Initialise the buffering subsystem */
bool buffering_init(char *buf, size_t buflen);
void buffering_init(void);
/* Reset the buffering system */
bool buffering_reset(char *buf, size_t buflen);
/***************************************************************************

View file

@ -3067,7 +3067,7 @@ static void audio_reset_buffer(void)
will already be line aligned */
filebuflen &= ~3;
buffering_init(filebuf, filebuflen);
buffering_reset(filebuf, filebuflen);
/* Clear any references to the file buffer */
buffer_state = BUFFER_STATE_INITIALIZED;
@ -3361,6 +3361,9 @@ void audio_init(void)
/* Set crossfade setting for next buffer init which should be about... */
pcmbuf_crossfade_enable(global_settings.crossfade);
/* initialize the buffering system */
buffering_init();
/* ...now! Set up the buffers */
audio_reset_buffer();