mixer.c
author Sam Lantinga <slouken@lokigames.com>
Thu, 21 Oct 1999 19:12:17 +0000
changeset 1 4ef9250a6471
parent 0 4ce2db4db959
child 4 5c4485704b30
permissions -rw-r--r--
Added caching wave loading (needed by CivCTP)
Only link in the mikmod and timidity libraries if they are configured.
'make dist' works now
slouken@0
     1
/*
slouken@0
     2
    MIXERLIB:  An audio mixer library based on the SDL library
slouken@0
     3
    Copyright (C) 1997-1999  Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@0
     6
    modify it under the terms of the GNU Library General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@0
     8
    version 2 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@0
    13
    Library General Public License for more details.
slouken@0
    14
slouken@0
    15
    You should have received a copy of the GNU Library General Public
slouken@0
    16
    License along with this library; if not, write to the Free
slouken@0
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@0
    20
    5635-34 Springhouse Dr.
slouken@0
    21
    Pleasanton, CA 94588 (USA)
slouken@0
    22
    slouken@devolution.com
slouken@0
    23
*/
slouken@0
    24
slouken@0
    25
#include <stdio.h>
slouken@0
    26
#include <stdlib.h>
slouken@0
    27
#include <string.h>
slouken@0
    28
slouken@0
    29
#include <SDL/SDL_mutex.h>
slouken@0
    30
#include <SDL/SDL_endian.h>
slouken@0
    31
slouken@0
    32
#include "mixer.h"
slouken@0
    33
slouken@0
    34
static int audio_opened = 0;
slouken@0
    35
slouken@0
    36
static SDL_AudioSpec mixer;
slouken@0
    37
static SDL_mutex *mixer_lock;
slouken@0
    38
static struct _Mix_Channel {
slouken@0
    39
	Mix_Chunk *chunk;
slouken@0
    40
	int playing;
slouken@0
    41
	int paused;
slouken@0
    42
	Uint8 *samples;
slouken@0
    43
	int volume;
slouken@0
    44
	int looping;
slouken@0
    45
} channel[MIX_CHANNELS];
slouken@0
    46
slouken@0
    47
#define MUSIC_VOL	64		/* Music volume 0-64 */
slouken@0
    48
slouken@0
    49
/* Support for user defined music functions, plus the default one */
slouken@0
    50
extern int music_active;
slouken@0
    51
extern void music_mixer(void *udata, Uint8 *stream, int len);
slouken@0
    52
static void (*mix_music)(void *udata, Uint8 *stream, int len) = music_mixer;
slouken@0
    53
static int num_channels; /* Holds the number of channels actually mixed, for debugging */
slouken@0
    54
static int reserved_channels = 0;
slouken@0
    55
void *music_data = NULL;
slouken@0
    56
slouken@0
    57
/* Mixing function */
slouken@0
    58
static void mix_channels(void *udata, Uint8 *stream, int len)
slouken@0
    59
{
slouken@0
    60
	int i, mixable, volume;
slouken@0
    61
slouken@0
    62
	/* Grab the channels we need to mix */
slouken@0
    63
	SDL_mutexP(mixer_lock);
slouken@0
    64
	num_channels = 0;
slouken@0
    65
	for ( i=0; i<MIX_CHANNELS; ++i ) {
slouken@0
    66
		if ( channel[i].playing && !channel[i].paused ) {
slouken@0
    67
		    ++ num_channels;
slouken@0
    68
			mixable = channel[i].playing;
slouken@0
    69
			if ( mixable > len ) {
slouken@0
    70
				mixable = len;
slouken@0
    71
			}
slouken@0
    72
			volume = (channel[i].volume*channel[i].chunk->volume) /
slouken@0
    73
								MIX_MAX_VOLUME;
slouken@0
    74
			SDL_MixAudio(stream,channel[i].samples,mixable,volume);
slouken@0
    75
			channel[i].samples += mixable;
slouken@0
    76
			channel[i].playing -= mixable;
slouken@0
    77
			if ( ! channel[i].playing && channel[i].looping ) {
slouken@0
    78
				if ( --channel[i].looping ) {
slouken@0
    79
				    channel[i].samples = channel[i].chunk->abuf;
slouken@0
    80
				    channel[i].playing = channel[i].chunk->alen;
slouken@0
    81
				}
slouken@0
    82
			}
slouken@0
    83
		}
slouken@0
    84
	}
slouken@0
    85
	SDL_mutexV(mixer_lock);
slouken@0
    86
slouken@0
    87
	/* Mix the music */
slouken@0
    88
	if ( music_active ) {
slouken@0
    89
		mix_music(music_data, stream, len);
slouken@0
    90
	}
slouken@0
    91
}
slouken@0
    92
