newlen = sp->data_length / a;
=============== 修正前 ===============
a = ((double) (sp->sample_rate) * freq_table[(int) (sp->note_to_use)]) /
((double) (sp->root_freq) * play_mode->rate);
newlen = sp->data_length / a;
dest = newdata = safe_malloc(newlen >> (FRACTION_BITS - 1));
======================================
=============== 修正後 ===============
a = ((double) (sp->sample_rate) * freq_table[(int) (sp->note_to_use)]) /
((double) (sp->root_freq) * play_mode->rate);
if(sp->data_length / a >= 0x7fffffffL)
{
/* Too large to compute */
ctl->cmsg(CMSG_INFO, VERB_DEBUG, " *** Can't pre-resampling for note %d",
sp->note_to_use);
return;
}
newlen = (int32)(sp->data_length / a);
======================================
=============== 修正箇所その 1 ===============
open_output() 関数の
/* Open the audio device */
fd=open(dpm.name, O_RDWR | O_NDELAY);
if (fd<0)
{
ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s",
dpm.name, sys_errlist[errno]);
return -1;
}
というところの直後に以下の行を追加:
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_NDELAY);
=============== 修正箇所その 2 ===============
output_data() 関数で
ssize_t rc;
と変数 rc を用意し、write しているところを以下のように修正:
/* Write the data out. Linux likes to give an EINTR if you suspend
a program while waiting on a write, so we may need to retry. */
do
{
rc = write(dpm.fd, buf, count * 2);
}
while ((rc == 0) || ((rc == -1) && (errno==EINTR)));
}
else
{
/* Convert to 8-bit unsigned and write out. */
s32tou8(buf, count);
do
{
rc = write(dpm.fd, buf, count);
}
while ((rc == 0) || ((rc == -1) && (errno==EINTR)));
}
}
timidity -in a.mid b.mid c.mid