openbsd-ports/audio/libmikmod/patches/patch-playercode_mplayer_c
miod ca650b05be Avoid setting envelope cursors to negative values; found the hard way with
0-point envelopes in kgb.xm on amd64 (blame recent malloc changes, it used
to work not so long ago on mips and alpha).

ok maintainer@ (for politeness' sake - I wrote this code after all so I don't
need his opinion (-: )
2008-10-23 22:06:26 +00:00

58 lines
1.6 KiB
Plaintext

$OpenBSD: patch-playercode_mplayer_c,v 1.5 2008/10/23 22:06:28 miod Exp $
--- playercode/mplayer.c.orig Mon Jan 21 21:23:56 2002
+++ playercode/mplayer.c Wed Oct 22 19:56:49 2008
@@ -254,7 +254,7 @@ static int MP_FindEmptyChannel(MODULE *mod)
Voice_Stopped_internal(t))
return t;
- tvol=0xffffffUL;t=0;a=mod->voice;
+ tvol=0xffffffUL;t=-1;a=mod->voice;
for (k=0;k<md_sngchn;k++,a++) {
/* allow us to take over a nonexisting sample */
if (!a->main.s)
@@ -367,9 +367,9 @@ static SWORD StartEnvelope(ENVPR *t,UBYTE flg,UBYTE pt
}
/* Fit in the envelope, still */
- if (t->a >= t->pts)
+ if (t->a >= t->pts && t->pts != 0)
t->a = t->pts - 1;
- if (t->b >= t->pts)
+ if (t->b >= t->pts && t->pts != 0)
t->b = t->pts-1;
return t->env[t->a].val;
@@ -442,24 +442,22 @@ static SWORD ProcessEnvelope(MP_VOICE *aout, ENVPR *t,
} else
/*
* Non looping situations.
- * Start to fade if the volume envelope is finished.
*/
- if (p > t->env[t->pts - 1].pos) {
+ if (a != b)
+ v = InterpolateEnv(p, &t->env[a], &t->env[b]);
+ else
v = t->env[a].val;
+
+ /*
+ * Start to fade if the volume envelope is finished.
+ */
+ if (p >= t->env[t->pts - 1].pos) {
if (t->flg & EF_VOLENV) {
aout->main.keyoff |= KEY_FADE;
if (!v)
aout->main.fadevol = 0;
}
} else {
- /*
- * Regular processing : compute value, progress one step.
- */
- if (a != b)
- v = InterpolateEnv(p, &t->env[a], &t->env[b]);
- else
- v = t->env[a].val;
-
p++;
/* did pointer reach point b? */
if (p >= t->env[b].pos)