annotate playsound/playsound.c @ 308:6a80b2f9c47c

Command line updates, added Darrell to the credits, and cleaned up other stuff. --loop now takes a numeric value.
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 24 Apr 2002 07:56:52 +0000
parents 414cfef0978e
children 9e21cb0d3ae7
rev   line source
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1 /*
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
2 * SDL_sound -- An abstract sound format decoding API.
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
3 * Copyright (C) 2001 Ryan C. Gordon.
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
4 *
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
8 * version 2.1 of the License, or (at your option) any later version.
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
9 *
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
13 * Lesser General Public License for more details.
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
14 *
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
18 */
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
19
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
20 /**
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
21 * This is a quick and dirty test of SDL_sound.
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
22 *
184
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 176
diff changeset
23 * Please see the file COPYING in the source's root directory.
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
24 *
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
25 * This file written by Ryan C. Gordon. (icculus@clutteredmind.org)
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
26 */
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
27
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
28 #include <stdio.h>
270
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
29 #include <stdlib.h>
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
30 #include <string.h>
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
31 #include <assert.h>
148
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
32 #include <signal.h>
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
33 #include "SDL.h"
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
34 #include "SDL_sound.h"
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
35
283
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
36 #if SUPPORT_PHYSFS
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
37 #include <alloca.h>
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
38 #include "physfs.h"
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
39 #include "physfsrwops.h"
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
40 #endif
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
41
187
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
42 #define DEFAULT_DECODEBUF 16384
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
43 #define DEFAULT_AUDIOBUF 4096
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
44
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
45 #define PLAYSOUND_VER_MAJOR 0
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
46 #define PLAYSOUND_VER_MINOR 1
252
c54eae85f5f1 Upped version to 0.1.5.
Ryan C. Gordon <icculus@icculus.org>
parents: 236
diff changeset
47 #define PLAYSOUND_VER_PATCH 5
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
48
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
49 static void output_versions(const char *argv0)
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
50 {
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
51 Sound_Version compiled;
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
52 Sound_Version linked;
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
53 SDL_version sdl_compiled;
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
54 const SDL_version *sdl_linked;
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
55
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
56 SOUND_VERSION(&compiled);
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
57 Sound_GetLinkedVersion(&linked);
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
58 SDL_VERSION(&sdl_compiled);
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
59 sdl_linked = SDL_Linked_Version();
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
60
176
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
61 printf("%s version %d.%d.%d\n"
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
62 "Copyright 2001 Ryan C. Gordon\n"
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
63 "This program is free software, covered by the GNU Lesser General\n"
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
64 "Public License, and you are welcome to change it and/or\n"
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
65 "distribute copies of it under certain conditions. There is\n"
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
66 "absolutely NO WARRANTY for this program.\n"
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
67 "\n"
148
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
68 " Compiled against SDL_sound version %d.%d.%d,\n"
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
69 " and linked against %d.%d.%d.\n"
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
70 " Compiled against SDL version %d.%d.%d,\n"
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
71 " and linked against %d.%d.%d.\n\n",
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
72 argv0,
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
73 PLAYSOUND_VER_MAJOR, PLAYSOUND_VER_MINOR, PLAYSOUND_VER_PATCH,
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
74 compiled.major, compiled.minor, compiled.patch,
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
75 linked.major, linked.minor, linked.patch,
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
76 sdl_compiled.major, sdl_compiled.minor, sdl_compiled.patch,
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
77 sdl_linked->major, sdl_linked->minor, sdl_linked->patch);
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
78 } /* output_versions */
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
79
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
80
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
81 static void output_decoders(void)
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
82 {
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
83 const Sound_DecoderInfo **rc = Sound_AvailableDecoders();
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
84 const Sound_DecoderInfo **i;
148
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
85 const char **ext;
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
86
148
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
87 printf("Supported sound formats:\n");
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
88 if (rc == NULL)
148
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
89 printf(" * Apparently, NONE!\n");
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
90 else
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
91 {
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
92 for (i = rc; *i != NULL; i++)
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
93 {
148
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
94 printf(" * %s\n", (*i)->description);
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
95 for (ext = (*i)->extensions; *ext != NULL; ext++)
150
033afe96afbc Commenting and fixes for the audio callback.
Ryan C. Gordon <icculus@icculus.org>
parents: 148
diff changeset
96 printf(" File extension \"%s\"\n", *ext);
148
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
97 printf(" Written by %s.\n %s\n\n", (*i)->author, (*i)->url);
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
98 } /* for */
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
99 } /* else */
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
100
148
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
101 printf("\n");
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
102 } /* output_decoders */
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
103
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
104
176
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
105 static void output_usage(const char *argv0)
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
106 {
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
107 fprintf(stderr,
187
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
108 "USAGE: %s [...options...] [soundFile1] ... [soundFileN]\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
109 "\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
110 " Options:\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
111 " --rate n Playback at sample rate of n HZ.\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
112 " --format fmt Playback in fmt format (see below).\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
113 " --channels n Playback on n channels (1 or 2).\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
114 " --decodebuf n Buffer n decoded bytes at a time (default %d).\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
115 " --audiobuf n Buffer n samples to audio device (default %d).\n"
270
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
116 " --volume n Playback volume multiplier (default 1.0).\n"
280
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
117 " --stdin [ext] Read from stdin (treat data as format [ext])\n"
187
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
118 " --version Display version information and exit.\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
119 " --decoders List supported data formats and exit.\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
120 " --predecode Decode entire sample before playback.\n"
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
121 " --loop n Loop playback n times. 0=forever.\n"
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
122
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
123 /*" --seek list List of seek points and playback durations.\n"*/
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
124
187
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
125 " --credits Shameless promotion.\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
126 " --help Display this information and exit.\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
127 "\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
128 " Valid arguments to the --format option are:\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
129 " U8 Unsigned 8-bit.\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
130 " S8 Signed 8-bit.\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
131 " U16LSB Unsigned 16-bit (least significant byte first).\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
132 " U16MSB Unsigned 16-bit (most significant byte first).\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
133 " S16LSB Signed 16-bit (least significant byte first).\n"
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
134 " S16MSB Signed 16-bit (most significant byte first).\n"
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
135
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
136 /*
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
137 "\n"
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
138 " Valid arguments to the --seek options look like:\n"
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
139 " --seek=\"mm:ss;mm:ss;mm:ss\"\n"
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
140 " Where the first \"mm:ss\" is the position, in minutes and\n"
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
141 " seconds to seek to at start of playback. The second mm:ss\n"
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
142 " is how long to play audio from that point. The third mm:ss\n"
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
143 " is another seek after the duration of playback has completed.\n"
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
144 " If the final playback duration is omitted, playback continues\n"
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
145 " until the end of the file. --loop and --seek can coexist.\n"
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
146 */
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
147
187
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
148 "\n",
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
149 argv0, DEFAULT_DECODEBUF, DEFAULT_AUDIOBUF);
176
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
150 } /* output_usage */
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
151
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
152
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
153 static void output_credits(void)
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
154 {
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
155 printf("playsound version %d.%d.%d\n"
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
156 "Copyright 2001 Ryan C. Gordon\n"
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
157 "playsound is free software, covered by the GNU Lesser General\n"
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
158 "Public License, and you are welcome to change it and/or\n"
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
159 "distribute copies of it under certain conditions. There is\n"
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
160 "absolutely NO WARRANTY for playsound.\n"
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
161 "\n"
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
162 " Written by Ryan C. Gordon, Torbjörn Andersson, Max Horn,\n"
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
163 " Tsuyoshi Iguchi, Tyler Montbriand, Darrell Walisser,\n"
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
164 " and a cast of thousands.\n"
176
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
165 "\n"
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
166 " Website and source code: http://icculus.org/SDL_sound/\n"
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
167 "\n",
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
168 PLAYSOUND_VER_MAJOR, PLAYSOUND_VER_MINOR, PLAYSOUND_VER_PATCH);
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
169 } /* output_credits */
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
170
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
171
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
172
302
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
173 /* archive stuff... */
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
174
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
175 static int init_archive(const char *argv0)
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
176 {
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
177 int retval = 1;
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
178
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
179 #if SUPPORT_PHYSFS
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
180 retval = PHYSFS_init(argv0);
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
181 if (!retval)
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
182 {
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
183 fprintf(stderr, "Couldn't init PhysicsFS: %s\n",
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
184 PHYSFS_getLastError());
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
185 } /* if */
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
186 #endif
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
187
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
188 return(retval);
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
189 } /* init_archive */
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
190
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
191
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
192 #if SUPPORT_PHYSFS
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
193 static SDL_RWops *rwops_from_physfs(const char *filename)
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
194 {
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
195 SDL_RWops *retval = NULL;
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
196
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
197 char *path = (char *) alloca(strlen(filename) + 1);
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
198 char *archive;
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
199
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
200 strcpy(path, filename);
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
201 archive = strchr(path, '@');
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
202 if (archive != NULL)
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
203 {
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
204 *(archive++) = '\0'; /* blank '@', point to archive name. */
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
205 if (!PHYSFS_addToSearchPath(archive, 0))
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
206 {
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
207 fprintf(stderr, "Couldn't open archive: %s\n",
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
208 PHYSFS_getLastError());
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
209 return(NULL);
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
210 } /* if */
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
211
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
212 retval = PHYSFSRWOPS_openRead(path);
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
213 } /* if */
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
214
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
215 return(retval);
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
216 } /* rwops_from_physfs */
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
217 #endif
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
218
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
219
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
220 static Sound_Sample *sample_from_archive(const char *fname,
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
221 Sound_AudioInfo *desired,
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
222 Uint32 decode_buffersize)
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
223 {
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
224 #if SUPPORT_PHYSFS
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
225 SDL_RWops *rw = rwops_from_physfs(fname);
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
226 if (rw != NULL)
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
227 {
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
228 char *path = (char *) alloca(strlen(fname) + 1);
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
229 char *ptr;
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
230 strcpy(path, fname);
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
231 ptr = strchr(path, '@');
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
232 *ptr = '\0';
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
233 ptr = strrchr(path, '.');
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
234 if (ptr != NULL)
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
235 ptr++;
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
236
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
237 return(Sound_NewSample(rw, ptr, desired, decode_buffersize));
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
238 } /* if */
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
239 #endif
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
240
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
241 return(NULL);
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
242 } /* sample_from_archive */
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
243
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
244
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
245 static void close_archive(const char *filename)
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
246 {
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
247 #if SUPPORT_PHYSFS
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
248 char *archive_name = strchr(filename, '@');
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
249 if (archive_name != NULL)
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
250 PHYSFS_removeFromSearchPath(archive_name + 1);
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
251 #endif
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
252 } /* close_archive */
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
253
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
254
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
255 static void deinit_archive(void)
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
256 {
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
257 #if SUPPORT_PHYSFS
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
258 PHYSFS_deinit();
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
259 #endif
302
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
260 } /* deinit_archive */
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
261
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
262
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
263
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
264 static volatile int done_flag = 0;
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
265
148
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
266
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
267 void sigint_catcher(int signum)
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
268 {
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
269 static Uint32 last_sigint = 0;
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
270 Uint32 ticks = SDL_GetTicks();
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
271
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
272 assert(signum == SIGINT);
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
273
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
274 if ((last_sigint != 0) && (ticks - last_sigint < 500))
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
275 {
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
276 SDL_PauseAudio(1);
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
277 SDL_CloseAudio();
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
278 Sound_Quit();
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
279 SDL_Quit();
302
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
280 deinit_archive();
148
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
281 exit(1);
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
282 } /* if */
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
283
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
284 else
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
285 {
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
286 last_sigint = ticks;
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
287 done_flag = 1;
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
288 } /* else */
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
289 } /* sigint_catcher */
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
290
d51546293fd1 Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents: 146
diff changeset
291
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
292 /* global decoding state. */
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
293 /* !!! FIXME: Put this in a struct and pass a pointer to it as the
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
294 * !!! FIXME: audio callback's argument. This will clean up the
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
295 * !!! FIXME: namespace and let me reinitialize this for each file in
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
296 * !!! FIXME: a cleaner way.
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
297 */
146
023c3e7f028b Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents: 144
diff changeset
298 static Uint8 *decoded_ptr = NULL;
023c3e7f028b Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents: 144
diff changeset
299 static Uint32 decoded_bytes = 0;
222
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
300 static int predecode = 0;
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
301 static int looping = 0;
270
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
302 static int wants_volume_change = 0;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
303 static float volume = 1.0;
222
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
304
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
305
222
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
306 /*
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
307 * This updates (decoded_bytes) and (decoder_ptr) with more audio data,
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
308 * taking into account looping and/or predecoding.
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
309 */
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
310 static int read_more_data(Sound_Sample *sample)
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
311 {
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
312 if (done_flag) /* probably a sigint; stop trying to read. */
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
313 decoded_bytes = 0;
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
314
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
315 if (decoded_bytes > 0) /* don't need more data; just return. */
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
316 return(decoded_bytes);
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
317
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
318 /* need more. See if there's more to be read... */
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
319 if (!(sample->flags & (SOUND_SAMPLEFLAG_ERROR | SOUND_SAMPLEFLAG_EOF)))
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
320 {
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
321 decoded_bytes = Sound_Decode(sample);
272
0ac181b5adc6 Corrected error reporting to respect Sound_GetError()'s new thread
Ryan C. Gordon <icculus@icculus.org>
parents: 270
diff changeset
322 if (sample->flags & SOUND_SAMPLEFLAG_ERROR)
0ac181b5adc6 Corrected error reporting to respect Sound_GetError()'s new thread
Ryan C. Gordon <icculus@icculus.org>
parents: 270
diff changeset
323 {
0ac181b5adc6 Corrected error reporting to respect Sound_GetError()'s new thread
Ryan C. Gordon <icculus@icculus.org>
parents: 270
diff changeset
324 fprintf(stderr, "Error in decoding sound file!\n"
0ac181b5adc6 Corrected error reporting to respect Sound_GetError()'s new thread
Ryan C. Gordon <icculus@icculus.org>
parents: 270
diff changeset
325 " reason: [%s].\n", Sound_GetError());
0ac181b5adc6 Corrected error reporting to respect Sound_GetError()'s new thread
Ryan C. Gordon <icculus@icculus.org>
parents: 270
diff changeset
326 } /* if */
0ac181b5adc6 Corrected error reporting to respect Sound_GetError()'s new thread
Ryan C. Gordon <icculus@icculus.org>
parents: 270
diff changeset
327
222
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
328 decoded_ptr = sample->buffer;
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
329 return(read_more_data(sample)); /* handle loops conditions. */
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
330 } /* if */
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
331
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
332 /* No more to be read from stream, but we may want to loop the sample. */
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
333
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
334 if (!looping)
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
335 return(0);
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
336
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
337 looping--;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
338
222
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
339 /* we just need to point predecoded samples to the start of the buffer. */
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
340 if (predecode)
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
341 {
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
342 decoded_bytes = sample->buffer_size;
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
343 decoded_ptr = sample->buffer;
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
344 return(decoded_bytes);
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
345 } /* if */
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
346 else
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
347 {
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
348 Sound_Rewind(sample); /* error is checked in recursion. */
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
349 return(read_more_data(sample));
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
350 } /* else */
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
351
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
352 assert(0); /* shouldn't ever hit this point. */
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
353 return(0);
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
354 } /* read_more_data */
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
355
146
023c3e7f028b Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents: 144
diff changeset
356
270
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
357 static void memcpy_with_volume(Sound_Sample *sample,
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
358 Uint8 *dst, Uint8 *src, int len)
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
359 {
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
360 int i;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
361 Uint16 *u16src = NULL;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
362 Uint16 *u16dst = NULL;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
363 Sint16 *s16src = NULL;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
364 Sint16 *s16dst = NULL;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
365
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
366 if (!wants_volume_change)
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
367 {
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
368 memcpy(dst, src, len);
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
369 return;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
370 }
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
371
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
372 /* !!! FIXME: This would be more efficient with a lookup table. */
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
373 switch (sample->desired.format)
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
374 {
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
375 case AUDIO_U8:
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
376 for (i = 0; i < len; i++, src++, dst++)
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
377 *dst = (Uint8) (((float) (*src)) * volume);
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
378 break;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
379
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
380 case AUDIO_S8:
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
381 for (i = 0; i < len; i++, src++, dst++)
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
382 *dst = (Sint8) (((float) (*src)) * volume);
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
383 break;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
384
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
385 case AUDIO_U16LSB:
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
386 u16src = (Uint16 *) src;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
387 u16dst = (Uint16 *) dst;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
388 for (i = 0; i < len; i += sizeof (Uint16), u16src++, u16dst++)
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
389 {
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
390 *u16dst = (Uint16) (((float) (SDL_SwapLE16(*u16src))) * volume);
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
391 *u16dst = SDL_SwapLE16(*u16dst);
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
392 }
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
393 break;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
394
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
395 case AUDIO_S16LSB:
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
396 s16src = (Sint16 *) src;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
397 s16dst = (Sint16 *) dst;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
398 for (i = 0; i < len; i += sizeof (Sint16), s16src++, s16dst++)
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
399 {
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
400 *s16dst = (Sint16) (((float) (SDL_SwapLE16(*s16src))) * volume);
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
401 *s16dst = SDL_SwapLE16(*s16dst);
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
402 }
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
403 break;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
404
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
405 case AUDIO_U16MSB:
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
406 u16src = (Uint16 *) src;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
407 u16dst = (Uint16 *) dst;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
408 for (i = 0; i < len; i += sizeof (Uint16), u16src++, u16dst++)
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
409 {
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
410 *u16dst = (Uint16) (((float) (SDL_SwapBE16(*u16src))) * volume);
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
411 *u16dst = SDL_SwapBE16(*u16dst);
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
412 }
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
413 break;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
414
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
415 case AUDIO_S16MSB:
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
416 s16src = (Sint16 *) src;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
417 s16dst = (Sint16 *) dst;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
418 for (i = 0; i < len; i += sizeof (Sint16), s16src++, s16dst++)
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
419 {
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
420 *s16dst = (Sint16) (((float) (SDL_SwapBE16(*s16src))) * volume);
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
421 *s16dst = SDL_SwapBE16(*s16dst);
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
422 }
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
423 break;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
424 }
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
425 }
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
426
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
427
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
428 static void audio_callback(void *userdata, Uint8 *stream, int len)
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
429 {
112
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
430 Sound_Sample *sample = (Sound_Sample *) userdata;
150
033afe96afbc Commenting and fixes for the audio callback.
Ryan C. Gordon <icculus@icculus.org>
parents: 148
diff changeset
431 int bw = 0; /* bytes written to stream this time through the callback */
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
432
146
023c3e7f028b Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents: 144
diff changeset
433 while (bw < len)
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
434 {
150
033afe96afbc Commenting and fixes for the audio callback.
Ryan C. Gordon <icculus@icculus.org>
parents: 148
diff changeset
435 int cpysize; /* bytes to copy on this iteration of the loop. */
033afe96afbc Commenting and fixes for the audio callback.
Ryan C. Gordon <icculus@icculus.org>
parents: 148
diff changeset
436
222
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
437 if (!read_more_data(sample)) /* read more data, if needed. */
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
438 {
222
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
439 /* ...there isn't any more data to read! */
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
440 memset(stream + bw, '\0', len - bw);
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
441 done_flag = 1;
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
442 return;
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
443 } /* if */
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
444
222
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
445 /* decoded_bytes and decoder_ptr are updated as necessary... */
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
446
146
023c3e7f028b Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents: 144
diff changeset
447 cpysize = len - bw;
023c3e7f028b Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents: 144
diff changeset
448 if (cpysize > decoded_bytes)
023c3e7f028b Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents: 144
diff changeset
449 cpysize = decoded_bytes;
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
450
146
023c3e7f028b Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents: 144
diff changeset
451 if (cpysize > 0)
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
452 {
270
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
453 memcpy_with_volume(sample, stream + bw, decoded_ptr, cpysize);
146
023c3e7f028b Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents: 144
diff changeset
454 bw += cpysize;
150
033afe96afbc Commenting and fixes for the audio callback.
Ryan C. Gordon <icculus@icculus.org>
parents: 148
diff changeset
455 decoded_ptr += cpysize;
033afe96afbc Commenting and fixes for the audio callback.
Ryan C. Gordon <icculus@icculus.org>
parents: 148
diff changeset
456 decoded_bytes -= cpysize;
146
023c3e7f028b Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents: 144
diff changeset
457 } /* if */
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
458 } /* while */
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
459 } /* audio_callback */
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
460
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
461
135
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
462 static int str_to_fmt(char *str)
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
463 {
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
464 if (strcmp(str, "U8") == 0)
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
465 return AUDIO_U8;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
466 if (strcmp(str, "S8") == 0)
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
467 return AUDIO_S8;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
468 if (strcmp(str, "U16LSB") == 0)
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
469 return AUDIO_U16LSB;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
470 if (strcmp(str, "S16LSB") == 0)
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
471 return AUDIO_S16LSB;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
472 if (strcmp(str, "U16MSB") == 0)
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
473 return AUDIO_U16MSB;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
474 if (strcmp(str, "S16MSB") == 0)
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
475 return AUDIO_S16MSB;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
476 return 0;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
477 } /* str_to_fmt */
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
478
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
479
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
480 int main(int argc, char **argv)
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
481 {
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
482 Sound_AudioInfo sound_desired;
187
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
483 Uint32 audio_buffersize = DEFAULT_AUDIOBUF;
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
484 Uint32 decode_buffersize = DEFAULT_DECODEBUF;
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
485 SDL_AudioSpec sdl_desired;
112
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
486 SDL_AudioSpec sdl_actual;
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
487 Sound_Sample *sample;
135
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
488 int use_specific_audiofmt = 0;
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
489 int i;
214
e27b33a6d5fe Now attempts to wait for SDL to finish playing the end of the buffered
Ryan C. Gordon <icculus@icculus.org>
parents: 196
diff changeset
490 int delay;
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
491 int new_sample = 1;
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
492
168
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
493 setbuf(stdout, NULL);
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
494 setbuf(stderr, NULL);
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
495
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
496 if (argc < 2)
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
497 {
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
498 output_usage(argv[0]);
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
499 return(42);
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
500 } /* if */
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
501
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
502 /* Check some command lines upfront. */
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
503 for (i = 0; i < argc; i++)
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
504 {
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
505 if (strncmp(argv[i], "--", 2) != 0)
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
506 continue;
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
507
135
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
508 if (strcmp(argv[i], "--version") == 0)
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
509 {
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
510 output_versions(argv[0]);
135
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
511 return(42);
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
512 } /* if */
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
513
176
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
514 if (strcmp(argv[i], "--credits") == 0)
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
515 {
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
516 output_credits();
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
517 return(42);
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
518 } /* if */
69922f6a5c74 Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents: 168
diff changeset
519
135
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
520 else if (strcmp(argv[i], "--help") == 0)
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
521 {
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
522 output_usage(argv[0]);
135
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
523 return(42);
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
524 } /* if */
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
525
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
526 else if (strcmp(argv[i], "--decoders") == 0)
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
527 {
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
528 if (!Sound_Init())
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
529 {
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
530 fprintf(stderr, "Sound_Init() failed!\n"
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
531 " reason: [%s].\n", Sound_GetError());
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
532 SDL_Quit();
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
533 return(42);
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
534 } /* if */
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
535
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
536 output_decoders();
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
537 Sound_Quit();
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
538 return(0);
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
539 } /* else if */
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
540
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
541 /* !!! FIXME: Verify other --arguments are valid. */
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
542 #if 0
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
543 else
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
544 {
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
545 fprintf(stderr, "unknown option: \"%s\"\n", argv[i]);
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
546 return(42);
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
547 } /* else */
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
548 #endif
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
549 } /* for */
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
550
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
551 if (!init_archive(argv[0]))
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
552 return(42);
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
553
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
554 if (SDL_Init(SDL_INIT_AUDIO) == -1)
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
555 {
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
556 fprintf(stderr, "SDL_Init(SDL_INIT_AUDIO) failed!\n"
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
557 " reason: [%s].\n", SDL_GetError());
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
558 return(42);
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
559 } /* if */
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
560
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
561 if (!Sound_Init())
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
562 {
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
563 fprintf(stderr, "Sound_Init() failed!\n"
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
564 " reason: [%s].\n", Sound_GetError());
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
565 SDL_Quit();
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
566 return(42);
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
567 } /* if */
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
568
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
569 signal(SIGINT, sigint_catcher);
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
570
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
571 for (i = 1; i < argc; i++)
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
572 {
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
573 char *filename = NULL;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
574
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
575 /* set variables back to defaults for next file... */
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
576 if (new_sample)
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
577 {
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
578 new_sample = 0;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
579 memset(&sound_desired, '\0', sizeof (sound_desired));
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
580 done_flag = 0;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
581 decoded_ptr = NULL;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
582 decoded_bytes = 0;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
583 predecode = 0;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
584 looping = 0;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
585 audio_buffersize = DEFAULT_AUDIOBUF;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
586 decode_buffersize = DEFAULT_DECODEBUF;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
587 sample = NULL;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
588 use_specific_audiofmt = 0;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
589 wants_volume_change = 0;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
590 volume = 1.0;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
591 } /* if */
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
592
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
593 if (strcmp(argv[i], "--rate") == 0 && argc > i + 1)
135
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
594 {
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
595 use_specific_audiofmt = 1;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
596 sound_desired.rate = atoi(argv[++i]);
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
597 if (sound_desired.rate <= 0)
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
598 {
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
599 fprintf(stderr, "Bad argument to --rate!\n");
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
600 return(42);
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
601 }
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
602 } /* else if */
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
603
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
604 else if (strcmp(argv[i], "--format") == 0 && argc > i + 1)
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
605 {
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
606 use_specific_audiofmt = 1;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
607 sound_desired.format = str_to_fmt(argv[++i]);
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
608 if (sound_desired.format == 0)
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
609 {
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
610 fprintf(stderr, "Bad argument to --format! Try one of:\n"
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
611 "U8, S8, U16LSB, S16LSB, U16MSB, S16MSB\n");
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
612 return(42);
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
613 }
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
614 } /* else if */
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
615
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
616 else if (strcmp(argv[i], "--channels") == 0 && argc > i + 1)
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
617 {
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
618 use_specific_audiofmt = 1;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
619 sound_desired.channels = atoi(argv[++i]);
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
620 if (sound_desired.channels < 1 || sound_desired.channels > 2)
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
621 {
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
622 fprintf(stderr,
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
623 "Bad argument to --channels! Try 1 (mono) or 2 "
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
624 "(stereo).\n");
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
625 return(42);
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
626 }
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
627 } /* else if */
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
628
187
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
629 else if (strcmp(argv[i], "--audiobuf") == 0 && argc > i + 1)
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
630 {
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
631 audio_buffersize = atoi(argv[++i]);
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
632 } /* else if */
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
633
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
634 else if (strcmp(argv[i], "--decodebuf") == 0 && argc > i + 1)
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
635 {
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
636 decode_buffersize = atoi(argv[++i]);
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
637 } /* else if */
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
638
270
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
639 else if (strcmp(argv[i], "--volume") == 0 && argc > i + 1)
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
640 {
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
641 volume = atof(argv[++i]);
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
642 if (volume != 1.0)
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
643 wants_volume_change = 1;
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
644 } /* else if */
cf8c0bbbdc19 --volume control.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
645
168
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
646 else if (strcmp(argv[i], "--predecode") == 0)
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
647 {
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
648 predecode = 1;
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
649 } /* else if */
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
650
222
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
651 else if (strcmp(argv[i], "--loop") == 0)
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
652 {
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
653 looping = atoi(argv[++i]);
222
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
654 } /* else if */
d6b24586822a Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents: 214
diff changeset
655
280
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
656 else if (strcmp(argv[i], "--stdin") == 0)
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
657 {
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
658 SDL_RWops *rw = SDL_RWFromFP(stdin, 1);
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
659 filename = "...from stdin...";
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
660
280
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
661 /*
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
662 * The second argument will be NULL if --stdin is the last
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
663 * thing on the command line. This is correct behaviour.
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
664 */
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
665 sample = Sound_NewSample(rw, argv[++i],
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
666 use_specific_audiofmt ? &sound_desired : NULL,
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
667 decode_buffersize);
283
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
668 } /* if */
280
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
669
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
670 else if (strncmp(argv[i], "--", 2) == 0)
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
671 /* ignore it. */ ;
280
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
672
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
673 else
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
674 {
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
675 filename = argv[i];
302
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
676 sample = sample_from_archive(filename,
283
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
677 use_specific_audiofmt ? &sound_desired : NULL,
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
678 decode_buffersize);
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
679
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
680 if (sample == NULL)
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
681 {
302
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
682 sample = Sound_NewSampleFromFile(filename,
283
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
683 use_specific_audiofmt ? &sound_desired : NULL,
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
684 decode_buffersize);
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
685 } /* if */
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
686 } /* else */
135
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
687
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
688 if (filename == NULL) /* still parsing command line stuff? */
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
689 continue;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
690
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
691 new_sample = 1;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
692
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
693 if (sample == NULL)
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
694 {
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
695 fprintf(stderr, "Couldn't load \"%s\"!\n"
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
696 " reason: [%s].\n",
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
697 filename, Sound_GetError());
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
698 continue;
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
699 } /* if */
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
700
135
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
701 /*
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
702 * Unless explicitly specified, pick the format from the sound
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
703 * to be played.
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
704 */
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
705 if (use_specific_audiofmt)
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
706 {
308
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
707 /* Pick sensible default for any value not explicitly specified. */
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
708 if (sound_desired.rate == 0)
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
709 sound_desired.rate = 44100;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
710 if (sound_desired.format == 0)
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
711 sound_desired.format = AUDIO_S16SYS;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
712 if (sound_desired.channels == 0)
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
713 sound_desired.channels = 2;
6a80b2f9c47c Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents: 302
diff changeset
714
135
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
715 sdl_desired.freq = sound_desired.rate;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
716 sdl_desired.format = sound_desired.format;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
717 sdl_desired.channels = sound_desired.channels;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
718 } /* if */
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
719 else
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
720 {
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
721 sdl_desired.freq = sample->actual.rate;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
722 sdl_desired.format = sample->actual.format;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
723 sdl_desired.channels = sample->actual.channels;
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
724 } /* else */
69cd80e80363 Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents: 112
diff changeset
725
187
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
726 sdl_desired.samples = audio_buffersize;
112
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
727 sdl_desired.callback = audio_callback;
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
728 sdl_desired.userdata = sample;
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
729
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
730 if (SDL_OpenAudio(&sdl_desired, NULL) < 0)
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
731 {
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
732 fprintf(stderr, "Couldn't open audio device!\n"
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
733 " reason: [%s].\n", SDL_GetError());
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
734 Sound_Quit();
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
735 SDL_Quit();
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
736 return(42);
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
737 } /* if */
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
738
280
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
739 printf("Now playing [%s]...\n", filename);
112
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
740
168
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
741 if (predecode)
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
742 {
280
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
743 printf(" predecoding...");
168
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
744 decoded_bytes = Sound_DecodeAll(sample);
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
745 decoded_ptr = sample->buffer;
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
746 if (sample->flags & SOUND_SAMPLEFLAG_ERROR)
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
747 {
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
748 fprintf(stderr,
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
749 "Couldn't fully decode \"%s\"!\n"
187
bfe5031726e8 printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
750 " reason: [%s].\n"
168
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
751 " (playing first %lu bytes of decoded data...)\n",
280
06fbb106a554 Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents: 272
diff changeset
752 filename, Sound_GetError(), decoded_bytes);
168
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
753 } /* if */
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
754 else
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
755 {
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
756 printf("done.\n");
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
757 } /* else */
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
758 } /* if */
87b00f023710 Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents: 150
diff changeset
759
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
760 SDL_PauseAudio(0);
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
761 while (!done_flag)
146
023c3e7f028b Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents: 144
diff changeset
762 {
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
763 SDL_Delay(10);
146
023c3e7f028b Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents: 144
diff changeset
764 } /* while */
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
765 SDL_PauseAudio(1);
146
023c3e7f028b Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents: 144
diff changeset
766
236
034b2e56f405 Fixed some tabs.
Ryan C. Gordon <icculus@icculus.org>
parents: 222
diff changeset
767 /*
034b2e56f405 Fixed some tabs.
Ryan C. Gordon <icculus@icculus.org>
parents: 222
diff changeset
768 * Sleep two buffers' worth of audio before closing, in order
034b2e56f405 Fixed some tabs.
Ryan C. Gordon <icculus@icculus.org>
parents: 222
diff changeset
769 * to allow the playback to finish. This isn't always enough;
034b2e56f405 Fixed some tabs.
Ryan C. Gordon <icculus@icculus.org>
parents: 222
diff changeset
770 * perhaps SDL needs a way to explicitly wait for device drain?
034b2e56f405 Fixed some tabs.
Ryan C. Gordon <icculus@icculus.org>
parents: 222
diff changeset
771 */
034b2e56f405 Fixed some tabs.
Ryan C. Gordon <icculus@icculus.org>
parents: 222
diff changeset
772 delay = 2 * 1000 * sdl_desired.samples / sdl_desired.freq;
034b2e56f405 Fixed some tabs.
Ryan C. Gordon <icculus@icculus.org>
parents: 222
diff changeset
773 SDL_Delay(delay);
214
e27b33a6d5fe Now attempts to wait for SDL to finish playing the end of the buffered
Ryan C. Gordon <icculus@icculus.org>
parents: 196
diff changeset
774
112
3fcb23da06ba Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents: 82
diff changeset
775 SDL_CloseAudio(); /* reopen with next sample's format if possible */
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
776 Sound_FreeSample(sample);
283
6c059c4d2cea Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents: 280
diff changeset
777
302
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
778 close_archive(filename);
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
779 } /* for */
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
780
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
781 Sound_Quit();
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
782 SDL_Quit();
302
414cfef0978e Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents: 288
diff changeset
783 deinit_archive();
58
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
784 return(0);
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
785 } /* main */
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
786
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
787 /* end of playsound.c ... */
4a51162099e0 Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
788