Shuffle some functions around so that interfacing with playback.c in particular isn't required. Though playback does finish the audio init, pcm doesn't care who does it.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30403 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2011-09-01 12:15:43 +00:00
parent d67d6a8462
commit 4db3e89652
23 changed files with 57 additions and 34 deletions

View File

@ -183,8 +183,7 @@ static struct albumart_slot
/* Buffer and thread state tracking */
static enum filling_state
{
STATE_BOOT = 0, /* audio thread is not ready yet */
STATE_IDLE, /* audio is stopped: nothing to do */
STATE_IDLE = 0, /* audio is stopped: nothing to do */
STATE_FILLING, /* adding tracks to the buffer */
STATE_FULL, /* can't add any more tracks */
STATE_END_OF_PLAYLIST, /* all remaining tracks have been added */
@ -194,7 +193,7 @@ static enum filling_state
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
STATE_USB, /* USB mode, ignore most messages */
#endif
} filling = STATE_BOOT;
} filling = STATE_IDLE;
/* Track info - holds information about each track in the buffer */
struct track_info
@ -2917,8 +2916,6 @@ static void audio_thread(void)
pcm_postinit();
filling = STATE_IDLE;
while (1)
{
switch (filling)
@ -3717,12 +3714,6 @@ unsigned long audio_prev_elapsed(void)
return prev_track_elapsed;
}
/* Is the audio thread ready to accept commands? */
bool audio_is_thread_ready(void)
{
return filling != STATE_BOOT;
}
/* Return total file buffer length after accounting for the talk buf */
size_t audio_get_filebuflen(void)
{

View File

@ -70,7 +70,6 @@ struct bufopen_bitmap_data {
#endif
/* Functions */
bool audio_is_thread_ready(void);
int audio_track_count(void);
long audio_filebufused(void);
void audio_pre_ff_rewind(void);

View File

@ -418,7 +418,7 @@ void radio_screen(void)
/* turn on radio */
#if CONFIG_CODEC == SWCODEC
/* This should be done before touching audio settings */
while (!audio_is_thread_ready())
while (!pcm_is_initialized())
sleep(0);
audio_set_input_source(AUDIO_SRC_FMRADIO,

View File

@ -1074,7 +1074,7 @@ bool recording_screen(bool no_source)
#if CONFIG_CODEC == SWCODEC
/* This should be done before touching audio settings */
while (!audio_is_thread_ready())
while (!pcm_is_initialized())
sleep(0);
/* recording_menu gets messed up: so prevent manus talking */

View File

@ -66,6 +66,7 @@ extern volatile bool pcm_paused;
void pcm_play_dma_lock(void);
void pcm_play_dma_unlock(void);
void pcm_play_dma_init(void) INIT_ATTR;
void pcm_play_dma_postinit(void);
void pcm_play_dma_start(const void *addr, size_t size);
void pcm_play_dma_stop(void);
void pcm_play_dma_pause(bool pause);

View File

@ -76,6 +76,7 @@ void pcm_play_unlock(void);
void pcm_init(void) INIT_ATTR;
void pcm_postinit(void);
bool pcm_is_initialized(void);
/* This is for playing "raw" PCM data */
void pcm_play_data(pcm_play_callback_type get_more,

View File

@ -43,6 +43,7 @@
* Semi-private -
* pcm_play_get_more_callback
* pcm_play_dma_init
* pcm_play_dma_postinit
* pcm_play_dma_start
* pcm_play_dma_stop
* pcm_play_dma_pause
@ -79,6 +80,9 @@
*
*/
/* 'true' when all stages of pcm initialization have completed */
static bool pcm_is_ready = false;
/* the registered callback function to ask for more mp3 data */
static pcm_play_callback_type pcm_callback_for_more SHAREDBSS_ATTR = NULL;
void (* pcm_play_dma_started)(void) SHAREDBSS_ATTR = NULL;
@ -105,6 +109,12 @@ static void pcm_play_stopped(void)
pcm_playing = false;
}
static void pcm_wait_for_init(void)
{
while (!pcm_is_ready)
sleep(0);
}
/**
* Perform peak calculation on a buffer of packed 16-bit samples.
*
@ -230,6 +240,23 @@ void pcm_init(void)
pcm_play_dma_init();
}
/* Finish delayed init */
void pcm_postinit(void)
{
logf("pcm_postinit");
logf(" pcm_play_dma_postinit");
pcm_play_dma_postinit();
pcm_is_ready = true;
}
bool pcm_is_initialized(void)
{
return pcm_is_ready;
}
/* Common code to pcm_play_data and pcm_play_pause */
static void pcm_play_data_start(unsigned char *start, size_t size)
{
@ -402,6 +429,8 @@ void pcm_apply_settings(void)
{
logf("pcm_apply_settings");
pcm_wait_for_init();
if (pcm_sampr != pcm_curr_sampr)
{
logf(" pcm_dma_apply_settings");
@ -487,6 +516,8 @@ void pcm_init_recording(void)
{
logf("pcm_init_recording");
pcm_wait_for_init();
/* Stop the beasty before attempting recording */
mixer_reset();

View File

@ -181,7 +181,7 @@ void pcm_play_dma_init(void)
audiohw_preinit();
}
void pcm_postinit(void)
void pcm_play_dma_postinit(void)
{
audiohw_postinit();
}

View File

@ -247,7 +247,7 @@ void pcm_play_dma_init(void)
audiohw_init();
}
void pcm_postinit(void)
void pcm_play_dma_postinit(void)
{
audiohw_postinit();
}

View File

@ -527,7 +527,7 @@ void pcm_play_dma_init(void)
IISCONFIG |= IIS_TXFIFOEN;
}
void pcm_postinit(void)
void void pcm_play_dma_postinit(void)
{
audiohw_postinit();
}

View File

@ -57,11 +57,6 @@ struct dma_data dma_play_data SHAREDBSS_ATTR =
.state = 0
};
void pcm_postinit(void)
{
audiohw_postinit();
}
const void * pcm_play_dma_get_peak_buffer(int *count)
{
unsigned long addr = (unsigned long)dma_play_data.p;
@ -110,6 +105,11 @@ void pcm_play_dma_init(void)
#endif
}
void pcm_play_dma_postinit(void)
{
audiohw_postinit();
}
void pcm_dma_apply_settings(void)
{
}

View File

@ -190,7 +190,7 @@ void pcm_init(void)
DMAR10(1) |= 1;
}
void pcm_postinit(void)
void pcm_play_dma_postinit(void)
{
audiohw_postinit();
}

View File

@ -94,7 +94,7 @@ void pcm_play_dma_init(void)
bitset32(&INTMOD, DMA2_MASK);
}
void pcm_postinit(void)
void pcm_play_dma_postinit(void)
{
audiohw_postinit();
}

View File

@ -120,7 +120,7 @@ void pcm_play_dma_init(void)
bitset32(&INTMOD, DMA2_MASK);
}
void pcm_postinit(void)
void pcm_play_dma_postinit(void)
{
audiohw_postinit();
}

