Skip to content

Latest commit

 

History

History
508 lines (422 loc) · 13.5 KB

playwave.c

File metadata and controls

508 lines (422 loc) · 13.5 KB
 
Oct 21, 1999
Oct 21, 1999
1
/*
Dec 31, 2011
Dec 31, 2011
2
PLAYWAVE: A test application for the SDL mixer library.
Jan 5, 2019
Jan 5, 2019
3
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
Dec 31, 2011
Dec 31, 2011
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Oct 21, 1999
Oct 21, 1999
20
21
*/
Dec 14, 2001
Dec 14, 2001
22
/* $Id$ */
Dec 14, 2001
Dec 14, 2001
23
Oct 21, 1999
Oct 21, 1999
24
25
26
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Apr 14, 2010
Apr 14, 2010
27
Feb 11, 2000
Feb 11, 2000
28
#ifdef unix
Oct 21, 1999
Oct 21, 1999
29
30
31
#include <unistd.h>
#endif
Dec 21, 1999
Dec 21, 1999
32
#include "SDL.h"
Jan 14, 2000
Jan 14, 2000
33
#include "SDL_mixer.h"
Oct 21, 1999
Oct 21, 1999
34
Feb 17, 2011
Feb 17, 2011
35
36
37
38
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
Oct 21, 1999
Oct 21, 1999
39
Sep 11, 2001
Sep 11, 2001
40
41
42
/*
* rcg06132001 various mixer tests. Define the ones you want.
*/
Jun 5, 2009
Jun 5, 2009
43
/*#define TEST_MIX_DECODERS*/
Oct 18, 2001
Oct 18, 2001
44
45
/*#define TEST_MIX_VERSIONS*/
/*#define TEST_MIX_CHANNELFINISHED*/
Sep 11, 2001
Sep 11, 2001
46
47
/*#define TEST_MIX_PANNING*/
/*#define TEST_MIX_DISTANCE*/
Oct 18, 2001
Oct 18, 2001
48
/*#define TEST_MIX_POSITION*/
Sep 11, 2001
Sep 11, 2001
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#if (defined TEST_MIX_POSITION)
#if (defined TEST_MIX_PANNING)
#error TEST_MIX_POSITION interferes with TEST_MIX_PANNING.
#endif
#if (defined TEST_MIX_DISTANCE)
#error TEST_MIX_POSITION interferes with TEST_MIX_DISTANCE.
#endif
#endif
/* rcg06192001 for debugging purposes. */
static void output_test_warnings(void)
{
#if (defined TEST_MIX_CHANNELFINISHED)
Oct 17, 2017
Oct 17, 2017
68
SDL_Log("Warning: TEST_MIX_CHANNELFINISHED is enabled in this binary...\n");
Sep 11, 2001
Sep 11, 2001
69
70
#endif
#if (defined TEST_MIX_PANNING)
Oct 17, 2017
Oct 17, 2017
71
SDL_Log("Warning: TEST_MIX_PANNING is enabled in this binary...\n");
Sep 11, 2001
Sep 11, 2001
72
73
#endif
#if (defined TEST_MIX_VERSIONS)
Oct 17, 2017
Oct 17, 2017
74
SDL_Log("Warning: TEST_MIX_VERSIONS is enabled in this binary...\n");
Sep 11, 2001
Sep 11, 2001
75
76
#endif
#if (defined TEST_MIX_DISTANCE)
Oct 17, 2017
Oct 17, 2017
77
SDL_Log("Warning: TEST_MIX_DISTANCE is enabled in this binary...\n");
Sep 11, 2001
Sep 11, 2001
78
79
#endif
#if (defined TEST_MIX_POSITION)
Oct 17, 2017
Oct 17, 2017
80
SDL_Log("Warning: TEST_MIX_POSITION is enabled in this binary...\n");
Sep 11, 2001
Sep 11, 2001
81
82
83
84
#endif
}
Oct 21, 1999
Oct 21, 1999
85
86
87
static int audio_open = 0;
static Mix_Chunk *wave = NULL;
Jun 5, 2009
Jun 5, 2009
88
89
90
91
/* rcg06042009 Report available decoders. */
#if (defined TEST_MIX_DECODERS)
static void report_decoders(void)
{
May 22, 2013
May 22, 2013
92
int i, total;
Jun 5, 2009
Jun 5, 2009
93
Oct 17, 2017
Oct 17, 2017
94
SDL_Log("Supported decoders...\n");
May 22, 2013
May 22, 2013
95
96
total = Mix_GetNumChunkDecoders();
for (i = 0; i < total; i++) {
Oct 17, 2017
Oct 17, 2017
97
SDL_Log(" - chunk decoder: %s\n", Mix_GetChunkDecoder(i));
May 22, 2013
May 22, 2013
98
99
100
101
}
total = Mix_GetNumMusicDecoders();
for (i = 0; i < total; i++) {
Oct 17, 2017
Oct 17, 2017
102
SDL_Log(" - music decoder: %s\n", Mix_GetMusicDecoder(i));
May 22, 2013
May 22, 2013
103
}
Jun 5, 2009
Jun 5, 2009
104
105
}
#endif
Sep 11, 2001
Sep 11, 2001
106
107
108
109
/* rcg06192001 Check new Mixer version API. */
#if (defined TEST_MIX_VERSIONS)
static void output_versions(const char *libname, const SDL_version *compiled,
May 22, 2013
May 22, 2013
110
const SDL_version *linked)
Sep 11, 2001
Sep 11, 2001
111
{
Oct 17, 2017
Oct 17, 2017
112
SDL_Log("This program was compiled against %s %d.%d.%d,\n"
May 22, 2013
May 22, 2013
113
114
115
" and is dynamically linked to %d.%d.%d.\n", libname,
compiled->major, compiled->minor, compiled->patch,
linked->major, linked->minor, linked->patch);
Sep 11, 2001
Sep 11, 2001
116
117
118
119
}
static void test_versions(void)
{
May 22, 2013
May 22, 2013
120
SDL_version compiled;
Nov 26, 2019
Nov 26, 2019
121
SDL_version linked;
Sep 11, 2001
Sep 11, 2001
122
May 22, 2013
May 22, 2013
123
SDL_VERSION(&compiled);
Nov 26, 2019
Nov 26, 2019
124
125
SDL_GetVersion(&linked);
output_versions("SDL", &compiled, &linked);
Sep 11, 2001
Sep 11, 2001
126
May 22, 2013
May 22, 2013
127
SDL_MIXER_VERSION(&compiled);
Nov 26, 2019
Nov 26, 2019
128
129
SDL_memcpy(&linked, Mix_Linked_Version(), sizeof(SDL_version));
output_versions("SDL_mixer", &compiled, &linked);
Sep 11, 2001
Sep 11, 2001
130
131
132
133
134
135
}
#endif
#ifdef TEST_MIX_CHANNELFINISHED /* rcg06072001 */
static volatile int channel_is_done = 0;
Oct 21, 2017
Oct 21, 2017
136
static void SDLCALL channel_complete_callback (int chan)
Sep 11, 2001
Sep 11, 2001
137
{
May 22, 2013
May 22, 2013
138
Mix_Chunk *done_chunk = Mix_GetChunk(chan);
Oct 17, 2017
Oct 17, 2017
139
SDL_Log("We were just alerted that Mixer channel #%d is done.\n", chan);
Nov 26, 2019
Nov 26, 2019
140
SDL_Log("Channel's chunk pointer is (%p).\n", (void*)done_chunk);
Oct 17, 2017
Oct 17, 2017
141
SDL_Log(" Which %s correct.\n", (wave == done_chunk) ? "is" : "is NOT");
May 22, 2013
May 22, 2013
142
channel_is_done = 1;
Sep 11, 2001
Sep 11, 2001
143
144
145
146
147
148
149
150
}
#endif
/* rcg06192001 abstract this out for testing purposes. */
static int still_playing(void)
{
#ifdef TEST_MIX_CHANNELFINISHED
May 22, 2013
May 22, 2013
151
return(!channel_is_done);
Sep 11, 2001
Sep 11, 2001
152
#else
May 22, 2013
May 22, 2013
153
return(Mix_Playing(0));
Sep 11, 2001
Sep 11, 2001
154
155
156
157
158
159
160
#endif
}
#if (defined TEST_MIX_PANNING)
static void do_panning_update(void)
{
May 22, 2013
May 22, 2013
161
162
static Uint8 leftvol = 128;
static Uint8 rightvol = 128;
Nov 26, 2019
Nov 26, 2019
163
164
static Sint8 leftincr = -1;
static Sint8 rightincr = 1;
May 22, 2013
May 22, 2013
165
166
167
168
169
170
static int panningok = 1;
static Uint32 next_panning_update = 0;
if ((panningok) && (SDL_GetTicks() >= next_panning_update)) {
panningok = Mix_SetPanning(0, leftvol, rightvol);
if (!panningok) {
Oct 17, 2017
Oct 17, 2017
171
SDL_Log("Mix_SetPanning(0, %d, %d) failed!\n",
May 22, 2013
May 22, 2013
172
(int) leftvol, (int) rightvol);
Oct 17, 2017
Oct 17, 2017
173
SDL_Log("Reason: [%s].\n", Mix_GetError());
May 22, 2013
May 22, 2013
174
175
176
}
if ((leftvol == 255) || (leftvol == 0)) {
Nov 26, 2019
Nov 26, 2019
177
if (leftvol == 255) {
Oct 17, 2017
Oct 17, 2017
178
SDL_Log("All the way in the left speaker.\n");
Nov 26, 2019
Nov 26, 2019
179
180
}
leftincr *= -1;
May 22, 2013
May 22, 2013
181
182
183
}
if ((rightvol == 255) || (rightvol == 0)) {
Nov 26, 2019
Nov 26, 2019
184
if (rightvol == 255) {
Oct 17, 2017
Oct 17, 2017
185
SDL_Log("All the way in the right speaker.\n");
Nov 26, 2019
Nov 26, 2019
186
}
May 22, 2013
May 22, 2013
187
188
189
190
191
192
193
rightincr *= -1;
}
leftvol += leftincr;
rightvol += rightincr;
next_panning_update = SDL_GetTicks() + 10;
}
Sep 11, 2001
Sep 11, 2001
194
195
196
197
198
199
200
}
#endif
#if (defined TEST_MIX_DISTANCE)
static void do_distance_update(void)
{
May 22, 2013
May 22, 2013
201
static Uint8 distance = 1;
Nov 26, 2019
Nov 26, 2019
202
static Sint8 distincr = 1;
May 22, 2013
May 22, 2013
203
204
205
206
207
208
static int distanceok = 1;
static Uint32 next_distance_update = 0;
if ((distanceok) && (SDL_GetTicks() >= next_distance_update)) {
distanceok = Mix_SetDistance(0, distance);
if (!distanceok) {
Oct 17, 2017
Oct 17, 2017
209
210
SDL_Log("Mix_SetDistance(0, %d) failed!\n", (int) distance);
SDL_Log("Reason: [%s].\n", Mix_GetError());
May 22, 2013
May 22, 2013
211
212
213
}
if (distance == 0) {
Oct 17, 2017
Oct 17, 2017
214
SDL_Log("Distance at nearest point.\n");
May 22, 2013
May 22, 2013
215
216
217
distincr *= -1;
}
else if (distance == 255) {
Oct 17, 2017
Oct 17, 2017
218
SDL_Log("Distance at furthest point.\n");
May 22, 2013
May 22, 2013
219
220
221
222
223
224
distincr *= -1;
}
distance += distincr;
next_distance_update = SDL_GetTicks() + 15;
}
Sep 11, 2001
Sep 11, 2001
225
226
227
228
229
230
231
}
#endif
#if (defined TEST_MIX_POSITION)
static void do_position_update(void)
{
May 22, 2013
May 22, 2013
232
233
static Sint16 distance = 1;
static Sint8 distincr = 1;
Nov 26, 2019
Nov 26, 2019
234
static Sint16 angle = 0;
May 22, 2013
May 22, 2013
235
236
237
238
239
static Sint8 angleincr = 1;
static int positionok = 1;
static Uint32 next_position_update = 0;
if ((positionok) && (SDL_GetTicks() >= next_position_update)) {
Nov 26, 2019
Nov 26, 2019
240
positionok = Mix_SetPosition(0, angle, (Uint8)distance);
May 22, 2013
May 22, 2013
241
if (!positionok) {
Oct 17, 2017
Oct 17, 2017
242
SDL_Log("Mix_SetPosition(0, %d, %d) failed!\n",
May 22, 2013
May 22, 2013
243
(int) angle, (int) distance);
Oct 17, 2017
Oct 17, 2017
244
SDL_Log("Reason: [%s].\n", Mix_GetError());
May 22, 2013
May 22, 2013
245
246
247
}
if (angle == 0) {
Oct 17, 2017
Oct 17, 2017
248
SDL_Log("Due north; now rotating clockwise...\n");
May 22, 2013
May 22, 2013
249
250
251
252
angleincr = 1;
}
else if (angle == 360) {
Oct 17, 2017
Oct 17, 2017
253
SDL_Log("Due north; now rotating counter-clockwise...\n");
May 22, 2013
May 22, 2013
254
255
256
257
258
259
260
angleincr = -1;
}
distance += distincr;
if (distance < 0) {
distance = 0;
distincr = 3;
Oct 17, 2017
Oct 17, 2017
261
SDL_Log("Distance is very, very near. Stepping away by threes...\n");
May 22, 2013
May 22, 2013
262
263
264
} else if (distance > 255) {
distance = 255;
distincr = -3;
Oct 17, 2017
Oct 17, 2017
265
SDL_Log("Distance is very, very far. Stepping towards by threes...\n");
May 22, 2013
May 22, 2013
266
267
268
269
270
}
angle += angleincr;
next_position_update = SDL_GetTicks() + 30;
}
Sep 11, 2001
Sep 11, 2001
271
272
273
274
}
#endif
May 14, 2006
May 14, 2006
275
static void CleanUp(int exitcode)
Oct 21, 1999
Oct 21, 1999
276
{
Oct 17, 2017
Oct 17, 2017
277
if (wave) {
May 22, 2013
May 22, 2013
278
279
280
Mix_FreeChunk(wave);
wave = NULL;
}
Oct 17, 2017
Oct 17, 2017
281
if (audio_open) {
May 22, 2013
May 22, 2013
282
283
284
285
286
287
Mix_CloseAudio();
audio_open = 0;
}
SDL_Quit();
exit(exitcode);
Oct 21, 1999
Oct 21, 1999
288
289
}
Sep 11, 2001
Sep 11, 2001
290
291
static void Usage(char *argv0)
Oct 21, 1999
Oct 21, 1999
292
{
Oct 21, 2017
Oct 21, 2017
293
SDL_Log("Usage: %s [-8] [-f32] [-r rate] [-c channels] [-f] [-F] [-l] [-m] <wavefile>\n", argv0);
Oct 21, 1999
Oct 21, 1999
294
}
Jun 10, 2001
Jun 10, 2001
295
296
Sep 11, 2001
Sep 11, 2001
297
298
299
300
301
302
303
304
305
306
307
308
309
/*
* rcg06182001 This is sick, but cool.
*
* Actually, it's meant to be an example of how to manipulate a voice
* without having to use the mixer effects API. This is more processing
* up front, but no extra during the mixing process. Also, in a case like
* this, when you need to touch the whole sample at once, it's the only
* option you've got. And, with the effects API, you are altering a copy of
* the original sample for each playback, and thus, your changes aren't
* permanent; here, you've got a reversed sample, and that's that until
* you either reverse it again, or reload it.
*/
static void flip_sample(Mix_Chunk *wave)
Jun 10, 2001
Jun 10, 2001
310
{
May 22, 2013
May 22, 2013
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
Uint16 format;
int channels, i, incr;
Uint8 *start = wave->abuf;
Uint8 *end = wave->abuf + wave->alen;
Mix_QuerySpec(NULL, &format, &channels);
incr = (format & 0xFF) * channels;
end -= incr;
switch (incr) {
case 8:
for (i = wave->alen / 2; i >= 0; i -= 1) {
Uint8 tmp = *start;
*start = *end;
*end = tmp;
start++;
end--;
}
break;
case 16:
for (i = wave->alen / 2; i >= 0; i -= 2) {
Uint16 tmp = *start;
*((Uint16 *) start) = *((Uint16 *) end);
*((Uint16 *) end) = tmp;
start += 2;
end -= 2;
}
break;
case 32:
for (i = wave->alen / 2; i >= 0; i -= 4) {
Uint32 tmp = *start;
*((Uint32 *) start) = *((Uint32 *) end);
*((Uint32 *) end) = tmp;
start += 4;
end -= 4;
}
break;
default:
Oct 17, 2017
Oct 17, 2017
353
SDL_Log("Unhandled format in sample flipping.\n");
May 22, 2013
May 22, 2013
354
355
return;
}
Jun 10, 2001
Jun 10, 2001
356
357
358
}
Sep 11, 2001
Sep 11, 2001
359
int main(int argc, char *argv[])
Oct 21, 1999
Oct 21, 1999
360
{
May 22, 2013
May 22, 2013
361
362
363
364
365
366
367
int audio_rate;
Uint16 audio_format;
int audio_channels;
int loops = 0;
int i;
int reverse_stereo = 0;
int reverse_sample = 0;
Sep 11, 2001
Sep 11, 2001
368
Nov 26, 2019
Nov 26, 2019
369
370
(void) argc;
Apr 14, 2010
Apr 14, 2010
371
#ifdef HAVE_SETBUF
May 22, 2013
May 22, 2013
372
373
setbuf(stdout, NULL); /* rcg06132001 for debugging purposes. */
setbuf(stderr, NULL); /* rcg06192001 for debugging purposes, too. */
Apr 14, 2010
Apr 14, 2010
374
#endif
May 22, 2013
May 22, 2013
375
376
377
378
379
output_test_warnings();
/* Initialize variables */
audio_rate = MIX_DEFAULT_FREQUENCY;
audio_format = MIX_DEFAULT_FORMAT;
Nov 26, 2019
Nov 26, 2019
380
audio_channels = MIX_DEFAULT_CHANNELS;
May 22, 2013
May 22, 2013
381
382
/* Check command line usage */
Oct 17, 2017
Oct 17, 2017
383
384
for (i=1; argv[i] && (*argv[i] == '-'); ++i) {
if ((strcmp(argv[i], "-r") == 0) && argv[i+1]) {
May 22, 2013
May 22, 2013
385
386
387
++i;
audio_rate = atoi(argv[i]);
} else
Oct 17, 2017
Oct 17, 2017
388
if (strcmp(argv[i], "-m") == 0) {
May 22, 2013
May 22, 2013
389
390
audio_channels = 1;
} else
Oct 17, 2017
Oct 17, 2017
391
if ((strcmp(argv[i], "-c") == 0) && argv[i+1]) {
May 22, 2013
May 22, 2013
392
393
394
++i;
audio_channels = atoi(argv[i]);
} else
Oct 17, 2017
Oct 17, 2017
395
if (strcmp(argv[i], "-l") == 0) {
May 22, 2013
May 22, 2013
396
397
loops = -1;
} else
Oct 17, 2017
Oct 17, 2017
398
if (strcmp(argv[i], "-8") == 0) {
May 22, 2013
May 22, 2013
399
400
audio_format = AUDIO_U8;
} else
Oct 17, 2017
Oct 17, 2017
401
if (strcmp(argv[i], "-f32") == 0) {
Sep 9, 2017
Sep 9, 2017
402
403
audio_format = AUDIO_F32;
} else
Oct 17, 2017
Oct 17, 2017
404
if (strcmp(argv[i], "-f") == 0) { /* rcg06122001 flip stereo */
May 22, 2013
May 22, 2013
405
406
reverse_stereo = 1;
} else
Oct 17, 2017
Oct 17, 2017
407
if (strcmp(argv[i], "-F") == 0) { /* rcg06172001 flip sample */
May 22, 2013
May 22, 2013
408
409
410
411
412
413
reverse_sample = 1;
} else {
Usage(argv[0]);
return(1);
}
}
Oct 17, 2017
Oct 17, 2017
414
if (! argv[i]) {
May 22, 2013
May 22, 2013
415
416
417
418
419
Usage(argv[0]);
return(1);
}
/* Initialize the SDL library */
Oct 17, 2017
Oct 17, 2017
420
421
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
SDL_Log("Couldn't initialize SDL: %s\n",SDL_GetError());
May 22, 2013
May 22, 2013
422
423
return(255);
}
Apr 14, 2010
Apr 14, 2010
424
#ifdef HAVE_SIGNAL_H
May 22, 2013
May 22, 2013
425
426
signal(SIGINT, CleanUp);
signal(SIGTERM, CleanUp);
Apr 14, 2010
Apr 14, 2010
427
#endif
Oct 21, 1999
Oct 21, 1999
428
May 22, 2013
May 22, 2013
429
430
/* Open the audio device */
if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) < 0) {
Oct 17, 2017
Oct 17, 2017
431
SDL_Log("Couldn't open audio: %s\n", SDL_GetError());
May 22, 2013
May 22, 2013
432
433
434
CleanUp(2);
} else {
Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
Oct 21, 2017
Oct 21, 2017
435
SDL_Log("Opened audio at %d Hz %d bit%s %s", audio_rate,
May 22, 2013
May 22, 2013
436
(audio_format&0xFF),
Oct 21, 2017
Oct 21, 2017
437
(SDL_AUDIO_ISFLOAT(audio_format) ? " (float)" : ""),
May 22, 2013
May 22, 2013
438
439
(audio_channels > 2) ? "surround" :
(audio_channels > 1) ? "stereo" : "mono");
Oct 17, 2017
Oct 17, 2017
440
441
if (loops) {
SDL_Log(" (looping)\n");
May 22, 2013
May 22, 2013
442
443
444
445
446
} else {
putchar('\n');
}
}
audio_open = 1;
Oct 21, 1999
Oct 21, 1999
447
Sep 11, 2001
Sep 11, 2001
448
#if (defined TEST_MIX_VERSIONS)
May 22, 2013
May 22, 2013
449
test_versions();
Sep 11, 2001
Sep 11, 2001
450
451
#endif
Jun 5, 2009
Jun 5, 2009
452
#if (defined TEST_MIX_DECODERS)
May 22, 2013
May 22, 2013
453
report_decoders();
Jun 5, 2009
Jun 5, 2009
454
455
#endif
May 22, 2013
May 22, 2013
456
457
/* Load the requested wave file */
wave = Mix_LoadWAV(argv[i]);
Oct 17, 2017
Oct 17, 2017
458
459
if (wave == NULL) {
SDL_Log("Couldn't load %s: %s\n",
May 22, 2013
May 22, 2013
460
461
462
argv[i], SDL_GetError());
CleanUp(2);
}
Oct 21, 1999
Oct 21, 1999
463
May 22, 2013
May 22, 2013
464
465
466
if (reverse_sample) {
flip_sample(wave);
}
Sep 11, 2001
Sep 11, 2001
467
Jun 10, 2001
Jun 10, 2001
468
#ifdef TEST_MIX_CHANNELFINISHED /* rcg06072001 */
May 22, 2013
May 22, 2013
469
Mix_ChannelFinished(channel_complete_callback);
Jun 10, 2001
Jun 10, 2001
470
471
#endif
Oct 17, 2017
Oct 17, 2017
472
473
if ((!Mix_SetReverseStereo(MIX_CHANNEL_POST, reverse_stereo)) &&
(reverse_stereo))
May 22, 2013
May 22, 2013
474
{
Oct 17, 2017
Oct 17, 2017
475
476
SDL_Log("Failed to set up reverse stereo effect!\n");
SDL_Log("Reason: [%s].\n", Mix_GetError());
May 22, 2013
May 22, 2013
477
}
Sep 11, 2001
Sep 11, 2001
478
May 22, 2013
May 22, 2013
479
480
/* Play and then exit */
Mix_PlayChannel(0, wave, loops);
Jun 10, 2001
Jun 10, 2001
481
May 22, 2013
May 22, 2013
482
while (still_playing()) {
Sep 11, 2001
Sep 11, 2001
483
484
#if (defined TEST_MIX_PANNING) /* rcg06132001 */
May 22, 2013
May 22, 2013
485
do_panning_update();
Jun 10, 2001
Jun 10, 2001
486
487
#endif
Sep 11, 2001
Sep 11, 2001
488
#if (defined TEST_MIX_DISTANCE) /* rcg06192001 */
May 22, 2013
May 22, 2013
489
do_distance_update();
Sep 11, 2001
Sep 11, 2001
490
491
492
#endif
#if (defined TEST_MIX_POSITION) /* rcg06202001 */
May 22, 2013
May 22, 2013
493
do_position_update();
Sep 11, 2001
Sep 11, 2001
494
495
#endif
May 22, 2013
May 22, 2013
496
SDL_Delay(1);
Sep 11, 2001
Sep 11, 2001
497
May 22, 2013
May 22, 2013
498
} /* while still_playing() loop... */
Sep 11, 2001
Sep 11, 2001
499
May 22, 2013
May 22, 2013
500
CleanUp(0);
May 14, 2006
May 14, 2006
501
May 22, 2013
May 22, 2013
502
503
/* Not reached, but fixes compiler warnings */
return 0;
Oct 21, 1999
Oct 21, 1999
504
}
Sep 11, 2001
Sep 11, 2001
505
506
507
/* end of playwave.c ... */
Oct 17, 2017
Oct 17, 2017
508
/* vi: set ts=4 sw=4 expandtab: */