comparison ALmixer.h @ 22:58f03008ea05

- Added Seek APIs - Added new API for interruption handling like on iOS - Made support for ALC_MAC_OSX_CONVERT_DATA_UPON_LOADING an opt-in compile define because iOS kept reporting it supported this even though it didn't and some people reported that on Mac, this sometimes failed (but I couldn't reproduce). - Made number of sources unsigned - Some minor 64-bit clean ups
author Eric Wing <ewing . public |-at-| gmail . com>
date Fri, 24 Dec 2010 03:23:02 -0800
parents bfe90b4f3d87
children ee96f91ba887
comparison
equal deleted inserted replaced
21:14c22fc3c753 22:58f03008ea05
166 #endif /* DOXYGEN_SHOULD_IGNORE_THIS */ 166 #endif /* DOXYGEN_SHOULD_IGNORE_THIS */
167 167
168 168
169 169
170 /* Needed for OpenAL types since altypes.h was removed in 1.1 */ 170 /* Needed for OpenAL types since altypes.h was removed in 1.1 */
171 #ifdef ANDROID_NDK 171 #include "al.h"
172 #include <AL/al.h>
173 #else
174 #include "al.h"
175 #endif
176 172
177 /* Set up for C function definitions, even when using C++ */ 173 /* Set up for C function definitions, even when using C++ */
178 #ifdef __cplusplus 174 #ifdef __cplusplus
179 extern "C" { 175 extern "C" {
180 #endif 176 #endif
298 #define ALmixer_SetError SDL_SetError 294 #define ALmixer_SetError SDL_SetError
299 #endif 295 #endif
300 296
301 297
302 #ifdef ALMIXER_COMPILE_WITHOUT_SDL 298 #ifdef ALMIXER_COMPILE_WITHOUT_SDL
303 #include "ALmixer_rwops.h" 299 #include "ALmixer_RWops.h"
304 #else 300 #else
305 #include "SDL_rwops.h" 301 #include "SDL_rwops.h"
306 /** 302 /**
307 * A struct that mimicks the SDL_RWops structure. 303 * A struct that mimicks the SDL_RWops structure.
308 * 304 *
342 * @param refresh_rate The refresh rate you want OpenAL to operate at. 338 * @param refresh_rate The refresh rate you want OpenAL to operate at.
343 * Note that OpenAL is not required to respect this value. 339 * Note that OpenAL is not required to respect this value.
344 * Pass in 0 or ALMIXER_DEFAULT_REFRESH to use OpenAL default behaviors. 340 * Pass in 0 or ALMIXER_DEFAULT_REFRESH to use OpenAL default behaviors.
345 * @return Returns AL_FALSE on a failure or AL_TRUE if successfully initialized. 341 * @return Returns AL_FALSE on a failure or AL_TRUE if successfully initialized.
346 */ 342 */
347 extern ALMIXER_DECLSPEC ALboolean ALMIXER_CALL ALmixer_Init(ALuint playback_frequency, ALint num_sources, ALuint refresh_rate); 343 extern ALMIXER_DECLSPEC ALboolean ALMIXER_CALL ALmixer_Init(ALuint playback_frequency, ALuint num_sources, ALuint refresh_rate);
348 344
349 /** 345 /**
350 * InitContext will only initialize the OpenAL context (and not the mixer part). 346 * InitContext will only initialize the OpenAL context (and not the mixer part).
351 * Note that SDL_Sound is also initialized here because load order matters 347 * Note that SDL_Sound is also initialized here because load order matters
352 * because SDL audio will conflict with OpenAL when using SMPEG. This is only 348 * because SDL audio will conflict with OpenAL when using SMPEG. This is only
369 * 365 *
370 * @note This is a backdoor in case you need to initialize the AL context and 366 * @note This is a backdoor in case you need to initialize the AL context and
371 * the mixer system separately. I strongly recommend avoiding these two functions 367 * the mixer system separately. I strongly recommend avoiding these two functions
372 * and use the normal Init() function. 368 * and use the normal Init() function.
373 */ 369 */
374 extern ALMIXER_DECLSPEC ALboolean ALMIXER_CALL ALmixer_InitMixer(ALint num_sources); 370 extern ALMIXER_DECLSPEC ALboolean ALMIXER_CALL ALmixer_InitMixer(ALuint num_sources);
375 371
372 /**
373 * (EXPERIMENTAL) Call to notify ALmixer that your device needs to handle an interruption.
374 * (EXPERIMENTAL) For devices like iOS that need special handling for interruption events like phone calls and alarms,
375 * this function will do the correct platform correct thing to handle the interruption w.r.t. OpenAL.
376 */
377 extern ALMIXER_DECLSPEC void ALMIXER_CALL ALmixer_BeginInterruption(void);
378
379 /**
380 * (EXPERIMENTAL) Call to notify ALmixer that your device needs to resume from an interruption.
381 * (EXPERIMENTAL) For devices like iOS that need special handling for interruption events like phone calls and alarms,
382 * this function will do the correct platform correct thing to resume from the interruption w.r.t. OpenAL.
383 */
384 extern ALMIXER_DECLSPEC void ALMIXER_CALL ALmixer_EndInterruption(void);
385
386
376 /** 387 /**
377 * This shuts down ALmixer. Please remember to free your ALmixer_Data* instances 388 * This shuts down ALmixer. Please remember to free your ALmixer_Data* instances
378 * before calling this method. 389 * before calling this method.
379 */ 390 */
380 extern ALMIXER_DECLSPEC void ALMIXER_CALL ALmixer_Quit(void); 391 extern ALMIXER_DECLSPEC void ALMIXER_CALL ALmixer_Quit(void);
1075 * @returns true on success or false on error. 1086 * @returns true on success or false on error.
1076 */ 1087 */
1077 extern ALMIXER_DECLSPEC ALboolean ALMIXER_CALL ALmixer_SeekData(ALmixer_Data* almixer_data, ALuint msec_pos); 1088 extern ALMIXER_DECLSPEC ALboolean ALMIXER_CALL ALmixer_SeekData(ALmixer_Data* almixer_data, ALuint msec_pos);
1078 1089
1079 /** 1090 /**
1091 * Seeks the sound to the beginning that is playing on a specific channel.
1092 * If decoded all, seek will instantly seek it. Data is not
1093 * affected, so it will start at the "Seek"'ed positiond.
1094 * Streamed data will seek the actual data, but the effect
1095 * may not be noticed until the currently buffered data is played.
1096 * @param which_channel The channel to seek or -1 to seek all channels.
1097 * @return The actual number of channels rewound on success or -1 on error.
1098 */
1099 extern ALMIXER_DECLSPEC ALint ALMIXER_CALL ALmixer_SeekChannel(ALint which_channel, ALuint msec_pos);
1100 /**
1101 * Seeks the sound to the beginning that is playing on a specific source.
1102 * If decoded all, seek will instantly seek it. Data is not
1103 * affected, so it will start at the "Seek"'ed positiond.
1104 * Streamed data will seek the actual data, but the effect
1105 * may not be noticed until the currently buffered data is played.
1106 * @param al_source The source to seek or 0 to seek all sources.
1107 * @return The actual number of sources rewound on success or -1 on error.
1108 */
1109 extern ALMIXER_DECLSPEC ALint ALMIXER_CALL ALmixer_SeekSource(ALuint al_source, ALuint msec_pos);
1110
1111 /**
1080 * Pauses playback on a channel. 1112 * Pauses playback on a channel.
1081 * Pauses playback on a channel. Should have no effect on channels that aren't playing. 1113 * Pauses playback on a channel. Should have no effect on channels that aren't playing.
1082 * @param which_channel The channel to pause or -1 to pause all channels. 1114 * @param which_channel The channel to pause or -1 to pause all channels.
1083 * @return The actual number of channels paused on success or -1 on error. 1115 * @return The actual number of channels paused on success or -1 on error.
1084 */ 1116 */
1438 * @see ALmixer_ReserveChannels 1470 * @see ALmixer_ReserveChannels
1439 */ 1471 */
1440 extern ALMIXER_DECLSPEC ALuint ALMIXER_CALL ALmixer_CountUnreservedFreeChannels(void); 1472 extern ALMIXER_DECLSPEC ALuint ALMIXER_CALL ALmixer_CountUnreservedFreeChannels(void);
1441 1473
1442 /** 1474 /**
1443 * Returns the number of channels that are currently in use (playing/paused), 1475 * Returns the number of channels that are currently in use (playing/paused).
1444 * excluding the channels that have been reserved.
1445 * @return The number of channels that are currently in use. 1476 * @return The number of channels that are currently in use.
1446 * @see ALmixer_ReserveChannels 1477 * @see ALmixer_ReserveChannels
1447 */ 1478 */
1448 extern ALMIXER_DECLSPEC ALuint ALMIXER_CALL ALmixer_CountAllUsedChannels(void); 1479 extern ALMIXER_DECLSPEC ALuint ALMIXER_CALL ALmixer_CountAllUsedChannels(void);
1449 1480