slouken@0
    93
static void PrintFormat(char *title, SDL_AudioSpec *fmt)
slouken@0
    94
{
slouken@0
    95
	printf("%s: %d bit %s audio (%s) at %u Hz\n", title, (fmt->format&0xFF),
slouken@0
    96
			(fmt->format&0x8000) ? "signed" : "unsigned",
slouken@0
    97
			(fmt->channels > 1) ? "stereo" : "mono", fmt->freq);
slouken@0
    98
}
slouken@0
    99
slouken@0
   100
/* Open the mixer with a certain desired audio format */
slouken@0
   101
int Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize)
slouken@0
   102
{
slouken@0
   103
	int i;
slouken@0
   104
	SDL_AudioSpec desired;
slouken@0
   105
slouken@0
   106
	/* If the mixer is already opened, increment open count */
slouken@0
   107
	if ( audio_opened ) {
slouken@0
   108
	    ++audio_opened;
slouken@0
   109
	    return(0);
slouken@0
   110
	}
slouken@0
   111
slouken@0
   112
	/* Set the desired format and frequency */
slouken@0
   113
	desired.freq = frequency;
slouken@0
   114
	desired.format = format;
slouken@0
   115
	desired.channels = channels;
slouken@0
   116
	desired.samples = chunksize;
slouken@0
   117
	desired.callback = mix_channels;
slouken@0
   118
	desired.userdata = NULL;
slouken@0
   119
slouken@0
   120
	/* Accept nearly any audio format */
slouken@0
   121
	if ( SDL_OpenAudio(&desired, &mixer) < 0 ) {
slouken@0
   122
		return(-1);
slouken@0
   123
	}
slouken@0
   124
#if 0
slouken@0
   125
	PrintFormat("Audio device", &mixer);
slouken@0
   126
#endif
slouken@0
   127
slouken@0
   128
	/* Create the channel lock mutex */
slouken@0
   129
	mixer_lock = SDL_CreateMutex();
slouken@0
   130
	if ( mixer_lock == NULL ) {
slouken@0
   131
		SDL_CloseAudio();
slouken@0
   132
		SDL_SetError("Unable to create mixer lock");
slouken@0
   133
		return(-1);
slouken@0
   134
	}
slouken@0
   135
slouken@0
   136
	/* Initialize the music players */
slouken@0
   137
	if ( open_music(&mixer) < 0 ) {
slouken@0
   138
		SDL_CloseAudio();
slouken@0
   139
		SDL_DestroyMutex(mixer_lock);
slouken@0
   140
		return(-1);
slouken@0
   141
	}
slouken@0
   142
	
slouken@0
   143
	/* Clear out the audio channels */
slouken@0
   144
	for ( i=0; i<MIX_CHANNELS; ++i ) {
slouken@0
   145
		channel[i].chunk = NULL;
slouken@0
   146
		channel[i].playing = 0;
slouken@0
   147
		channel[i].looping = 0;
slouken@0
   148
		channel[i].volume = SDL_MIX_MAXVOLUME;
slouken@0
   149
	}
slouken@0
   150
	Mix_VolumeMusic(SDL_MIX_MAXVOLUME);
slouken@0
   151
	audio_opened = 1;
slouken@0
   152
	SDL_PauseAudio(0);
slouken@0
   153
	return(0);
slouken@0
   154
}
slouken@0
   155
slouken@0
   156
/* Return the actual mixer parameters */
slouken@0
   157
int Mix_QuerySpec(int *frequency, Uint16 *format, int *channels)
slouken@0
   158
{
slouken@0
   159
	if ( audio_opened ) {
slouken@0
   160
		if ( frequency ) {
slouken@0
   161
			*frequency = mixer.freq;
slouken@0
   162
		}
slouken@0
   163
		if ( format ) {
slouken@0
   164
			*format = mixer.format;
slouken@0
   165
		}
slouken@0
   166
		if ( channels ) {
slouken@0
   167
			*channels = mixer.channels;
slouken@0
   168
		}
slouken@0
   169
	}
slouken@0
   170
	return(audio_opened);
slouken@0
   171
}
slouken@0
   172
