Even more quiet audio initialization.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6705 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Miika Pekkarinen 2005-06-14 07:54:09 +00:00
parent 37f59a0f6f
commit 6ab53ba458
4 changed files with 28 additions and 21 deletions

View file

@ -105,7 +105,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parm)
#endif #endif
ci->configure(CODEC_SET_FILEBUF_LIMIT, (int *)(1024*1024*2)); ci->configure(CODEC_SET_FILEBUF_LIMIT, (int *)(1024*1024*2));
ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*32)); ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*64));
/* We need to flush reserver memory every track load. */ /* We need to flush reserver memory every track load. */
next_track: next_track:

View file

@ -128,20 +128,27 @@ int uda1380_set_regs(void)
return 0; return 0;
} }
/* Silently enable / disable audio output */
void uda1380_enable_output(bool enable)
{
if (enable) {
uda1380_write_reg(REG_PWR, uda1380_regs[REG_PWR] | PON_HP);
/* Sleep a while, then disable the master mute */
sleep(HZ/8);
uda1380_write_reg(REG_MUTE, MUTE_CH2);
} else {
uda1380_write_reg(REG_MUTE, MUTE_MASTER);
uda1380_write_reg(REG_PWR, uda1380_regs[REG_PWR] & ~PON_HP);
}
}
/* Initialize UDA1380 codec with default register values (uda1380_defaults) */ /* Initialize UDA1380 codec with default register values (uda1380_defaults) */
int uda1380_init(void) int uda1380_init(void)
{ {
if (uda1380_set_regs() == -1) if (uda1380_set_regs() == -1)
return -1; return -1;
/* Sleep a while, then power on headphone amp */
sleep(HZ/8);
uda1380_write_reg(REG_PWR, uda1380_regs[REG_PWR] | PON_HP);
/* Sleep a little more, then disable the master mute */
sleep(HZ/8);
uda1380_write_reg(REG_MUTE, MUTE_CH2);
return 0; return 0;
} }

View file

@ -27,6 +27,7 @@
#define _UDA1380_H #define _UDA1380_H
extern int uda1380_init(void); extern int uda1380_init(void);
extern void uda1380_enable_output(bool enable);
extern int uda1380_setvol(int vol); extern int uda1380_setvol(int vol);
extern int uda1380_mute(int mute); extern int uda1380_mute(int mute);
extern void uda1380_close(void); extern void uda1380_close(void);

View file

@ -116,10 +116,11 @@ void pcm_boost(bool state)
static void dma_stop(void) static void dma_stop(void)
{ {
pcm_playing = false; pcm_playing = false;
uda1380_enable_output(false);
pcm_boost(false);
/* Reset the FIFO */ /* Reset the FIFO */
IIS2CONFIG = 0x800; IIS2CONFIG = 0x800;
pcm_boost(false);
} }
/* set volume of the main channel */ /* set volume of the main channel */
@ -222,17 +223,23 @@ void pcm_play_data(const unsigned char* start, int size,
dma_start(start, size); dma_start(start, size);
get_more(&next_start, &next_size); get_more(&next_start, &next_size);
/* Sleep a while, then power on audio output */
sleep(HZ/16);
uda1380_enable_output(true);
} }
void pcm_play_stop(void) void pcm_play_stop(void)
{ {
dma_stop(); if (pcm_playing)
dma_stop();
pcmbuf_unplayed_bytes = 0;
last_chunksize = 0;
audiobuffer_pos = 0; audiobuffer_pos = 0;
audiobuffer_fillpos = 0; audiobuffer_fillpos = 0;
audiobuffer_free = PCMBUF_SIZE; audiobuffer_free = PCMBUF_SIZE;
pcmbuf_read_index = 0; pcmbuf_read_index = 0;
pcmbuf_write_index = 0; pcmbuf_write_index = 0;
pcmbuf_unplayed_bytes = 0;
next_start = NULL; next_start = NULL;
next_size = 0; next_size = 0;
pcm_set_boost_mode(false); pcm_set_boost_mode(false);
@ -431,7 +438,7 @@ bool audiobuffer_insert(char *buf, size_t length)
if (!pcm_is_playing() && !pcm_paused) { if (!pcm_is_playing() && !pcm_paused) {
pcm_boost(true); pcm_boost(true);
crossfade_active = false; crossfade_active = false;
if (audiobuffer_free < PCMBUF_SIZE - CHUNK_SIZE*2) if (audiobuffer_free < PCMBUF_SIZE - CHUNK_SIZE*4)
pcm_play_start(); pcm_play_start();
} }
@ -497,14 +504,6 @@ void pcm_play_init(void)
pcmbuf_unplayed_bytes = 0; pcmbuf_unplayed_bytes = 0;
crossfade_enabled = false; crossfade_enabled = false;
pcm_play_set_watermark(PCM_WATERMARK, pcm_watermark_callback); pcm_play_set_watermark(PCM_WATERMARK, pcm_watermark_callback);
/* Play a small chunk of zeroes to initialize the playback system. */
audiobuffer_pos = 32000;
audiobuffer_free -= audiobuffer_pos;
memset(&audiobuffer[0], 0, audiobuffer_pos);
pcm_play_add_chunk(&audiobuffer[0], audiobuffer_pos, NULL);
pcm_play_start();
} }
void pcm_crossfade_enable(bool on_off) void pcm_crossfade_enable(bool on_off)