From: notaz Date: Sun, 30 Sep 2007 20:08:34 +0000 (+0000) Subject: working audio sync? X-Git-Tag: v1.85~652 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3d1de29dacce5e79cc644ce05064da9bc44af62;p=picodrive.git working audio sync? git-svn-id: file:///home/notaz/opt/svn/PicoDrive@266 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/platform/gizmondo/emu.c b/platform/gizmondo/emu.c index d8a22476..d404d554 100644 --- a/platform/gizmondo/emu.c +++ b/platform/gizmondo/emu.c @@ -557,7 +557,7 @@ void emu_Loop(void) snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps; snd_cbuf_samples = (PsndRate<>3, Pico.m.pal); + PsndRate, PsndLen, snd_excess_add, stereo, Pico.m.pal); ret = FrameworkAudio_Init(PsndRate, snd_cbuf_samples, stereo); if (ret != 0) { lprintf("FrameworkAudio_Init() failed: %i\n", ret); @@ -632,11 +632,27 @@ void emu_Loop(void) if (PsndOut != NULL) { - int audio_skew, adj; + /* some code which tries to sync things to audio clock, the dirty way */ + static int audio_skew_prev = 0; + int audio_skew, adj, co = 9, shift = 7; audio_skew = snd_all_samples*2 - FrameworkAudio_BufferPos(); - if (audio_skew < 0) - adj = -((-audio_skew) >> 10); - else adj = audio_skew >> 10; + if (PsndRate == 22050) co = 10; + if (PsndRate > 22050) co = 11; + if (PicoOpt&8) shift++; + if (audio_skew < 0) { + adj = -((-audio_skew) >> shift); + if (audio_skew > -(6<>=1; + if (audio_skew > -(4<>=1; + if (audio_skew > -(2<>=1; + if (audio_skew > audio_skew_prev) adj>>=2; // going up already + } else { + adj = audio_skew >> shift; + if (audio_skew < (6<>=1; + if (audio_skew < (4<>=1; + if (audio_skew < (2<>=1; + if (audio_skew < audio_skew_prev) adj>>=2; + } + audio_skew_prev = audio_skew; target_frametime += adj; sec_ms = (target_frametime * target_fps) >> 8; stdbg("%i %i %i", audio_skew, adj, sec_ms); diff --git a/platform/gizmondo/menu.c b/platform/gizmondo/menu.c index 1662da18..b062ffdc 100644 --- a/platform/gizmondo/menu.c +++ b/platform/gizmondo/menu.c @@ -1175,7 +1175,7 @@ static int sndrate_prevnext(int rate, int dir) if (rates[i] == rate) break; i += dir ? 1 : -1; - if (i > 4) return dir ? 44100 : 22050; + if (i > 2) return dir ? 44100 : 22050; if (i < 0) return dir ? 22050 : 11025; return rates[i]; }