slouken@0
   173
/* Load a wave file */
slouken@0
   174
Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)
slouken@0
   175
{
slouken@0
   176
	Mix_Chunk *chunk;
slouken@0
   177
	SDL_AudioSpec wavespec;
slouken@0
   178
	SDL_AudioCVT wavecvt;
slouken@0
   179
slouken@0
   180
	/* Make sure audio has been opened */
slouken@0
   181
	if ( ! audio_opened ) {
slouken@0
   182
		SDL_SetError("Audio device hasn't been opened");
slouken@0
   183
		if ( freesrc ) {
slouken@0
   184
			SDL_RWclose(src);
slouken@0
   185
		}
slouken@0
   186
		return(NULL);
slouken@0
   187
	}
slouken@0
   188
slouken@0
   189
	/* Allocate the chunk memory */
slouken@0
   190
	chunk = (Mix_Chunk *)malloc(sizeof(Mix_Chunk));
slouken@0
   191
	if ( chunk == NULL ) {
slouken@0
   192
		SDL_SetError("Out of memory");
slouken@0
   193
		if ( freesrc ) {
slouken@0
   194
			SDL_RWclose(src);
slouken@0
   195
		}
slouken@0
   196
		return(NULL);
slouken@0
   197
	}
slouken@0
   198
slouken@0
   199
	/* Load the WAV file into the chunk */
slouken@0
   200
	if ( SDL_LoadWAV_RW(src, freesrc,
slouken@0
   201
		&wavespec, (Uint8 **)&chunk->abuf, &chunk->alen) == NULL ) {
slouken@0
   202
		free(chunk);
slouken@0
   203
		return(NULL);
slouken@0
   204
	}
slouken@0
   205
#if 0
slouken@0
   206
	PrintFormat("Audio device", &mixer);
slouken@0
   207
	PrintFormat("-- Wave file", &wavespec);
slouken@0
   208
#endif
slouken@0
   209
slouken@0
   210
	/* Build the audio converter and create conversion buffers */
slouken@0
   211
	if ( SDL_BuildAudioCVT(&wavecvt,
slouken@0
   212
			wavespec.format, wavespec.channels, wavespec.freq,
slouken@0
   213
			mixer.format, mixer.channels, mixer.freq) < 0 ) {
slouken@0
   214
		SDL_FreeWAV(chunk->abuf);
slouken@0
   215
		free(chunk);
slouken@0
   216
		return(NULL);
slouken@0
   217
	}
slouken@0
   218
	wavecvt.len = chunk->alen;
slouken@0
   219
	wavecvt.buf = (Uint8 *)malloc(wavecvt.len*wavecvt.len_mult);
slouken@0
   220
	if ( wavecvt.buf == NULL ) {
slouken@0
   221
		SDL_SetError("Out of memory");
slouken@0
   222
		SDL_FreeWAV(chunk->abuf);
slouken@0
   223
		free(chunk);
slouken@0
   224
		return(NULL);
slouken@0
   225
	}
slouken@0
   226
	memcpy(wavecvt.buf, chunk->abuf, chunk->alen);
slouken@0
   227
	SDL_FreeWAV(chunk->abuf);
slouken@0
   228
slouken@0
   229
	/* Run the audio converter */
slouken@0
   230
	if ( SDL_ConvertAudio(&wavecvt) < 0 ) {
slouken@0
   231
		free(wavecvt.buf);
slouken@0
   232
		free(chunk);
slouken@0
   233
		return(NULL);
slouken@0
   234
	}
slouken@1
   235
	chunk->allocated = 1;
slouken@0
   236
	chunk->abuf = wavecvt.buf;
slouken@0
   237
	chunk->alen = wavecvt.len_cvt;
slouken@0
   238
	chunk->volume = MIX_MAX_VOLUME;
slouken@0
   239
	return(chunk);
slouken@0
   240
}
slouken@0
   241
slouken@1
   242
/* Load a wave file of the mixer format from a memory buffer */
slouken@1
   243
