From: notaz Date: Thu, 1 Nov 2007 09:39:56 +0000 (+0000) Subject: psp snd output improved X-Git-Tag: v1.85~630 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88b3d7c16ae976d332b8462de839b86f856a7180;p=picodrive.git psp snd output improved git-svn-id: file:///home/notaz/opt/svn/PicoDrive@288 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/Pico/sound/sound.c b/Pico/sound/sound.c index f43252ff..aa2acb2e 100644 --- a/Pico/sound/sound.c +++ b/Pico/sound/sound.c @@ -220,8 +220,14 @@ PICO_INTERNAL void PsndClear(void) { int len = PsndLen; if (PsndLen_exc_add) len++; - if (PicoOpt & 8) memset32((int *) PsndOut, 0, len); // clear both channels at once - else memset(PsndOut, 0, len<<1); + if (PicoOpt & 8) + memset32((int *) PsndOut, 0, len); // assume PsndOut to be aligned + else { + short *out = PsndOut; + if ((int)out & 2) { *out++ = 0; len--; } + memset32((int *) out, 0, len/2); + if (len & 1) out[len-1] = 0; + } } @@ -248,9 +254,9 @@ PICO_INTERNAL int PsndRender(int offset, int length) SN76496Update(PsndOut+offset, length, stereo); // Add in the stereo FM buffer - if (PicoOpt & 1) { + if (PicoOpt & 1) buf32_updated = YM2612UpdateOne(buf32, length, stereo, 1); - } else + else memset32(buf32, 0, length<= samples_block*3) { + //lprintf("block skip (%i)\n", samples_made - samples_done); + samples_done += samples_block; // skip + snd_playptr += samples_block; + } + } lprintf("sthr: exit\n"); @@ -546,8 +555,7 @@ static void sound_prepare(void) stereo=(PicoOpt&8)>>3; samples_block = Pico.m.pal ? SOUND_BLOCK_SIZE_PAL : SOUND_BLOCK_SIZE_NTSC; - if (PsndRate == 22050) samples_block /= 2; - else if (PsndRate == 11025) samples_block /= 4; + if (PsndRate <= 22050) samples_block /= 2; sndBuffer_endptr = &sndBuffer[samples_block*SOUND_BLOCK_COUNT]; lprintf("starting audio: %i, len: %i, stereo: %i, pal: %i, block samples: %i\n", @@ -606,7 +614,7 @@ static void writeSound(int len) // signal the snd thread samples_made += len; - if (samples_made - samples_done >= samples_block) { + if (samples_made - samples_done > samples_block*2) { // lprintf("signal, %i/%i\n", samples_done, samples_made); ret = sceKernelSignalSema(sound_sem, 1); // lprintf("signal ret %i\n", ret); @@ -938,12 +946,10 @@ void emu_Loop(void) int tval_diff; tval = sceKernelGetSystemTimeLow(); tval_diff = (int)(tval - tval_thissec) << 8; - if (tval_diff > lim_time) + if (tval_diff > lim_time && (frames_done/16 < frames_shown)) { // no time left for this frame - skip if (tval_diff - lim_time >= (300000<<8)) { - /* something caused a slowdown for us (disk access? cache flush?) - * try to recover by resetting timing... */ reset_timing = 1; continue; }