annotate SDL_sound.h @ 355:5dbf2f9cde00

Added docs stuff.
author Ryan C. Gordon <icculus@icculus.org>
date Fri, 07 Jun 2002 13:26:13 +0000
parents 2740fad98dfe
children b3ac77d08e79
rev   line source
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
1 /** \file SDL_sound.h */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
2
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
3 /*
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
4 * SDL_sound -- An abstract sound format decoding API.
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
5 * Copyright (C) 2001 Ryan C. Gordon.
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
6 *
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
7 * This library is free software; you can redistribute it and/or
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
11 *
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
12 * This library is distributed in the hope that it will be useful,
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
15 * Lesser General Public License for more details.
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
16 *
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
18 * License along with this library; if not, write to the Free Software
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
20 */
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
21
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
22 /**
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
23 * \mainpage SDL_sound
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
24 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
25 * The latest version of SDL_sound can be found at:
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
26 * http://icculus.org/SDL_sound/
184
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
27 *
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
28 * The basic gist of SDL_sound is that you use an SDL_RWops to get sound data
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
29 * into this library, and SDL_sound will take that data, in one of several
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
30 * popular formats, and decode it into raw waveform data in the format of
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
31 * your choice. This gives you a nice abstraction for getting sound into your
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
32 * game or application; just feed it to SDL_sound, and it will handle
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
33 * decoding and converting, so you can just pass it to your SDL audio
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
34 * callback (or whatever). Since it gets data from an SDL_RWops, you can get
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
35 * the initial sound data from any number of sources: file, memory buffer,
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
36 * network connection, etc.
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
37 *
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
38 * As the name implies, this library depends on SDL: Simple Directmedia Layer,
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
39 * which is a powerful, free, and cross-platform multimedia library. It can
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
40 * be found at http://www.libsdl.org/
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
41 *
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
42 * Support is in place or planned for the following sound formats:
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
43 * - .WAV (Microsoft WAVfile RIFF data, internal.)
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
44 * - .VOC (Creative Labs' Voice format, internal.)
305
c345a40a8a99 VERY preliminary work on Sound_Seek() API.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
45 * - .MP3 (MPEG-1 Layer 3 support, via the SMPEG and mpglib libraries.)
252
c54eae85f5f1 Upped version to 0.1.5.
Ryan C. Gordon <icculus@icculus.org>
parents: 223
diff changeset
46 * - .MID (MIDI music converted to Waveform data, internal.)
c54eae85f5f1 Upped version to 0.1.5.
Ryan C. Gordon <icculus@icculus.org>
parents: 223
diff changeset
47 * - .MOD (MOD files, via MikMod and ModPlug.)
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
48 * - .OGG (Ogg files, via Ogg Vorbis libraries.)
252
c54eae85f5f1 Upped version to 0.1.5.
Ryan C. Gordon <icculus@icculus.org>
parents: 223
diff changeset
49 * - .SHN (Shorten files, internal.)
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
50 * - .RAW (Raw sound data in any format, internal.)
252
c54eae85f5f1 Upped version to 0.1.5.
Ryan C. Gordon <icculus@icculus.org>
parents: 223
diff changeset
51 * - .AU (Sun's Audio format, internal.)
c54eae85f5f1 Upped version to 0.1.5.
Ryan C. Gordon <icculus@icculus.org>
parents: 223
diff changeset
52 * - .AIFF (Audio Interchange format, internal.)
c54eae85f5f1 Upped version to 0.1.5.
Ryan C. Gordon <icculus@icculus.org>
parents: 223
diff changeset
53 * - .FLAC (Lossless audio compression, via libFLAC.)
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
54 *
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
55 * (...and more to come...)
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
56 *
184
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
57 * Please see the file COPYING in the source's root directory.
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
58 *
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
59 * \author Ryan C. Gordon (icculus@clutteredmind.org)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
60 * \author many others, please see CREDITS in the source's root directory.
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
61 */
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
62
1
508aac690b19 Whoops...changed some overlooked "voice" to "sound".
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
63 #ifndef _INCLUDE_SDL_SOUND_H_
508aac690b19 Whoops...changed some overlooked "voice" to "sound".
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
64 #define _INCLUDE_SDL_SOUND_H_
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
65
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
66 #include "SDL.h"
19
734e5d75acec Now includes SDL_endian.h ...
Ryan C. Gordon <icculus@icculus.org>
parents: 15
diff changeset
67 #include "SDL_endian.h"
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
68
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
69 #ifdef __cplusplus
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
70 extern "C" {
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
71 #endif
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
72
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
73 /* !!! FIXME: Use SDLCALL instead. */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
74 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
130
ac49f81e42d6 Win32 fix, upped version to 0.1.3.
Ryan C. Gordon <icculus@icculus.org>
parents: 44
diff changeset
75 #ifdef SDL_SOUND_DLL_EXPORTS
ac49f81e42d6 Win32 fix, upped version to 0.1.3.
Ryan C. Gordon <icculus@icculus.org>
parents: 44
diff changeset
76 # undef DECLSPEC
ac49f81e42d6 Win32 fix, upped version to 0.1.3.
Ryan C. Gordon <icculus@icculus.org>
parents: 44
diff changeset
77 # define DECLSPEC __declspec(dllexport)
ac49f81e42d6 Win32 fix, upped version to 0.1.3.
Ryan C. Gordon <icculus@icculus.org>
parents: 44
diff changeset
78 #endif
ac49f81e42d6 Win32 fix, upped version to 0.1.3.
Ryan C. Gordon <icculus@icculus.org>
parents: 44
diff changeset
79
29
0e27c909c952 Upped version to 0.1.1
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
80 #define SOUND_VER_MAJOR 0
0e27c909c952 Upped version to 0.1.1
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
81 #define SOUND_VER_MINOR 1
252
c54eae85f5f1 Upped version to 0.1.5.
Ryan C. Gordon <icculus@icculus.org>
parents: 223
diff changeset
82 #define SOUND_VER_PATCH 5
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
83 #endif
29
0e27c909c952 Upped version to 0.1.1
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
84
0e27c909c952 Upped version to 0.1.1
Ryan C. Gordon <icculus@icculus.org>
parents: 19
diff changeset
85
184
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
86 /**
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
87 * \enum Sound_SampleFlags
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
88 * \brief Flags that are used in a Sound_Sample to show various states.
184
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
89 *
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
90 * To use:
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
91 * \code
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
92 * if (sample->flags & SOUND_SAMPLEFLAG_ERROR) { dosomething(); }
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
93 * \endcode
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
94 */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
95 typedef enum
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
96 {
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
97 SOUND_SAMPLEFLAG_NONE = 0, /**< No special attributes. */
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
98
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
99 /* these are set at sample creation time... */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
100 SOUND_SAMPLEFLAG_CANSEEK = 1, /**< sample can seek to arbitrary points. */
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
101
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
102 /* these are set during decoding... */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
103 SOUND_SAMPLEFLAG_EOF = 1 << 29, /**< end of input stream. */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
104 SOUND_SAMPLEFLAG_ERROR = 1 << 30, /**< unrecoverable error. */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
105 SOUND_SAMPLEFLAG_EAGAIN = 1 << 31 /**< function would block, or temp error. */
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
106 } Sound_SampleFlags;
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
107
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
108
184
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
109 /**
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
110 * \struct Sound_AudioInfo
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
111 * \brief Information about an existing sample's format.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
112 *
184
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
113 * These are the basics of a decoded sample's data structure: data format
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
114 * (see AUDIO_U8 and friends in SDL_audio.h), number of channels, and sample
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
115 * rate. If you need more explanation than that, you should stop developing
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
116 * sound code right now.
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
117 */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
118 typedef struct
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
119 {
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
120 Uint16 format; /**< Equivalent of SDL_AudioSpec.format. */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
121 Uint8 channels; /**< Number of sound channels. 1 == mono, 2 == stereo. */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
122 Uint32 rate; /**< Sample rate; frequency of sample points per second. */
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
123 } Sound_AudioInfo;
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
124
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
125
184
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
126 /**
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
127 * \struct Sound_DecoderInfo
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
128 * \brief Information about available soudn decoders.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
129 *
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
130 * Each decoder sets up one of these structs, which can be retrieved via
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
131 * the Sound_AvailableDecoders() function. EVERY FIELD IN THIS IS READ-ONLY.
184
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
132 *
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
133 * The extensions field is a NULL-terminated list of ASCIZ strings. You
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
134 * should read it like this:
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
135 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
136 * \code
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
137 * const char **ext;
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
138 * for (ext = info->extensions; *ext != NULL; ext++) {
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
139 * printf(" File extension \"%s\"\n", *ext);
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
140 * }
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
141 * \endcode
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
142 *
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
143 */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
144 typedef struct
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
145 {
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
146 const char **extensions; /**< File extensions, list ends with NULL. */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
147 const char *description; /**< Human readable description of decoder. */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
148 const char *author; /**< "Name Of Author \<email@emailhost.dom\>" */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
149 const char *url; /**< URL specific to this decoder. */
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
150 } Sound_DecoderInfo;
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
151
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
152
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
153
184
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
154 /**
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
155 * \struct Sound_Sample
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
156 * \brief Represents sound data in the process of being decoded.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
157 *
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
158 * The Sound_Sample structure is the heart of SDL_sound. This holds
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
159 * information about a source of sound data as it is being decoded.
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
160 * EVERY FIELD IN THIS IS READ-ONLY. Please use the API functions to
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
161 * change them.
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
162 */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
163 typedef struct
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
164 {
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
165 void *opaque; /**< Internal use only. Don't touch. */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
166 const Sound_DecoderInfo *decoder; /**< Decoder used for this sample. */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
167 Sound_AudioInfo desired; /**< Desired audio format for conversion. */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
168 Sound_AudioInfo actual; /**< Actual audio format of sample. */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
169 void *buffer; /**< Decoded sound data lands in here. */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
170 Uint32 buffer_size; /**< Current size of (buffer), in bytes (Uint8). */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
171 Sound_SampleFlags flags; /**< Flags relating to this sample. */
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
172 } Sound_Sample;
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
173
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
174
184
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
175 /**
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
176 * \struct Sound_Version
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
177 * \brief Information the version of SDL_sound in use.
184
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
178 *
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
179 * Represents the library's version as three levels: major revision
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
180 * (increments with massive changes, additions, and enhancements),
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
181 * minor revision (increments with backwards-compatible changes to the
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
182 * major revision), and patchlevel (increments with fixes to the minor
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
183 * revision).
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
184 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
185 * \sa SOUND_VERSION
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
186 * \sa Sound_GetLinkedVersion
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
187 */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
188 typedef struct
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
189 {
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
190 int major; /**< major revision */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
191 int minor; /**< minor revision */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
192 int patch; /**< patchlevel */
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
193 } Sound_Version;
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
194
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
195
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
196 /* functions and macros... */
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
197
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
198 /**
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
199 * \def SOUND_VERSION(x)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
200 * \brief Macro to determine SDL_sound version program was compiled against.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
201 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
202 * This macro fills in a Sound_Version structure with the version of the
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
203 * library you compiled against. This is determined by what header the
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
204 * compiler uses. Note that if you dynamically linked the library, you might
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
205 * have a slightly newer or older version at runtime. That version can be
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
206 * determined with Sound_GetLinkedVersion(), which, unlike SOUND_VERSION,
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
207 * is not a macro.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
208 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
209 * \param x A pointer to a Sound_Version struct to initialize.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
210 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
211 * \sa Sound_Version
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
212 * \sa Sound_GetLinkedVersion
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
213 */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
214 #define SOUND_VERSION(x) \
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
215 { \
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
216 (x)->major = SOUND_VER_MAJOR; \
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
217 (x)->minor = SOUND_VER_MINOR; \
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
218 (x)->patch = SOUND_VER_PATCH; \
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
219 }
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
220
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
221
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
222 /**
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
223 * \fn void Sound_GetLinkedVersion(Sound_Version *ver)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
224 * \brief Get the version of SDL_sound that is linked against your program.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
225 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
226 * If you are using a shared library (DLL) version of SDL_sound, then it is
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
227 * possible that it will be different than the version you compiled against.
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
228 *
1
508aac690b19 Whoops...changed some overlooked "voice" to "sound".
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
229 * This is a real function; the macro SOUND_VERSION tells you what version
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
230 * of SDL_sound you compiled against:
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
231 *
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
232 * \code
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
233 * Sound_Version compiled;
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
234 * Sound_Version linked;
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
235 *
1
508aac690b19 Whoops...changed some overlooked "voice" to "sound".
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
236 * SOUND_VERSION(&compiled);
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
237 * Sound_GetLinkedVersion(&linked);
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
238 * printf("We compiled against SDL_sound version %d.%d.%d ...\n",
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
239 * compiled.major, compiled.minor, compiled.patch);
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
240 * printf("But we linked against SDL_sound version %d.%d.%d.\n",
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
241 * linked.major, linked.minor, linked.patch);
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
242 * \endcode
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
243 *
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
244 * This function may be called safely at any time, even before Sound_Init().
184
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
245 *
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
246 * \param ver Sound_Version structure to fill with shared library's version.
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
247 */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
248 DECLSPEC void Sound_GetLinkedVersion(Sound_Version *ver);
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
249
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
250
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
251 /**
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
252 * \fn Sound_Init(void)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
253 * \brief Initialize SDL_sound.
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
254 *
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
255 * This must be called before any other SDL_sound function (except perhaps
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
256 * Sound_GetLinkedVersion()). You should call SDL_Init() before calling this.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
257 * Sound_Init() will attempt to call SDL_Init(SDL_INIT_AUDIO), just in case.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
258 * This is a safe behaviour, but it may not configure SDL to your liking by
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
259 * itself.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
260 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
261 * \return nonzero on success, zero on error. Specifics of the
186
70561bf8d5fd Updated and clarified some documentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
262 * error can be gleaned from Sound_GetError().
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
263 */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
264 DECLSPEC int Sound_Init(void);
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
265
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
266
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
267 /**
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
268 * \fn Sound_Quit(void)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
269 * \brief Shutdown SDL_sound.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
270 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
271 * This closes any SDL_RWops that were being used as sound sources, and frees
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
272 * any resources in use by SDL_sound.
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
273 *
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
274 * All Sound_Sample pointers you had prior to this call are INVALIDATED.
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
275 *
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
276 * Once successfully deinitialized, Sound_Init() can be called again to
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
277 * restart the subsystem. All default API states are restored at this
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
278 * point.
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
279 *
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
280 * You should call this BEFORE SDL_Quit(). This will NOT call SDL_Quit()
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
281 * for you!
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
282 *
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
283 * \return nonzero on success, zero on error. Specifics of the error
186
70561bf8d5fd Updated and clarified some documentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
284 * can be gleaned from Sound_GetError(). If failure, state of
184
47cc2de2ae36 Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
285 * SDL_sound is undefined, and probably badly screwed up.
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
286 */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
287 DECLSPEC int Sound_Quit(void);
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
288
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
289
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
290 /**
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
291 * \fn const Sound_DecoderInfo **Sound_AvailableDecoders(void)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
292 * \brief Get a list of sound formats supported by this version of SDL_sound.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
293 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
294 * This is for informational purposes only. Note that the extension listed is
11
Ryan C. Gordon <icculus@icculus.org>
parents: 3
diff changeset
295 * merely convention: if we list "MP3", you can open an MPEG-1 Layer 3 audio
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
296 * file with an extension of "XYZ", if you like. The file extensions are
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
297 * informational, and only required as a hint to choosing the correct
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
298 * decoder, since the sound data may not be coming from a file at all, thanks
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
299 * to the abstraction that an SDL_RWops provides.
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
300 *
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
301 * The returned value is an array of pointers to Sound_DecoderInfo structures,
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
302 * with a NULL entry to signify the end of the list:
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
303 *
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
304 * \code
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
305 * Sound_DecoderInfo **i;
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
306 *
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
307 * for (i = Sound_AvailableDecoders(); *i != NULL; i++)
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
308 * {
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
309 * printf("Supported sound format: [%s], which is [%s].\n",
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
310 * i->extension, i->description);
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
311 * // ...and other fields...
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
312 * }
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
313 * \endcode
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
314 *
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
315 * The return values are pointers to static internal memory, and should
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
316 * be considered READ ONLY, and never freed.
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
317 *
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
318 * \return READ ONLY Null-terminated array of READ ONLY structures.
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
319 */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
320 DECLSPEC const Sound_DecoderInfo **Sound_AvailableDecoders(void);
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
321
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
322
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
323 /**
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
324 * \fn const char *Sound_GetError(void)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
325 * \brief Get the last SDL_sound error message as a null-terminated string.
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
326 *
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
327 * This will be NULL if there's been no error since the last call to this
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
328 * function. The pointer returned by this call points to an internal buffer,
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
329 * and should not be deallocated. Each thread has a unique error state
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
330 * associated with it, but each time a new error message is set, it will
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
331 * overwrite the previous one associated with that thread. It is safe to call
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
332 * this function at anytime, even before Sound_Init().
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
333 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
334 * \return READ ONLY string of last error message.
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
335 */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
336 DECLSPEC const char *Sound_GetError(void);
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
337
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
338
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
339 /**
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
340 * \fn void Sound_ClearError(void)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
341 * \brief Clear the current error message.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
342 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
343 * The next call to Sound_GetError() after Sound_ClearError() will return NULL.
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
344 */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
345 DECLSPEC void Sound_ClearError(void);
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
346
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
347
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
348 /**
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
349 * \fn Sound_Sample *Sound_NewSample(SDL_RWops *rw, const char *ext, Sound_AudioInfo *desired, Uint32 bufferSize)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
350 * \brief Start decoding a new sound sample.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
351 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
352 * The data is read via an SDL_RWops structure (see SDL_rwops.h in the SDL
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
353 * include directory), so it may be coming from memory, disk, network stream,
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
354 * etc. The (ext) parameter is merely a hint to determining the correct
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
355 * decoder; if you specify, for example, "mp3" for an extension, and one of
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
356 * the decoders lists that as a handled extension, then that decoder is given
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
357 * first shot at trying to claim the data for decoding. If none of the
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
358 * extensions match (or the extension is NULL), then every decoder examines
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
359 * the data to determine if it can handle it, until one accepts it. In such a
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
360 * case your SDL_RWops will need to be capable of rewinding to the start of
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
361 * the stream.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
362 *
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
363 * If no decoders can handle the data, a NULL value is returned, and a human
186
70561bf8d5fd Updated and clarified some documentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
364 * readable error message can be fetched from Sound_GetError().
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
365 *
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
366 * Optionally, a desired audio format can be specified. If the incoming data
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
367 * is in a different format, SDL_sound will convert it to the desired format
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
368 * on the fly. Note that this can be an expensive operation, so it may be
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
369 * wise to convert data before you need to play it back, if possible, or
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
370 * make sure your data is initially in the format that you need it in.
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
371 * If you don't want to convert the data, you can specify NULL for a desired
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
372 * format. The incoming format of the data, preconversion, can be found
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
373 * in the Sound_Sample structure.
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
374 *
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
375 * Note that the raw sound data "decoder" needs you to specify both the
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
376 * extension "RAW" and a "desired" format, or it will refuse to handle
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
377 * the data. This is to prevent it from catching all formats unsupported
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
378 * by the other decoders.
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
379 *
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
380 * Finally, specify an initial buffer size; this is the number of bytes that
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
381 * will be allocated to store each read from the sound buffer. The more you
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
382 * can safely allocate, the more decoding can be done in one block, but the
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
383 * more resources you have to use up, and the longer each decoding call will
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
384 * take. Note that different data formats require more or less space to
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
385 * store. This buffer can be resized via Sound_SetBufferSize() ...
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
386 *
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
387 * The buffer size specified must be a multiple of the size of a single
186
70561bf8d5fd Updated and clarified some documentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
388 * sample point. So, if you want 16-bit, stereo samples, then your sample
70561bf8d5fd Updated and clarified some documentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
389 * point size is (2 channels * 16 bits), or 32 bits per sample, which is four
70561bf8d5fd Updated and clarified some documentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
390 * bytes. In such a case, you could specify 128 or 132 bytes for a buffer,
70561bf8d5fd Updated and clarified some documentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
391 * but not 129, 130, or 131 (although in reality, you'll want to specify a
70561bf8d5fd Updated and clarified some documentation.
Ryan C. Gordon <icculus@icculus.org>
parents: 184
diff changeset
392 * MUCH larger buffer).
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
393 *
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
394 * When you are done with this Sound_Sample pointer, you can dispose of it
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
395 * via Sound_FreeSample().
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
396 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
397 * You do not have to keep a reference to (rw) around. If this function
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
398 * suceeds, it stores (rw) internally (and disposes of it during the call
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
399 * to Sound_FreeSample()). If this function fails, it will dispose of the
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
400 * SDL_RWops for you.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
401 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
402 * \param rw SDL_RWops with sound data.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
403 * \param ext File extension normally associated with a data format.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
404 * Can usually be NULL.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
405 * \param desired Format to convert sound data into. Can usually be NULL,
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
406 * if you don't need conversion.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
407 * \param bufferSize Size, in bytes, to allocate for the decoding buffer.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
408 * \return Sound_Sample pointer, which is used as a handle to several other
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
409 * SDL_sound APIs. NULL on error. If error, use
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
410 * Sound_GetError() to see what went wrong.
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
411 */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
412 DECLSPEC Sound_Sample *Sound_NewSample(SDL_RWops *rw, const char *ext,
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
413 Sound_AudioInfo *desired,
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
414 Uint32 bufferSize);
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
415
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
416 /**
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
417 * \fn Sound_Sample *Sound_NewSampleFromFile(const char *filename, Sound_AudioInfo *desired, Uint32 bufferSize)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
418 * \brief Start decoding a new sound sample from a file on disk.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
419 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
420 * This is identical to Sound_NewSample(), but it creates an SDL_RWops for you
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
421 * from the file located in (filename). Note that (filename) is specified in
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
422 * platform-dependent notation. ("C:\\music\\mysong.mp3" on windows, and
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
423 * "/home/icculus/music/mysong.mp3" or whatever on Unix, etc.)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
424 * Sound_NewSample()'s "ext" parameter is gleaned from the contents of
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
425 * (filename).
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
426 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
427 * \param filename file containing sound data.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
428 * \param desired Format to convert sound data into. Can usually be NULL,
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
429 * if you don't need conversion.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
430 * \param bufferSize size, in bytes, of initial read buffer.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
431 * \return Sound_Sample pointer, which is used as a handle to several other
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
432 * SDL_sound APIs. NULL on error. If error, use
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
433 * Sound_GetError() to see what went wrong.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
434 */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
435 DECLSPEC Sound_Sample *Sound_NewSampleFromFile(const char *filename,
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
436 Sound_AudioInfo *desired,
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
437 Uint32 bufferSize);
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
438
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
439 /**
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
440 * \fn void Sound_FreeSample(Sound_Sample *sample)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
441 * \brief Dispose of a Dispose of a Sound_Sample.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
442 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
443 * This will also close/dispose of the SDL_RWops that was used at creation
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
444 * time, so there's no need to keep a reference to that around.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
445 * The Sound_Sample pointer is invalid after this call, and will almost
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
446 * certainly result in a crash if you attempt to keep using it.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
447 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
448 * \param sample The Sound_Sample to delete.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
449 */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
450 DECLSPEC void Sound_FreeSample(Sound_Sample *sample);
3
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
451
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
452
fd6cd0e04e6f First stab at implementation complete.
Ryan C. Gordon <icculus@icculus.org>
parents: 1
diff changeset
453 /**
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
454 * \fn int Sound_SetBufferSize(Sound_Sample *sample, Uint32 new_size)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
455 * \brief Change the current buffer size for a sample.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
456 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
457 * If the buffer size could be changed, then the sample->buffer and
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
458 * sample->buffer_size fields will reflect that. If they could not be
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
459 * changed, then your original sample state is preserved. If the buffer is
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
460 * shrinking, the data at the end of buffer is truncated. If the buffer is
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
461 * growing, the contents of the new space at the end is undefined until you
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
462 * decode more into it or initialize it yourself.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
463 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
464 * The buffer size specified must be a multiple of the size of a single
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
465 * sample point. So, if you want 16-bit, stereo samples, then your sample
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
466 * point size is (2 channels * 16 bits), or 32 bits per sample, which is four
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
467 * bytes. In such a case, you could specify 128 or 132 bytes for a buffer,
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
468 * but not 129, 130, or 131 (although in reality, you'll want to specify a
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
469 * MUCH larger buffer).
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
470 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
471 * \param sample The Sound_Sample whose buffer to modify.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
472 * \param new_size The desired size, in bytes, of the new buffer.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
473 * \return non-zero if buffer size changed, zero on failure.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
474 */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
475 DECLSPEC int Sound_SetBufferSize(Sound_Sample *sample, Uint32 new_size);
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
476
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
477
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
478 /**
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
479 * \fn Uint32 Sound_Decode(Sound_Sample *sample)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
480 * \brief Decode more of the sound data in a Sound_Sample.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
481 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
482 * It will decode at most sample->buffer_size bytes into sample->buffer in the
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
483 * desired format, and return the number of decoded bytes.
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
484 * If sample->buffer_size bytes could not be decoded, then please refer to
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
485 * sample->flags to determine if this was an End-of-stream or error condition.
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
486 *
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
487 * \param sample Do more decoding to this Sound_Sample.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
488 * \return number of bytes decoded into sample->buffer. If it is less than
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
489 * sample->buffer_size, then you should check sample->flags to see
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
490 * what the current state of the sample is (EOF, error, read again).
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
491 */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
492 DECLSPEC Uint32 Sound_Decode(Sound_Sample *sample);
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
493
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
494
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
495 /**
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
496 * \fn Uint32 Sound_DecodeAll(Sound_Sample *sample)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
497 * \brief Decode the remainder of the sound data in a Sound_Sample.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
498 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
499 * This will dynamically allocate memory for the ENTIRE remaining sample.
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
500 * sample->buffer_size and sample->buffer will be updated to reflect the
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
501 * new buffer. Please refer to sample->flags to determine if the decoding
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
502 * finished due to an End-of-stream or error condition.
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
503 *
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
504 * Be aware that sound data can take a large amount of memory, and that
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
505 * this function may block for quite awhile while processing. Also note
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
506 * that a streaming source (for example, from a SDL_RWops that is getting
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
507 * fed from an Internet radio feed that doesn't end) may fill all available
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
508 * memory before giving up...be sure to use this on finite sound sources
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
509 * only!
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
510 *
170
e91fb8d5bd62 Updated Sound_DecodeAll()'s comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 149
diff changeset
511 * When decoding the sample in its entirety, the work is done one buffer at a
e91fb8d5bd62 Updated Sound_DecodeAll()'s comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 149
diff changeset
512 * time. That is, sound is decoded in sample->buffer_size blocks, and
e91fb8d5bd62 Updated Sound_DecodeAll()'s comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 149
diff changeset
513 * appended to a continually-growing buffer until the decoding completes.
e91fb8d5bd62 Updated Sound_DecodeAll()'s comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 149
diff changeset
514 * That means that this function will need enough RAM to hold approximately
e91fb8d5bd62 Updated Sound_DecodeAll()'s comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 149
diff changeset
515 * sample->buffer_size bytes plus the complete decoded sample at most. The
e91fb8d5bd62 Updated Sound_DecodeAll()'s comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 149
diff changeset
516 * larger your buffer size, the less overhead this function needs, but beware
e91fb8d5bd62 Updated Sound_DecodeAll()'s comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 149
diff changeset
517 * the possibility of paging to disk. Best to make this user-configurable if
e91fb8d5bd62 Updated Sound_DecodeAll()'s comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 149
diff changeset
518 * the sample isn't specific and small.
e91fb8d5bd62 Updated Sound_DecodeAll()'s comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 149
diff changeset
519 *
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
520 * \param sample Do all decoding for this Sound_Sample.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
521 * \return number of bytes decoded into sample->buffer. You should check
170
e91fb8d5bd62 Updated Sound_DecodeAll()'s comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 149
diff changeset
522 * sample->flags to see what the current state of the sample is
e91fb8d5bd62 Updated Sound_DecodeAll()'s comments.
Ryan C. Gordon <icculus@icculus.org>
parents: 149
diff changeset
523 * (EOF, error, read again).
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
524 */
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
525 DECLSPEC Uint32 Sound_DecodeAll(Sound_Sample *sample);
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
526
223
249186e31431 Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents: 194
diff changeset
527
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
528 /**
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
529 * \fn int Sound_Rewind(Sound_Sample *sample)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
530 * \brief Rewind a sample to the start.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
531 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
532 * Restart a sample at the start of its waveform data, as if newly
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
533 * created with Sound_NewSample(). If successful, the next call to
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
534 * Sound_Decode[All]() will give audio data from the earliest point
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
535 * in the stream.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
536 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
537 * Beware that this function will fail if the SDL_RWops that feeds the
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
538 * decoder can not be rewound via it's seek method, but this can
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
539 * theoretically be avoided by wrapping it in some sort of buffering
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
540 * SDL_RWops.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
541 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
542 * This function should ONLY fail if the RWops is not seekable, or
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
543 * SDL_sound is not initialized. Both can be controlled by the application,
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
544 * and thus, it is up to the developer's paranoia to dictate whether this
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
545 * function's return value need be checked at all.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
546 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
547 * If this function fails, the state of the sample is undefined, but it
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
548 * is still safe to call Sound_FreeSample() to dispose of it.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
549 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
550 * On success, ERROR, EOF, and EAGAIN are cleared from sample->flags. The
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
551 * ERROR flag is set on error.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
552 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
553 * \param sample The Sound_Sample to rewind.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
554 * \return nonzero on success, zero on error. Specifics of the
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
555 * error can be gleaned from Sound_GetError().
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
556 */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
557 DECLSPEC int Sound_Rewind(Sound_Sample *sample);
223
249186e31431 Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents: 194
diff changeset
558
249186e31431 Sound_Rewind() support code.
Ryan C. Gordon <icculus@icculus.org>
parents: 194
diff changeset
559
353
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
560 /**
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
561 * \fn int Sound_Seek(Sound_Sample *sample, Uint32 ms)
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
562 * \brief Seek to a different point in a sample.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
563 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
564 * Reposition a sample's stream. If successful, the next call to
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
565 * Sound_Decode[All]() will give audio data from the offset you
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
566 * specified.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
567 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
568 * The offset is specified in milliseconds from the start of the
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
569 * sample.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
570 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
571 * Beware that this function can fail for several reasons. If the
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
572 * SDL_RWops that feeds the decoder can not seek, this call will almost
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
573 * certainly fail, but this can theoretically be avoided by wrapping it
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
574 * in some sort of buffering SDL_RWops. Some decoders can never seek,
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
575 * others can only seek with certain files. The decoders will set a flag
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
576 * in the sample at creation time to help you determine this.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
577 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
578 * You should check sample->flags & SOUND_SAMPLEFLAG_CANSEEK
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
579 * before attempting. Sound_Seek() reports failure immediately if this
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
580 * flag isn't set. This function can still fail for other reasons if the
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
581 * flag is set.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
582 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
583 * This function can be emulated in the application with Sound_Rewind()
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
584 * and predecoding a specific amount of the sample, but this can be
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
585 * extremely inefficient. Sound_Seek() accelerates the seek on a
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
586 * with decoder-specific code.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
587 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
588 * If this function fails, the sample should continue to function as if
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
589 * this call was never made. If there was an unrecoverable error,
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
590 * sample->flags & SOUND_SAMPLEFLAG_ERROR will be set, which you regular
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
591 * decoding loop can pick up.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
592 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
593 * On success, ERROR, EOF, and EAGAIN are cleared from sample->flags.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
594 *
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
595 * \param sample The Sound_Sample to seek.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
596 * \param ms The new position, in milliseconds from start of sample.
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
597 * \return nonzero on success, zero on error. Specifics of the
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
598 * error can be gleaned from Sound_GetError().
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
599 */
2740fad98dfe Tweaked and enhanced for Doxygen support.
Ryan C. Gordon <icculus@icculus.org>
parents: 305
diff changeset
600 DECLSPEC int Sound_Seek(Sound_Sample *sample, Uint32 ms);
305
c345a40a8a99 VERY preliminary work on Sound_Seek() API.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
601
c345a40a8a99 VERY preliminary work on Sound_Seek() API.
Ryan C. Gordon <icculus@icculus.org>
parents: 252
diff changeset
602
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
603 #ifdef __cplusplus
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
604 }
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
605 #endif
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
606
1
508aac690b19 Whoops...changed some overlooked "voice" to "sound".
Ryan C. Gordon <icculus@icculus.org>
parents: 0
diff changeset
607 #endif /* !defined _INCLUDE_SDL_SOUND_H_ */
0
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
608
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
609 /* end of SDL_sound.h ... */
1078b3528e6f Initial revision
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
610