Page 1 of 1
SND_startPlay_4PCM_ENV bug, starting a new song, both play
Posted: Wed Sep 13, 2017 12:09 pm
by cero
SND_startPlay_4PCM_ENV docs say that if a sample is already playing on that channel, it is stopped and the new one started.
This doesn't happen. Both samples keep playing.
Re: SND_startPlay_4PCM_ENV bug, starting a new song, both play
Posted: Wed Sep 13, 2017 1:16 pm
by Stef
No way to get 2 samples playing on the same channel :p
I guess you used it wrongly, can you provide the source code ?
Re: SND_startPlay_4PCM_ENV bug, starting a new song, both play
Posted: Wed Sep 13, 2017 5:42 pm
by cero
Not complete source, but the important bits.
// Called on the title screen
SND_startPlay_4PCM_ENV(title_music, sizeof(title_music), 0, 1);
// Called in-game
SND_startPlay_4PCM_ENV(game_music, sizeof(game_music), 0, 1);
As you see, both are on channel 0 and looping. Imagine my surprise when both songs continued to play in-game.
Re: SND_startPlay_4PCM_ENV bug, starting a new song, both play
Posted: Wed Sep 13, 2017 5:47 pm
by cero
And I see this is the guilty source in sound.c:
Code: Select all
void SND_startPlay_4PCM_ENV(const u8 *sample, const u32 len, const u16 channel, const u8 loop)
...
// auto channel ?
if (channel == SOUND_PCM_CH_AUTO)
{
// scan for first free channel
ch = 0;
while ((ch < 4) && (status & (Z80_DRV_STAT_PLAYING << ch))) ch++;
// if all channel busy we use the first
if (ch == 4) ch = 0;
}
SOUND_PCM_CH_AUTO is 0, the same as channel 0.
Re: SND_startPlay_4PCM_ENV bug, starting a new song, both play
Posted: Wed Sep 13, 2017 6:06 pm
by Stef
Outch ! that hurts ! What a stupid bug, i should have put auto to -1 of 0xFF..
Ok ^^ I will fix that quickly, thanks for reporting !