1
0
Fork 0
forked from len0rd/rockbox

Vorbis playback problems fixed.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6967 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Miika Pekkarinen 2005-07-01 17:05:09 +00:00
parent 0ec97339ae
commit 6d887afc3e

View file

@ -83,6 +83,8 @@ static void (*pcm_event_handler)(void);
static unsigned char *next_start; static unsigned char *next_start;
static long next_size; static long next_size;
static int last_chunksize = 0;
struct pcmbufdesc struct pcmbufdesc
{ {
void *addr; void *addr;
@ -107,7 +109,7 @@ static void dma_start(const void *addr, long size)
/* Reset the audio FIFO */ /* Reset the audio FIFO */
IIS2CONFIG = 0x800; IIS2CONFIG = 0x800;
EBU1CONFIG = 0x800; EBU1CONFIG = 0x800;
/* Set up DMA transfer */ /* Set up DMA transfer */
SAR0 = ((unsigned long)addr); /* Source address */ SAR0 = ((unsigned long)addr); /* Source address */
DAR0 = (unsigned long)&PDOR3; /* Destination address */ DAR0 = (unsigned long)&PDOR3; /* Destination address */
@ -144,6 +146,18 @@ static void dma_stop(void)
/* Reset the FIFO */ /* Reset the FIFO */
IIS2CONFIG = 0x800; IIS2CONFIG = 0x800;
EBU1CONFIG = 0x800; EBU1CONFIG = 0x800;
pcmbuf_unplayed_bytes = 0;
last_chunksize = 0;
audiobuffer_pos = 0;
audiobuffer_fillpos = 0;
audiobuffer_free = PCMBUF_SIZE;
pcmbuf_read_index = 0;
pcmbuf_write_index = 0;
next_start = NULL;
next_size = 0;
crossfade_init = 0;
pcm_paused = false;
} }
/* sets frequency of input to DAC */ /* sets frequency of input to DAC */
@ -175,8 +189,6 @@ int pcm_play_num_used_buffers(void)
return (pcmbuf_write_index - pcmbuf_read_index) & NUM_PCM_BUFFERS_MASK; return (pcmbuf_write_index - pcmbuf_read_index) & NUM_PCM_BUFFERS_MASK;
} }
static int last_chunksize = 0;
static void pcm_play_callback(unsigned char** start, long* size) static void pcm_play_callback(unsigned char** start, long* size)
{ {
struct pcmbufdesc *desc = &pcmbuffers[pcmbuf_read_index]; struct pcmbufdesc *desc = &pcmbuffers[pcmbuf_read_index];
@ -232,9 +244,8 @@ void pcm_play_data(const unsigned char* start, int size,
void (*get_more)(unsigned char** start, long* size)) void (*get_more)(unsigned char** start, long* size))
{ {
callback_for_more = get_more; callback_for_more = get_more;
dma_start(start, size);
get_more(&next_start, &next_size); get_more(&next_start, &next_size);
dma_start(start, size);
/* Sleep a while, then power on audio output */ /* Sleep a while, then power on audio output */
sleep(HZ/16); sleep(HZ/16);
@ -251,15 +262,6 @@ void pcm_play_stop(void)
sleep(HZ/16); sleep(HZ/16);
dma_stop(); dma_stop();
} }
pcmbuf_unplayed_bytes = 0;
last_chunksize = 0;
audiobuffer_pos = 0;
audiobuffer_fillpos = 0;
audiobuffer_free = PCMBUF_SIZE;
pcmbuf_read_index = 0;
pcmbuf_write_index = 0;
next_start = NULL;
next_size = 0;
} }
void pcm_play_pause(bool play) void pcm_play_pause(bool play)
@ -298,11 +300,13 @@ void DMA0(void)
int res = DSR0; int res = DSR0;
DSR0 = 1; /* Clear interrupt */ DSR0 = 1; /* Clear interrupt */
DCR0 &= ~DMA_EEXT;
/* Stop on error */ /* Stop on error */
if(res & 0x70) if(res & 0x70)
{ {
dma_stop(); dma_stop();
logf("DMA Error");
} }
else else
{ {
@ -310,6 +314,7 @@ void DMA0(void)
{ {
SAR0 = (unsigned long)next_start; /* Source address */ SAR0 = (unsigned long)next_start; /* Source address */
BCR0 = next_size; /* Bytes to transfer */ BCR0 = next_size; /* Bytes to transfer */
DCR0 |= DMA_EEXT;
if (callback_for_more) if (callback_for_more)
callback_for_more(&next_start, &next_size); callback_for_more(&next_start, &next_size);
} }
@ -317,6 +322,7 @@ void DMA0(void)
{ {
/* Finished playing */ /* Finished playing */
dma_stop(); dma_stop();
logf("DMA No Data");
} }
} }
@ -442,7 +448,11 @@ void pcm_flush_fillpos(void)
if (audiobuffer_fillpos) { if (audiobuffer_fillpos) {
while (!pcm_play_add_chunk(&audiobuffer[audiobuffer_pos], while (!pcm_play_add_chunk(&audiobuffer[audiobuffer_pos],
audiobuffer_fillpos, pcm_event_handler)) { audiobuffer_fillpos, pcm_event_handler)) {
pcm_boost(false);
yield(); yield();
/* This is a fatal error situation that should never happen. */
if (!pcm_playing)
break ;
} }
pcm_event_handler = NULL; pcm_event_handler = NULL;
audiobuffer_pos += audiobuffer_fillpos; audiobuffer_pos += audiobuffer_fillpos;
@ -527,7 +537,7 @@ inline static bool prepare_insert(long length)
return false; return false;
} }
if (!pcm_is_playing() && !pcm_paused) { if (!pcm_is_playing()) {
pcm_boost(true); pcm_boost(true);
crossfade_active = false; crossfade_active = false;
if (audiobuffer_free < PCMBUF_SIZE - CHUNK_SIZE*4) if (audiobuffer_free < PCMBUF_SIZE - CHUNK_SIZE*4)
@ -659,7 +669,7 @@ bool pcm_insert_buffer(char *buf, long length)
length -= copy_n; length -= copy_n;
/* Pre-buffer to meet CHUNK_SIZE requirement */ /* Pre-buffer to meet CHUNK_SIZE requirement */
if (copy_n + audiobuffer_fillpos < CHUNK_SIZE && length == 0) { if (audiobuffer_fillpos < CHUNK_SIZE && length == 0) {
return true; return true;
} }