Mix_Chunk *Mix_QuickLoad_WAV(Uint8 *mem)
slouken@1
   244
{
slouken@1
   245
	Mix_Chunk *chunk;
slouken@1
   246
	Uint8 magic[4];
slouken@1
   247
slouken@1
   248
	/* Make sure audio has been opened */
slouken@1
   249
	if ( ! audio_opened ) {
slouken@1
   250
		SDL_SetError("Audio device hasn't been opened");
slouken@1
   251
		return(NULL);
slouken@1
   252
	}
slouken@1
   253
slouken@1
   254
	/* Allocate the chunk memory */
slouken@1
   255
	chunk = (Mix_Chunk *)malloc(sizeof(Mix_Chunk));
slouken@1
   256
	if ( chunk == NULL ) {
slouken@1
   257
		SDL_SetError("Out of memory");
slouken@1
   258
		return(NULL);
slouken@1
   259
	}
slouken@1
   260
slouken@1
   261
	/* Essentially just skip to the audio data (no error checking - fast) */
slouken@1
   262
	chunk->allocated = 0;
slouken@1
   263
	mem += 12; /* WAV header */
slouken@1
   264
	do {
slouken@1
   265
		memcpy(magic, mem, 4);
slouken@1
   266
		mem += 4;
slouken@1
   267
		chunk->alen = ((mem[3]<<24)|(mem[2]<<16)|(mem[1]<<8)|(mem[0]));
slouken@1
   268
		mem += 4;
slouken@1
   269
		chunk->abuf = mem;
slouken@1
   270
		mem += chunk->alen;
slouken@1
   271
	} while ( memcmp(magic, "data", 4) != 0 );
slouken@1
   272
	chunk->volume = MIX_MAX_VOLUME;
slouken@1
   273
slouken@1
   274
	return(chunk);
slouken@1
   275
}
slouken@1
   276
slouken@0
   277
/* Free an audio chunk previously loaded */
slouken@0
   278
void Mix_FreeChunk(Mix_Chunk *chunk)
slouken@0
   279
{
slouken@0
   280
	int i;
slouken@0
   281
slouken@0
   282
	/* Caution -- if the chunk is playing, the mixer will crash */
slouken@0
   283
	if ( chunk ) {
slouken@0
   284
		/* Guarantee that this chunk isn't playing */
slouken@0
   285
		SDL_mutexP(mixer_lock);
slouken@0
   286
		for ( i=0; i<MIX_CHANNELS; ++i ) {
slouken@0
   287
			if ( chunk == channel[i].chunk ) {
slouken@0
   288
				channel[i].playing = 0;
slouken@0
   289
			}
slouken@0
   290
		}
slouken@0
   291
		SDL_mutexV(mixer_lock);
slouken@0
   292
slouken@0
   293
		/* Actually free the chunk */
slouken@1
   294
		if ( chunk->allocated ) {
slouken@1
   295
			free(chunk->abuf);
slouken@1
   296
		}
slouken@0
   297
		free(chunk);
slouken@0
   298
	}
slouken@0
   299
}
slouken@0
   300
slouken@0
   301
/* Add your own music player or mixer function.
slouken@0
   302
   If 'mix_func' is NULL, the default music player is re-enabled.
slouken@0
   303
 */
slouken@0
   304
void Mix_HookMusic(void (*mix_func)(void *udata, Uint8 *stream, int len),
slouken@0
   305
                                                                void *arg)
slouken@0
   306
{
slouken@0
   307
	SDL_LockAudio();
slouken@0
   308
	if ( mix_func != NULL ) {
slouken@0
   309
		music_data = arg;
slouken@0
   310
		mix_music = mix_func;
slouken@0
   311
	} else {
slouken@0
   312
		music_data = NULL;
slouken@0
   313
		mix_music = music_mixer;
slouken@0
   314
	}
slouken@0
   315
	SDL_UnlockAudio();
slouken@0
   316
}
slouken@0
   317
slouken@0
   318
void *Mix_GetMusicHookData(void)
slouken@0
   319
{
slouken@0
   320
	return(music_data);
slouken@0
   321
}
slouken@0
   322
slouken@0
   323
/* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
slouken@0
   324
   them dynamically to the next sample if requested with a -1 value below.
slouken@0
   325
   Returns the number of reserved channels.
slouken@0
   326
 */
