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:
parent
d67d6a8462
commit
4db3e89652
23 changed files with 57 additions and 34 deletions
|
@ -183,8 +183,7 @@ static struct albumart_slot
|
||||||
/* Buffer and thread state tracking */
|
/* Buffer and thread state tracking */
|
||||||
static enum filling_state
|
static enum filling_state
|
||||||
{
|
{
|
||||||
STATE_BOOT = 0, /* audio thread is not ready yet */
|
STATE_IDLE = 0, /* audio is stopped: nothing to do */
|
||||||
STATE_IDLE, /* audio is stopped: nothing to do */
|
|
||||||
STATE_FILLING, /* adding tracks to the buffer */
|
STATE_FILLING, /* adding tracks to the buffer */
|
||||||
STATE_FULL, /* can't add any more tracks */
|
STATE_FULL, /* can't add any more tracks */
|
||||||
STATE_END_OF_PLAYLIST, /* all remaining tracks have been added */
|
STATE_END_OF_PLAYLIST, /* all remaining tracks have been added */
|
||||||
|
@ -194,7 +193,7 @@ static enum filling_state
|
||||||
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
||||||
STATE_USB, /* USB mode, ignore most messages */
|
STATE_USB, /* USB mode, ignore most messages */
|
||||||
#endif
|
#endif
|
||||||
} filling = STATE_BOOT;
|
} filling = STATE_IDLE;
|
||||||
|
|
||||||
/* Track info - holds information about each track in the buffer */
|
/* Track info - holds information about each track in the buffer */
|
||||||
struct track_info
|
struct track_info
|
||||||
|
@ -2917,8 +2916,6 @@ static void audio_thread(void)
|
||||||
|
|
||||||
pcm_postinit();
|
pcm_postinit();
|
||||||
|
|
||||||
filling = STATE_IDLE;
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
switch (filling)
|
switch (filling)
|
||||||
|
@ -3717,12 +3714,6 @@ unsigned long audio_prev_elapsed(void)
|
||||||
return prev_track_elapsed;
|
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 */
|
/* Return total file buffer length after accounting for the talk buf */
|
||||||
size_t audio_get_filebuflen(void)
|
size_t audio_get_filebuflen(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,7 +70,6 @@ struct bufopen_bitmap_data {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
bool audio_is_thread_ready(void);
|
|
||||||
int audio_track_count(void);
|
int audio_track_count(void);
|
||||||
long audio_filebufused(void);
|
long audio_filebufused(void);
|
||||||
void audio_pre_ff_rewind(void);
|
void audio_pre_ff_rewind(void);
|
||||||
|
|
|
@ -418,7 +418,7 @@ void radio_screen(void)
|
||||||
/* turn on radio */
|
/* turn on radio */
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
/* This should be done before touching audio settings */
|
/* This should be done before touching audio settings */
|
||||||
while (!audio_is_thread_ready())
|
while (!pcm_is_initialized())
|
||||||
sleep(0);
|
sleep(0);
|
||||||
|
|
||||||
audio_set_input_source(AUDIO_SRC_FMRADIO,
|
audio_set_input_source(AUDIO_SRC_FMRADIO,
|
||||||
|
|
|
@ -1074,7 +1074,7 @@ bool recording_screen(bool no_source)
|
||||||
|
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
/* This should be done before touching audio settings */
|
/* This should be done before touching audio settings */
|
||||||
while (!audio_is_thread_ready())
|
while (!pcm_is_initialized())
|
||||||
sleep(0);
|
sleep(0);
|
||||||
|
|
||||||
/* recording_menu gets messed up: so prevent manus talking */
|
/* recording_menu gets messed up: so prevent manus talking */
|
||||||
|
|
|
@ -66,6 +66,7 @@ extern volatile bool pcm_paused;
|
||||||
void pcm_play_dma_lock(void);
|
void pcm_play_dma_lock(void);
|
||||||
void pcm_play_dma_unlock(void);
|
void pcm_play_dma_unlock(void);
|
||||||
void pcm_play_dma_init(void) INIT_ATTR;
|
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_start(const void *addr, size_t size);
|
||||||
void pcm_play_dma_stop(void);
|
void pcm_play_dma_stop(void);
|
||||||
void pcm_play_dma_pause(bool pause);
|
void pcm_play_dma_pause(bool pause);
|
||||||
|
|
|
@ -76,6 +76,7 @@ void pcm_play_unlock(void);
|
||||||
|
|
||||||
void pcm_init(void) INIT_ATTR;
|
void pcm_init(void) INIT_ATTR;
|
||||||
void pcm_postinit(void);
|
void pcm_postinit(void);
|
||||||
|
bool pcm_is_initialized(void);
|
||||||
|
|
||||||
/* This is for playing "raw" PCM data */
|
/* This is for playing "raw" PCM data */
|
||||||
void pcm_play_data(pcm_play_callback_type get_more,
|
void pcm_play_data(pcm_play_callback_type get_more,
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
* Semi-private -
|
* Semi-private -
|
||||||
* pcm_play_get_more_callback
|
* pcm_play_get_more_callback
|
||||||
* pcm_play_dma_init
|
* pcm_play_dma_init
|
||||||
|
* pcm_play_dma_postinit
|
||||||
* pcm_play_dma_start
|
* pcm_play_dma_start
|
||||||
* pcm_play_dma_stop
|
* pcm_play_dma_stop
|
||||||
* pcm_play_dma_pause
|
* 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 */
|
/* the registered callback function to ask for more mp3 data */
|
||||||
static pcm_play_callback_type pcm_callback_for_more SHAREDBSS_ATTR = NULL;
|
static pcm_play_callback_type pcm_callback_for_more SHAREDBSS_ATTR = NULL;
|
||||||
void (* pcm_play_dma_started)(void) 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;
|
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.
|
* Perform peak calculation on a buffer of packed 16-bit samples.
|
||||||
*
|
*
|
||||||
|
@ -230,6 +240,23 @@ void pcm_init(void)
|
||||||
pcm_play_dma_init();
|
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 */
|
/* Common code to pcm_play_data and pcm_play_pause */
|
||||||
static void pcm_play_data_start(unsigned char *start, size_t size)
|
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");
|
logf("pcm_apply_settings");
|
||||||
|
|
||||||
|
pcm_wait_for_init();
|
||||||
|
|
||||||
if (pcm_sampr != pcm_curr_sampr)
|
if (pcm_sampr != pcm_curr_sampr)
|
||||||
{
|
{
|
||||||
logf(" pcm_dma_apply_settings");
|
logf(" pcm_dma_apply_settings");
|
||||||
|
@ -487,6 +516,8 @@ void pcm_init_recording(void)
|
||||||
{
|
{
|
||||||
logf("pcm_init_recording");
|
logf("pcm_init_recording");
|
||||||
|
|
||||||
|
pcm_wait_for_init();
|
||||||
|
|
||||||
/* Stop the beasty before attempting recording */
|
/* Stop the beasty before attempting recording */
|
||||||
mixer_reset();
|
mixer_reset();
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ void pcm_play_dma_init(void)
|
||||||
audiohw_preinit();
|
audiohw_preinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
audiohw_postinit();
|
audiohw_postinit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,7 +247,7 @@ void pcm_play_dma_init(void)
|
||||||
audiohw_init();
|
audiohw_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
audiohw_postinit();
|
audiohw_postinit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -527,7 +527,7 @@ void pcm_play_dma_init(void)
|
||||||
IISCONFIG |= IIS_TXFIFOEN;
|
IISCONFIG |= IIS_TXFIFOEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_postinit(void)
|
void void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
audiohw_postinit();
|
audiohw_postinit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,11 +57,6 @@ struct dma_data dma_play_data SHAREDBSS_ATTR =
|
||||||
.state = 0
|
.state = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
void pcm_postinit(void)
|
|
||||||
{
|
|
||||||
audiohw_postinit();
|
|
||||||
}
|
|
||||||
|
|
||||||
const void * pcm_play_dma_get_peak_buffer(int *count)
|
const void * pcm_play_dma_get_peak_buffer(int *count)
|
||||||
{
|
{
|
||||||
unsigned long addr = (unsigned long)dma_play_data.p;
|
unsigned long addr = (unsigned long)dma_play_data.p;
|
||||||
|
@ -110,6 +105,11 @@ void pcm_play_dma_init(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pcm_play_dma_postinit(void)
|
||||||
|
{
|
||||||
|
audiohw_postinit();
|
||||||
|
}
|
||||||
|
|
||||||
void pcm_dma_apply_settings(void)
|
void pcm_dma_apply_settings(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,7 @@ void pcm_init(void)
|
||||||
DMAR10(1) |= 1;
|
DMAR10(1) |= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
audiohw_postinit();
|
audiohw_postinit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ void pcm_play_dma_init(void)
|
||||||
bitset32(&INTMOD, DMA2_MASK);
|
bitset32(&INTMOD, DMA2_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
audiohw_postinit();
|
audiohw_postinit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ void pcm_play_dma_init(void)
|
||||||
bitset32(&INTMOD, DMA2_MASK);
|
bitset32(&INTMOD, DMA2_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
audiohw_postinit();
|
audiohw_postinit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,7 +262,7 @@ void pcm_play_dma_init(void)
|
||||||
audiohw_preinit();
|
audiohw_preinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
audiohw_postinit();
|
audiohw_postinit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ void pcm_play_dma_init(void)
|
||||||
audiohw_preinit();
|
audiohw_preinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
audiohw_postinit();
|
audiohw_postinit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ void pcm_play_dma_init(void)
|
||||||
// dsp_init();
|
// dsp_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
audiohw_postinit();
|
audiohw_postinit();
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
*/
|
*/
|
||||||
static void *start;
|
static void *start;
|
||||||
|
|
||||||
void pcm_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
/* Configure clock divider */
|
/* Configure clock divider */
|
||||||
tsc2100_writereg(CONTROL_PAGE2, TSPP1_ADDRESS, 0x1120);
|
tsc2100_writereg(CONTROL_PAGE2, TSPP1_ADDRESS, 0x1120);
|
||||||
|
|
|
@ -203,7 +203,7 @@ void pcm_play_dma_init(void)
|
||||||
#endif
|
#endif
|
||||||
} /* pcm_play_dma_init */
|
} /* pcm_play_dma_init */
|
||||||
|
|
||||||
void pcm_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
audiohw_postinit();
|
audiohw_postinit();
|
||||||
iis_play_reset();
|
iis_play_reset();
|
||||||
|
|
|
@ -206,7 +206,7 @@ void pcm_play_dma_init(void)
|
||||||
write_method = e->GetMethodID(env_ptr, RockboxPCM_class, "write", "([BII)I");
|
write_method = e->GetMethodID(env_ptr, RockboxPCM_class, "write", "([BII)I");
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -397,7 +397,7 @@ void pcm_shutdown_gstreamer(void)
|
||||||
g_main_loop_unref (pcm_loop);
|
g_main_loop_unref (pcm_loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -410,7 +410,7 @@ void pcm_play_dma_init(void)
|
||||||
pcm_dma_apply_settings_nolock();
|
pcm_dma_apply_settings_nolock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
** Playback DMA transfer
|
** Playback DMA transfer
|
||||||
**/
|
**/
|
||||||
|
|
||||||
void pcm_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
audiohw_postinit();
|
audiohw_postinit();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue