#149642 - sowee - Wed Jan 23, 2008 5:59 am
I set up streaming code using vblank, fifo, and a timer, theres a counter for every time the code runs through the vblank but it seems to stop at 5...i've been debugging for a while now and can't seem to find the problem
my arm7 main method:
vblankHandler does this:
and SoundFifoHandler does this:
while SoundSetTimer is:
My problem seems to be that it gets stuck such that it never enters SoundSwapAndMix() so my program keeps on streaming garbage (popping sound).
The relevant code in my arm9 main method is this:
where VBlankHandler just increments a variable for me to check that it runs continuosly...and that variable gets stuck at 5!
FifoHandler looks the same as the one in arm7 and calls a MixSound method when notified with UPDATE_ONARM9 from arm7...and this also never happens.. i don't get what the problem is, can someone help me?
Last edited by sowee on Tue Feb 05, 2008 5:27 am; edited 4 times in total
my arm7 main method:
Code: |
readUserSettings();
powerON(POWER_SOUND); writePowerManagement(PM_CONTROL_REG, ( readPowerManagement(PM_CONTROL_REG) & ~PM_SOUND_MUTE ) | PM_SOUND_AMP ); SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F); irqInit(); initClockIRQ(); SetYtrigger(80); irqSet(IRQ_VCOUNT , VcountHandler); irqSet(IRQ_VBLANK, VblankHandler); irqSet(IRQ_FIFO_NOT_EMPTY, SoundFifoHandler); irqEnable(IRQ_VBLANK); irqEnable(IRQ_VCOUNT); irqEnable(IRQ_FIFO_NOT_EMPTY); REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR | IPC_FIFO_RECV_IRQ; SoundSetTimer(0); while (1) swiWaitForVBlank(); |
vblankHandler does this:
Code: |
if(sharedSoundControl->stream.cmd & INIT)
{ SoundSetTimer(sharedSoundControl->stream.period); sharedSoundControl->stream.cmd &= ~INIT; } else if(sharedSoundControl->stream.cmd & MIXING) { sharedSoundControl->stream.inswapandmix++; SoundSwapAndMix(); } if(sharedSoundControl->stream.cmd & MIX) { StreamSound(&sharedSoundControl->stream); sharedSoundControl->stream.cmd &= ~MIX; sharedSoundControl->stream.cmd |= MIXING; } |
and SoundFifoHandler does this:
Code: |
u32 command;
if (!(REG_IPC_FIFO_CR & IPC_FIFO_RECV_EMPTY)) { command = REG_IPC_FIFO_RX; switch(command) { case FIFO_NONE: break; case MIXCOMPLETE_ONARM9: sharedSoundControl->stream.soundcursor += sharedSoundControl->stream.numsamples; if(sharedSoundControl->stream.bits_per_sample == 8) while (sharedSoundControl->stream.soundcursor > sharedSoundControl->stream.buffersize) sharedSoundControl->stream.soundcursor -= sharedSoundControl->stream.buffersize; else while (sharedSoundControl->stream.soundcursor > (sharedSoundControl->stream.buffersize >> 1)) sharedSoundControl->stream.soundcursor -= (sharedSoundControl->stream.buffersize >> 1); break; } } |
while SoundSetTimer is:
Code: |
void SoundSetTimer(int period) { if(!period) { TIMER0_DATA = 0; TIMER0_CR = 0; TIMER1_DATA = 0; TIMER1_CR = 0; } else { TIMER0_DATA = 0x10000 - (period * 2); TIMER0_CR = TIMER_ENABLE | TIMER_DIV_1; TIMER1_DATA = 0; TIMER1_CR = TIMER_ENABLE | TIMER_CASCADE | TIMER_DIV_1; } } |
My problem seems to be that it gets stuck such that it never enters SoundSwapAndMix() so my program keeps on streaming garbage (popping sound).
The relevant code in my arm9 main method is this:
Code: |
irqSet(IRQ_VBLANK, VBlankHandler); irqSet(IRQ_FIFO_NOT_EMPTY, FifoHandler); irqEnable(IRQ_VBLANK); irqEnable(IRQ_FIFO_NOT_EMPTY); REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR | IPC_FIFO_RECV_IRQ; |
where VBlankHandler just increments a variable for me to check that it runs continuosly...and that variable gets stuck at 5!
FifoHandler looks the same as the one in arm7 and calls a MixSound method when notified with UPDATE_ONARM9 from arm7...and this also never happens.. i don't get what the problem is, can someone help me?
Last edited by sowee on Tue Feb 05, 2008 5:27 am; edited 4 times in total