slouken@0
   327
int Mix_ReserveChannels(int num)
slouken@0
   328
{
slouken@0
   329
	if (num > MIX_CHANNELS)
slouken@0
   330
		num = MIX_CHANNELS;
slouken@0
   331
	reserved_channels = num;
slouken@0
   332
	return num;
slouken@0
   333
}
slouken@0
   334
slouken@0
   335
/* Play an audio chunk on a specific channel.
slouken@0
   336
   If the specified channel is -1, play on the first free channel.
slouken@0
   337
   Returns which channel was used to play the sound.
slouken@0
   338
*/
slouken@0
   339
int Mix_PlayChannel(int which, Mix_Chunk *chunk, int loops)
slouken@0
   340
{
slouken@0
   341
	int i;
slouken@0
   342
slouken@0
   343
	/* Don't play null pointers :-) */
slouken@0
   344
	if ( chunk == NULL ) {
slouken@0
   345
		return(-1);
slouken@0
   346
	}
slouken@0
   347
slouken@0
   348
	/* Lock the mixer while modifying the playing channels */
slouken@0
   349
	SDL_mutexP(mixer_lock);
slouken@0
   350
	{
slouken@0
   351
		/* If which is -1, play on the first free channel */
slouken@0
   352
		if ( which == -1 ) {
slouken@0
   353
			for ( i=reserved_channels; i<MIX_CHANNELS; ++i ) {
slouken@0
   354
				if ( channel[i].playing <= 0 )
slouken@0
   355
					break;
slouken@0
   356
			}
slouken@0
   357
			if ( i == MIX_CHANNELS ) {
slouken@0
   358
				which = -1;
slouken@0
   359
			} else {
slouken@0
   360
				which = i;
slouken@0
   361
			}
slouken@0
   362
		}
slouken@0
   363
slouken@0
   364
		/* Queue up the audio data for this channel */
slouken@0
   365
		if ( which >= 0 ) {
slouken@0
   366
			channel[which].samples = chunk->abuf;
slouken@0
   367
			channel[which].playing = chunk->alen;
slouken@0
   368
			channel[which].looping = loops;
slouken@0
   369
			channel[which].chunk = chunk;
slouken@0
   370
			channel[which].paused = 0;
slouken@0
   371
		}
slouken@0
   372
	}
slouken@0
   373
	SDL_mutexV(mixer_lock);
slouken@0
   374
slouken@0
   375
	/* Return the channel on which the sound is being played */
slouken@0
   376
	return(which);
slouken@0
   377
}
slouken@0
   378
slouken@0
   379
/* Set volume of a particular channel */
slouken@0
   380
int Mix_Volume(int which, int volume)
slouken@0
   381
{
slouken@0
   382
	int i;
slouken@0
   383
	int prev_volume;
slouken@0
   384
slouken@0
   385
	if ( which == -1 ) {
slouken@0
   386
		prev_volume = 0;
slouken@0
   387
		for ( i=0; i<MIX_CHANNELS; ++i ) {
slouken@0
   388
			prev_volume += Mix_Volume(i, volume);
slouken@0
   389
		}
slouken@0
   390
		prev_volume /= MIX_CHANNELS;
slouken@0
   391
	} else {
slouken@0
   392
		prev_volume = channel[which].volume;
slouken@0
   393
		if ( volume >= 0 ) {
slouken@0
   394
			if ( volume > SDL_MIX_MAXVOLUME ) {
slouken@0
   395
				volume = SDL_MIX_MAXVOLUME;
slouken@0
   396
			}
slouken@0
   397
			channel[which].volume = volume;
slouken@0
   398
		}
slouken@0
   399
	}
slouken@0
   400
	return(prev_volume);
slouken@0
   401
}
slouken@0
   402
/* Set volume of a particular chunk */
slouken@0
   403
int Mix_VolumeChunk(Mix_Chunk *chunk, int volume)
slouken@0
   404
{
slouken@0
   405
	int prev_volume;
slouken@0
   406
slouken@0
   407
	prev_volume = chunk->volume;
slouken@0
   408
	if ( volume >= 0 ) {
slouken@0
   409
		if ( volume > MIX_MAX_VOLUME ) {
slouken@0
   410
			volume = MIX_MAX_VOLUME;
slouken@0
   411
		}
slouken@0
   412
		chunk->volume = volume;
slouken@0
   413
	}
slouken@0
   414
	return(prev_volume);
slouken@0
   415
}
slouken@0
   416
