Skip to content

Commit

Permalink
further resampler fixes to avaid crashes (e.g. in rs_loop) with broke…
Browse files Browse the repository at this point in the history
…n situations.
  • Loading branch information
sezero committed Oct 21, 2017
1 parent 80f3924 commit 4ec8009
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions timidity/resample.c
Expand Up @@ -47,7 +47,7 @@ static sample_t *rs_plain(MidiSong *song, int v, Sint32 *countptr)
incr=vp->sample_increment,
le=vp->sample->data_length,
count=*countptr;
Sint32 i;
Sint32 i, j;

if (incr<0) incr = -incr; /* In case we're coming out of a bidir loop */

Expand All @@ -62,7 +62,7 @@ static sample_t *rs_plain(MidiSong *song, int v, Sint32 *countptr)
}
else count -= i;

while (i--)
for (j = 0; j < i; j++)
{
v1 = src[ofs >> FRACTION_BITS];
v2 = src[(ofs >> FRACTION_BITS)+1];
Expand Down Expand Up @@ -96,7 +96,7 @@ static sample_t *rs_loop(MidiSong *song, Voice *vp, Sint32 count)
sample_t
*dest=song->resample_buffer,
*src=vp->sample->data;
Sint32 i;
Sint32 i, j;

while (count)
{
Expand All @@ -110,7 +110,7 @@ static sample_t *rs_loop(MidiSong *song, Voice *vp, Sint32 count)
count = 0;
}
else count -= i;
while (i--)
for (j = 0; j < i; j++)
{
v1 = src[ofs >> FRACTION_BITS];
v2 = src[(ofs >> FRACTION_BITS)+1];
Expand All @@ -135,9 +135,9 @@ static sample_t *rs_bidir(MidiSong *song, Voice *vp, Sint32 count)
*dest=song->resample_buffer,
*src=vp->sample->data;
Sint32
le2 = le<<1,
le2 = le<<1,
ls2 = ls<<1,
i;
i, j;
/* Play normally until inside the loop region */

if (incr > 0 && ofs < ls)
Expand All @@ -152,7 +152,7 @@ static sample_t *rs_bidir(MidiSong *song, Voice *vp, Sint32 count)
count = 0;
}
else count -= i;
while (i--)
for (j = 0; j < i; j++)
{
v1 = src[ofs >> FRACTION_BITS];
v2 = src[(ofs >> FRACTION_BITS)+1];
Expand All @@ -173,7 +173,7 @@ static sample_t *rs_bidir(MidiSong *song, Voice *vp, Sint32 count)
count = 0;
}
else count -= i;
while (i--)
for (j = 0; j < i; j++)
{
v1 = src[ofs >> FRACTION_BITS];
v2 = src[(ofs >> FRACTION_BITS)+1];
Expand Down Expand Up @@ -340,7 +340,7 @@ static sample_t *rs_vib_loop(MidiSong *song, Voice *vp, Sint32 count)
*src=vp->sample->data;
int
cc=vp->vibrato_control_counter;
Sint32 i;
Sint32 i, j;
int
vibflag=0;

Expand All @@ -360,7 +360,7 @@ static sample_t *rs_vib_loop(MidiSong *song, Voice *vp, Sint32 count)
}
else cc -= i;
count -= i;
while(i--)
for (j = 0; j < i; j++)
{
v1 = src[ofs >> FRACTION_BITS];
v2 = src[(ofs >> FRACTION_BITS)+1];
Expand Down Expand Up @@ -397,7 +397,7 @@ static sample_t *rs_vib_bidir(MidiSong *song, Voice *vp, Sint32 count)
Sint32
le2=le<<1,
ls2=ls<<1,
i;
i, j;
int
vibflag = 0;

Expand All @@ -413,7 +413,7 @@ static sample_t *rs_vib_bidir(MidiSong *song, Voice *vp, Sint32 count)
}
else cc -= i;
count -= i;
while (i--)
for (j = 0; j < i; j++)
{
v1 = src[ofs >> FRACTION_BITS];
v2 = src[(ofs >> FRACTION_BITS)+1];
Expand Down

0 comments on commit 4ec8009

Please sign in to comment.