View File

@ -262,7 +262,7 @@ void pcm_play_dma_init(void)
audiohw_preinit();
}
void pcm_postinit(void)
void pcm_play_dma_postinit(void)
{
audiohw_postinit();
}

View File

@ -152,7 +152,7 @@ void pcm_play_dma_init(void)
audiohw_preinit();
}
void pcm_postinit(void)
void pcm_play_dma_postinit(void)
{
audiohw_postinit();
}

View File

@ -44,7 +44,7 @@ void pcm_play_dma_init(void)
// dsp_init();
}
void pcm_postinit(void)
void pcm_play_dma_postinit(void)
{
audiohw_postinit();

View File

@ -35,7 +35,7 @@
*/
static void *start;
void pcm_postinit(void)
void pcm_play_dma_postinit(void)
{
/* Configure clock divider */
tsc2100_writereg(CONTROL_PAGE2, TSPP1_ADDRESS, 0x1120);

View File

@ -203,7 +203,7 @@ void pcm_play_dma_init(void)
#endif
} /* pcm_play_dma_init */
void pcm_postinit(void)
void pcm_play_dma_postinit(void)
{
audiohw_postinit();
iis_play_reset();

View File

@ -206,7 +206,7 @@ void pcm_play_dma_init(void)
write_method = e->GetMethodID(env_ptr, RockboxPCM_class, "write", "([BII)I");
}
void pcm_postinit(void)
void pcm_play_dma_postinit(void)
{
}

View File

@ -397,7 +397,7 @@ void pcm_shutdown_gstreamer(void)
g_main_loop_unref (pcm_loop);
}
void pcm_postinit(void)
void pcm_play_dma_postinit(void)
{
}

View File

@ -410,7 +410,7 @@ void pcm_play_dma_init(void)
pcm_dma_apply_settings_nolock();
}
void pcm_postinit(void)
void pcm_play_dma_postinit(void)
{
}

View File

@ -33,7 +33,7 @@
** Playback DMA transfer
**/
void pcm_postinit(void)
void pcm_play_dma_postinit(void)
{
audiohw_postinit();