notaz.gp2x.de
/
picodrive.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
psp snd output improved
[picodrive.git]
/
platform
/
psp
/
emu.c
diff --git
a/platform/psp/emu.c
b/platform/psp/emu.c
index
0db88ca
..
0e64f2a
100644
(file)
--- a/
platform/psp/emu.c
+++ b/
platform/psp/emu.c
@@
-469,8
+469,8
@@
static void vidResetMode(void)
/* sound stuff */
/* sound stuff */
-#define SOUND_BLOCK_SIZE_NTSC (
294
0*2) // 1024 // 1152
-#define SOUND_BLOCK_SIZE_PAL (
3528
*2)
+#define SOUND_BLOCK_SIZE_NTSC (
147
0*2) // 1024 // 1152
+#define SOUND_BLOCK_SIZE_PAL (
1764
*2)
#define SOUND_BLOCK_COUNT 4
static short __attribute__((aligned(4))) sndBuffer[SOUND_BLOCK_SIZE_PAL*SOUND_BLOCK_COUNT + 44100/50*2];
#define SOUND_BLOCK_COUNT 4
static short __attribute__((aligned(4))) sndBuffer[SOUND_BLOCK_SIZE_PAL*SOUND_BLOCK_COUNT + 44100/50*2];
@@
-485,14
+485,15
@@
static int sound_thread(SceSize args, void *argp)
{
int ret;
{
int ret;
- lprintf("s
ound_thread
: started, priority %i\n", sceKernelGetThreadCurrentPriority());
+ lprintf("s
thr
: started, priority %i\n", sceKernelGetThreadCurrentPriority());
while (!sound_thread_exit)
{
if (samples_made - samples_done < samples_block) {
while (!sound_thread_exit)
{
if (samples_made - samples_done < samples_block) {
- // wait for data...
- //lprintf("sthr: wait... (%i/%i)\n", samples_done, samples_made);
- ret = sceKernelWaitSema(sound_sem, 1, 0);
+ // wait for data (use at least 2 blocks)
+ //lprintf("sthr: wait... (%i)\n", samples_made - samples_done);
+ while (samples_made - samples_done <= samples_block*2 && !sound_thread_exit)
+ ret = sceKernelWaitSema(sound_sem, 1, 0);
//lprintf("sthr: sceKernelWaitSema: %i\n", ret);
continue;
}
//lprintf("sthr: sceKernelWaitSema: %i\n", ret);
continue;
}
@@
-507,6
+508,14
@@
static int sound_thread(SceSize args, void *argp)
snd_playptr = sndBuffer;
if (ret)
lprintf("sthr: outf: %i; pos %i/%i\n", ret, samples_done, samples_made);
snd_playptr = sndBuffer;
if (ret)
lprintf("sthr: outf: %i; pos %i/%i\n", ret, samples_done, samples_made);
+
+ // shouln't happen, but just in case
+ if (samples_made - samples_done >= 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");
}
lprintf("sthr: exit\n");
@@
-521,6
+530,8
@@
static void sound_init(void)
sound_sem = sceKernelCreateSema("sndsem", 0, 0, 1, NULL);
if (sound_sem < 0) lprintf("sceKernelCreateSema() failed: %i\n", sound_sem);
sound_sem = sceKernelCreateSema("sndsem", 0, 0, 1, NULL);
if (sound_sem < 0) lprintf("sceKernelCreateSema() failed: %i\n", sound_sem);
+ samples_made = samples_done = 0;
+ samples_block = SOUND_BLOCK_SIZE_NTSC; // make sure it goes to sema
sound_thread_exit = 0;
thid = sceKernelCreateThread("sndthread", sound_thread, 0x12, 0x10000, 0, NULL);
if (thid >= 0)
sound_thread_exit = 0;
thid = sceKernelCreateThread("sndthread", sound_thread, 0x12, 0x10000, 0, NULL);
if (thid >= 0)
@@
-544,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;
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",
sndBuffer_endptr = &sndBuffer[samples_block*SOUND_BLOCK_COUNT];
lprintf("starting audio: %i, len: %i, stereo: %i, pal: %i, block samples: %i\n",
@@
-604,7
+614,7
@@
static void writeSound(int len)
// signal the snd thread
samples_made += 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);
// lprintf("signal, %i/%i\n", samples_done, samples_made);
ret = sceKernelSignalSema(sound_sem, 1);
// lprintf("signal ret %i\n", ret);
@@
-683,13
+693,10
@@
static void RunEvents(unsigned int which)
vidResetMode();
vidResetMode();
- if (PicoOpt&0x10) {
- strcpy(noticeMsg, " 8bit fast renderer");
- } else if (currentConfig.EmuOpt&0x80) {
- strcpy(noticeMsg, "16bit accurate renderer");
- } else {
- strcpy(noticeMsg, " 8bit accurate renderer");
- }
+ if (PicoOpt&0x10)
+ strcpy(noticeMsg, "fast renderer");
+ else if (currentConfig.EmuOpt&0x80)
+ strcpy(noticeMsg, "accurate renderer");
noticeMsgTime = sceKernelGetSystemTimeLow();
}
noticeMsgTime = sceKernelGetSystemTimeLow();
}
@@
-939,12
+946,10
@@
void emu_Loop(void)
int tval_diff;
tval = sceKernelGetSystemTimeLow();
tval_diff = (int)(tval - tval_thissec) << 8;
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)) {
{
// 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;
}
reset_timing = 1;
continue;
}