slouken@0
   417
/* Halt playing of a particular channel */
slouken@0
   418
int Mix_HaltChannel(int which)
slouken@0
   419
{
slouken@0
   420
	int i;
slouken@0
   421
slouken@0
   422
	if ( which == -1 ) {
slouken@0
   423
		for ( i=0; i<MIX_CHANNELS; ++i ) {
slouken@0
   424
			Mix_HaltChannel(i);
slouken@0
   425
		}
slouken@0
   426
	} else {
slouken@0
   427
		SDL_mutexP(mixer_lock);
slouken@0
   428
		channel[which].playing = 0;
slouken@0
   429
		SDL_mutexV(mixer_lock);
slouken@0
   430
	}
slouken@0
   431
	return(0);
slouken@0
   432
}
slouken@0
   433
slouken@0
   434
/* Check the status of a specific channel.
slouken@0
   435
   If the specified channel is -1, check all channels.
slouken@0
   436
*/
slouken@0
   437
int Mix_Playing(int which)
slouken@0
   438
{
slouken@0
   439
	int status;
slouken@0
   440
slouken@0
   441
	status = 0;
slouken@0
   442
	if ( which == -1 ) {
slouken@0
   443
		int i;
slouken@0
   444
slouken@0
   445
		for ( i=0; i<MIX_CHANNELS; ++i ) {
slouken@0
   446
			if ( channel[i].playing > 0 ) {
slouken@0
   447
				++status;
slouken@0
   448
			}
slouken@0
   449
		}
slouken@0
   450
	} else {
slouken@0
   451
		if ( channel[which].playing > 0 ) {
slouken@0
   452
			++status;
slouken@0
   453
		}
slouken@0
   454
	}
slouken@0
   455
	return(status);
slouken@0
   456
}
slouken@0
   457
slouken@0
   458
/* Close the mixer, halting all playing audio */
slouken@0
   459
void Mix_CloseAudio(void)
slouken@0
   460
{
slouken@0
   461
	if ( audio_opened ) {
slouken@0
   462
		if ( audio_opened == 1 ) {
slouken@0
   463
			close_music();
slouken@0
   464
			Mix_HaltChannel(-1);
slouken@0
   465
			SDL_CloseAudio();
slouken@0
   466
			SDL_DestroyMutex(mixer_lock);
slouken@0
   467
		}
slouken@0
   468
		--audio_opened;
slouken@0
   469
	}
slouken@0
   470
}
slouken@0
   471
slouken@0
   472
/* Pause a particular channel (or all) */
slouken@0
   473
void Mix_Pause(int which)
slouken@0
   474
{
slouken@0
   475
	if ( which == -1 ) {
slouken@0
   476
		int i;
slouken@0
   477
slouken@0
   478
		for ( i=0; i<MIX_CHANNELS; ++i ) {
slouken@0
   479
			if ( channel[i].playing > 0 ) {
slouken@0
   480
				channel[i].paused = 1;
slouken@0
   481
			}
slouken@0
   482
		}
slouken@0
   483
	} else {
slouken@0
   484
		if ( channel[which].playing > 0 ) {
slouken@0
   485
			channel[which].paused = 1;
slouken@0
   486
		}
slouken@0
   487
	}
slouken@0
   488
}
slouken@0
   489
slouken@0
   490
/* Resume a paused channel */
slouken@0
   491
void Mix_Resume(int which)
slouken@0
   492
{
slouken@0
   493
	if ( which == -1 ) {
slouken@0
   494
		int i;
slouken@0
   495
slouken@0
   496
		for ( i=0; i<MIX_CHANNELS; ++i ) {
slouken@0
   497
			if ( channel[i].playing > 0 ) {
slouken@0
   498
				channel[i].paused = 0;
slouken@0
   499
			}
slouken@0
   500
		}
slouken@0
   501
	} else {
slouken@0
   502
		if ( channel[which].playing > 0 ) {
slouken@0
   503
			channel[which].paused = 0;
slouken@0
   504
		}
slouken@0
   505
	}
slouken@0
   506
}