Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Lantinga committed Feb 2, 2000
1 parent dca6186 commit bb00353
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGES
@@ -1,5 +1,7 @@

1.0.4:
* Markus Oberhumer Wed Feb 2 13:16:17 PST 2000
- Fixed problem with short looping sounds
* Sam Lantinga Tue Feb 1 13:25:44 PST 2000
- Added Visual C++ project file
* Markus Oberhumer Tue Feb 1 13:23:11 PST 2000
Expand Down
36 changes: 19 additions & 17 deletions mixer.c
Expand Up @@ -111,30 +111,32 @@ static void mix_channels(void *udata, Uint8 *stream, int len)
}
}
if ( channel[i].playing > 0 ) {
volume = (channel[i].volume*channel[i].chunk->volume) /
MIX_MAX_VOLUME;
volume = (channel[i].volume*channel[i].chunk->volume) / MIX_MAX_VOLUME;
mixable = channel[i].playing;
if ( mixable > len ) {
mixable = len;
}
SDL_MixAudio(stream,channel[i].samples,mixable,volume);
channel[i].samples += mixable;
channel[i].playing -= mixable;
/* If looping the sample and we are at its end, make sure
we will still return a full buffer */
if ( channel[i].looping && mixable < len ) {
int remaining = len - mixable;
SDL_MixAudio(stream, channel[i].samples, mixable, volume);
while ( channel[i].looping && mixable < len ) {
int remaining = len - mixable;
int alen = channel[i].chunk->alen;
if (remaining > alen) {
remaining = alen;
}
SDL_MixAudio(stream+mixable, channel[i].chunk->abuf, remaining, volume);
--channel[i].looping;
channel[i].samples = channel[i].chunk->abuf + remaining;
channel[i].playing = channel[i].chunk->alen - remaining;
} else {
if ( mixable > len ) {
mixable = len;
}
SDL_MixAudio(stream,channel[i].samples,mixable,volume);
channel[i].samples += mixable;
channel[i].playing -= mixable;
if ( ! channel[i].playing && channel[i].looping ) {
if ( --channel[i].looping ) {
channel[i].samples = channel[i].chunk->abuf;
channel[i].playing = channel[i].chunk->alen;
}
mixable += remaining;
}
if ( ! channel[i].playing && channel[i].looping ) {
if ( --channel[i].looping ) {
channel[i].samples = channel[i].chunk->abuf;
channel[i].playing = channel[i].chunk->alen;
}
}
}
Expand Down

0 comments on commit bb00353

Please sign in to comment.