Mercurial > SDL_sound_CoreAudio
annotate playsound/playsound.c @ 310:9e21cb0d3ae7
Seek support added.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 24 Apr 2002 20:01:20 +0000 |
parents | 6a80b2f9c47c |
children | 8195b86207bb |
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 | 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 | 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" |
310 | 121 " --loop n Loop playback n times.\n" |
122 " --seek list List of seek points and playback durations.\n" | |
187
bfe5031726e8
printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
123 " --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
|
124 " --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
|
125 "\n" |
bfe5031726e8
printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
126 " 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
|
127 " 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
|
128 " 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
|
129 " 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
|
130 " 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
|
131 " 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
|
132 " 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
|
133 "\n" |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
134 " 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
|
135 " --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
|
136 " 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
|
137 " 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
|
138 " 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
|
139 " 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
|
140 " 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
|
141 " until the end of the file. --loop and --seek can coexist.\n" |
187
bfe5031726e8
printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
142 "\n", |
bfe5031726e8
printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
143 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
|
144 } /* output_usage */ |
69922f6a5c74
Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents:
168
diff
changeset
|
145 |
69922f6a5c74
Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents:
168
diff
changeset
|
146 |
69922f6a5c74
Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents:
168
diff
changeset
|
147 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
|
148 { |
69922f6a5c74
Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents:
168
diff
changeset
|
149 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
|
150 "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
|
151 "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
|
152 "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
|
153 "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
|
154 "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
|
155 "\n" |
69922f6a5c74
Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents:
168
diff
changeset
|
156 " 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
|
157 " 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
|
158 " 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
|
159 "\n" |
69922f6a5c74
Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents:
168
diff
changeset
|
160 " 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
|
161 "\n", |
69922f6a5c74
Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents:
168
diff
changeset
|
162 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
|
163 } /* output_credits */ |
69922f6a5c74
Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents:
168
diff
changeset
|
164 |
69922f6a5c74
Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents:
168
diff
changeset
|
165 |
69922f6a5c74
Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents:
168
diff
changeset
|
166 |
302
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
167 /* archive stuff... */ |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
168 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
169 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
|
170 { |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
171 int retval = 1; |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
172 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
173 #if SUPPORT_PHYSFS |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
174 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
|
175 if (!retval) |
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 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
|
178 PHYSFS_getLastError()); |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
179 } /* if */ |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
180 #endif |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
181 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
182 return(retval); |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
183 } /* init_archive */ |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
184 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
185 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
186 #if SUPPORT_PHYSFS |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
187 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
|
188 { |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
189 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
|
190 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
191 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
|
192 char *archive; |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
193 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
194 strcpy(path, filename); |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
195 archive = strchr(path, '@'); |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
196 if (archive != NULL) |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
197 { |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
198 *(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
|
199 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
|
200 { |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
201 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
|
202 PHYSFS_getLastError()); |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
203 return(NULL); |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
204 } /* if */ |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
205 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
206 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
|
207 } /* if */ |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
208 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
209 return(retval); |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
210 } /* rwops_from_physfs */ |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
211 #endif |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
212 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
213 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
214 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
|
215 Sound_AudioInfo *desired, |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
216 Uint32 decode_buffersize) |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
217 { |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
218 #if SUPPORT_PHYSFS |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
219 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
|
220 if (rw != NULL) |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
221 { |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
222 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
|
223 char *ptr; |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
224 strcpy(path, fname); |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
225 ptr = strchr(path, '@'); |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
226 *ptr = '\0'; |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
227 ptr = strrchr(path, '.'); |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
228 if (ptr != NULL) |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
229 ptr++; |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
230 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
231 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
|
232 } /* if */ |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
233 #endif |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
234 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
235 return(NULL); |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
236 } /* sample_from_archive */ |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
237 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
238 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
239 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
|
240 { |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
241 #if SUPPORT_PHYSFS |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
242 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
|
243 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
|
244 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
|
245 #endif |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
246 } /* close_archive */ |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
247 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
248 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
249 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
|
250 { |
308
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
251 #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
|
252 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
|
253 #endif |
302
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
254 } /* deinit_archive */ |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
255 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
256 |
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
257 |
58
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
258 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
|
259 |
148
d51546293fd1
Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
260 |
d51546293fd1
Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
261 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
|
262 { |
d51546293fd1
Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
263 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
|
264 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
|
265 |
d51546293fd1
Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
266 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
|
267 |
d51546293fd1
Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
268 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
|
269 { |
d51546293fd1
Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
270 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
|
271 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
|
272 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
|
273 SDL_Quit(); |
302
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
274 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
|
275 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
|
276 } /* if */ |
d51546293fd1
Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
277 |
d51546293fd1
Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
278 else |
d51546293fd1
Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
279 { |
d51546293fd1
Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
280 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
|
281 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
|
282 } /* else */ |
d51546293fd1
Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
283 } /* 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
|
284 |
d51546293fd1
Support for multiple file extensions in the decoders, and a SIGINT catcher.
Ryan C. Gordon <icculus@icculus.org>
parents:
146
diff
changeset
|
285 |
308
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
286 /* 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
|
287 /* !!! 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
|
288 * !!! 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
|
289 * !!! 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
|
290 * !!! 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
|
291 */ |
310 | 292 static volatile Uint8 *decoded_ptr = NULL; |
293 static volatile Uint32 decoded_bytes = 0; | |
294 static volatile int predecode = 0; | |
295 static volatile int looping = 0; | |
296 static volatile int wants_volume_change = 0; | |
297 static volatile float volume = 1.0; | |
298 static volatile Uint32 total_seeks = 0; | |
299 static volatile Uint32 *seek_list = NULL; | |
300 static volatile Uint32 seek_index = 0; | |
301 static volatile Sint32 bytes_before_next_seek = -1; | |
302 | |
303 static Uint32 cvtMsToBytePos(Sound_AudioInfo *info, Uint32 ms) | |
304 { | |
305 /* "frames" == "sample frames" */ | |
306 float frames_per_ms = ((float) info->rate) / 1000.0; | |
307 Uint32 frame_offset = (Uint32) (frames_per_ms * ((float) ms)); | |
308 Uint32 frame_size = (Uint32) ((info->format & 0xFF) / 8) * info->channels; | |
309 return(frame_offset * frame_size); | |
310 } /* cvtMsToBytePos */ | |
311 | |
312 | |
313 static void do_seek(Sound_Sample *sample) | |
314 { | |
315 printf("Seeking to %.2d:%.2d...\n", | |
316 ((seek_list[seek_index] / 1000) / 60), | |
317 ((seek_list[seek_index] / 1000) % 60)); | |
318 | |
319 if (predecode) | |
320 { | |
321 Uint32 pos = cvtMsToBytePos(&sample->desired, seek_list[seek_index]); | |
322 if (pos > sample->buffer_size) | |
323 { | |
324 fprintf(stderr, "Seek past end of predecoded buffer.\n"); | |
325 done_flag = 1; | |
326 } /* if */ | |
327 else | |
328 { | |
329 decoded_ptr = (((Uint8 *) sample->buffer) + pos); | |
330 decoded_bytes = sample->buffer_size - pos; | |
331 } /* else */ | |
332 } /* if */ | |
333 else | |
334 { | |
335 if (!Sound_Seek(sample, seek_list[seek_index])) | |
336 { | |
337 fprintf(stderr, "Sound_Seek() failed: %s\n", Sound_GetError()); | |
338 done_flag = 1; | |
339 } /* if */ | |
340 } /* else */ | |
341 | |
342 seek_index++; | |
343 if (seek_index >= total_seeks) | |
344 bytes_before_next_seek = -1; /* no more seeks. */ | |
345 else | |
346 { | |
347 bytes_before_next_seek = cvtMsToBytePos(&sample->desired, | |
348 seek_list[seek_index]); | |
349 seek_index++; | |
350 } /* else */ | |
351 } /* do_seek */ | |
222
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
352 |
308
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
353 |
222
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
354 /* |
310 | 355 * This updates (decoded_bytes) and (decoded_ptr) with more audio data, |
356 * taking into account potential looping, seeking and predecoding. | |
222
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
357 */ |
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
358 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
|
359 { |
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
360 if (done_flag) /* probably a sigint; stop trying to read. */ |
310 | 361 { |
222
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
362 decoded_bytes = 0; |
310 | 363 return(0); |
364 } /* if */ | |
365 | |
366 if ((bytes_before_next_seek >= 0) && | |
367 (decoded_bytes > bytes_before_next_seek)) | |
368 { | |
369 decoded_bytes = bytes_before_next_seek; | |
370 } /* if */ | |
222
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
371 |
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
372 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
|
373 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
|
374 |
310 | 375 /* Need more audio data. See if we're supposed to seek... */ |
376 if ((bytes_before_next_seek == 0) && (seek_index < total_seeks)) | |
377 { | |
378 do_seek(sample); /* do it, baby! */ | |
379 return(read_more_data(sample)); /* handle loops conditions. */ | |
380 } /* if */ | |
381 | |
382 /* See if there's more to be read... */ | |
383 if ( (bytes_before_next_seek != 0) && | |
384 (!(sample->flags & (SOUND_SAMPLEFLAG_ERROR | SOUND_SAMPLEFLAG_EOF))) ) | |
222
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
385 { |
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
386 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
|
387 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
|
388 { |
0ac181b5adc6
Corrected error reporting to respect Sound_GetError()'s new thread
Ryan C. Gordon <icculus@icculus.org>
parents:
270
diff
changeset
|
389 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
|
390 " 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
|
391 } /* if */ |
0ac181b5adc6
Corrected error reporting to respect Sound_GetError()'s new thread
Ryan C. Gordon <icculus@icculus.org>
parents:
270
diff
changeset
|
392 |
222
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
393 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
|
394 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
|
395 } /* if */ |
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
396 |
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
397 /* 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
|
398 |
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
399 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
|
400 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
|
401 |
308
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
402 looping--; |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
403 |
310 | 404 seek_index = 0; |
405 bytes_before_next_seek = (total_seeks > 0) ? 0 : -1; | |
406 | |
222
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
407 /* 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
|
408 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
|
409 { |
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
410 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
|
411 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
|
412 } /* if */ |
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
413 else |
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
414 { |
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
415 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
|
416 } /* else */ |
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
417 |
310 | 418 return(read_more_data(sample)); |
222
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
419 } /* 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
|
420 |
146
023c3e7f028b
Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents:
144
diff
changeset
|
421 |
270 | 422 static void memcpy_with_volume(Sound_Sample *sample, |
423 Uint8 *dst, Uint8 *src, int len) | |
424 { | |
425 int i; | |
426 Uint16 *u16src = NULL; | |
427 Uint16 *u16dst = NULL; | |
428 Sint16 *s16src = NULL; | |
429 Sint16 *s16dst = NULL; | |
430 | |
431 if (!wants_volume_change) | |
432 { | |
433 memcpy(dst, src, len); | |
434 return; | |
435 } | |
436 | |
437 /* !!! FIXME: This would be more efficient with a lookup table. */ | |
438 switch (sample->desired.format) | |
439 { | |
440 case AUDIO_U8: | |
441 for (i = 0; i < len; i++, src++, dst++) | |
442 *dst = (Uint8) (((float) (*src)) * volume); | |
443 break; | |
444 | |
445 case AUDIO_S8: | |
446 for (i = 0; i < len; i++, src++, dst++) | |
447 *dst = (Sint8) (((float) (*src)) * volume); | |
448 break; | |
449 | |
450 case AUDIO_U16LSB: | |
451 u16src = (Uint16 *) src; | |
452 u16dst = (Uint16 *) dst; | |
453 for (i = 0; i < len; i += sizeof (Uint16), u16src++, u16dst++) | |
454 { | |
455 *u16dst = (Uint16) (((float) (SDL_SwapLE16(*u16src))) * volume); | |
456 *u16dst = SDL_SwapLE16(*u16dst); | |
457 } | |
458 break; | |
459 | |
460 case AUDIO_S16LSB: | |
461 s16src = (Sint16 *) src; | |
462 s16dst = (Sint16 *) dst; | |
463 for (i = 0; i < len; i += sizeof (Sint16), s16src++, s16dst++) | |
464 { | |
465 *s16dst = (Sint16) (((float) (SDL_SwapLE16(*s16src))) * volume); | |
466 *s16dst = SDL_SwapLE16(*s16dst); | |
467 } | |
468 break; | |
469 | |
470 case AUDIO_U16MSB: | |
471 u16src = (Uint16 *) src; | |
472 u16dst = (Uint16 *) dst; | |
473 for (i = 0; i < len; i += sizeof (Uint16), u16src++, u16dst++) | |
474 { | |
475 *u16dst = (Uint16) (((float) (SDL_SwapBE16(*u16src))) * volume); | |
476 *u16dst = SDL_SwapBE16(*u16dst); | |
477 } | |
478 break; | |
479 | |
480 case AUDIO_S16MSB: | |
481 s16src = (Sint16 *) src; | |
482 s16dst = (Sint16 *) dst; | |
483 for (i = 0; i < len; i += sizeof (Sint16), s16src++, s16dst++) | |
484 { | |
485 *s16dst = (Sint16) (((float) (SDL_SwapBE16(*s16src))) * volume); | |
486 *s16dst = SDL_SwapBE16(*s16dst); | |
487 } | |
488 break; | |
489 } | |
490 } | |
491 | |
308
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
492 |
58
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
493 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
|
494 { |
112
3fcb23da06ba
Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents:
82
diff
changeset
|
495 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
|
496 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
|
497 |
146
023c3e7f028b
Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents:
144
diff
changeset
|
498 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
|
499 { |
150
033afe96afbc
Commenting and fixes for the audio callback.
Ryan C. Gordon <icculus@icculus.org>
parents:
148
diff
changeset
|
500 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
|
501 |
222
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
502 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
|
503 { |
222
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
504 /* ...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
|
505 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
|
506 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
|
507 return; |
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
508 } /* if */ |
58
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
509 |
222
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
510 /* 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
|
511 |
146
023c3e7f028b
Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents:
144
diff
changeset
|
512 cpysize = len - bw; |
023c3e7f028b
Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents:
144
diff
changeset
|
513 if (cpysize > decoded_bytes) |
023c3e7f028b
Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents:
144
diff
changeset
|
514 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
|
515 |
146
023c3e7f028b
Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents:
144
diff
changeset
|
516 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
|
517 { |
310 | 518 memcpy_with_volume(sample, stream + bw, |
519 (Uint8 *) decoded_ptr, cpysize); | |
146
023c3e7f028b
Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents:
144
diff
changeset
|
520 bw += cpysize; |
150
033afe96afbc
Commenting and fixes for the audio callback.
Ryan C. Gordon <icculus@icculus.org>
parents:
148
diff
changeset
|
521 decoded_ptr += cpysize; |
033afe96afbc
Commenting and fixes for the audio callback.
Ryan C. Gordon <icculus@icculus.org>
parents:
148
diff
changeset
|
522 decoded_bytes -= cpysize; |
310 | 523 if (bytes_before_next_seek >= 0) |
524 bytes_before_next_seek -= cpysize; | |
146
023c3e7f028b
Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents:
144
diff
changeset
|
525 } /* if */ |
58
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
526 } /* while */ |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
527 } /* audio_callback */ |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
528 |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
529 |
310 | 530 static int count_seek_list(const char *list) |
531 { | |
532 const char *ptr; | |
533 int retval = 0; | |
534 | |
535 for (ptr = list; ptr != NULL; ptr = strchr(ptr + 1, ';')) | |
536 retval++; | |
537 | |
538 return(retval); | |
539 } /* count_seek_list */ | |
540 | |
541 | |
542 static Uint32 parse_time_str(char *str) | |
543 { | |
544 Uint32 minutes = 0; | |
545 Uint32 seconds = 0; | |
546 char *ptr = strchr(str, ':'); | |
547 if (ptr != NULL) | |
548 { | |
549 *ptr = '\0'; | |
550 minutes = atoi(str); | |
551 str = ptr + 1; | |
552 } /* if */ | |
553 | |
554 seconds = atoi(str); | |
555 | |
556 return( ((minutes * 60) + seconds) * 1000 ); | |
557 } /* parse_time_str */ | |
558 | |
559 | |
560 static void parse_seek_list(const char *_list) | |
561 { | |
562 Uint32 i; | |
563 char *list = alloca(strlen(_list) + 1); | |
564 if (list == NULL) | |
565 { | |
566 fprintf(stderr, "alloca() failed. Skipping seek list.\n"); | |
567 return; | |
568 } /* if */ | |
569 | |
570 strcpy(list, _list); | |
571 | |
572 if (seek_list != NULL) | |
573 free((void *) seek_list); | |
574 | |
575 total_seeks = count_seek_list(list); | |
576 seek_list = (Uint32 *) malloc(total_seeks * sizeof (Uint32)); | |
577 if (seek_list == NULL) | |
578 { | |
579 fprintf(stderr, "malloc() failed. Skipping seek list.\n"); | |
580 total_seeks = 0; | |
581 return; | |
582 } /* if */ | |
583 | |
584 for (i = 0; i < total_seeks; i++) | |
585 { | |
586 char *ptr = strchr(list, ';'); | |
587 if (ptr != NULL) | |
588 *ptr = '\0'; | |
589 seek_list[i] = parse_time_str(list); | |
590 list = ptr + 1; | |
591 } /* for */ | |
592 } /* parse_seek_list */ | |
593 | |
594 | |
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
|
595 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
|
596 { |
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 (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
|
598 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
|
599 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
|
600 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
|
601 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
|
602 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
|
603 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
|
604 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
|
605 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
|
606 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
|
607 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
|
608 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
|
609 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
|
610 } /* 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
|
611 |
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 |
58
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
613 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
|
614 { |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
615 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
|
616 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
|
617 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
|
618 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
|
619 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
|
620 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
|
621 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
|
622 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
|
623 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
|
624 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
|
625 |
168
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
626 setbuf(stdout, NULL); |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
627 setbuf(stderr, NULL); |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
628 |
58
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
629 if (argc < 2) |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
630 { |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
631 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
|
632 return(42); |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
633 } /* if */ |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
634 |
308
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
635 /* 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
|
636 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
|
637 { |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
638 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
|
639 continue; |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
640 |
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
|
641 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
|
642 { |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
643 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
|
644 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
|
645 } /* 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
|
646 |
176
69922f6a5c74
Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents:
168
diff
changeset
|
647 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
|
648 { |
69922f6a5c74
Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents:
168
diff
changeset
|
649 output_credits(); |
69922f6a5c74
Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents:
168
diff
changeset
|
650 return(42); |
69922f6a5c74
Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents:
168
diff
changeset
|
651 } /* if */ |
69922f6a5c74
Added GNU disclaimers and a --credits option with our names.
Ryan C. Gordon <icculus@icculus.org>
parents:
168
diff
changeset
|
652 |
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
|
653 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
|
654 { |
58
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
655 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
|
656 return(42); |
58
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
657 } /* 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
|
658 |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
659 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
|
660 { |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
661 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
|
662 { |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
663 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
|
664 " 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
|
665 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
|
666 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
|
667 } /* if */ |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
668 |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
669 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
|
670 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
|
671 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
|
672 } /* 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
|
673 |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
674 /* !!! 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
|
675 #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
|
676 else |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
677 { |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
678 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
|
679 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
|
680 } /* else */ |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
681 #endif |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
682 } /* for */ |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
683 |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
684 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
|
685 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
|
686 |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
687 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
|
688 { |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
689 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
|
690 " 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
|
691 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
|
692 } /* if */ |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
693 |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
694 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
|
695 { |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
696 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
|
697 " 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
|
698 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
|
699 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
|
700 } /* if */ |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
701 |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
702 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
|
703 |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
704 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
|
705 { |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
706 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
|
707 |
310 | 708 /* !!! FIXME: Go read gripe about all the global variables. */ |
308
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
709 /* 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
|
710 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
|
711 { |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
712 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
|
713 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
|
714 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
|
715 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
|
716 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
|
717 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
|
718 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
|
719 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
|
720 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
|
721 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
|
722 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
|
723 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
|
724 volume = 1.0; |
310 | 725 if (seek_list != NULL) |
726 { | |
727 free((void *) seek_list); | |
728 seek_list = NULL; | |
729 } /* if */ | |
730 total_seeks = 0; | |
731 seek_index = 0; | |
732 bytes_before_next_seek = -1; | |
308
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
733 } /* if */ |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
734 |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
735 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
|
736 { |
69cd80e80363
Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents:
112
diff
changeset
|
737 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
|
738 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
|
739 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
|
740 { |
69cd80e80363
Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents:
112
diff
changeset
|
741 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
|
742 return(42); |
310 | 743 } /* if */ |
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
|
744 } /* 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
|
745 |
69cd80e80363
Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents:
112
diff
changeset
|
746 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
|
747 { |
69cd80e80363
Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents:
112
diff
changeset
|
748 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
|
749 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
|
750 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
|
751 { |
69cd80e80363
Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents:
112
diff
changeset
|
752 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
|
753 "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
|
754 return(42); |
310 | 755 } /* if */ |
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
|
756 } /* 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
|
757 |
69cd80e80363
Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents:
112
diff
changeset
|
758 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
|
759 { |
69cd80e80363
Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents:
112
diff
changeset
|
760 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
|
761 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
|
762 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
|
763 { |
69cd80e80363
Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents:
112
diff
changeset
|
764 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
|
765 "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
|
766 "(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
|
767 return(42); |
310 | 768 } /* if */ |
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
|
769 } /* else if */ |
58
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
770 |
187
bfe5031726e8
printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
771 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
|
772 { |
bfe5031726e8
printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
773 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
|
774 } /* else if */ |
bfe5031726e8
printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
775 |
bfe5031726e8
printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
776 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
|
777 { |
bfe5031726e8
printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
778 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
|
779 } /* else if */ |
bfe5031726e8
printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
780 |
270 | 781 else if (strcmp(argv[i], "--volume") == 0 && argc > i + 1) |
782 { | |
783 volume = atof(argv[++i]); | |
784 if (volume != 1.0) | |
785 wants_volume_change = 1; | |
786 } /* else if */ | |
787 | |
168
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
788 else if (strcmp(argv[i], "--predecode") == 0) |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
789 { |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
790 predecode = 1; |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
791 } /* else if */ |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
792 |
222
d6b24586822a
Support for looping sounds via a new --loop command line. Rewritten (again!)
Ryan C. Gordon <icculus@icculus.org>
parents:
214
diff
changeset
|
793 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
|
794 { |
308
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
795 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
|
796 } /* 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
|
797 |
310 | 798 else if (strcmp(argv[i], "--seek") == 0) |
799 { | |
800 parse_seek_list(argv[++i]); | |
801 } /* else if */ | |
802 | |
280
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
803 else if (strcmp(argv[i], "--stdin") == 0) |
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
804 { |
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
805 SDL_RWops *rw = SDL_RWFromFP(stdin, 1); |
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
806 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
|
807 |
280
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
808 /* |
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
809 * 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
|
810 * 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
|
811 */ |
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
812 sample = Sound_NewSample(rw, argv[++i], |
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
813 use_specific_audiofmt ? &sound_desired : NULL, |
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
814 decode_buffersize); |
283
6c059c4d2cea
Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents:
280
diff
changeset
|
815 } /* if */ |
280
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
816 |
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
817 else if (strncmp(argv[i], "--", 2) == 0) |
310 | 818 { |
819 /* ignore it. */ | |
820 } /* else if */ | |
280
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
821 |
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
822 else |
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
823 { |
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
824 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
|
825 sample = sample_from_archive(filename, |
283
6c059c4d2cea
Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents:
280
diff
changeset
|
826 use_specific_audiofmt ? &sound_desired : NULL, |
6c059c4d2cea
Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents:
280
diff
changeset
|
827 decode_buffersize); |
6c059c4d2cea
Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents:
280
diff
changeset
|
828 |
6c059c4d2cea
Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents:
280
diff
changeset
|
829 if (sample == NULL) |
6c059c4d2cea
Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents:
280
diff
changeset
|
830 { |
302
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
831 sample = Sound_NewSampleFromFile(filename, |
283
6c059c4d2cea
Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents:
280
diff
changeset
|
832 use_specific_audiofmt ? &sound_desired : NULL, |
6c059c4d2cea
Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents:
280
diff
changeset
|
833 decode_buffersize); |
6c059c4d2cea
Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents:
280
diff
changeset
|
834 } /* if */ |
6c059c4d2cea
Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents:
280
diff
changeset
|
835 } /* 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
|
836 |
308
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
837 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
|
838 continue; |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
839 |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
840 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
|
841 |
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
842 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
|
843 { |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
844 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
|
845 " 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
|
846 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
|
847 continue; |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
848 } /* if */ |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
849 |
310 | 850 if (total_seeks > 0) |
851 { | |
852 if ((!predecode) && (!(sample->flags & SOUND_SAMPLEFLAG_CANSEEK))) | |
853 { | |
854 fprintf(stderr, "Want seeks, but sample cannot handle it!\n"); | |
855 Sound_FreeSample(sample); | |
856 close_archive(filename); | |
857 continue; | |
858 } /* if */ | |
859 | |
860 bytes_before_next_seek = 0; | |
861 } /* if */ | |
862 | |
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
|
863 /* |
69cd80e80363
Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents:
112
diff
changeset
|
864 * 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
|
865 * 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
|
866 */ |
69cd80e80363
Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents:
112
diff
changeset
|
867 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
|
868 { |
308
6a80b2f9c47c
Command line updates, added Darrell to the credits, and cleaned up other
Ryan C. Gordon <icculus@icculus.org>
parents:
302
diff
changeset
|
869 /* 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
|
870 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
|
871 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
|
872 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
|
873 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
|
874 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
|
875 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
|
876 |
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
|
877 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
|
878 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
|
879 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
|
880 } /* 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
|
881 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
|
882 { |
69cd80e80363
Added Torbj�rn Andersson's command lines, and cleaned up the usage output.
Ryan C. Gordon <icculus@icculus.org>
parents:
112
diff
changeset
|
883 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
|
884 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
|
885 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
|
886 } /* 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
|
887 |
187
bfe5031726e8
printf() fix (extra comma was in there), and --decodebuf/--audiobuf
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
888 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
|
889 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
|
890 sdl_desired.userdata = sample; |
3fcb23da06ba
Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents:
82
diff
changeset
|
891 |
3fcb23da06ba
Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents:
82
diff
changeset
|
892 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
|
893 { |
3fcb23da06ba
Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents:
82
diff
changeset
|
894 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
|
895 " 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
|
896 Sound_Quit(); |
3fcb23da06ba
Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents:
82
diff
changeset
|
897 SDL_Quit(); |
3fcb23da06ba
Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents:
82
diff
changeset
|
898 return(42); |
3fcb23da06ba
Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents:
82
diff
changeset
|
899 } /* if */ |
3fcb23da06ba
Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents:
82
diff
changeset
|
900 |
280
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
901 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
|
902 |
168
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
903 if (predecode) |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
904 { |
280
06fbb106a554
Can now read from stdin.
Ryan C. Gordon <icculus@icculus.org>
parents:
272
diff
changeset
|
905 printf(" predecoding..."); |
168
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
906 decoded_bytes = Sound_DecodeAll(sample); |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
907 decoded_ptr = sample->buffer; |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
908 if (sample->flags & SOUND_SAMPLEFLAG_ERROR) |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
909 { |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
910 fprintf(stderr, |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
911 "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
|
912 " reason: [%s].\n" |
168
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
913 " (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
|
914 filename, Sound_GetError(), decoded_bytes); |
168
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
915 } /* if */ |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
916 else |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
917 { |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
918 printf("done.\n"); |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
919 } /* else */ |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
920 } /* if */ |
87b00f023710
Added --predecode functionality.
Ryan C. Gordon <icculus@icculus.org>
parents:
150
diff
changeset
|
921 |
58
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
922 SDL_PauseAudio(0); |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
923 while (!done_flag) |
146
023c3e7f028b
Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents:
144
diff
changeset
|
924 { |
58
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
925 SDL_Delay(10); |
146
023c3e7f028b
Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents:
144
diff
changeset
|
926 } /* while */ |
58
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
927 SDL_PauseAudio(1); |
146
023c3e7f028b
Cleaned up the overflow buffer hack.
Ryan C. Gordon <icculus@icculus.org>
parents:
144
diff
changeset
|
928 |
236 | 929 /* |
930 * Sleep two buffers' worth of audio before closing, in order | |
931 * to allow the playback to finish. This isn't always enough; | |
932 * perhaps SDL needs a way to explicitly wait for device drain? | |
933 */ | |
934 delay = 2 * 1000 * sdl_desired.samples / sdl_desired.freq; | |
935 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
|
936 |
112
3fcb23da06ba
Made more robust; fixes most sample rate, etc incompatibilities.
Ryan C. Gordon <icculus@icculus.org>
parents:
82
diff
changeset
|
937 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
|
938 Sound_FreeSample(sample); |
283
6c059c4d2cea
Added PhysicsFS support.
Ryan C. Gordon <icculus@icculus.org>
parents:
280
diff
changeset
|
939 |
302
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
940 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
|
941 } /* for */ |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
942 |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
943 Sound_Quit(); |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
944 SDL_Quit(); |
302
414cfef0978e
Cleaned up archive support. Fixes segfault when playing non-archived
Ryan C. Gordon <icculus@icculus.org>
parents:
288
diff
changeset
|
945 deinit_archive(); |
58
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
946 return(0); |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
947 } /* main */ |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
948 |
4a51162099e0
Renamed from test/test_sdlsound.c ... lots of other updates, too.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
949 /* 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
|
950 |