annotate ALmixer.c @ 49:4b0268d86298

Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
author Eric Wing <ewing@anscamobile.com>
date Fri, 30 Sep 2011 17:48:23 -0700
parents 00b770b0d2aa
children db5bc1c80057
rev   line source
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2 /* Here's an OpenAL implementation modeled after
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3 * the SDL_SoundMixer which was built ontop of SDL_Mixer
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4 * and SDL_Sound.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5 * Eric Wing
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7
3
a929285e1db0 Added CMake build system.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 2
diff changeset
8 #include "ALmixer.h"
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
10 #ifdef ALMIXER_COMPILE_WITHOUT_SDL
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
11 #include "ALmixer_RWops.h"
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
12 #include "SoundDecoder.h"
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
13 #else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
14 #include "SDL_sound.h"
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
15 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
16
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
17 #include "al.h" /* OpenAL */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
18 #include "alc.h" /* For creating OpenAL contexts */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
19
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
20 #ifdef __APPLE__
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
21 /* For performance things like ALC_CONVERT_DATA_UPON_LOADING */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
22 /* Note: ALC_CONVERT_DATA_UPON_LOADING used to be in the alc.h header.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
23 * But in the Tiger OpenAL 1.1 release (10.4.7 and Xcode 2.4), the
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
24 * define was moved to a new header file and renamed to
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
25 * ALC_MAC_OSX_CONVERT_DATA_UPON_LOADING.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
26 */
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
27 #include <TargetConditionals.h>
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
28 /*
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
29 #if (TARGET_OS_IPHONE == 1) || (TARGET_IPHONE_SIMULATOR == 1)
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
30 #include <AudioToolbox/AudioToolbox.h>
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
31 #else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
32 #include <OpenAL/MacOSX_OALExtensions.h>
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
33 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
34 */
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
35 #endif
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
36
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
37 /* For malloc, bsearch, qsort */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
38 #include <stdlib.h>
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
39
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
40 /* For memcpy */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
41 #include <string.h>
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
42
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
43 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
44 /* for toupper */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
45 #include <ctype.h>
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
46 /* for strrchr */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
47 #include <string.h>
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
48 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
49
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
50 /* Currently used in the output debug functions */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
51 #include <stdio.h>
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
52
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
53 /* My own CircularQueue implementation needed
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
54 * to work around the Nvidia problem of the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
55 * lack of a buffer query.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
56 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
57 #include "CircularQueue.h"
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
58
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
59 /* SDL_sound keeps a private linked list of sounds which get auto-deleted
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
60 * on Sound_Quit. This might actually create some leaks for me in certain
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
61 * usage patterns. To be safe, I should do the same.
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
62 */
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
63 #include "LinkedList.h"
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
64
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
65 #ifdef ANDROID_NDK
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
66 #undef fprintf
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
67 #include <android/log.h>
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
68 #define fprintf(stderr, ...) __android_log_print(ANDROID_LOG_INFO, "ALmixer", __VA_ARGS__)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
69 #endif
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
70
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
71
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
72 #ifdef ENABLE_ALMIXER_THREADS
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
73 /* Needed for the Mutex locks (and threads if enabled) */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
74 #ifdef ALMIXER_COMPILE_WITHOUT_SDL
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
75 #include "SimpleMutex.h"
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
76 #include "SimpleThread.h"
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
77 typedef struct SimpleMutex SDL_mutex;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
78 typedef struct SimpleThread SDL_Thread;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
79 #define SDL_CreateMutex SimpleMutex_CreateMutex
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
80 #define SDL_DestroyMutex SimpleMutex_DestroyMutex
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
81 #define SDL_LockMutex SimpleMutex_LockMutex
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
82 #define SDL_UnlockMutex SimpleMutex_UnlockMutex
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
83 #define SDL_CreateThread SimpleThread_CreateThread
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
84 #define SDL_WaitThread SimpleThread_WaitThread
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
85
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
86 #else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
87 #include "SDL_thread.h"
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
88 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
89 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
90
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
91 /* Because of the API differences between the Loki
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
92 * and Creative distributions, we need to know which
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
93 * version to use. The LOKI distribution currently
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
94 * has AL_BYTE_LOKI defined in altypes.h which
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
95 * I will use as a flag to identify the distributions.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
96 * If this is ever removed, I might revert back to the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
97 * if defined(_WIN32) or defined(__APPLE__) test to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
98 * identify the Creative dist.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
99 * I'm not sure if or how the Nvidia distribution differs
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
100 * from the Creative distribution. So for
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
101 * now, the Nvidia distribution gets lumped with the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
102 * Creative dist and I hope nothing will break.
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
103 * My alGetString may be the most vulnerable.
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
104 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
105 #ifdef AL_BYTE_LOKI
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
106 #define USING_LOKI_AL_DIST
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
107 /* This is a short term fix to get around the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
108 * queuing problem with non-power of two buffer sizes.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
109 * Hopefully the maintainers will fix this before
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
110 * we're ready to ship.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
111 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
112 #define ENABLE_LOKI_QUEUE_FIX_HACK
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
113
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
114 /* The AL_GAIN in the Loki dist doesn't seem to do
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
115 * what I want/expect it to do. I want to use it for
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
116 * Fading, but it seems to work like an off/on switch.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
117 * 0 = off, >0 = on.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
118 * The AL_GAIN_LINEAR_LOKI switch seems to do what
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
119 * I want, so I'll redefine it here so the code is consistent
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
120 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
121 /* Update: I've changed the source volume implementations
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
122 * to use AL_MAX_GAIN, so I don't think I need this block
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
123 * of code anymore. The listener uses AL_GAIN, but I
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
124 * hope they got this one right since there isn't a AL_MAX_GAIN
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
125 * for the listener.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
126 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
127 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
128 #undef AL_GAIN
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
129 #include "alexttypes.h"
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
130 #define AL_GAIN AL_GAIN_LINEAR_LOKI
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
131 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
132 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
133 /* Might need to run other tests to figure out the DIST */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
134 /* I've been told that Nvidia doesn't define constants
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
135 * in the headers like Creative. Instead of
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
136 * #define AL_REFERENCE_DISTANCE 0x1020,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
137 * Nvidia prefers you query OpenAL for a value.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
138 * int AL_REFERENCE_DISTANCE = alGetEnumValue(ALubyte*)"AL_REFERNECE_DISTANCE");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
139 * So I'm assuming this means the Nvidia lacks this value.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
140 * If this is the case,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
141 * I guess we can use it to identify the Nvidia dist
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
142 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
143 #ifdef AL_REFERENCE_DISTANCE
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
144 #define USING_CREATIVE_AL_DIST
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
145 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
146 #define USING_NVIDIA_AL_DIST
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
147 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
148 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
149
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
150 #ifdef ENABLE_LOKI_QUEUE_FIX_HACK
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
151 /* Need memset to zero out data */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
152 #include <string.h>
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
153 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
154
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
155
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
156 /* Seek issues for predecoded samples:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
157 * The problem is that OpenAL makes us copy an
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
158 * entire buffer if we want to use it. This
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
159 * means we potentially have two copies of the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
160 * same data. For predecoded data, this can be a
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
161 * large amount of memory. However, for seek
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
162 * support, I need to be able to get access to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
163 * the original data so I can set byte positions.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
164 * The following flags let you disable seek support
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
165 * if you don't want the memory hit, keep everything,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
166 * or let you try to minimize the memory wasted by
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
167 * fetching it from the OpenAL buffer if needed
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
168 * and making a copy of it.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
169 * Update: I don't think I need this flag anymore. I've made the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
170 * effects of this user customizable by the access_data flag on load.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
171 * If set to true, then seek and data callbacks work, with the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
172 * cost of more memory and possibly CPU for copying the data through
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
173 * the callbacks. If false, then the extra memory is freed, but
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
174 * you don't get the features.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
175 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
176 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
177 #define DISABLE_PREDECODED_SEEK
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
178 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
179 /* Problem: Even though alGetBufferi(., AL_DATA, .)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
180 * is in the Creative Programmer's reference,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
181 * it actually isn't in the dist. (Invalid enum
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
182 * in Creative, can't compile in Loki.)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
183 * So we have to keep it disabled
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
184 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
185 #define DISABLE_SEEK_MEMORY_OPTIMIZATION
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
186
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
187 #ifndef DISABLE_SEEK_MEMORY_OPTIMIZATION
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
188 /* Needed for memcpy */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
189 #include <string.h>
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
190 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
191
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
192 /* Old way of doing things:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
193 #if defined(_WIN32) || defined(__APPLE__)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
194 #define USING_CREATIVE_AL_DIST
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
195 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
196 #define USING_LOKI_AL_DIST
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
197 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
198 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
199
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
200 /************ REMOVE ME (Don't need anymore) ********/
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
201 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
202 /* Let's get fancy and see if triple buffering
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
203 * does anything good for us
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
204 * Must be 2 or more or things will probably break
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
205 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
206 #define NUMBER_OF_QUEUE_BUFFERS 5
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
207 /* This is the number of buffers that are queued up
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
208 * when play first starts up. This should be at least 1
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
209 * and no more than NUMBER_OF_QUEUE_BUFFERS
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
210 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
211 #define NUMBER_OF_START_UP_BUFFERS 2
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
212 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
213 /************ END REMOVE ME (Don't need anymore) ********/
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
214
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
215 #ifdef ALMIXER_COMPILE_WITHOUT_SDL
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
216 #include "tErrorLib.h"
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
217 static TErrorPool* s_ALmixerErrorPool = NULL;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
218 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
219
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
220 static ALboolean ALmixer_Initialized = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
221 /* This should be set correctly by Init */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
222 static ALuint ALmixer_Frequency_global = ALMIXER_DEFAULT_FREQUENCY;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
223
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
224 /* Will be initialized in Init */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
225 static ALint Number_of_Channels_global = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
226 static ALint Number_of_Reserve_Channels_global = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
227 static ALuint Is_Playing_global = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
228
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
229 #ifdef ENABLE_ALMIXER_THREADS
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
230 /* This is for a simple lock system. It is not meant to be good,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
231 * but just sufficient to minimize/avoid threading issues
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
232 */
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
233 static ALboolean g_StreamThreadEnabled = AL_FALSE;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
234 static SDL_mutex* s_simpleLock;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
235 static SDL_Thread* Stream_Thread_global = NULL;
26
884cce2515eb Put LowerThreadPriority in ENABLE_ALMIXER_THREADS_BLOCK
Eric Wing <ewing . public |-at-| gmail . com>
parents: 25
diff changeset
236 #endif /* ENABLE_ALMIXER_THREADS */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
237
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
238 static LinkedList* s_listOfALmixerData = NULL;
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
239
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
240 /* Special stuff for iOS interruption handling */
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
241 ALboolean g_inInterruption = AL_FALSE;
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
242 static ALCcontext* s_interruptionContext = NULL;
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
243
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
244
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
245 #ifdef __APPLE__
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
246 static ALvoid Internal_alcMacOSXMixerOutputRate(const ALdouble sample_rate)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
247 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
248 static void (*alcMacOSXMixerOutputRateProcPtr)(const ALdouble) = NULL;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
249
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
250 if(NULL == alcMacOSXMixerOutputRateProcPtr)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
251 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
252 alcMacOSXMixerOutputRateProcPtr = alGetProcAddress((const ALCchar*) "alcMacOSXMixerOutputRate");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
253 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
254
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
255 if(NULL != alcMacOSXMixerOutputRateProcPtr)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
256 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
257 alcMacOSXMixerOutputRateProcPtr(sample_rate);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
258 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
259
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
260 return;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
261 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
262
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
263 ALdouble Internal_alcMacOSXGetMixerOutputRate()
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
264 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
265 static ALdouble (*alcMacOSXGetMixerOutputRateProcPtr)(void) = NULL;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
266
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
267 if(NULL == alcMacOSXGetMixerOutputRateProcPtr)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
268 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
269 alcMacOSXGetMixerOutputRateProcPtr = alGetProcAddress((const ALCchar*) "alcMacOSXGetMixerOutputRate");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
270 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
271
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
272 if(NULL != alcMacOSXGetMixerOutputRateProcPtr)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
273 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
274 return alcMacOSXGetMixerOutputRateProcPtr();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
275 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
276
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
277 return 0.0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
278 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
279 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
280
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
281 #ifdef ALMIXER_COMPILE_WITHOUT_SDL
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
282
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
283 #if defined(__APPLE__)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
284 #include <QuartzCore/QuartzCore.h>
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
285 #include <unistd.h>
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
286 static CFTimeInterval s_ticksBaseTime = 0.0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
287
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
288 #elif defined(_WIN32)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
289 #define WIN32_LEAN_AND_MEAN
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
290 #include <windows.h>
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
291 #include <winbase.h>
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
292 LARGE_INTEGER s_hiResTicksPerSecond;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
293 double s_hiResSecondsPerTick;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
294 LARGE_INTEGER s_ticksBaseTime;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
295 #else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
296 #include <unistd.h>
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
297 #include <time.h>
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
298 static struct timespec s_ticksBaseTime;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
299 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
300 static void ALmixer_InitTime()
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
301 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
302 #if defined(__APPLE__)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
303 s_ticksBaseTime = CACurrentMediaTime();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
304
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
305 #elif defined(_WIN32)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
306 LARGE_INTEGER hi_res_ticks_per_second;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
307 if(TRUE == QueryPerformanceFrequency(&hi_res_ticks_per_second))
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
308 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
309 QueryPerformanceCounter(&s_ticksBaseTime);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
310 s_hiResSecondsPerTick = 1.0 / hi_res_ticks_per_second;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
311 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
312 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
313 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
314 ALMixer_SetError("Windows error: High resolution clock failed.");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
315 fprintf(stderr, "Windows error: High resolution clock failed. Audio will not work correctly.\n");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
316 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
317 #else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
318 /* clock_gettime is POSIX.1-2001 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
319 clock_gettime(CLOCK_MONOTONIC, &s_ticksBaseTime);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
320 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
321
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
322 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
323 static ALuint ALmixer_GetTicks()
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
324 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
325 #if defined(__APPLE__)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
326 return (ALuint)((CACurrentMediaTime()-s_ticksBaseTime)*1000.0);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
327 #elif defined(_WIN32)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
328 LARGE_INTEGER current_time;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
329 QueryPerformanceCounter(&current_time);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
330 return (ALuint)((current_time.QuadPart - s_ticksBaseTime.QuadPart) * 1000 * s_hiResSecondsPerTick);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
331 #else /* assuming POSIX */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
332 /* clock_gettime is POSIX.1-2001 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
333 struct timespec current_time;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
334 clock_gettime(CLOCK_MONOTONIC, &current_time);
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
335 return (ALuint)((current_time.tv_sec - s_ticksBaseTime.tv_sec)*1000.0 + (current_time.tv_nsec - s_ticksBaseTime.tv_nsec) / 1000000);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
336 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
337 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
338 static void ALmixer_Delay(ALuint milliseconds_delay)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
339 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
340 #if defined(_WIN32)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
341 Sleep(milliseconds_delay);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
342 #else
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
343 usleep(milliseconds_delay*1000);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
344 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
345 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
346 #else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
347 #include "SDL.h" /* For SDL_GetTicks(), SDL_Delay */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
348 #define ALmixer_GetTicks SDL_GetTicks
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
349 #define ALmixer_Delay SDL_Delay
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
350 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
351
24
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
352 /* On iOS, usleep() of small numbers (say less than 100, very pronounced from 0-50)
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
353 * seems to be sucking up quite a bit of CPU time and causing performance problems.
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
354 * Instead of increasing the sleep time, I started changing the thread priority.
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
355 * This seemed to help the problem.
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
356 * Experimentally, the default priority seems to be 31. According to the docs,
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
357 * valid ranges are from 0 to 31. 6 was still giving me some hiccups so setting to
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
358 * 0 (PTHREAD_MIN_PRIORITY) seems to be the best value so far.
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
359 * Mac also reports 31 as the default. However, I have not noticed the same
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
360 * performance problems and cannot get audio to show up as a significant percentage
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
361 * of the CPU time in Shark/Instruments.
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
362 */
26
884cce2515eb Put LowerThreadPriority in ENABLE_ALMIXER_THREADS_BLOCK
Eric Wing <ewing . public |-at-| gmail . com>
parents: 25
diff changeset
363 #ifdef ENABLE_ALMIXER_THREADS
24
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
364 #if defined(__APPLE__) && !defined(ALMIXER_COMPILE_WITHOUT_SDL) && ( (TARGET_OS_IPHONE == 1) || (TARGET_IPHONE_SIMULATOR == 1) )
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
365 #include <pthread.h>
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
366 #endif
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
367 static void Internal_LowerThreadPriority(SDL_Thread* simple_thread)
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
368 {
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
369 /* Might open to other platforms as needed */
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
370 #if defined(__APPLE__) && ( (TARGET_OS_IPHONE == 1) || (TARGET_IPHONE_SIMULATOR == 1) )
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
371 #ifdef ALMIXER_COMPILE_WITHOUT_SDL
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
372 SimpleThread_SetThreadPriority(Stream_Thread_global, 0);
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
373 #else
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
374 struct sched_param schedule_param;
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
375 int sched_policy;
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
376 int ret_val;
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
377 schedule_param.sched_priority = 0; /* PTHREAD_MIN_PRIORITY, max=31 */
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
378 /* EVIL! This will break if the SDL_Thread structure layout changes. */
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
379 pthread_t* native_thread_ptr_hack = (pthread_t*)(((char*)(Stream_Thread_global))+sizeof(unsigned long));
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
380 ret_val = pthread_setschedparam(*native_thread_ptr_hack, SCHED_OTHER, &schedule_param);
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
381 #endif
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
382 #else
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
383 /* No-Op */
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
384 #endif
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
385 }
26
884cce2515eb Put LowerThreadPriority in ENABLE_ALMIXER_THREADS_BLOCK
Eric Wing <ewing . public |-at-| gmail . com>
parents: 25
diff changeset
386 #endif /* ENABLE_ALMIXER_THREADS */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
387
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
388 /* If ENABLE_PARANOID_SIGNEDNESS_CHECK is used,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
389 * these values will be reset on Init()
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
390 * Consider these values Read-Only.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
391 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
392
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
393 #define ALMIXER_SIGNED_VALUE 127
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
394 #define ALMIXER_UNSIGNED_VALUE 255
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
395
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
396 #ifdef ENABLE_PARANOID_SIGNEDNESS_CHECK
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
397 static ALushort SIGN_TYPE_16_BIT_FORMAT = AUDIO_S16SYS;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
398 static ALushort SIGN_TYPE_8_BIT_FORMAT = AUDIO_S8;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
399 #else
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
400 static const ALushort SIGN_TYPE_16_BIT_FORMAT = AUDIO_S16SYS;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
401 static const ALushort SIGN_TYPE_8_BIT_FORMAT = AUDIO_S8;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
402 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
403
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
404
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
405 /* This can be private instead of being in the header now that I moved
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
406 * ALmixer_Data inside here.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
407 */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
408 typedef struct ALmixer_Buffer_Map ALmixer_Buffer_Map;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
409
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
410
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
411 struct ALmixer_Data
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
412 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
413 ALboolean decoded_all; /* dictates different behaviors */
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
414 ALint total_time; /* total playing time of sample (msec), obsolete now that we pushed our changes to SDL_sound */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
415
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
416 ALuint in_use; /* needed to prevent sharing for streams */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
417 ALboolean eof; /* flag for eof, only used for streams */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
418
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
419 ALuint total_bytes; /* For predecoded */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
420 ALuint loaded_bytes; /* For predecoded (for seek) */
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
421
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
422 Sound_Sample* sample; /* SDL_Sound provides the data */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
423 ALuint* buffer; /* array of OpenAL buffers (at least 1 for predecoded) */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
424
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
425 /* Needed for streamed buffers */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
426 ALuint max_queue_buffers; /* Max number of queue buffers */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
427 ALuint num_startup_buffers; /* Number of ramp-up buffers */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
428 ALuint num_buffers_in_use; /* number of buffers in use */
28
60500a33735a Initial backend changes to decouple assumption of 1 buffer queued per channel / per pass. API will eventually be changed/broken to support this.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 27
diff changeset
429 ALuint num_target_buffers_per_pass; /* number of buffers to try to queue in an update pass */
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
430
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
431 /* This stuff is for streamed buffers that require data access */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
432 ALmixer_Buffer_Map* buffer_map_list; /* translate ALbuffer to index
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
433 and holds pointer to copy of data for
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
434 data access */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
435 ALuint current_buffer; /* The current playing buffer */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
436
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
437 /* Nvidia distribution refuses to recognize a simple buffer query command
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
438 * unlike all other distributions. It's forcing me to redo the code
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
439 * to accomodate this Nvidia flaw by making me maintain a "best guess"
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
440 * copy of what I think the buffer queue state looks like.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
441 * A circular queue would a helpful data structure for this task,
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
442 * but I wanted to avoid making an additional header requirement,
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
443 * so I'm making it a void*
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
444 */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
445 void* circular_buffer_queue;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
446
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
447
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
448 };
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
449
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
450 static struct ALmixer_Channel
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
451 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
452 ALboolean channel_in_use;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
453 ALboolean callback_update; /* For streaming determination */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
454 ALboolean needs_stream; /* For streaming determination */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
455 ALboolean halted;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
456 ALboolean paused;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
457 ALuint alsource;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
458 ALmixer_Data* almixer_data;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
459 ALint loops;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
460 ALint expire_ticks;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
461 ALuint start_time;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
462
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
463 ALboolean fade_enabled;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
464 ALuint fade_expire_ticks;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
465 ALuint fade_start_time;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
466 ALfloat fade_inv_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
467 ALfloat fade_start_volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
468 ALfloat fade_end_volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
469 ALfloat max_volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
470 ALfloat min_volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
471
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
472 /* Do we need other flags?
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
473 ALbyte *samples;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
474 int volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
475 int looping;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
476 int tag;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
477 ALuint expire;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
478 ALuint start_time;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
479 Mix_Fading fading;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
480 int fade_volume;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
481 ALuint fade_length;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
482 ALuint ticks_fade;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
483 effect_info *effects;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
484 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
485 } *ALmixer_Channel_List = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
486
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
487 struct ALmixer_Buffer_Map
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
488 {
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
489 ALuint albuffer;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
490 ALint index; /* might not need */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
491 ALbyte* data;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
492 ALuint num_bytes;
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
493 };
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
494
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
495 /* This will be used to find a channel if the user supplies a source */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
496 typedef struct Source_Map
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
497 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
498 ALuint source;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
499 ALint channel;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
500 } Source_Map;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
501 /* Keep an array of all sources with their associated channel */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
502 static Source_Map* Source_Map_List;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
503
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
504 static int Compare_Source_Map(const void* a, const void* b)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
505 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
506 return ( ((Source_Map*)a)->source - ((Source_Map*)b)->source );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
507 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
508
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
509 /* Sort by channel instead of source */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
510 static int Compare_Source_Map_by_channel(const void* a, const void* b)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
511 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
512 return ( ((Source_Map*)a)->channel - ((Source_Map*)b)->channel );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
513 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
514
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
515 /* Compare by albuffer */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
516 static int Compare_Buffer_Map(const void* a, const void* b)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
517 {
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
518 return ( ((ALmixer_Buffer_Map*)a)->albuffer - ((ALmixer_Buffer_Map*)b)->albuffer );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
519 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
520
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
521 /* This is for the user defined callback via
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
522 * ALmixer_ChannelFinished()
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
523 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
524 static void (*Channel_Done_Callback)(ALint which_channel, ALuint al_source, ALmixer_Data* almixer_data, ALboolean finished_naturally, void* user_data) = NULL;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
525 static void* Channel_Done_Callback_Userdata = NULL;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
526 static void (*Channel_Data_Callback)(ALint which_channel, ALuint al_source, ALbyte* data, ALuint num_bytes, ALuint frequency, ALubyte channels, ALubyte bit_depth, ALboolean is_unsigned, ALboolean decode_mode_is_predecoded, ALuint length_in_msec, void* user_data) = NULL;
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
527 static void* Channel_Data_Callback_Userdata = NULL;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
528
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
529
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
530 static void PrintQueueStatus(ALuint source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
531 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
532 ALint buffers_queued = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
533 ALint buffers_processed = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
534 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
535
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
536 /* Get the number of buffers still queued */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
537 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
538 source,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
539 AL_BUFFERS_QUEUED,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
540 &buffers_queued
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
541 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
542
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
543 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
544 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
545 fprintf(stderr, "Error in PrintQueueStatus, Can't get buffers_queued: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
546 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
547 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
548 /* Get the number of buffers processed
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
549 * so we know if we need to refill
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
550 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
551 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
552 source,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
553 AL_BUFFERS_PROCESSED,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
554 &buffers_processed
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
555 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
556 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
557 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
558 fprintf(stderr, "Error in PrintQueueStatus, Can't get buffers_processed: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
559 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
560 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
561
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
562 /*
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
563 fprintf(stderr, "For source: %d, buffers_queued=%d, buffers_processed=%d\n",
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
564 source,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
565 buffers_queued,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
566 buffers_processed);
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
567 */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
568 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
569
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
570
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
571
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
572 static void Init_Channel(ALint channel)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
573 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
574 ALmixer_Channel_List[channel].channel_in_use = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
575 ALmixer_Channel_List[channel].callback_update = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
576 ALmixer_Channel_List[channel].needs_stream = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
577 ALmixer_Channel_List[channel].paused = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
578 ALmixer_Channel_List[channel].halted = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
579 ALmixer_Channel_List[channel].loops = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
580
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
581 ALmixer_Channel_List[channel].expire_ticks = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
582 ALmixer_Channel_List[channel].start_time = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
583
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
584 ALmixer_Channel_List[channel].fade_enabled = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
585 ALmixer_Channel_List[channel].fade_expire_ticks = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
586 ALmixer_Channel_List[channel].fade_start_time = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
587 ALmixer_Channel_List[channel].fade_inv_time = 0.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
588 ALmixer_Channel_List[channel].fade_start_volume = 0.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
589 ALmixer_Channel_List[channel].fade_end_volume = 0.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
590 ALmixer_Channel_List[channel].max_volume = 1.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
591 ALmixer_Channel_List[channel].min_volume = 0.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
592
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
593 ALmixer_Channel_List[channel].almixer_data = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
594 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
595 /* Quick helper function to clean up a channel
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
596 * after it's done playing */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
597 static void Clean_Channel(ALint channel)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
598 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
599 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
600 ALmixer_Channel_List[channel].channel_in_use = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
601 ALmixer_Channel_List[channel].callback_update = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
602 ALmixer_Channel_List[channel].needs_stream = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
603 ALmixer_Channel_List[channel].paused = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
604 ALmixer_Channel_List[channel].halted = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
605 ALmixer_Channel_List[channel].loops = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
606
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
607
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
608 ALmixer_Channel_List[channel].expire_ticks = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
609 ALmixer_Channel_List[channel].start_time = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
610
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
611 ALmixer_Channel_List[channel].fade_enabled = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
612 ALmixer_Channel_List[channel].fade_expire_ticks = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
613 ALmixer_Channel_List[channel].fade_start_time = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
614 ALmixer_Channel_List[channel].fade_inv_time = 0.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
615 ALmixer_Channel_List[channel].fade_start_volume = 0.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
616 ALmixer_Channel_List[channel].fade_end_volume = 0.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
617
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
618 alSourcef(ALmixer_Channel_List[channel].alsource, AL_MAX_GAIN,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
619 ALmixer_Channel_List[channel].max_volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
620
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
621 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
622 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
623 fprintf(stderr, "10Testing errpr before unqueue because getting stuff, for OS X this is expected: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
624 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
625 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
626
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
627 alSourcef(ALmixer_Channel_List[channel].alsource, AL_MIN_GAIN,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
628 ALmixer_Channel_List[channel].min_volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
629 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
630 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
631 fprintf(stderr, "11Testing errpr before unqueue because getting stuff, for OS X this is expected: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
632 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
633 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
634
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
635 if(ALmixer_Channel_List[channel].almixer_data != NULL)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
636 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
637 if(ALmixer_Channel_List[channel].almixer_data->in_use > 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
638 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
639 ALmixer_Channel_List[channel].almixer_data->in_use--;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
640 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
641 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
642 /* Needed to determine if rewind is needed, can't reset */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
643 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
644 ALmixer_Channel_List[channel].almixer_data->eof = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
645 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
646
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
647 ALmixer_Channel_List[channel].almixer_data = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
648 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
649
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
650 /* What shoud this return?
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
651 * 127 for signed, 255 for unsigned
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
652 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
653 static ALubyte GetSignednessValue(ALushort format)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
654 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
655 switch(format)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
656 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
657 case AUDIO_U8:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
658 case AUDIO_U16LSB:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
659 case AUDIO_U16MSB:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
660 return ALMIXER_UNSIGNED_VALUE;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
661 break;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
662 case AUDIO_S8:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
663 case AUDIO_S16LSB:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
664 case AUDIO_S16MSB:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
665 return ALMIXER_SIGNED_VALUE;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
666 break;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
667 default:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
668 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
669 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
670 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
671 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
672
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
673
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
674 static ALubyte GetBitDepth(ALushort format)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
675 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
676 ALubyte bit_depth = 16;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
677
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
678 switch(format)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
679 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
680 case AUDIO_U8:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
681 case AUDIO_S8:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
682 bit_depth = 8;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
683 break;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
684
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
685 case AUDIO_U16LSB:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
686 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
687 case AUDIO_U16:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
688 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
689 case AUDIO_S16LSB:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
690 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
691 case AUDIO_S16:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
692 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
693 case AUDIO_U16MSB:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
694 case AUDIO_S16MSB:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
695 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
696 case AUDIO_U16SYS:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
697 case AUDIO_S16SYS:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
698 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
699 bit_depth = 16;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
700 break;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
701 default:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
702 bit_depth = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
703 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
704 return bit_depth;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
705 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
706
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
707 /* Need to translate between SDL/SDL_Sound audiospec
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
708 * and OpenAL conventions */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
709 static ALenum TranslateFormat(Sound_AudioInfo* info)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
710 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
711 ALubyte bit_depth;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
712
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
713 bit_depth = GetBitDepth(info->format);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
714 if(0 == bit_depth)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
715 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
716 fprintf(stderr, "Warning: Unknown bit depth. Setting to 16\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
717 bit_depth = 16;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
718 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
719
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
720 if(2 == info->channels)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
721 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
722 if(16 == bit_depth)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
723 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
724 return AL_FORMAT_STEREO16;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
725 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
726 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
727 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
728 return AL_FORMAT_STEREO8;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
729 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
730 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
731 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
732 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
733 if(16 == bit_depth)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
734 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
735 return AL_FORMAT_MONO16;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
736 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
737 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
738 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
739 return AL_FORMAT_MONO8;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
740 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
741 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
742 /* Make compiler happy. Shouldn't get here */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
743 return AL_FORMAT_STEREO16;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
744 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
745
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
746
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
747 /* This will compute the total playing time
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
748 * based upon the number of bytes and audio info.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
749 * (In prinicple, it should compute the time for any given length)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
750 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
751 static ALuint Compute_Total_Time_Decomposed(ALuint bytes_per_sample, ALuint frequency, ALubyte channels, size_t total_bytes)
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
752 {
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
753 double total_sec;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
754 ALuint total_msec;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
755 ALuint bytes_per_sec;
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
756
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
757 if(0 == total_bytes)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
758 {
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
759 return 0;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
760 }
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
761 /* To compute Bytes per second, do
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
762 * samples_per_sec * bytes_per_sample * number_of_channels
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
763 */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
764 bytes_per_sec = frequency * bytes_per_sample * channels;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
765
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
766 /* Now to get total time (sec), do
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
767 * total_bytes / bytes_per_sec
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
768 */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
769 total_sec = total_bytes / (double)bytes_per_sec;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
770
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
771 /* Now convert seconds to milliseconds
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
772 * Add .5 to the float to do rounding before the final cast
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
773 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
774 total_msec = (ALuint) ( (total_sec * 1000) + 0.5 );
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
775 /*
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
776 fprintf(stderr, "freq=%d, bytes_per_sample=%d, channels=%d, total_msec=%d\n", frequency, bytes_per_sample, channels, total_msec);
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
777 */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
778 return total_msec;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
779 }
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
780
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
781 static ALuint Compute_Total_Time(Sound_AudioInfo *info, size_t total_bytes)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
782 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
783 ALuint bytes_per_sample;
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
784
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
785 if(0 == total_bytes)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
786 {
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
787 return 0;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
788 }
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
789 /* SDL has a mask trick I was not aware of. Mask the upper bits
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
790 * of the format, and you get 8 or 16 which is the bits per sample.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
791 * Divide by 8bits_per_bytes and you get bytes_per_sample
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
792 * I tested this under 32-bit and 64-bit and big and little endian
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
793 * to make sure this still works since I have since moved from
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
794 * Uint32 to unspecified size types like ALuint.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
795 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
796 bytes_per_sample = (ALuint) ((info->format & 0xFF) / 8);
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
797
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
798 return Compute_Total_Time_Decomposed(bytes_per_sample, info->rate, info->channels, total_bytes);
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
799 } /* End Compute_Total_Time */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
800
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
801
24
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
802 #ifdef ALMIXER_DISABLE_PREDECODED_PRECOMPUTE_BUFFER_SIZE_OPTIMIZATION
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
803 static size_t Compute_Total_Bytes_Decomposed(ALuint bytes_per_sample, ALuint frequency, ALubyte channels, ALuint total_msec)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
804 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
805 double total_sec;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
806 ALuint bytes_per_sec;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
807 size_t total_bytes;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
808
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
809 if(0 >= total_msec)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
810 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
811 return 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
812 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
813 /* To compute Bytes per second, do
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
814 * samples_per_sec * bytes_per_sample * number_of_channels
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
815 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
816 bytes_per_sec = frequency * bytes_per_sample * channels;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
817
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
818 /* convert milliseconds to seconds */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
819 total_sec = total_msec / 1000.0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
820
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
821 /* Now to get total bytes */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
822 total_bytes = (size_t)(((double)bytes_per_sec * total_sec) + 0.5);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
823
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
824 /* fprintf(stderr, "freq=%d, bytes_per_sample=%d, channels=%d, total_msec=%d, total_bytes=%d\n", frequency, bytes_per_sample, channels, total_msec, total_bytes);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
825 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
826
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
827 return total_bytes;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
828 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
829
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
830 static size_t Compute_Total_Bytes(Sound_AudioInfo *info, ALuint total_msec)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
831 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
832 ALuint bytes_per_sample;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
833
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
834 if(0 >= total_msec)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
835 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
836 return 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
837 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
838 /* SDL has a mask trick I was not aware of. Mask the upper bits
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
839 * of the format, and you get 8 or 16 which is the bits per sample.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
840 * Divide by 8bits_per_bytes and you get bytes_per_sample
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
841 * I tested this under 32-bit and 64-bit and big and little endian
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
842 * to make sure this still works since I have since moved from
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
843 * Uint32 to unspecified size types like ALuint.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
844 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
845 bytes_per_sample = (ALuint) ((info->format & 0xFF) / 8);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
846
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
847 return Compute_Total_Bytes_Decomposed(bytes_per_sample, info->rate, info->channels, total_msec);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
848 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
849
24
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
850
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
851 /* The back-end decoders seem to need to decode in quantized frame sizes.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
852 * So if I can pad the bytes to the next quanta, things might go more smoothly.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
853 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
854 static size_t Compute_Total_Bytes_With_Frame_Padding(Sound_AudioInfo *info, ALuint total_msec)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
855 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
856 ALuint bytes_per_sample;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
857 ALuint bytes_per_frame;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
858 size_t evenly_divisible_frames;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
859 size_t remainder_frames;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
860 size_t return_bytes;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
861
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
862 size_t total_bytes = Compute_Total_Bytes(info, total_msec);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
863
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
864 bytes_per_sample = (ALuint) ((info->format & 0xFF) / 8);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
865
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
866 bytes_per_frame = bytes_per_sample * info->channels;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
867
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
868 evenly_divisible_frames = total_bytes / bytes_per_frame;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
869 remainder_frames = total_bytes % bytes_per_frame;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
870
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
871 return_bytes = (evenly_divisible_frames * bytes_per_frame) + (remainder_frames * bytes_per_frame);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
872
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
873 /* Experimentally, some times I see to come up short in
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
874 * actual bytes decoded and I see a second pass is needed.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
875 * I'm worried this may have additional performance implications.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
876 * Sometimes in the second pass (depending on file),
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
877 * I have seen between 0 and 18 bytes.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
878 * I'm tempted to pad the bytes by some arbitrary amount.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
879 * However, I think currently the way SDL_sound is implemented,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
880 * there is a big waste of memory up front instead of per-pass,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
881 * so maybe I shouldn't worry about this.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
882 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
883 /*
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
884 return_bytes += 64;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
885 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
886 /*
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
887 fprintf(stderr, "remainder_frames=%d, padded_total_bytes=%d\n", remainder_frames, return_bytes);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
888 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
889 return return_bytes;
24
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
890 }
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
891 #endif /* ALMIXER_DISABLE_PREDECODED_PRECOMPUTE_BUFFER_SIZE_OPTIMIZATION */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
892
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
893
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
894
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
895 /**************** REMOVED ****************************/
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
896 /* This was removed because I originally thought
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
897 * OpenAL could return a pointer to the buffer data,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
898 * but I was wrong. If something like that is ever
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
899 * implemented, then this might become useful.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
900 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
901 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
902 /* Reconstruct_Sound_Sample and Set_AudioInfo only
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
903 * are needed if the Seek memory optimization is
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
904 * used. Also, the Loki dist doesn't seem to support
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
905 * AL_DATA which I need for it.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
906 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
907 #ifndef DISABLE_SEEK_MEMORY_OPTIMIZATION
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
908
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
909 static void Set_AudioInfo(Sound_AudioInfo* info, ALint frequency, ALint bits, ALint channels)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
910 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
911 info->rate = (ALuint)frequency;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
912 info->channels = (ALubyte)channels;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
913
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
914 /* Not sure if it should be signed or unsigned. Hopefully
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
915 * that detail won't be needed.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
916 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
917 if(8 == bits)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
918 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
919 info->format = AUDIO_U8;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
920 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
921 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
922 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
923 info->format = AUDIO_U16SYS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
924 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
925 fprintf(stderr, "Audio info: freq=%d, chan=%d, format=%d\n",
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
926 info->rate, info->channels, info->format);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
927
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
928 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
929
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
930
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
931 static ALint Reconstruct_Sound_Sample(ALmixer_Data* data)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
932 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
933 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
934 ALint* data_from_albuffer;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
935 ALint freq;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
936 ALint bits;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
937 ALint channels;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
938 ALint size;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
939
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
940 /* Create memory all initiallized to 0. */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
941 data->sample = (Sound_Sample*)calloc(1, sizeof(Sound_Sample));
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
942 if(NULL == data->sample)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
943 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
944 ALmixer_SetError("Out of memory for Sound_Sample");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
945 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
946 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
947
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
948 /* Clear errors */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
949 alGetError();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
950
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
951 alGetBufferi(data->buffer[0], AL_FREQUENCY, &freq);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
952 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
953 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
954 ALmixer_SetError("alGetBufferi(AL_FREQUENCY): %s", alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
955 free(data->sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
956 data->sample = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
957 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
958 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
959
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
960 alGetBufferi(data->buffer[0], AL_BITS, &bits);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
961 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
962 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
963 ALmixer_SetError("alGetBufferi(AL_BITS): %s", alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
964 free(data->sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
965 data->sample = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
966 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
967 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
968
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
969 alGetBufferi(data->buffer[0], AL_CHANNELS, &channels);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
970 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
971 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
972 ALmixer_SetError("alGetBufferi(AL_CHANNELS): %s", alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
973 free(data->sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
974 data->sample = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
975 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
976 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
977
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
978 alGetBufferi(data->buffer[0], AL_SIZE, &size);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
979 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
980 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
981 ALmixer_SetError("alGetBufferi(AL_SIZE): %s", alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
982 free(data->sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
983 data->sample = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
984 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
985 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
986
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
987 alGetBufferi(data->buffer[0], AL_DATA, data_from_albuffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
988 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
989 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
990 ALmixer_SetError("alGetBufferi(AL_DATA): %s", alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
991 free(data->sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
992 data->sample = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
993 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
994 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
995
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
996 if(size <= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
997 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
998 ALmixer_SetError("No data in al buffer");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
999 free(data->sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1000 data->sample = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1001 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1002 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1003
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1004 /* Now that we have all the attributes, we need to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1005 * allocate memory for the buffer and reconstruct
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1006 * the AudioInfo attributes.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1007 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1008 data->sample->buffer = malloc(size*sizeof(ALbyte));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1009 if(NULL == data->sample->buffer)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1010 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1011 ALmixer_SetError("Out of memory for sample->buffer");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1012 free(data->sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1013 data->sample = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1014 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1015 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1016
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1017 memcpy(data->sample->buffer, data_from_albuffer, size);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1018 data->sample->buffer_size = size;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1019
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1020 /* Fill up the Sound_AudioInfo structures */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1021 Set_AudioInfo(&data->sample->desired, freq, bits, channels);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1022 Set_AudioInfo(&data->sample->actual, freq, bits, channels);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1023
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1024 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1025 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1026
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1027 #endif /* End DISABLE_SEEK_MEMORY_OPTIMIZATION */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1028 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1029 /*************** END REMOVED *************************/
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1030
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1031 static void Invoke_Channel_Done_Callback(ALint which_channel, ALboolean did_finish_naturally)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1032 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1033 if(NULL == Channel_Done_Callback)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1034 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1035 return;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1036 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1037 Channel_Done_Callback(which_channel, ALmixer_Channel_List[which_channel].alsource, ALmixer_Channel_List[which_channel].almixer_data, did_finish_naturally, Channel_Done_Callback_Userdata);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1038 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1039
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1040 static ALint LookUpBuffer(ALuint buffer, ALmixer_Buffer_Map* buffer_map_list, ALuint num_items_in_list)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1041 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1042 /* Only the first value is used for the key */
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1043 ALmixer_Buffer_Map key = { 0, 0, NULL, 0 };
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1044 ALmixer_Buffer_Map* found_item = NULL;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1045 key.albuffer = buffer;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1046
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1047 /* Use the ANSI C binary search feature (yea!) */
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1048 found_item = (ALmixer_Buffer_Map*)bsearch(&key, buffer_map_list, num_items_in_list, sizeof(ALmixer_Buffer_Map), Compare_Buffer_Map);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1049 if(NULL == found_item)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1050 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1051 ALmixer_SetError("Can't find buffer");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1052 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1053 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1054 return found_item->index;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1055 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1056
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1057
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1058 /* FIXME: Need to pass back additional info to be useful.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1059 * Bit rate, stereo/mono (num chans), time in msec?
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1060 * Precoded/streamed flag so user can plan for future data?
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1061 */
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1062 /*
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1063 * channels: 1 for mono, 2 for stereo
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1064 *
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1065 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1066 static void Invoke_Channel_Data_Callback(ALint which_channel, ALbyte* data, ALuint num_bytes, ALuint frequency, ALubyte channels, ALushort format, ALboolean decode_mode_is_predecoded)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1067 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1068 ALboolean is_unsigned;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1069 ALubyte bits_per_sample = GetBitDepth(format);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1070 ALuint bytes_per_sample;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1071 ALuint length_in_msec;
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1072
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1073 if(GetSignednessValue(format) == ALMIXER_UNSIGNED_VALUE)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1074 {
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1075 is_unsigned = 1;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1076 }
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1077 else
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1078 {
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1079 is_unsigned = 0;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1080 }
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1081
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1082 bytes_per_sample = (ALuint) (bits_per_sample / 8);
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1083
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1084 length_in_msec = Compute_Total_Time_Decomposed(bytes_per_sample, frequency, channels, num_bytes);
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1085
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1086 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1087 fprintf(stderr, "%x %x %x %x, bytes=%d, whichchan=%d, freq=%d, channels=%d\n", data[0], data[1], data[2], data[3], num_bytes, channels, frequency, channels);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1088 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1089 if(NULL == Channel_Data_Callback)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1090 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1091 return;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1092 }
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1093 /*
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1094 * Channel_Data_Callback(which_channel, data, num_bytes, frequency, channels, GetBitDepth(format), format, decode_mode_is_predecoded);
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
1095 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1096 Channel_Data_Callback(which_channel, ALmixer_Channel_List[which_channel].alsource, data, num_bytes, frequency, channels, bits_per_sample, is_unsigned, decode_mode_is_predecoded, length_in_msec, Channel_Data_Callback_Userdata);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1097 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1098
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1099 static void Invoke_Predecoded_Channel_Data_Callback(ALint channel, ALmixer_Data* data)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1100 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1101 if(NULL == data->sample)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1102 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1103 return;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1104 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1105 /* The buffer position is complicated because if the current data was seeked,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1106 * we must adjust the buffer to the seek position
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1107 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1108 Invoke_Channel_Data_Callback(channel,
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1109 (((ALbyte*) data->sample->buffer) + (data->total_bytes - data->loaded_bytes) ),
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1110 data->loaded_bytes,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1111 data->sample->desired.rate,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1112 data->sample->desired.channels,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1113 data->sample->desired.format,
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1114 AL_TRUE
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1115 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1116 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1117
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1118 static void Invoke_Streamed_Channel_Data_Callback(ALint channel, ALmixer_Data* data, ALuint buffer)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1119 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1120 ALint index;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1121 if(NULL == data->buffer_map_list)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1122 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1123 return;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1124 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1125 index = LookUpBuffer(buffer, data->buffer_map_list, data->max_queue_buffers);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1126 /* This should catch the case where all buffers are unqueued
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1127 * and the "current" buffer is id: 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1128 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1129 if(-1 == index)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1130 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1131 return;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1132 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1133 Invoke_Channel_Data_Callback(channel,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1134 data->buffer_map_list[index].data,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1135 data->buffer_map_list[index].num_bytes,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1136 data->sample->desired.rate,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1137 data->sample->desired.channels,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1138 data->sample->desired.format,
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1139 AL_FALSE
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1140 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1141 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1142
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
1143 /* Converts milliseconds to byte positions.
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1144 * This is needed for seeking on predecoded samples
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1145 */
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1146 static ALuint Convert_Msec_To_Byte_Pos(Sound_AudioInfo* audio_info, ALuint number_of_milliseconds)
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1147 {
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1148 ALuint bytes_per_sample;
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1149 ALuint bytes_per_frame;
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1150 float bytes_per_millisecond;
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1151 float byte_position;
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1152
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1153 if(audio_info == NULL)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1154 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1155 fprintf(stderr, "Error, info is NULL\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1156 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1157
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1158 /* SDL has a mask trick I was not aware of. Mask the upper bits
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1159 * of the format, and you get 8 or 16 which is the bits per sample.
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1160 * Divide by 8bits_per_bytes and you get bytes_per_sample
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1161 * I tested this under 32-bit and 64-bit and big and little endian
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1162 * to make sure this still works since I have since moved from
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1163 * Uint32 to unspecified size types like ALuint.
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1164 */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1165 bytes_per_sample = (ALuint) ((audio_info->format & 0xFF) / 8);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1166 bytes_per_frame = bytes_per_sample * audio_info->channels;
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1167 bytes_per_millisecond = (float)bytes_per_frame * (audio_info->rate / 1000.0f);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1168 byte_position = ((float)(number_of_milliseconds)) * bytes_per_millisecond;
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
1169 return (ALuint)(byte_position + 0.5);
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
1170 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1171
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1172 static ALint Set_Predecoded_Seek_Position(ALmixer_Data* data, ALuint byte_position)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1173 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1174 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1175 /* clear error */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1176 alGetError();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1177
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1178 /* Is it greater than, or greater-than or equal to ?? */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1179 if(byte_position > data->total_bytes)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1180 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1181 /* We can't go past the end, so set to end? */
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
1182 /*
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1183 fprintf(stderr, "Error, can't seek past end\n");
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
1184 */
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
1185
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1186 /* In case the below thing doesn't work,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1187 * just rewind the whole thing.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1188 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1189 alBufferData(data->buffer[0],
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1190 TranslateFormat(&data->sample->desired),
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1191 (ALbyte*) data->sample->buffer,
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1192 data->total_bytes,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1193 data->sample->desired.rate
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1194 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1195 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1196
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1197 /* I was trying to set to the end, (1 byte remaining),
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1198 * but I was getting freezes. I'm thinking it might be
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1199 * another Power of 2 bug in the Loki dist. I tried 2,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1200 * and it still hung. 4 didn't hang, but I got a clip
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1201 * artifact. 8 seemed to work okay.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1202 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1203 alBufferData(data->buffer[0],
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1204 TranslateFormat(&data->sample->desired),
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1205 (((ALbyte*) data->sample->buffer) + (data->total_bytes - 8) ),
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1206 8,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1207 data->sample->desired.rate
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1208 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1209 if( (error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1210 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1211 ALmixer_SetError("Can't seek past end and alBufferData failed: %s\n", alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1212 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1213 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1214 /* Need to set the loaded_bytes field because I don't trust the OpenAL
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1215 * query command to work because I don't know if it will mutilate the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1216 * size for its own purposes or return the original size
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1217 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1218 data->loaded_bytes = 8;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1219
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1220 /* Not sure if this should be an error or not */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1221 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1222 ALmixer_SetError("Can't Seek past end");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1223 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1224 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1225 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1226 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1227
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1228 alBufferData(data->buffer[0],
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1229 TranslateFormat(&data->sample->desired),
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1230 &(((ALbyte*)data->sample->buffer)[byte_position]),
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1231 data->total_bytes - byte_position,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1232 data->sample->desired.rate
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1233 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1234 if( (error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1235 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1236 ALmixer_SetError("alBufferData failed: %s\n", alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1237 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1238 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1239 /* Need to set the loaded_bytes field because I don't trust the OpenAL
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1240 * query command to work because I don't know if it will mutilate the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1241 * size for its own purposes or return the original size
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1242 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1243 data->loaded_bytes = data->total_bytes - byte_position;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1244
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1245 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1246 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1247
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1248 /* Because we have multiple queue buffers and OpenAL won't let
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1249 * us access them, we need to keep copies of each buffer around
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1250 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1251 static ALint CopyDataToAccessBuffer(ALmixer_Data* data, ALuint num_bytes, ALuint buffer)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1252 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1253 ALint index;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1254 /* We only want to copy if access_data is true.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1255 * This is determined by whether memory has been
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1256 * allocated in the buffer_map_list or not
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1257 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1258 if(NULL == data->buffer_map_list)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1259 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1260 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1261 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1262 index = LookUpBuffer(buffer, data->buffer_map_list, data->max_queue_buffers);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1263 if(-1 == index)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1264 {
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
1265 /*
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1266 fprintf(stderr, ">>>>>>>CopyData catch, albuffer=%d\n",buffer);
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
1267 */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1268 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1269 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1270 /* Copy the data to the access buffer */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1271 memcpy(data->buffer_map_list[index].data, data->sample->buffer, num_bytes);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1272 data->buffer_map_list[index].num_bytes = data->sample->buffer_size;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1273
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1274 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1275 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1276
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1277
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1278 /* For streamed data, gets more data
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1279 * and prepares it in the active Mix_chunk
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1280 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1281 static ALuint GetMoreData(ALmixer_Data* data, ALuint buffer)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1282 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1283 ALuint bytes_decoded;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1284 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1285 if(NULL == data)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1286 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1287 ALmixer_SetError("Cannot GetMoreData() because ALmixer_Data* is NULL\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1288 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1289 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1290
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1291 bytes_decoded = Sound_Decode(data->sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1292 if(data->sample->flags & SOUND_SAMPLEFLAG_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1293 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1294 fprintf(stderr, "Sound_Decode triggered an ERROR>>>>>>\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1295 ALmixer_SetError(Sound_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1296 /* Force cleanup through FreeData
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1297 Sound_FreeSample(data->sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1298 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1299 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1300 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1301
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1302 /* fprintf(stderr, "GetMoreData bytes_decoded=%d\n", bytes_decoded); */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1303
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1304 /* Don't forget to add check for EOF */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1305 /* Will return 0 bytes and pass the buck to check sample->flags */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1306 if(0 == bytes_decoded)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1307 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1308 data->eof = 1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1309
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1310 #if 0
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1311 fprintf(stderr, "Hit eof while trying to buffer\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1312 if(data->sample->flags & SOUND_SAMPLEFLAG_EOF)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1313 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1314 fprintf(stderr, "\tEOF flag\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1315 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1316 if(data->sample->flags & SOUND_SAMPLEFLAG_CANSEEK)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1317 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1318 fprintf(stderr, "\tCanSeek flag\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1319 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1320 if(data->sample->flags & SOUND_SAMPLEFLAG_EAGAIN)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1321 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1322 fprintf(stderr, "\tEAGAIN flag\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1323 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1324 if(data->sample->flags & SOUND_SAMPLEFLAG_NONE)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1325 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1326 fprintf(stderr, "\tNONE flag\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1327 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1328 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1329 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1330 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1331
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1332 #ifdef ENABLE_LOKI_QUEUE_FIX_HACK
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1333 /******* REMOVE ME ********************************/
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1334 /***************** ANOTHER EXPERIEMENT *******************/
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1335 /* The PROBLEM: It seems that the Loki distribution has problems
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1336 * with Queuing when the buffer size is not a power of two
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1337 * and additional buffers must come after it.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1338 * The behavior is inconsistent, but one of several things
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1339 * usually happens:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1340 * Playback is normal
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1341 * Playback immediately stops after the non-pow2 buffer
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1342 * Playback gets distorted on the non-pow2 buffer
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1343 * The entire program segfaults.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1344 * The workaround is to always specify a power of two buffer size
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1345 * and hope that SDL_sound always fill it. (By lucky coincidence,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1346 * I already submitted the Ogg fix.) However, this won't catch
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1347 * cases where a loop happens because the read at the end of the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1348 * file is typically less than the buffer size.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1349 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1350 * This fix addresses this issue, however it may break in
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1351 * other conditions. Always decode in buffer sizes of powers of 2.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1352 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1353 * The HACK:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1354 * If the buffer is short, try filling it up with 0's
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1355 * to meet the user requested buffer_size which
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1356 * is probably a nice number OpenAL likes, in
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1357 * hopes to avoid a possible Loki bug with
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1358 * short buffers. If looping (which is the main
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1359 * reason for this), the negative side effect is
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1360 * that it may take longer for the loop to start
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1361 * because it must play dead silence. Or if the decoder
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1362 * doesn't guarantee to return the requested bytes
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1363 * (like Ogg), then you will get breakup in between
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1364 * packets.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1365 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1366 if( (bytes_decoded) < data->sample->buffer_size)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1367 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1368 ALubyte bit_depth;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1369 ALubyte signedness_value;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1370 int silence_value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1371 /* Crap, memset value needs to be the "silent" value,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1372 * but it will differ for signed/unsigned and bit depth
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1373 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1374 bit_depth = GetBitDepth(data->sample->desired.format);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1375 signedness_value = GetSignednessValue(data->sample->desired.format);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1376 if(ALMIXER_SIGNED_VALUE == signedness_value)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1377 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1378 /* I'm guessing that if it's signed, then 0 is the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1379 * "silent" value */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1380 silence_value = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1381 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1382 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1383 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1384 if(8 == bit_depth)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1385 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1386 /* If 8 bit, I'm guessing it's (2^7)-1 = 127 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1387 silence_value = 127;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1388 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1389 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1390 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1391 /* For 16 bit, I'm guessing it's (2^15)-1 = 32767 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1392 silence_value = 32767;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1393 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1394 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1395 /* Now fill up the rest of the data buffer with the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1396 * silence_value.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1397 * I don't think I have to worry about endian issues for
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1398 * this part since the data is for internal use only
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1399 * at this point.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1400 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1401 memset( &( ((ALbyte*)(data->sample->buffer))[bytes_decoded] ), silence_value, data->sample->buffer_size - bytes_decoded);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1402 /* Now reset the bytes_decoded to reflect the entire
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1403 * buffer to tell alBufferData what our full size is.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1404 */
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
1405 /*
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1406 fprintf(stderr, "ALTERED bytes decoded for silence: Original end was %d\n", bytes_decoded);
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
1407 */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1408 bytes_decoded = data->sample->buffer_size;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1409 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1410 /*********** END EXPERIMENT ******************************/
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1411 /******* END REMOVE ME ********************************/
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1412 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1413
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1414 /* Now copy the data to the OpenAL buffer */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1415 /* We can't just set a pointer because the API needs
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1416 * its own copy to assist hardware acceleration */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1417 alBufferData(buffer,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1418 TranslateFormat(&data->sample->desired),
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1419 data->sample->buffer,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1420 bytes_decoded,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1421 data->sample->desired.rate
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1422 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1423 if( (error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1424 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1425 ALmixer_SetError("alBufferData failed: %s\n", alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1426 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1427 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1428
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1429 /* If we need to, copy the data also to the access area
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1430 * (the function will do the check for us)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1431 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1432 CopyDataToAccessBuffer(data, bytes_decoded, buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1433 return bytes_decoded;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1434 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1435
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1436
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1437
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1438
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1439 /******************** EXPERIEMENT ****************************
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1440 * Test function to force maximum buffer filling during loops
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1441 * REMOVE LATER
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1442 *********************************************/
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1443 #if 0
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1444 static ALint GetMoreData2(ALmixer_Data* data, ALuint buffer)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1445 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1446 ALint bytes_decoded;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1447 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1448 if(NULL == data)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1449 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1450 ALmixer_SetError("Cannot GetMoreData() because ALmixer_Data* is NULL\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1451 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1452 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1453
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1454 if(AL_FALSE == alIsBuffer(buffer))
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1455 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1456 fprintf(stderr, "NOT A BUFFER>>>>>>>>>>>>>>>\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1457 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1458 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1459 fprintf(stderr, "Entered GetMoreData222222: buffer id is %d\n", buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1460
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1461 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1462 fprintf(stderr, "Decode in GetMoreData\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1463 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1464
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1465 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1466 if(buffer%2 == 1)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1467 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1468 fprintf(stderr, "Setting buffer size to 16384\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1469 Sound_SetBufferSize(data->sample, 16384);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1470 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1471 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1472 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1473 fprintf(stderr, "Setting buffer size to 8192\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1474 Sound_SetBufferSize(data->sample, 8192);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1475 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1476 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1477
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1478 bytes_decoded = Sound_Decode(data->sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1479 if(data->sample->flags & SOUND_SAMPLEFLAG_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1480 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1481 fprintf(stderr, "Sound_Decode triggered an ERROR>>>>>>\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1482 ALmixer_SetError(Sound_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1483 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1484 Sound_FreeSample(data->sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1485 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1486 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1487 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1488 /* Don't forget to add check for EOF */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1489 /* Will return 0 bytes and pass the buck to check sample->flags */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1490 if(0 == bytes_decoded)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1491 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1492 #if 1
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1493 fprintf(stderr, "Hit eof while trying to buffer\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1494 data->eof = 1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1495 if(data->sample->flags & SOUND_SAMPLEFLAG_EOF)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1496 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1497 fprintf(stderr, "\tEOF flag\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1498 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1499 if(data->sample->flags & SOUND_SAMPLEFLAG_CANSEEK)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1500 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1501 fprintf(stderr, "\tCanSeek flag\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1502 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1503 if(data->sample->flags & SOUND_SAMPLEFLAG_EAGAIN)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1504 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1505 fprintf(stderr, "\tEAGAIN flag\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1506 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1507 if(data->sample->flags & SOUND_SAMPLEFLAG_NONE)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1508 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1509 fprintf(stderr, "\tNONE flag\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1510 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1511 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1512 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1513 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1514
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1515 if(bytes_decoded < 16384)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1516 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1517 char* tempbuffer1 = (char*)malloc(16384);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1518 char* tempbuffer2 = (char*)malloc(16384);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1519 int retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1520 memcpy(tempbuffer1, data->sample->buffer, bytes_decoded);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1521 retval = Sound_SetBufferSize(data->sample, 16384-bytes_decoded);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1522 if(retval == 1)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1523 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1524 ALuint new_bytes;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1525 Sound_Rewind(data->sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1526 new_bytes = Sound_Decode(data->sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1527 fprintf(stderr, "Orig bytes: %d, Make up bytes_decoded=%d, total=%d\n", bytes_decoded, new_bytes, new_bytes+bytes_decoded);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1528
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1529 memcpy(tempbuffer2, data->sample->buffer, new_bytes);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1530
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1531 retval = Sound_SetBufferSize(data->sample, 16384);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1532 fprintf(stderr, "Finished reset...now danger copy\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1533 memcpy(data->sample->buffer, tempbuffer1,bytes_decoded);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1534
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1535 fprintf(stderr, "Finished reset...now danger copy2\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1536 memcpy( &( ((char*)(data->sample->buffer))[bytes_decoded] ), tempbuffer2, new_bytes);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1537
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1538 fprintf(stderr, "Finished \n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1539
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1540 free(tempbuffer1);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1541 free(tempbuffer2);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1542 bytes_decoded += new_bytes;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1543 fprintf(stderr, "ASSERT bytes should equal 16384: %d\n", bytes_decoded);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1544 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1545 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1546 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1547 fprintf(stderr, "Experiment failed: %s\n", Sound_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1548 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1549 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1550
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1551 /* Now copy the data to the OpenAL buffer */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1552 /* We can't just set a pointer because the API needs
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1553 * its own copy to assist hardware acceleration */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1554 alBufferData(buffer,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1555 TranslateFormat(&data->sample->desired),
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1556 data->sample->buffer,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1557 bytes_decoded,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1558 data->sample->desired.rate
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1559 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1560 if( (error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1561 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1562 ALmixer_SetError("alBufferData failed: %s\n", alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1563 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1564 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1565
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1566 fprintf(stderr, "GetMoreData2222 returning %d bytes decoded\n", bytes_decoded);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1567 return bytes_decoded;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1568 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1569 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1570
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1571 /************ END EXPERIEMENT - REMOVE ME *************************/
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1572
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1573
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1574
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1575
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1576
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1577
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1578
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1579
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1580
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1581 /* This function will look up the source for the corresponding channel */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1582 /* Must return 0 on error instead of -1 because of unsigned int */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1583 static ALuint Internal_GetSource(ALint channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1584 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1585 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1586 /* Make sure channel is in bounds */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1587 if(channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1588 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1589 ALmixer_SetError("Requested channel (%d) exceeds maximum channel (%d) because only %d channels are allocated", channel, Number_of_Channels_global-1, Number_of_Channels_global);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1590 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1591 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1592 /* If the user specified -1, then return the an available source */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1593 if(channel < 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1594 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1595 for(i=Number_of_Reserve_Channels_global; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1596 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1597 if( ! ALmixer_Channel_List[i].channel_in_use )
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1598 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1599 return ALmixer_Channel_List[i].alsource;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1600 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1601 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1602 /* If we get here, all sources are in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1603 /* Error message seems too harsh
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1604 ALmixer_SetError("All sources are in use");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1605 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1606 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1607 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1608 /* Last case: Return the source for the channel */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1609 return ALmixer_Channel_List[channel].alsource;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1610 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1611
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1612 /* This function will look up the channel for the corresponding source */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1613 static ALint Internal_GetChannel(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1614 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1615 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1616 /* Only the first value is used for the key */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1617 Source_Map key = { 0, 0 };
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1618 Source_Map* found_item = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1619 key.source = source;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1620
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1621 /* If the source is 0, look up the first available channel */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1622 if(0 == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1623 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1624 for(i=Number_of_Reserve_Channels_global; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1625 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1626 if( ! ALmixer_Channel_List[i].channel_in_use )
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1627 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1628 return i;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1629 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1630 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1631 /* If we get here, all sources are in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1632 /* Error message seems too harsh
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1633 ALmixer_SetError("All channels are in use");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1634 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1635 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1636 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1637
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1638
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1639 /* Else, look up the source and return the channel */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1640 if(AL_FALSE == alIsSource(source))
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1641 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1642 ALmixer_SetError("Is not a source");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1643 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1644 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1645
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1646 /* Use the ANSI C binary search feature (yea!) */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1647 found_item = (Source_Map*)bsearch(&key, Source_Map_List, Number_of_Channels_global, sizeof(Source_Map), Compare_Source_Map);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1648 if(NULL == found_item)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1649 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1650 ALmixer_SetError("Source is valid but not registered with ALmixer (to a channel)");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1651 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1652 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1653 return found_item->channel;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1654 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1655
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1656
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1657
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1658 /* This function will find the first available channel (not in use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1659 * from the specified start channel. Reserved channels to not qualify
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1660 * as available.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1661 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1662 static ALint Internal_FindFreeChannel(ALint start_channel)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1663 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1664 /* Start at the number of reserved so we skip over
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1665 * all the reserved channels.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1666 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1667 ALint i = Number_of_Reserve_Channels_global;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1668 /* Quick check to see if we're out of bounds */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1669 if(start_channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1670 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1671 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1672 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1673
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1674 /* If the start channel is even higher than the reserved,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1675 * then start at the higher value.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1676 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1677 if(start_channel > Number_of_Reserve_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1678 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1679 i = start_channel;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1680 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1681
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1682 /* i has already been set */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1683 for( ; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1684 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1685 if( ! ALmixer_Channel_List[i].channel_in_use )
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1686 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1687 return i;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1688 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1689 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1690 /* If we get here, all sources are in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1691 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1692 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1693
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1694
48
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1695 static ALboolean Internal_DetachBuffersFromSource(ALuint source_id, ALboolean is_predecoded)
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1696 {
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1697 ALboolean retval = AL_TRUE;
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1698 ALenum error;
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1699 /* Here's the situation. My old method of using
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1700 * alSourceUnqueueBuffers() seemed to be invalid in light
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1701 * of all the problems I suffered through with getting
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1702 * the CoreData backend to work with this code.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1703 * As such, I'm changing all the code to set the buffer to
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1704 * AL_NONE. Furthermore, the queued vs. non-queued issue
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1705 * doesn't need to apply here. For non-queued, Loki,
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1706 * Creative Windows, and CoreAudio seem to leave the
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1707 * buffer queued (Old Mac didn't.) For queued, we need to
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1708 * remove the processed buffers and force remove the
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1709 * still-queued buffers.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1710 * Update: This code is was changed agian due to a serious regression bug in iOS 5.0
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1711 * Since the 1.1 spec, I think I can make some simplifying assumptions sans the iOS 5.0 bug.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1712 * Before I looked at buffers_still_queued and buffers_processed.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1713 * According to the spec, all buffers get marked processed when alSourceStop is called.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1714 * Also, in addition, alSourcei(source, AL_BUFFER, AL_NONE) is supposed
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1715 * to detach buffers for both streamed and non-streamed so all the code
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1716 * should just go through that.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1717 * Unfortunately, the iOS 5.0 bug doesn't detach/clear buffers with AL_NONE.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1718 * So I need a special handler for iOS 5.0 which manually unqueues the buffers.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1719 * Ironically, I think the original Mac version did not work reliably
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1720 * with unqueuing buffers which is why I moved the code to the AL_NONE
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1721 * solution in the first place. This means for safety, I need to
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1722 * conditionalize the workaround as not to risk breaking Mac or other * platforms.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1723 */
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1724 #ifdef __APPLE__ /* iOS 5.0 workaround */
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1725 #if (TARGET_OS_IPHONE == 1) || (TARGET_IPHONE_SIMULATOR == 1)
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1726 /*
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1727 fprintf(stderr, "kCFCoreFoundationVersionNumber: %lf\n", kCFCoreFoundationVersionNumber);
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1728 */
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1729 /* I needed a C way to get the iOS version at runtime. This is returning 674.0 iOS 5.0 Beta 7. Apple hasn't updated the headers
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1730 * for these constants since iOS 4.2, so I don't know if the value is also catching 4.3.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1731 * TODO: Once I learn which version Apple fixes the bug in, I need to update the range so this check is not run on fixed versions.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1732 */
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1733 if(kCFCoreFoundationVersionNumber >= 674.0)
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1734 {
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1735 if(AL_FALSE == is_predecoded)
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1736 {
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1737 ALint buffers_processed;
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1738 /* Wow this is the bug that just keeps on sucking. There is even a race condition bug where the unqueue may not actually work.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1739 * So I have to keep doing it until it does.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1740 */
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1741 do
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1742 {
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1743 ALint temp_count;
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1744
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1745 /* Wow this is the bug that just keeps on sucking. There is even a race condition bug where the unqueue may not actually work.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1746 * So I have to keep doing it until it does.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1747 * Sleeping for 20ms seems to help. 10ms was not long enough. (iPad 2)
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1748 */
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1749 ALmixer_Delay(20);
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1750
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1751 alGetSourcei(
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1752 source_id,
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1753 AL_BUFFERS_PROCESSED, &buffers_processed
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1754 );
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1755 if((error = alGetError()) != AL_NO_ERROR)
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1756 {
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1757 fprintf(stderr, "17aTesting Error with buffers_processed on Halt. (You may be seeing this because of a bad Apple OpenAL iOS 5.0 regression bug): %s",
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1758 alGetString(error));
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1759 ALmixer_SetError("Failed detecting still processed buffers: %s",
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1760 alGetString(error) );
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1761 /* This whole iOS 5.0 bug is so messed up that returning an error value probably isn't helpful.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1762 retval = AL_FALSE;
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1763 */
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1764 }
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1765 /*
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1766 fprintf(stderr, "Going to unqueue %d buffers\n", buffers_processed);
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1767 */
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1768 for(temp_count=0; temp_count<buffers_processed; temp_count++)
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1769 {
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1770 ALuint unqueued_buffer_id;
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1771
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1772 alSourceUnqueueBuffers(
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1773 source_id,
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1774 1, &unqueued_buffer_id
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1775 );
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1776 if((error = alGetError()) != AL_NO_ERROR)
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1777 {
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1778 fprintf(stderr, "17bTesting error with unqueuing buffers on Halt (You may be seeing this because of a bad Apple OpenAL iOS 5.0 regression bug): %s\n",
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1779 alGetString(error));
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1780 /* This whole iOS 5.0 bug is so messed up that returning an error value probably isn't helpful.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1781 retval = AL_FALSE;
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1782 */
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1783 }
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1784 }
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1785
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1786 alGetSourcei(
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1787 source_id,
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1788 AL_BUFFERS_PROCESSED, &buffers_processed
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1789 );
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1790 if((error = alGetError()) != AL_NO_ERROR)
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1791 {
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1792 fprintf(stderr, "17cTesting Error with buffers_processed on Halt. (You may be seeing this because of a bad Apple OpenAL iOS 5.0 regression bug): %s",
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1793 alGetString(error));
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1794 ALmixer_SetError("Failed detecting still processed buffers: %s",
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1795 alGetString(error) );
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1796 /* This whole iOS 5.0 bug is so messed up that returning an error value probably isn't helpful.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1797 retval = AL_FALSE;
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1798 */
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1799 }
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1800 /*
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1801 fprintf(stderr, "unqueued buffers should be 0. Actual value is %d\n", buffers_processed);
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1802 */
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1803 /* Wow this is the bug that just keeps on sucking. There is an additional race condition bug where the unqueue may not actually work.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1804 * So I have to keep doing it until it does.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1805 * I hope this doesn't infinite loop.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1806 */
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1807 if(0 != buffers_processed)
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1808 {
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1809 fprintf(stderr, "Evil Apple OpenAL iOS 5.0 race condition. Buffers didn't actually unqueue. Repeating unqueue loop.\n");
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1810 }
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1811 } while(0 != buffers_processed);
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1812
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1813 }
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1814 }
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1815
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1816
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1817 #endif
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1818 #endif /* iOS 5.0 workaround */
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1819
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1820 /* According to the spec, this is the best way to clear a source.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1821 * This is supposed to work for both streamed and non-streamed sources.
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1822 */
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1823 alSourcei(source_id, AL_BUFFER, AL_NONE);
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1824 if((error = alGetError()) != AL_NO_ERROR)
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1825 {
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1826 fprintf(stderr, "17dTesting Error with clearing buffer from source: %s",
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1827 alGetString(error));
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1828 ALmixer_SetError("Failed to clear buffer from source: %s",
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1829 alGetString(error) );
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1830 retval = AL_FALSE;
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1831 }
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1832
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1833 return retval;
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1834 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1835
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1836 /* Will return the number of channels halted
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1837 * or 0 for error
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1838 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1839 static ALint Internal_HaltChannel(ALint channel, ALboolean did_finish_naturally)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1840 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1841 ALint retval = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1842 ALint counter = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1843 ALenum error;
48
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1844 ALboolean clear_succeeded;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1845
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1846 if(channel >= Number_of_Channels_global)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1847 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1848 ALmixer_SetError("Cannot halt channel %d because it exceeds maximum number of channels (%d)\n", channel, Number_of_Channels_global);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1849 return -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1850 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1851 /* If the user specified a specific channel */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1852 if(channel >= 0)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1853 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1854 /* only need to process channel if in use */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1855 if(ALmixer_Channel_List[channel].channel_in_use)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1856 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1857 alSourceStop(ALmixer_Channel_List[channel].alsource);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1858 if((error = alGetError()) != AL_NO_ERROR)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1859 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1860 fprintf(stderr, "14Testing error: %s\n",
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1861 alGetString(error));
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1862 }
48
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1863
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1864 clear_succeeded = Internal_DetachBuffersFromSource(ALmixer_Channel_List[channel].alsource, ALmixer_Channel_List[channel].almixer_data->decoded_all);
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1865 if(AL_FALSE == clear_succeeded)
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1866 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1867 retval = -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1868 }
48
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1869
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1870
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1871 ALmixer_Channel_List[channel].almixer_data->num_buffers_in_use = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1872
10
c808684660a7 Bug fix: Moved Invoke_Callback before CleanChannel because I was trying to get the ALmixer_Data pointer, but it was cleared:
Eric Wing <ewing . public |-at-| gmail . com>
parents: 6
diff changeset
1873 /* Launch callback for consistency? */
c808684660a7 Bug fix: Moved Invoke_Callback before CleanChannel because I was trying to get the ALmixer_Data pointer, but it was cleared:
Eric Wing <ewing . public |-at-| gmail . com>
parents: 6
diff changeset
1874 Invoke_Channel_Done_Callback(channel, did_finish_naturally);
c808684660a7 Bug fix: Moved Invoke_Callback before CleanChannel because I was trying to get the ALmixer_Data pointer, but it was cleared:
Eric Wing <ewing . public |-at-| gmail . com>
parents: 6
diff changeset
1875
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1876 Clean_Channel(channel);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1877 Is_Playing_global--;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1878 counter++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1879 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1880 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1881 /* The user wants to halt all channels */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1882 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1883 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1884 ALint i;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1885 for(i=0; i<Number_of_Channels_global; i++)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1886 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1887 /* only need to process channel if in use */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1888 if(ALmixer_Channel_List[i].channel_in_use)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1889 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1890 alSourceStop(ALmixer_Channel_List[i].alsource);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1891 if((error = alGetError()) != AL_NO_ERROR)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1892 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1893 fprintf(stderr, "19Testing error: %s\n",
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1894 alGetString(error));
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1895 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1896
48
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1897 clear_succeeded = Internal_DetachBuffersFromSource(ALmixer_Channel_List[i].alsource, ALmixer_Channel_List[i].almixer_data->decoded_all);
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1898 if(AL_FALSE == clear_succeeded)
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1899 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1900 retval = -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1901 }
48
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
1902
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1903 ALmixer_Channel_List[i].almixer_data->num_buffers_in_use = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1904
10
c808684660a7 Bug fix: Moved Invoke_Callback before CleanChannel because I was trying to get the ALmixer_Data pointer, but it was cleared:
Eric Wing <ewing . public |-at-| gmail . com>
parents: 6
diff changeset
1905 /* Launch callback for consistency? */
c808684660a7 Bug fix: Moved Invoke_Callback before CleanChannel because I was trying to get the ALmixer_Data pointer, but it was cleared:
Eric Wing <ewing . public |-at-| gmail . com>
parents: 6
diff changeset
1906 Invoke_Channel_Done_Callback(i, did_finish_naturally);
c808684660a7 Bug fix: Moved Invoke_Callback before CleanChannel because I was trying to get the ALmixer_Data pointer, but it was cleared:
Eric Wing <ewing . public |-at-| gmail . com>
parents: 6
diff changeset
1907
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1908 Clean_Channel(i);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1909 Is_Playing_global--;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1910
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1911 /* Increment the counter */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1912 counter++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1913 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1914 /* Let's halt everything just in case there
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1915 * are bugs.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1916 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1917 /*
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1918 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1919 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1920 alSourceStop(ALmixer_Channel_List[channel].alsource);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1921 / * Can't clean because the in_use counter for
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1922 * data will get messed up * /
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1923 Clean_Channel(channel);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1924 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1925 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1926 /* Just in case */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1927 Is_Playing_global = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1928 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1929 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1930 if(-1 == retval)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1931 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1932 return -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1933 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1934 return counter;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1935 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1936
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1937
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1938 /* Will return the source halted or the total number of channels
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1939 * if all were halted or 0 for error
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1940 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1941 static ALint Internal_HaltSource(ALuint source, ALboolean did_finish_naturally)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1942 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1943 ALint channel;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1944 if(0 == source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1945 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1946 /* Will return the number of sources halted */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1947 return Internal_HaltChannel(-1, did_finish_naturally);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1948 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1949
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1950 channel = Internal_GetChannel(source);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1951 if(-1 == channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1952 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1953 ALmixer_SetError("Cannot halt source: %s", ALmixer_GetError());
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1954 return -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1955 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1956 return Internal_HaltChannel(channel, did_finish_naturally);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1957 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1958
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1959
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1960
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1961 /* Note: Behaves, almost like SDL_mixer, but keep in mind
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1962 * that there is no "music" channel anymore, so 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1963 * will remove everything. (Note, I no longer allow 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1964 * so it gets set to the default number.)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1965 * Also, callbacks for deleted channels will not be called.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1966 * I really need to do error checking, for realloc and
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1967 * GenSources, but reversing the damage is too painful
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1968 * for me to think about at the moment, so it's not in here.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1969 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
1970 static ALint Internal_AllocateChannels(ALint numchans)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1971 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1972 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1973 int i;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1974 /* Return info */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1975 if(numchans < 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1976 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1977 return Number_of_Channels_global;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1978 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1979 if(0 == numchans)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1980 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1981 numchans = ALMIXER_DEFAULT_NUM_CHANNELS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1982 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1983 /* No change */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1984 if(numchans == Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1985 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1986 return Number_of_Channels_global;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1987 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1988 /* We need to increase the number of channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1989 if(numchans > Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1990 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1991 /* Not sure how safe this is, but SDL_mixer does it
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1992 * the same way */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1993 ALmixer_Channel_List = (struct ALmixer_Channel*) realloc( ALmixer_Channel_List, numchans * sizeof(struct ALmixer_Channel));
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1994
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1995 /* Allocate memory for the list of sources that map to the channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1996 Source_Map_List = (Source_Map*) realloc(Source_Map_List, numchans * sizeof(Source_Map));
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1997
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1998 for(i=Number_of_Channels_global; i<numchans; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1999 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2000 Init_Channel(i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2001 /* Generate a new source and associate it with the channel */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2002 alGenSources(1, &ALmixer_Channel_List[i].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2003 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2004 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2005 fprintf(stderr, "12Testing errpr before unqueue because getting stuff, for OS X this is expected: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2006 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2007 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2008 /* Copy the source so the SourceMap has it too */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2009 Source_Map_List[i].source = ALmixer_Channel_List[i].alsource;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2010 Source_Map_List[i].channel = i;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2011 /* Clean the channel because there are some things that need to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2012 * be done that can't happen until the source is set
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2013 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2014 Clean_Channel(i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2015 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2016
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2017 /* The Source_Map_List must be sorted by source for binary searches
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2018 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2019 qsort(Source_Map_List, numchans, sizeof(Source_Map), Compare_Source_Map);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2020
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2021 Number_of_Channels_global = numchans;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2022 return numchans;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2023 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2024 /* Need to remove channels. This might be dangerous */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2025 if(numchans < Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2026 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2027 for(i=numchans; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2028 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2029 /* Halt the channel */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2030 Internal_HaltChannel(i, AL_FALSE);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2031
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2032 /* Delete source associated with the channel */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2033 alDeleteSources(1, &ALmixer_Channel_List[i].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2034 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2035 {
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
2036 fprintf(stderr, "13bTesting error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2037 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2038 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2039 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2040
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2041
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2042 /* Not sure how safe this is, but SDL_mixer does it
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2043 * the same way */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2044 ALmixer_Channel_List = (struct ALmixer_Channel*) realloc( ALmixer_Channel_List, numchans * sizeof(struct ALmixer_Channel));
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2045
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2046 /* The tricky part is that we must remove the entries
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2047 * in the source map that correspond to the deleted channels.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2048 * We'll resort the map by channels so we can pick them off
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2049 * in order.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2050 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2051 qsort(Source_Map_List, Number_of_Channels_global, sizeof(Source_Map), Compare_Source_Map_by_channel);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2052
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2053 /* Deallocate memory for the list of sources that map to the channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2054 Source_Map_List = (Source_Map*) realloc(Source_Map_List, numchans * sizeof(Source_Map));
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2055
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2056 /* Now resort the map by source and the correct num of chans */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2057 qsort(Source_Map_List, numchans, sizeof(Source_Map), Compare_Source_Map);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2058
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2059 /* Reset the number of channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2060 Number_of_Channels_global = numchans;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2061 return numchans;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2062 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2063 /* Shouldn't ever reach here */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2064 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2065
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2066 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2067
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2068 static ALint Internal_ReserveChannels(ALint num)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2069 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2070 /* Can't reserve more than the max num of channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2071 /* Actually, I'll allow it for people who just want to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2072 * set the value really high to effectively disable
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2073 * auto-assignment
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2074 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2075
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2076 /* Return the current number of reserved channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2077 if(num < 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2078 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2079 return Number_of_Reserve_Channels_global;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2080 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2081 Number_of_Reserve_Channels_global = num;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2082 return Number_of_Reserve_Channels_global;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2083 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2084
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2085
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2086 /* This will rewind the SDL_Sound sample for streamed
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2087 * samples and start buffering up the data for the next
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2088 * playback. This may require samples to be halted
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2089 */
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2090 static ALboolean Internal_RewindData(ALmixer_Data* data)
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2091 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2092 ALint retval = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2093 /*
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2094 ALint bytes_returned;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2095 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2096 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2097 if(NULL == data)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2098 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2099 ALmixer_SetError("Cannot rewind because data is NULL\n");
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2100 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2101 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2102
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2103
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2104 /* Might have to require Halt */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2105 /* Okay, we assume Halt or natural stop has already
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2106 * cleared the data buffers
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2107 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2108 if(data->in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2109 {
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
2110 /*
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2111 fprintf(stderr, "Warning sample is in use. May not be able to rewind\n");
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
2112 */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2113 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2114 ALmixer_SetError("Data is in use. Cannot rewind unless all sources using the data are halted\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2115 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2116 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2117 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2118
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2119
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2120 /* Because Seek can alter things even in predecoded data,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2121 * decoded data must also be rewound
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2122 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2123 if(data->decoded_all)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2124 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2125 data->eof = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2126
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2127 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2128 #if defined(DISABLE_PREDECODED_SEEK)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2129 /* Since we can't seek predecoded stuff, it should be rewound */
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2130 return AL_TRUE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2131 #elif !defined(DISABLE_SEEK_MEMORY_OPTIMIZATION)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2132 /* This case is if the Sound_Sample has been deleted.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2133 * It assumes the data is already at the beginning.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2134 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2135 if(NULL == data->sample)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2136 {
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2137 return AL_TRUE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2138 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2139 /* Else, the sample has already been reallocated,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2140 * and we can fall to normal behavior
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2141 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2142 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2143 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2144 /* If access_data, was enabled, the sound sample
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2145 * still exists and we can do stuff.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2146 * If it's NULL, we can't do anything, but
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2147 * it should already be "rewound".
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2148 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2149 if(NULL == data->sample)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2150 {
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2151 return AL_TRUE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2152 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2153 /* Else, the sample has already been reallocated,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2154 * and we can fall to normal behavior
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2155 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2156
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2157 Set_Predecoded_Seek_Position(data, 0);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2158 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2159 return data->total_bytes;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2160 */
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2161 return AL_TRUE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2162 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2163
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2164 /* Remaining stuff for streamed data */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2165
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2166 data->eof = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2167 retval = Sound_Rewind(data->sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2168 if(0 == retval)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2169 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2170 ALmixer_SetError( Sound_GetError() );
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2171 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2172 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2173 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2174 /* Clear error */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2175 alGetError();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2176 for(i=0; i<data->num_buffers; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2177 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2178 bytes_returned = GetMoreData(data, data->buffer[i]);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2179 if(-1 == bytes_returned)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2180 {
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2181 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2182 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2183 else if(0 == bytes_returned)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2184 {
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2185 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2186 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2187 retval += bytes_returned;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2188
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2189 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2190 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2191
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2192
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2193
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2194 return AL_TRUE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2195 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2196
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2197
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2198
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2199
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2200 static ALint Internal_RewindChannel(ALint channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2201 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2202 ALint retval = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2203 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2204 ALint state;
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2205 ALint running_count = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2206
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2207 if(channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2208 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2209 ALmixer_SetError("Cannot rewind channel %d because it exceeds maximum number of channels (%d)\n", channel, Number_of_Channels_global);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2210 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2211 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2212
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2213 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2214 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2215 fprintf(stderr, "24Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2216 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2217 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2218 /* Clear error */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2219 alGetError();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2220
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2221 /* If the user specified a specific channel */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2222 if(channel >= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2223 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2224 /* only need to process channel if in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2225 if(ALmixer_Channel_List[channel].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2226 {
49
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
2227 running_count = 1;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2228 /* What should I do? Do I just rewind the channel
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2229 * or also rewind the data? Since the data is
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2230 * shared, let's make it the user's responsibility
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2231 * to rewind the data.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2232 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2233 if(ALmixer_Channel_List[channel].almixer_data->decoded_all)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2234 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2235 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2236 ALmixer_Channel_List[channel].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2237 AL_SOURCE_STATE, &state
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2238 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2239 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2240 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2241 fprintf(stderr, "25Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2242 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2243 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2244 alSourceRewind(ALmixer_Channel_List[channel].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2245 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2246 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2247 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2248 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2249 retval = -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2250 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2251 /* Need to resume playback if it was originally playing */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2252 if(AL_PLAYING == state)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2253 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2254 alSourcePlay(ALmixer_Channel_List[channel].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2255 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2256 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2257 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2258 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2259 retval = -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2260 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2261 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2262 else if(AL_PAUSED == state)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2263 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2264 /* HACK: The problem is that when paused, after
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2265 * the Rewind, I can't get it off the INITIAL
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2266 * state without restarting
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2267 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2268 alSourcePlay(ALmixer_Channel_List[channel].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2269 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2270 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2271 fprintf(stderr, "25Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2272 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2273 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2274 alSourcePause(ALmixer_Channel_List[channel].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2275 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2276 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2277 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2278 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2279 retval = -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2280 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2281 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2282 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2283 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2284 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2285 /* Streamed data is different. Rewinding the channel
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2286 * does no good. Rewinding the data will have an
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2287 * effect, but it will be lagged based on how
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2288 * much data is queued. Recommend users call Halt
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2289 * before rewind if they want immediate results.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2290 */
49
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
2291 if(AL_FALSE == Internal_RewindData(ALmixer_Channel_List[channel].almixer_data))
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
2292 {
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
2293 retval = -1;
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
2294 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2295 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2296 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2297 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2298 /* The user wants to rewind all channels */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2299 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2300 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2301 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2302 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2303 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2304 /* only need to process channel if in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2305 if(ALmixer_Channel_List[i].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2306 {
49
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
2307 running_count++;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2308 /* What should I do? Do I just rewind the channel
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2309 * or also rewind the data? Since the data is
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2310 * shared, let's make it the user's responsibility
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2311 * to rewind the data.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2312 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2313 if(ALmixer_Channel_List[i].almixer_data->decoded_all)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2314 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2315 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2316 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2317 AL_SOURCE_STATE, &state
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2318 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2319 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2320 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2321 fprintf(stderr, "26Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2322 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2323 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2324 alSourceRewind(ALmixer_Channel_List[i].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2325 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2326 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2327 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2328 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2329 retval = -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2330 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2331 /* Need to resume playback if it was originally playing */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2332 if(AL_PLAYING == state)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2333 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2334 alSourcePlay(ALmixer_Channel_List[i].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2335 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2336 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2337 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2338 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2339 retval = -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2340 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2341 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2342 else if(AL_PAUSED == state)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2343 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2344 /* HACK: The problem is that when paused, after
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2345 * the Rewind, I can't get it off the INITIAL
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2346 * state without restarting
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2347 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2348 alSourcePlay(ALmixer_Channel_List[i].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2349 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2350 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2351 fprintf(stderr, "27Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2352 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2353 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2354 alSourcePause(ALmixer_Channel_List[i].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2355 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2356 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2357 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2358 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2359 retval = -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2360 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2361 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2362 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2363 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2364 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2365 /* Streamed data is different. Rewinding the channel
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2366 * does no good. Rewinding the data will have an
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2367 * effect, but it will be lagged based on how
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2368 * much data is queued. Recommend users call Halt
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2369 * before rewind if they want immediate results.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2370 */
49
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
2371 if(AL_FALSE == Internal_RewindData(ALmixer_Channel_List[i].almixer_data))
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
2372 {
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
2373 retval = -1;
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
2374 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2375 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2376 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2377 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2378 }
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2379 if(-1 == retval)
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2380 {
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2381 return -1;
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2382 }
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2383 else
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2384 {
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2385 return running_count;
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2386 }
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
2387
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2388 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2389
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2390
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2391 static ALint Internal_RewindSource(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2392 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2393 ALint channel;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2394 if(0 == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2395 {
20
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
2396 return Internal_RewindChannel(-1);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2397 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2398
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2399 channel = Internal_GetChannel(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2400 if(-1 == channel)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2401 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2402 ALmixer_SetError("Cannot rewind source: %s", ALmixer_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2403 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2404 }
20
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
2405 return Internal_RewindChannel(channel);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2406 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2407
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2408
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2409
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2410
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2411
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2412 static ALint Internal_PlayChannelTimed(ALint channel, ALmixer_Data* data, ALint loops, ALint ticks)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2413 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2414 ALenum error;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2415 int ret_flag = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2416 if(NULL == data)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2417 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2418 ALmixer_SetError("Can't play because data is NULL\n");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2419 return -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2420 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2421
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2422 /* There isn't a good way to share streamed files because
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2423 * the decoded data doesn't stick around.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2424 * You must "Load" a brand new instance of
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2425 * the data. If you try using the same data,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2426 * bad things may happen. This check will attempt
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2427 * to prevent sharing
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2428 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2429 if(0 == data->decoded_all)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2430 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2431 if(data->in_use)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2432 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2433 ALmixer_SetError("Can't play shared streamed sample because it is already in use");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2434 return -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2435 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2436
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2437 /* Make sure SDL_sound sample is not at EOF.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2438 * This mainly affects streamed files,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2439 * so the check is placed here
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2440 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2441 if(data->eof)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2442 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2443 if( -1 == Internal_RewindData(data) )
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2444 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2445 ALmixer_SetError("Can't play sample because it is at EOF and cannot rewind");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2446 return -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2447 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2448 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2449 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2450 /* We need to provide the user with the first available channel */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2451 if(-1 == channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2452 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2453 ALint i;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2454 for(i=Number_of_Reserve_Channels_global; i<Number_of_Channels_global; i++)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2455 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2456 if(0 == ALmixer_Channel_List[i].channel_in_use)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2457 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2458 channel = i;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2459 break;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2460 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2461 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2462 /* if we couldn't find a channel, return an error */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2463 if(i == Number_of_Channels_global)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2464 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2465 ALmixer_SetError("No channels available for playing");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2466 return -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2467 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2468 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2469 /* If we didn't assign the channel number, make sure it's not
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2470 * out of bounds or in use */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2471 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2472 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2473 if(channel >= Number_of_Channels_global)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2474 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2475 ALmixer_SetError("Requested channel (%d) exceeds maximum channel (%d) because only %d channels are allocated", channel, Number_of_Channels_global-1, Number_of_Channels_global);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2476 return -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2477 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2478 else if(ALmixer_Channel_List[channel].channel_in_use)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2479 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2480 ALmixer_SetError("Requested channel (%d) is in use", channel, Number_of_Channels_global-1, Number_of_Channels_global);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2481 return -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2482 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2483 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2484 /* Make sure the user doesn't enter some meaningless value */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2485 if(loops < -1)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2486 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2487 loops = -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2488 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2489
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2490 /* loops will probably have to change to be controlled by SDL_Sound */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2491
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2492 /* Set up the initial values for playing */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2493 ALmixer_Channel_List[channel].channel_in_use = 1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2494 data->in_use++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2495
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2496 /* Shouldn't need updating until a callback is fired
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2497 * (assuming that we call Play in this function
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2498 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2499 ALmixer_Channel_List[channel].needs_stream = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2500 ALmixer_Channel_List[channel].almixer_data = data;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2501 ALmixer_Channel_List[channel].start_time = ALmixer_GetTicks();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2502
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2503 /* If user entered -1 (or less), set to -1 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2504 if(ticks < 0)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2505 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2506 ALmixer_Channel_List[channel].expire_ticks = -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2507 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2508 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2509 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2510 ALmixer_Channel_List[channel].expire_ticks = ticks;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2511 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2512
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2513
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2514 ALmixer_Channel_List[channel].halted = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2515 ALmixer_Channel_List[channel].paused = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2516
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2517 /* Ran just use OpenAL to control loops if predecoded and infinite */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2518 ALmixer_Channel_List[channel].loops = loops;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2519 if( (-1 == loops) && (data->decoded_all) )
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2520 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2521 alSourcei(ALmixer_Channel_List[channel].alsource, AL_LOOPING, AL_TRUE);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2522 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2523 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2524 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2525 alSourcei(ALmixer_Channel_List[channel].alsource, AL_LOOPING, AL_FALSE);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2526 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2527 if((error = alGetError()) != AL_NO_ERROR)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2528 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2529 fprintf(stderr, "13Testing error: %s\n",
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2530 alGetString(error));
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2531 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2532
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2533 #if 0
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2534 /* Because of the corner case, predecoded
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2535 * files must add +1 to the loops.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2536 * Streams do not have this problem
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2537 * because they can use the eof flag to
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2538 * avoid the conflict.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2539 * Sharing data chunks prevents the use of the eof flag.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2540 * Since streams, cannot share, only predecoded
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2541 * files are affected
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2542 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2543 if(data->decoded_all)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2544 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2545 /* Corner Case: Now that play calls are pushed
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2546 * off to update(), the start call must
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2547 * also come through here. So, start loops
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2548 * must be +1
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2549 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2550 if(-1 == loops)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2551 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2552 /* -1 is a special case, and you don't want
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2553 * to add +1 to it */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2554 ALmixer_Channel_List[channel].loops = -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2555 alSourcei(ALmixer_Channel_List[channel].alsource, AL_LOOPING, AL_TRUE);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2556 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2557 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2558 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2559 ALmixer_Channel_List[channel].loops = loops+1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2560 alSourcei(ALmixer_Channel_List[channel].alsource, AL_LOOPING, AL_FALSE);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2561 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2562 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2563 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2564 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2565 ALmixer_Channel_List[channel].loops = loops;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2566 /* Can we really loop on streamed data? */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2567 alSourcei(ALmixer_Channel_List[channel].alsource, AL_LOOPING, AL_TRUE);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2568 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2569 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2570
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2571 /* Should I start playing here or pass the buck to update? */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2572 /* Unlike SDL_SoundMixer, I think I'll do it here because
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2573 * this library isn't a *total* hack and OpenAL has more
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2574 * built in functionality I need, so less needs to be
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2575 * controlled and directed through the update function.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2576 * The downside is less functionality is centralized.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2577 * The upside is that the update function should be
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2578 * easier to maintain.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2579 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2580
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2581 /* Clear the error flag */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2582 alGetError();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2583 if(data->decoded_all)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2584 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2585 /* Bind the data to the source */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2586 alSourcei(
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2587 ALmixer_Channel_List[channel].alsource,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2588 AL_BUFFER,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2589 data->buffer[0]);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2590 if((error = alGetError()) != AL_NO_ERROR)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2591 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2592 ALmixer_SetError("Could not bind data to source: %s",
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2593 alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2594 Clean_Channel(channel);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2595 return -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2596 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2597
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2598 /* Make data available if access_data is enabled */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2599 Invoke_Predecoded_Channel_Data_Callback(channel, data);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2600 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2601 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2602 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2603 /* Need to use the streaming buffer for binding */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2604
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2605 ALuint bytes_returned;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2606 ALuint j;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2607 data->num_buffers_in_use=0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2608 /****** MODIFICATION must go here *********/
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2609 /* Since buffer queuing is pushed off until here to
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2610 * avoid buffer conflicts, we must start reading
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2611 * data here. First we make sure we have at least one
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2612 * packet. Then we queue up until we hit our limit.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2613 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2614 bytes_returned = GetMoreData(
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2615 data,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2616 data->buffer[0]);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2617 if(0 == bytes_returned)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2618 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2619 /* No data or error */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2620 ALmixer_SetError("Could not get data for streamed PlayChannel: %s", ALmixer_GetError());
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2621 Clean_Channel(channel);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2622 return -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2623 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2624 /* Increment the number of buffers in use */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2625 data->num_buffers_in_use++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2626
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2627
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2628 /* Now we need to fill up the rest of the buffers.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2629 * There is a corner case where we run out of data
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2630 * before the last buffer is filled.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2631 * Stop conditions are we run out of
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2632 * data or we max out our preload buffers.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2633 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2634
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
2635 /*
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2636 fprintf(stderr, "Filling buffer #%d (AL id is %d)\n", 0, data->buffer[0]);
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
2637 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2638 for(j=1; j<data->num_startup_buffers; j++)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2639 {
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
2640 /*
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2641 fprintf(stderr, "Filling buffer #%d (AL id is %d)\n", j, data->buffer[j]);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2642 fprintf(stderr, ">>>>>>>>>>>>>>>>>>HACK for GetMoreData2\n");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2643 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2644 bytes_returned = GetMoreData(
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2645 data,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2646 data->buffer[j]);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2647 /*
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2648 * This might be a problem. I made a mistake with the types. I accidentally
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2649 * made the bytes returned an ALint and returned -1 on error.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2650 * Bytes returned should be a ALuint, so now I no longer have a -1 case
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2651 * to check. I hope I didn't break anything here
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2652 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2653 #if 0
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2654 if(bytes_returned < 0)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2655 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2656 /* Error found */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2657 ALmixer_SetError("Could not get data for additional startup buffers for PlayChannel: %s", ALmixer_GetError());
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2658 /* We'll continue on because we do have some valid data */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2659 ret_flag = -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2660 break;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2661 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2662 else if(0 == bytes_returned)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2663 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2664 if(0 == bytes_returned)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2665 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2666 /* No more data to buffer */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2667 /* Check for loops */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2668 if( ALmixer_Channel_List[channel].loops != 0 )
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2669 {
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
2670 /*
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2671 fprintf(stderr, "Need to rewind. In RAMPUP, handling loop\n");
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
2672 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2673 if(0 == Sound_Rewind(data->sample))
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2674 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2675 fprintf(stderr, "error in rewind\n");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2676 ALmixer_SetError( Sound_GetError() );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2677 ALmixer_Channel_List[channel].loops = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2678 ret_flag = -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2679 /* We'll continue on because we do have some valid data */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2680 break;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2681 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2682 /* Remember to reset the data->eof flag */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2683 data->eof = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2684 if(ALmixer_Channel_List[channel].loops > 0)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2685 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2686 ALmixer_Channel_List[channel].loops--;
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
2687 /*
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2688 fprintf(stderr, "Inside 000 >>>>>>>>>>Loops=%d\n", ALmixer_Channel_List[channel].loops);
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
2689 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2690 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2691 /* Would like to redo the loop, but due to
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2692 * Sound_Rewind() bugs, we would risk falling
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2693 * into an infinite loop
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2694 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2695 bytes_returned = GetMoreData(
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2696 data,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2697 data->buffer[j]);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2698 if(bytes_returned <= 0)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2699 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2700 ALmixer_SetError("Could not get data: %s", ALmixer_GetError());
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2701 /* We'll continue on because we do have some valid data */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2702 ret_flag = -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2703 break;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2704 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2705 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2706 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2707 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2708 /* No loops to do so quit here */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2709 break;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2710 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2711 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2712 /* Increment the number of buffers in use */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2713 data->num_buffers_in_use++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2714 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2715 /*
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2716 fprintf(stderr, "In PlayChannel, about to queue: source=%d, num_buffers_in_use=%d\n",
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2717 ALmixer_Channel_List[channel].alsource,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2718 data->num_buffers_in_use);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2719 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2720
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2721 alSourceQueueBuffers(
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2722 ALmixer_Channel_List[channel].alsource,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2723 data->num_buffers_in_use,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2724 data->buffer);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2725 if((error = alGetError()) != AL_NO_ERROR)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2726 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2727 ALmixer_SetError("Could not bind data to source: %s",
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2728 alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2729 Clean_Channel(channel);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2730 return -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2731 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2732 /* This is part of the hideous Nvidia workaround. In order to figure out
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2733 * which buffer to show during callbacks (for things like
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2734 * o-scopes), I must keep a copy of the buffers that are queued in my own
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2735 * data structure. This code will be called only if
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2736 * "access_data" was set, indicated by whether the queue is NULL.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2737 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2738 if(data->circular_buffer_queue != NULL)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2739 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2740 ALuint k;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2741 ALuint queue_ret_flag;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2742 for(k=0; k<data->num_buffers_in_use; k++)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2743 {
47
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
2744 /* fprintf(stderr, "56c: CircularQueue_PushBack.\n"); */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2745 queue_ret_flag = CircularQueueUnsignedInt_PushBack(data->circular_buffer_queue, data->buffer[k]);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2746 if(0 == queue_ret_flag)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2747 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2748 fprintf(stderr, "Serious internal error: CircularQueue could not push into queue.\n");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2749 ALmixer_SetError("Serious internal error: CircularQueue failed to push into queue");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2750 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2751 /*
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2752 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2753 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2754 fprintf(stderr, "Queue in PlayTimed\n");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2755 CircularQueueUnsignedInt_Print(data->circular_buffer_queue);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2756 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2757 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2758 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2759 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2760
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2761
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2762 /****** END **********/
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2763 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2764 /* We have finished loading the data (predecoded or queued)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2765 * so now we can play
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2766 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2767 alSourcePlay(ALmixer_Channel_List[channel].alsource);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2768 if((error = alGetError()) != AL_NO_ERROR)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2769 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2770 ALmixer_SetError("Play failed: %s",
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2771 alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2772 Clean_Channel(channel);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2773 return -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2774 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2775
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2776 /* Add to the counter that something is playing */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2777 Is_Playing_global++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2778 if(-1 == ret_flag)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2779 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2780 fprintf(stderr, "BACKDOOR ERROR >>>>>>>>>>>>>>>>>>\n");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2781 return -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2782 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2783 return channel;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2784 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2785
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2786
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2787 /* In case the user wants to specify a source instead of a channel,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2788 * they may use this function. This function will look up the
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2789 * source-to-channel map, and convert the call into a
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2790 * PlayChannelTimed() function call.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2791 * Returns the channel it's being played on.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2792 * Note: If you are prefer this method, then you need to be careful
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2793 * about using PlayChannel, particularly if you request the
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2794 * first available channels because source and channels have
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2795 * a one-to-one mapping in this API. It is quite easy for
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2796 * a channel/source to already be in use because of this.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2797 * In this event, an error message will be returned to you.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2798 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2799 static ALuint Internal_PlaySourceTimed(ALuint source, ALmixer_Data* data, ALint loops, ALint ticks)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2800 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2801 ALint channel;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2802 ALint retval;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2803 if(0 == source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2804 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2805 retval = Internal_PlayChannelTimed(-1, data, loops, ticks);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2806 if(-1 == retval)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2807 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2808 return 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2809 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2810 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2811 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2812 return Internal_GetSource(retval);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2813 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2814 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2815
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2816 channel = Internal_GetChannel(source);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2817 if(-1 == channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2818 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2819 ALmixer_SetError("Cannot Play source: %s", ALmixer_GetError());
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2820 return 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2821 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2822 retval = Internal_PlayChannelTimed(channel, data, loops, ticks);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2823 if(-1 == retval)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2824 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2825 return 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2826 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2827 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2828 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2829 return source;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2830 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2831 /* make compiler happy */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2832 return 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2833 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2834
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2835
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2836
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2837
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2838 /* Returns the channel or number of channels actually paused */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2839
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2840 static ALint Internal_PauseChannel(ALint channel)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2841 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2842 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2843 ALint state;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2844 ALint retval = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2845 ALint counter = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2846
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2847 if(channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2848 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2849 ALmixer_SetError("Cannot pause channel %d because it exceeds maximum number of channels (%d)\n", channel, Number_of_Channels_global);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2850 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2851 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2852
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2853 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2854 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2855 fprintf(stderr, "28Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2856 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2857 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2858 /* Clear error */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2859 alGetError();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2860
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2861 /* If the user specified a specific channel */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2862 if(channel >= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2863 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2864 /* only need to process channel if in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2865 if(ALmixer_Channel_List[channel].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2866 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2867 /* We don't want to repause if already
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2868 * paused because the fadeout/expire
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2869 * timing will get messed up
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2870 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2871 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2872 ALmixer_Channel_List[channel].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2873 AL_SOURCE_STATE, &state
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2874 );
44
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
2875 if((error = alGetError()) != AL_NO_ERROR)
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
2876 {
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
2877 fprintf(stderr, "Internal_PauseChannel specific channel error: %s\n",
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
2878 alGetString(error));
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
2879 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2880 if(AL_PLAYING == state)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2881 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2882 /* Count the actual number of channels being paused */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2883 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2884
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2885 alSourcePause(ALmixer_Channel_List[channel].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2886 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2887 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2888 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2889 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2890 retval = -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2891 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2892 /* We need to pause the expire time count down */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2893 if(ALmixer_Channel_List[channel].expire_ticks != -1)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2894 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2895 ALuint current_time = ALmixer_GetTicks();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2896 ALuint diff_time;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2897 diff_time = current_time -
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2898 ALmixer_Channel_List[channel].start_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2899 /* When we unpause, we will want to reset
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2900 * the start time so we can continue
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2901 * to base calculations off GetTicks().
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2902 * This means we need to subtract the amount
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2903 * of time already used up from expire_ticks.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2904 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2905 ALmixer_Channel_List[channel].expire_ticks =
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2906 ALmixer_Channel_List[channel].expire_ticks -
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2907 diff_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2908 /* Because -1 is a special value, we can't
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2909 * allow the time to go negative
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2910 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2911 if(ALmixer_Channel_List[channel].expire_ticks < 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2912 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2913 ALmixer_Channel_List[channel].expire_ticks = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2914 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2915 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2916 /* Do the same as expire time for fading */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2917 if(ALmixer_Channel_List[channel].fade_enabled)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2918 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2919 ALuint current_time = ALmixer_GetTicks();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2920 ALuint diff_time;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2921 diff_time = current_time -
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2922 ALmixer_Channel_List[channel].fade_start_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2923 /* When we unpause, we will want to reset
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2924 * the start time so we can continue
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2925 * to base calculations off GetTicks().
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2926 * This means we need to subtract the amount
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2927 * of time already used up from expire_ticks.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2928 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2929 ALmixer_Channel_List[channel].fade_expire_ticks =
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2930 ALmixer_Channel_List[channel].fade_expire_ticks -
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2931 diff_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2932 /* Don't allow the time to go negative */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2933 if(ALmixer_Channel_List[channel].expire_ticks < 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2934 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2935 ALmixer_Channel_List[channel].expire_ticks = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2936 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2937 } /* End fade check */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2938 } /* End if PLAYING */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2939 } /* End If in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2940 } /* End specific channel */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2941 /* The user wants to halt all channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2942 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2943 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2944 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2945 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2946 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2947 /* only need to process channel if in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2948 if(ALmixer_Channel_List[i].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2949 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2950 /* We don't want to repause if already
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2951 * paused because the fadeout/expire
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2952 * timing will get messed up
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2953 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2954 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2955 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2956 AL_SOURCE_STATE, &state
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2957 );
44
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
2958 if((error = alGetError()) != AL_NO_ERROR)
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
2959 {
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
2960 fprintf(stderr, "Internal_PauseChannel all channels error: %s\n",
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
2961 alGetString(error));
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
2962 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2963 if(AL_PLAYING == state)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2964 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2965 /* Count the actual number of channels being paused */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2966 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2967
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2968 alSourcePause(ALmixer_Channel_List[i].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2969 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2970 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2971 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2972 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2973 retval = -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2974 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2975 /* We need to pause the expire time count down */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2976 if(ALmixer_Channel_List[i].expire_ticks != -1)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2977 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2978 ALuint current_time = ALmixer_GetTicks();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
2979 ALuint diff_time;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2980 diff_time = current_time -
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2981 ALmixer_Channel_List[i].start_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2982 /* When we unpause, we will want to reset
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2983 * the start time so we can continue
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2984 * to base calculations off GetTicks().
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2985 * This means we need to subtract the amount
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2986 * of time already used up from expire_ticks.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2987 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2988 ALmixer_Channel_List[i].expire_ticks =
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2989 ALmixer_Channel_List[i].expire_ticks -
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2990 diff_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2991 /* Because -1 is a special value, we can't
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2992 * allow the time to go negative
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2993 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2994 if(ALmixer_Channel_List[i].expire_ticks < 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2995 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2996 ALmixer_Channel_List[i].expire_ticks = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2997 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2998 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2999 /* Do the same as expire time for fading */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3000 if(ALmixer_Channel_List[i].fade_enabled)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3001 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3002 ALuint current_time = ALmixer_GetTicks();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3003 ALuint diff_time;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3004 diff_time = current_time -
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3005 ALmixer_Channel_List[i].fade_start_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3006 /* When we unpause, we will want to reset
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3007 * the start time so we can continue
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3008 * to base calculations off GetTicks().
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3009 * This means we need to subtract the amount
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3010 * of time already used up from expire_ticks.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3011 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3012 ALmixer_Channel_List[i].fade_expire_ticks =
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3013 ALmixer_Channel_List[i].fade_expire_ticks -
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3014 diff_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3015 /* Don't allow the time to go negative */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3016 if(ALmixer_Channel_List[i].expire_ticks < 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3017 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3018 ALmixer_Channel_List[i].expire_ticks = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3019 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3020 } /* End fade check */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3021 } /* End if PLAYING */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3022 } /* End channel in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3023 } /* End for-loop */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3024 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3025 if(-1 == retval)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3026 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3027 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3028 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3029 return counter;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3030 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3031
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3032 /* Returns the channel or number of channels actually paused */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3033 static ALint Internal_PauseSource(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3034 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3035 ALint channel;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3036 if(0 == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3037 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3038 return Internal_PauseChannel(-1);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3039 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3040
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3041 channel = Internal_GetChannel(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3042 if(-1 == channel)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3043 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3044 ALmixer_SetError("Cannot pause source: %s", ALmixer_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3045 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3046 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3047 return Internal_PauseChannel(channel);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3048 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3049
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3050
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3051
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3052 static ALint Internal_ResumeChannel(ALint channel)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3053 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3054 ALint state;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3055 ALenum error;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3056 ALint retval = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3057 ALint counter = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3058
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3059 if(channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3060 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3061 ALmixer_SetError("Cannot pause channel %d because it exceeds maximum number of channels (%d)\n", channel, Number_of_Channels_global);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3062 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3063 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3064
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3065 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3066 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3067 fprintf(stderr, "31Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3068 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3069 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3070 /* Clear error */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3071 alGetError();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3072
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3073 /* If the user specified a specific channel */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3074 if(channel >= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3075 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3076 /* only need to process channel if in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3077 if(ALmixer_Channel_List[channel].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3078 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3079 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3080 ALmixer_Channel_List[channel].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3081 AL_SOURCE_STATE, &state
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3082 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3083 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3084 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3085 fprintf(stderr, "32Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3086 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3087 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3088 if(AL_PAUSED == state)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3089 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3090 /* Count the actual number of channels resumed */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3091 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3092
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3093 /* We need to resume the expire time count down */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3094 if(ALmixer_Channel_List[channel].expire_ticks != -1)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3095 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3096 ALmixer_Channel_List[channel].start_time = ALmixer_GetTicks();
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3097 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3098 /* Do the same as expire time for fading */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3099 if(ALmixer_Channel_List[channel].fade_enabled)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3100 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3101 ALmixer_Channel_List[channel].fade_start_time = ALmixer_GetTicks();
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3102 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3103
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3104 alSourcePlay(ALmixer_Channel_List[channel].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3105 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3106 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3107 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3108 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3109 retval = -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3110 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3111 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3112 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3113 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3114 /* The user wants to halt all channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3115 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3116 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3117 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3118 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3119 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3120 /* only need to process channel if in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3121 if(ALmixer_Channel_List[i].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3122 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3123 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3124 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3125 AL_SOURCE_STATE, &state
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3126 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3127 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3128 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3129 fprintf(stderr, "33Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3130 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3131 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3132 if(AL_PAUSED == state)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3133 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3134 /* Count the actual number of channels resumed */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3135 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3136
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3137 /* We need to resume the expire time count down */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3138 if(ALmixer_Channel_List[i].expire_ticks != -1)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3139 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3140 ALmixer_Channel_List[i].start_time = ALmixer_GetTicks();
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3141 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3142 /* Do the same as expire time for fading */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3143 if(ALmixer_Channel_List[i].fade_enabled)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3144 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3145 ALmixer_Channel_List[i].fade_start_time = ALmixer_GetTicks();
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3146 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3147
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3148 alSourcePlay(ALmixer_Channel_List[i].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3149 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3150 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3151 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3152 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3153 retval = -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3154 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3155 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3156 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3157 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3158 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3159 if(-1 == retval)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3160 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3161 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3162 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3163 return counter;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3164 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3165
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3166
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3167 static ALint Internal_ResumeSource(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3168 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3169 ALint channel;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3170 if(0 == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3171 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3172 return Internal_ResumeChannel(-1);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3173 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3174
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3175 channel = Internal_GetChannel(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3176 if(-1 == channel)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3177 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3178 ALmixer_SetError("Cannot resume source: %s", ALmixer_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3179 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3180 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3181 return Internal_ResumeChannel(channel);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3182 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3183
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3184
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3185 /* Might consider setting eof to 0 as a "feature"
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3186 * This will allow seek to end to stay there because
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3187 * Play automatically rewinds if at the end */
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3188 static ALboolean Internal_SeekData(ALmixer_Data* data, ALuint msec)
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3189 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3190 ALint retval;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3191
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3192 if(NULL == data)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3193 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3194 ALmixer_SetError("Cannot Seek because data is NULL");
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3195 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3196 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3197
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3198 /* Seek for predecoded files involves moving the chunk pointer around */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3199 if(data->decoded_all)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3200 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3201 ALuint byte_position;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3202
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3203 /* OpenAL doesn't seem to like it if I change the buffer
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3204 * while playing (crashes), so I must require that Seek only
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3205 * be done when the data is not in use.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3206 * Since data may be shared among multiple sources,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3207 * I can't shut them down myself, so I have to return an error.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3208 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3209 if(data->in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3210 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3211 ALmixer_SetError("Cannot seek on predecoded data while instances are playing");
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3212 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3213 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3214 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3215 #if defined(DISABLE_PREDECODED_SEEK)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3216 ALmixer_SetError("Seek support for predecoded samples was not compiled in");
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3217 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3218
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3219 #elif !defined(DISABLE_SEEK_MEMORY_OPTIMIZATION)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3220 /* By default, ALmixer frees the Sound_Sample for predecoded
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3221 * samples because of the potential memory waste.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3222 * However, to seek a sample, we need to have a full
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3223 * copy of the data around. So the strategy is to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3224 * recreate a hackish Sound_Sample to be used for seeking
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3225 * purposes. If Sound_Sample is NULL, we will reallocate
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3226 * memory for it and then procede as if everything
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3227 * was normal.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3228 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3229 if(NULL == data->sample)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3230 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3231 if( -1 == Reconstruct_Sound_Sample(data) )
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3232 {
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3233 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3234 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3235 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3236 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3237 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3238 /* If access_data was set, then we still have the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3239 * Sound_Sample and we can move around in the data.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3240 * If it was not set, the data has been freed and we
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3241 * cannot do anything because there is no way to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3242 * recover the data because OpenAL won't let us
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3243 * get access to the buffers
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3244 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3245 if(NULL == data->sample)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3246 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3247 ALmixer_SetError("Cannot seek because access_data flag was set false when data was initialized");
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3248 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3249 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3250
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3251 byte_position = Convert_Msec_To_Byte_Pos(&data->sample->desired, msec);
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3252 retval = Set_Predecoded_Seek_Position(data, byte_position);
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3253 if(-1 == retval)
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3254 {
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3255 return AL_FALSE;
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3256 }
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3257 else
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3258 {
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3259 return AL_TRUE;
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3260 }
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3261
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3262 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3263 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3264 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3265 /* Reset eof flag?? */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3266 data->eof = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3267 retval = Sound_Seek(data->sample, msec);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3268 if(0 == retval)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3269 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3270 ALmixer_SetError(Sound_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3271
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3272 fprintf(stderr, "Sound seek error: %s\n", ALmixer_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3273 /* Try rewinding to clean up? */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3274 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3275 Internal_RewindData(data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3276 */
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3277 return AL_FALSE;
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3278 }
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3279 return AL_TRUE;
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3280 }
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3281
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
3282 return AL_TRUE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3283 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3284
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3285
20
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3286 static ALint Internal_SeekChannel(ALint channel, ALuint msec)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3287 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3288 ALint retval = 0;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3289 ALenum error;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3290 ALint state;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3291 ALint running_count = 0;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3292
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3293 if(0 == msec)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3294 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3295 return Internal_RewindChannel(channel);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3296 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3297
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3298 if(channel >= Number_of_Channels_global)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3299 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3300 ALmixer_SetError("Cannot seek channel %d because it exceeds maximum number of channels (%d)\n", channel, Number_of_Channels_global);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3301 return -1;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3302 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3303
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3304 if((error = alGetError()) != AL_NO_ERROR)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3305 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3306 fprintf(stderr, "24Testing error: %s\n",
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3307 alGetString(error));
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3308 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3309 /* Clear error */
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3310 alGetError();
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3311
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3312 /* If the user specified a specific channel */
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3313 if(channel >= 0)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3314 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3315 /* only need to process channel if in use */
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3316 if(ALmixer_Channel_List[channel].channel_in_use)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3317 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3318
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3319 /* What should I do? Do I just rewind the channel
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3320 * or also rewind the data? Since the data is
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3321 * shared, let's make it the user's responsibility
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3322 * to rewind the data.
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3323 */
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3324 if(ALmixer_Channel_List[channel].almixer_data->decoded_all)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3325 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3326 /* convert milliseconds to seconds */
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3327 ALfloat sec_offset = msec / 1000.0f;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3328
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3329 alGetSourcei(
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3330 ALmixer_Channel_List[channel].alsource,
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3331 AL_SOURCE_STATE, &state
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3332 );
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3333 if((error = alGetError()) != AL_NO_ERROR)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3334 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3335 fprintf(stderr, "25Testing error: %s\n",
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3336 alGetString(error));
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3337 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3338 /* OpenAL seek */
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3339 alSourcef(ALmixer_Channel_List[channel].alsource, AL_SEC_OFFSET, sec_offset);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3340 if((error = alGetError()) != AL_NO_ERROR)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3341 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3342 ALmixer_SetError("%s",
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3343 alGetString(error) );
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3344 retval = -1;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3345 }
49
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
3346 /* OpenAL 1.1 spec says if this succeeds on a playing source, it will automatically jump */
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
3347 if(AL_PAUSED == state)
20
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3348 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3349 /* HACK: The problem is that when paused, after
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3350 * the Rewind, I can't get it off the INITIAL
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3351 * state without restarting
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3352 */
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3353 alSourcePlay(ALmixer_Channel_List[channel].alsource);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3354 if((error = alGetError()) != AL_NO_ERROR)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3355 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3356 fprintf(stderr, "25Testing error: %s\n",
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3357 alGetString(error));
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3358 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3359 alSourcePause(ALmixer_Channel_List[channel].alsource);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3360 if((error = alGetError()) != AL_NO_ERROR)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3361 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3362 ALmixer_SetError("%s",
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3363 alGetString(error) );
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3364 retval = -1;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3365 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3366 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3367 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3368 else
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3369 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3370 /* Streamed data is different. Rewinding the channel
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3371 * does no good. Rewinding the data will have an
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3372 * effect, but it will be lagged based on how
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3373 * much data is queued. Recommend users call Halt
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3374 * before rewind if they want immediate results.
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3375 */
49
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
3376 if(AL_FALSE == Internal_SeekData(ALmixer_Channel_List[channel].almixer_data, msec))
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
3377 {
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
3378 retval = -1;
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
3379 }
20
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3380 }
49
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
3381 running_count = 1;
20
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3382 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3383 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3384 /* The user wants to rewind all channels */
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3385 else
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3386 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3387 ALint i;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3388 ALfloat sec_offset = msec / 1000.0f;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3389
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3390 for(i=0; i<Number_of_Channels_global; i++)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3391 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3392 /* only need to process channel if in use */
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3393 if(ALmixer_Channel_List[i].channel_in_use)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3394 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3395 /* What should I do? Do I just rewind the channel
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3396 * or also rewind the data? Since the data is
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3397 * shared, let's make it the user's responsibility
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3398 * to rewind the data.
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3399 */
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3400 if(ALmixer_Channel_List[i].almixer_data->decoded_all)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3401 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3402 alGetSourcei(
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3403 ALmixer_Channel_List[i].alsource,
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3404 AL_SOURCE_STATE, &state
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3405 );
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3406 if((error = alGetError()) != AL_NO_ERROR)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3407 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3408 fprintf(stderr, "26Testing error: %s\n",
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3409 alGetString(error));
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3410 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3411
49
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
3412 /* OpenAL 1.1 spec says if this succeeds on a playing source, it will automatically jump */
20
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3413 alSourcef(ALmixer_Channel_List[channel].alsource, AL_SEC_OFFSET, sec_offset);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3414 if((error = alGetError()) != AL_NO_ERROR)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3415 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3416 ALmixer_SetError("%s",
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3417 alGetString(error) );
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3418 retval = -1;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3419 }
49
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
3420 if(AL_PAUSED == state)
20
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3421 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3422 /* HACK: The problem is that when paused, after
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3423 * the Rewind, I can't get it off the INITIAL
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3424 * state without restarting
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3425 */
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3426 alSourcePlay(ALmixer_Channel_List[i].alsource);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3427 if((error = alGetError()) != AL_NO_ERROR)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3428 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3429 fprintf(stderr, "27Testing error: %s\n",
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3430 alGetString(error));
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3431 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3432 alSourcePause(ALmixer_Channel_List[i].alsource);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3433 if((error = alGetError()) != AL_NO_ERROR)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3434 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3435 ALmixer_SetError("%s",
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3436 alGetString(error) );
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3437 retval = -1;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3438 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3439 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3440 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3441 else
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3442 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3443 /* Streamed data is different. Rewinding the channel
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3444 * does no good. Rewinding the data will have an
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3445 * effect, but it will be lagged based on how
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3446 * much data is queued. Recommend users call Halt
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3447 * before rewind if they want immediate results.
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3448 */
49
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
3449 if(AL_FALSE == Internal_SeekData(ALmixer_Channel_List[i].almixer_data, msec))
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
3450 {
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
3451 retval = -1;
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
3452 }
20
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3453 }
49
4b0268d86298 Fixed bug with seeking channels with predecoded samples. The OpenAL 1.1 spec specifies that a playing source should automatically jump when already playing. The code was unnecessarily recalling alPlaySource again which is not necessarily the correct thing to do. I think the previous code is another remnant of the Open 1.0 era. Also fixed bugs in the return codes for seek and rewind. For single channels, the return code was 0 channels processed in ALmixer which resulted in returning false to Lua. The implementation now should return 1/true for single channels, but 0/false for no channels. Errors will return -1/false.
Eric Wing <ewing@anscamobile.com>
parents: 48
diff changeset
3454 running_count++;
20
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3455 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3456 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3457 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3458 if(-1 == retval)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3459 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3460 return -1;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3461 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3462 else
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3463 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3464 return running_count;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3465 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3466
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3467 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3468
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3469 static ALint Internal_SeekSource(ALuint source, ALuint msec)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3470 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3471 ALint channel;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3472 if(0 == source)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3473 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3474 return Internal_SeekChannel(-1, msec);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3475 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3476
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3477 channel = Internal_GetChannel(source);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3478 if(-1 == channel)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3479 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3480 ALmixer_SetError("Cannot seek source: %s", ALmixer_GetError());
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3481 return 0;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3482 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3483 return Internal_SeekChannel(channel, msec);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3484 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3485
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
3486
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3487
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3488 static ALint Internal_FadeInChannelTimed(ALint channel, ALmixer_Data* data, ALint loops, ALuint fade_ticks, ALint expire_ticks)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3489 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3490 ALfloat value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3491 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3492 ALfloat original_value;
24
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
3493 /* ALuint current_time = ALmixer_GetTicks(); */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3494 ALint retval;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3495
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3496
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3497
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3498 if(channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3499 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3500 ALmixer_SetError("Requested channel (%d) exceeds maximum channel (%d) because only %d channels are allocated", channel, Number_of_Channels_global-1, Number_of_Channels_global);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3501 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3502 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3503 /* Let's call PlayChannelTimed to do the job.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3504 * There are two catches:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3505 * First is that we must set the volumes before the play call(s).
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3506 * Second is that we must initialize the channel values
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3507 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3508
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3509 if(channel < 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3510 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3511 /* This might cause a problem for threads/race conditions.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3512 * We need to set the volume on an unknown channel,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3513 * so we need to request a channel first. Remember
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3514 * that requesting a channel doesn't lock and it
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3515 * could be surrendered to somebody else before we claim it.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3516 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3517 channel = Internal_GetChannel(0);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3518 if(-1 == channel)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3519 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3520 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3521 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3522 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3523 else if(ALmixer_Channel_List[channel].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3524 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3525 ALmixer_SetError("Channel %d is already in use", channel);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3526 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3527 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3528
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3529
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3530 /* Get the original volume in case of a problem */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3531 alGetSourcef(ALmixer_Channel_List[channel].alsource,
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3532 AL_GAIN, &original_value);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3533
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3534 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3535 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3536 fprintf(stderr, "35Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3537 alGetString(error));
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3538 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3539 ALmixer_Channel_List[channel].fade_end_volume = original_value;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3540
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3541 /* Get the Min volume */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3542 alGetSourcef(ALmixer_Channel_List[channel].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3543 AL_MIN_GAIN, &value);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3544 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3545 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3546 fprintf(stderr, "36Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3547 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3548 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3549 ALmixer_Channel_List[channel].fade_start_volume = value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3550
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3551 /* Set the actual volume */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3552 alSourcef(ALmixer_Channel_List[channel].alsource,
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3553 AL_GAIN, value);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3554 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3555 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3556 fprintf(stderr, "37Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3557 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3558 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3559
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3560
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3561 /* Now call PlayChannelTimed */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3562 retval = Internal_PlayChannelTimed(channel, data, loops, expire_ticks);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3563 if(-1 == retval)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3564 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3565 /* Chance of failure is actually pretty high since
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3566 * a channel might already be in use or streamed
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3567 * data can be shared
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3568 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3569 /* Restore the original value to avoid accidental
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3570 * distruption of playback
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3571 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3572 alSourcef(ALmixer_Channel_List[channel].alsource,
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3573 AL_GAIN, original_value);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3574 if((error = alGetError()) != AL_NO_ERROR)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3575 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3576 fprintf(stderr, "38Testing error: %s\n",
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3577 alGetString(error));
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3578 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3579 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3580 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3581
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3582 /* We can't accept 0 as a value because of div-by-zero.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3583 * If zero, just call PlayChannelTimed at normal
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3584 * volume
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3585 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3586 if(0 == fade_ticks)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3587 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3588 alSourcef(ALmixer_Channel_List[channel].alsource,
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3589 AL_GAIN,
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3590 ALmixer_Channel_List[channel].fade_end_volume
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3591 );
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3592 if((error = alGetError()) != AL_NO_ERROR)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3593 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3594 fprintf(stderr, "39Testing error: %s\n",
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3595 alGetString(error));
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3596 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3597
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3598 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3599 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3600
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3601 /* Enable fading effects via the flag */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3602 ALmixer_Channel_List[channel].fade_enabled = 1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3603 /* Set fade start time */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3604 ALmixer_Channel_List[channel].fade_start_time
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3605 = ALmixer_Channel_List[channel].start_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3606 /* Set the fade expire ticks */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3607 ALmixer_Channel_List[channel].fade_expire_ticks = fade_ticks;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3608
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3609 /* Set 1/(endtime-starttime) or 1/deltaT */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3610 ALmixer_Channel_List[channel].fade_inv_time = 1.0f / fade_ticks;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3611
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3612 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3613
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3614 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3615
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3616
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3617 static ALuint Internal_FadeInSourceTimed(ALuint source, ALmixer_Data* data, ALint loops, ALuint fade_ticks, ALint expire_ticks)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3618 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3619 ALint channel;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3620 ALint retval;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3621 if(0 == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3622 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3623 retval = Internal_FadeInChannelTimed(-1, data, loops, fade_ticks, expire_ticks);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3624 if(-1 == retval)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3625 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3626 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3627 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3628 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3629 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3630 return Internal_GetSource(retval);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3631 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3632 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3633
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3634 channel = Internal_GetChannel(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3635 if(-1 == channel)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3636 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3637 ALmixer_SetError("Cannot FadeIn source: %s", ALmixer_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3638 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3639 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3640 retval = Internal_FadeInChannelTimed(channel, data, loops, fade_ticks, expire_ticks);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3641 if(-1 == retval)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3642 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3643 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3644 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3645 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3646 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3647 return source;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3648 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3649 /* make compiler happy */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3650 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3651 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3652
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3653
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3654
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3655
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3656 /* Will fade out currently playing channels.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3657 * It starts at the current volume level and goes down */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3658 static ALint Internal_FadeOutChannel(ALint channel, ALuint ticks)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3659 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3660 ALfloat value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3661 ALenum error;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3662 ALuint current_time = ALmixer_GetTicks();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3663 ALuint counter = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3664
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3665 /* We can't accept 0 as a value because of div-by-zero.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3666 * If zero, just call Halt at normal
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3667 * volume
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3668 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3669 if(0 == ticks)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3670 {
10
c808684660a7 Bug fix: Moved Invoke_Callback before CleanChannel because I was trying to get the ALmixer_Data pointer, but it was cleared:
Eric Wing <ewing . public |-at-| gmail . com>
parents: 6
diff changeset
3671 return Internal_HaltChannel(channel, AL_FALSE);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3672 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3673
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3674
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3675 if(channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3676 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3677 ALmixer_SetError("Requested channel (%d) exceeds maximum channel (%d) because only %d channels are allocated", channel, Number_of_Channels_global-1, Number_of_Channels_global);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3678 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3679 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3680
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3681 if(channel >= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3682 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3683 if(ALmixer_Channel_List[channel].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3684 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3685 /* Get the current volume */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3686 alGetSourcef(ALmixer_Channel_List[channel].alsource,
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3687 AL_GAIN, &value);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3688 ALmixer_Channel_List[channel].fade_start_volume = value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3689 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3690 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3691 fprintf(stderr, "40Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3692 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3693 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3694
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3695 /* Get the Min volume */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3696 alGetSourcef(ALmixer_Channel_List[channel].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3697 AL_MIN_GAIN, &value);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3698 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3699 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3700 fprintf(stderr, "41Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3701 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3702 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3703 ALmixer_Channel_List[channel].fade_end_volume = value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3704
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3705 /* Set expire start time */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3706 ALmixer_Channel_List[channel].start_time = current_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3707 /* Set the expire ticks */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3708 ALmixer_Channel_List[channel].expire_ticks = ticks;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3709 /* Set fade start time */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3710 ALmixer_Channel_List[channel].fade_start_time = current_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3711 /* Set the fade expire ticks */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3712 ALmixer_Channel_List[channel].fade_expire_ticks = ticks;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3713 /* Enable fading effects via the flag */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3714 ALmixer_Channel_List[channel].fade_enabled = 1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3715
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3716 /* Set 1/(endtime-starttime) or 1/deltaT */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3717 ALmixer_Channel_List[channel].fade_inv_time = 1.0f / ticks;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3718
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3719 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3720 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3721 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3722 /* Else need to fade out all channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3723 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3724 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3725 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3726 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3727 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3728 if(ALmixer_Channel_List[i].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3729 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3730 /* Get the current volume */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3731 alGetSourcef(ALmixer_Channel_List[i].alsource,
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3732 AL_GAIN, &value);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3733 ALmixer_Channel_List[i].fade_start_volume = value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3734 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3735 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3736 fprintf(stderr, "42Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3737 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3738 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3739
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3740 /* Get the Min volume */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3741 alGetSourcef(ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3742 AL_MIN_GAIN, &value);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3743 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3744 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3745 fprintf(stderr, "43Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3746 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3747 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3748 ALmixer_Channel_List[i].fade_end_volume = value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3749
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3750 /* Set expire start time */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3751 ALmixer_Channel_List[i].start_time = current_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3752 /* Set the expire ticks */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3753 ALmixer_Channel_List[i].expire_ticks = ticks;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3754 /* Set fade start time */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3755 ALmixer_Channel_List[i].fade_start_time = current_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3756 /* Set the fade expire ticks */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3757 ALmixer_Channel_List[i].fade_expire_ticks = ticks;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3758 /* Enable fading effects via the flag */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3759 ALmixer_Channel_List[i].fade_enabled = 1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3760
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3761 /* Set 1/(endtime-starttime) or 1/deltaT */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3762 ALmixer_Channel_List[i].fade_inv_time = 1.0f / ticks;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3763
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3764 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3765 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3766 } /* End for loop */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3767 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3768 return counter;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3769 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3770
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3771
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3772 static ALint Internal_FadeOutSource(ALuint source, ALuint ticks)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3773 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3774 ALint channel;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3775 if(0 == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3776 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3777 return Internal_FadeOutChannel(-1, ticks);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3778 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3779
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3780 channel = Internal_GetChannel(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3781 if(-1 == channel)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3782 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3783 ALmixer_SetError("Cannot FadeOut source: %s", ALmixer_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3784 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3785 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3786 return Internal_FadeOutChannel(channel, ticks);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3787 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3788
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3789
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3790 /* Will fade currently playing channels.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3791 * It starts at the current volume level and go to target
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3792 * Only affects channels that are playing
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3793 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3794 static ALint Internal_FadeChannel(ALint channel, ALuint ticks, ALfloat volume)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3795 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3796 ALfloat value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3797 ALenum error;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3798 ALuint current_time = ALmixer_GetTicks();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3799 ALuint counter = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3800
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3801 if(channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3802 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3803 ALmixer_SetError("Requested channel (%d) exceeds maximum channel (%d) because only %d channels are allocated", channel, Number_of_Channels_global-1, Number_of_Channels_global);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3804 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3805 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3806
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3807 if(channel >= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3808 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3809 if(volume < ALmixer_Channel_List[channel].min_volume)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3810 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3811 volume = ALmixer_Channel_List[channel].min_volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3812 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3813 else if(volume > ALmixer_Channel_List[channel].max_volume)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3814 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3815 volume = ALmixer_Channel_List[channel].max_volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3816 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3817
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3818 if(ALmixer_Channel_List[channel].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3819 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3820 if(ticks > 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3821 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3822 /* Get the current volume */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3823 alGetSourcef(ALmixer_Channel_List[channel].alsource,
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3824 AL_GAIN, &value);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3825 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3826 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3827 fprintf(stderr, "44Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3828 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3829 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3830 ALmixer_Channel_List[channel].fade_start_volume = value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3831
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3832 /* Set the target volume */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3833 ALmixer_Channel_List[channel].fade_end_volume = volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3834
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3835 /* Set fade start time */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3836 ALmixer_Channel_List[channel].fade_start_time = current_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3837 /* Set the fade expire ticks */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3838 ALmixer_Channel_List[channel].fade_expire_ticks = ticks;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3839 /* Enable fading effects via the flag */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3840 ALmixer_Channel_List[channel].fade_enabled = 1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3841
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3842 /* Set 1/(endtime-starttime) or 1/deltaT */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3843 ALmixer_Channel_List[channel].fade_inv_time = 1.0f / ticks;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3844 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3845 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3846 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3847 alSourcef(ALmixer_Channel_List[channel].alsource,
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3848 AL_GAIN, volume);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3849 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3850 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3851 fprintf(stderr, "45Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3852 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3853 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3854 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3855 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3856 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3857 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3858 /* Else need to fade out all channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3859 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3860 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3861 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3862 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3863 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3864 if(volume < ALmixer_Channel_List[i].min_volume)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3865 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3866 volume = ALmixer_Channel_List[i].min_volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3867 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3868 else if(volume > ALmixer_Channel_List[i].max_volume)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3869 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3870 volume = ALmixer_Channel_List[i].max_volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3871 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3872
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3873 if(ALmixer_Channel_List[i].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3874 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3875 if(ticks > 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3876 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3877 /* Get the current volume */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3878 alGetSourcef(ALmixer_Channel_List[i].alsource,
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3879 AL_GAIN, &value);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3880 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3881 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3882 fprintf(stderr, "46Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3883 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3884 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3885 ALmixer_Channel_List[i].fade_start_volume = value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3886
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3887 /* Set target volume */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3888 ALmixer_Channel_List[i].fade_end_volume = volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3889
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3890 /* Set fade start time */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3891 ALmixer_Channel_List[i].fade_start_time = current_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3892 /* Set the fade expire ticks */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3893 ALmixer_Channel_List[i].fade_expire_ticks = ticks;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3894 /* Enable fading effects via the flag */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3895 ALmixer_Channel_List[i].fade_enabled = 1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3896
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3897 /* Set 1/(endtime-starttime) or 1/deltaT */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3898 ALmixer_Channel_List[i].fade_inv_time = 1.0f / ticks;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3899 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3900 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3901 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3902 alSourcef(ALmixer_Channel_List[i].alsource,
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3903 AL_GAIN, volume);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3904 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3905 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3906 fprintf(stderr, "47Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3907 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3908 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3909 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3910 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3911 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3912 } /* End for loop */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3913 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3914 return counter;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3915 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3916
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3917 static ALint Internal_FadeSource(ALuint source, ALuint ticks, ALfloat volume)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3918 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3919 ALint channel;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3920 if(0 == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3921 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3922 return Internal_FadeChannel(-1, ticks, volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3923 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3924
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3925 channel = Internal_GetChannel(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3926 if(-1 == channel)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3927 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3928 ALmixer_SetError("Cannot Fade source: %s", ALmixer_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3929 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3930 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3931 return Internal_FadeChannel(channel, ticks, volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3932 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3933
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3934
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3935
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3936
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3937 /* Set a volume regardless if it's in use or not.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3938 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3939 static ALboolean Internal_SetVolumeChannel(ALint channel, ALfloat volume)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3940 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
3941 ALenum error;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3942 ALboolean retval = AL_TRUE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3943
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3944 if(channel >= Number_of_Channels_global)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3945 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3946 ALmixer_SetError("Requested channel (%d) exceeds maximum channel (%d) because only %d channels are allocated", channel, Number_of_Channels_global-1, Number_of_Channels_global);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3947 return AL_FALSE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3948 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3949
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3950 if(channel >= 0)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3951 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3952 if(volume < 0.0f)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3953 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3954 volume = 0.0f;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3955 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3956 else if(volume > 1.0f)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3957 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3958 volume = 1.0f;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3959 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3960 alSourcef(ALmixer_Channel_List[channel].alsource,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3961 AL_GAIN, volume);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3962 if((error = alGetError()) != AL_NO_ERROR)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3963 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3964 ALmixer_SetError("%s",
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3965 alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3966 retval = AL_FALSE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3967 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3968 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3969 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3970 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3971 ALint i;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3972 for(i=0; i<Number_of_Channels_global; i++)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3973 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3974 if(volume < 0.0f)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3975 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3976 volume = 0.0f;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3977 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3978 else if(volume > 1.0f)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3979 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3980 volume = 1.0f;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3981 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3982 alSourcef(ALmixer_Channel_List[i].alsource,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3983 AL_GAIN, volume);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3984 if((error = alGetError()) != AL_NO_ERROR)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3985 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3986 ALmixer_SetError("%s",
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3987 alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3988 retval = AL_FALSE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3989 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3990 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3991 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3992 return retval;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3993 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3994
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3995 static ALboolean Internal_SetVolumeSource(ALuint source, ALfloat volume)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3996 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3997 ALint channel;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3998 if(0 == source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3999 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4000 return Internal_SetVolumeChannel(-1, volume);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4001 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4002
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4003 channel = Internal_GetChannel(source);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4004 if(-1 == channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4005 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4006 ALmixer_SetError("Cannot SetMaxVolume: %s", ALmixer_GetError());
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4007 return AL_FALSE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4008 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4009 return Internal_SetVolumeChannel(channel, volume);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4010 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4011
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4012
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4013 static ALfloat Internal_GetVolumeChannel(ALint channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4014 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4015 ALfloat value;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4016 ALenum error;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4017 ALfloat running_total = 0.0f;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4018 ALfloat retval = 0.0f;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4019
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4020 if(channel >= Number_of_Channels_global)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4021 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4022 ALmixer_SetError("Requested channel (%d) exceeds maximum channel (%d) because only %d channels are allocated", channel, Number_of_Channels_global-1, Number_of_Channels_global);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4023 return -1.0f;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4024 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4025
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4026 if(channel >= 0)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4027 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4028 alGetSourcef(ALmixer_Channel_List[channel].alsource,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4029 AL_GAIN, &value);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4030 if((error = alGetError()) != AL_NO_ERROR)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4031 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4032 ALmixer_SetError("%s", alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4033 retval = -1.0f;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4034 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4035 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4036 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4037 retval = value;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4038 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4039 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4040 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4041 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4042 ALint i;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4043 for(i=0; i<Number_of_Channels_global; i++)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4044 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4045 alGetSourcef(ALmixer_Channel_List[i].alsource,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4046 AL_GAIN, &value);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4047 if((error = alGetError()) != AL_NO_ERROR)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4048 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4049 ALmixer_SetError("%s", alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4050 retval = -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4051 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4052 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4053 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4054 running_total += value;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4055 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4056 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4057 if(0 == Number_of_Channels_global)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4058 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4059 ALmixer_SetError("No channels are allocated");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4060 retval = -1.0f;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4061 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4062 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4063 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4064 retval = running_total / Number_of_Channels_global;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4065 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4066 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4067 return retval;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4068 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4069
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4070 static ALfloat Internal_GetVolumeSource(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4071 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4072 ALint channel;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4073 if(0 == source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4074 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4075 return Internal_GetVolumeChannel(-1);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4076 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4077
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4078 channel = Internal_GetChannel(source);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4079 if(-1 == channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4080 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4081 ALmixer_SetError("Cannot GetVolume: %s", ALmixer_GetError());
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4082 return -1.0f;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4083 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4084
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4085 return Internal_GetVolumeChannel(channel);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4086 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4087
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4088
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4089
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4090 /* Set a volume regardless if it's in use or not.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4091 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4092 static ALboolean Internal_SetMaxVolumeChannel(ALint channel, ALfloat volume)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4093 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4094 ALenum error;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4095 ALboolean retval = AL_TRUE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4096
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4097 if(channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4098 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4099 ALmixer_SetError("Requested channel (%d) exceeds maximum channel (%d) because only %d channels are allocated", channel, Number_of_Channels_global-1, Number_of_Channels_global);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4100 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4101 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4102
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4103 if(channel >= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4104 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4105 if(volume < 0.0f)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4106 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4107 volume = 0.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4108 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4109 else if(volume > 1.0f)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4110 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4111 volume = 1.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4112 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4113 ALmixer_Channel_List[channel].max_volume = volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4114 alSourcef(ALmixer_Channel_List[channel].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4115 AL_MAX_GAIN, volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4116 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4117 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4118 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4119 alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4120 retval = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4121 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4122 if(ALmixer_Channel_List[channel].max_volume < ALmixer_Channel_List[channel].min_volume)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4123 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4124 ALmixer_Channel_List[channel].min_volume = volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4125 alSourcef(ALmixer_Channel_List[channel].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4126 AL_MIN_GAIN, volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4127 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4128 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4129 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4130 alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4131 retval = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4132 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4133 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4134 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4135 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4136 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4137 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4138 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4139 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4140 if(volume < 0.0f)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4141 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4142 volume = 0.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4143 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4144 else if(volume > 1.0f)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4145 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4146 volume = 1.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4147 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4148 ALmixer_Channel_List[i].max_volume = volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4149 alSourcef(ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4150 AL_MAX_GAIN, volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4151 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4152 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4153 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4154 alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4155 retval = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4156 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4157 if(ALmixer_Channel_List[i].max_volume < ALmixer_Channel_List[i].min_volume)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4158 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4159 ALmixer_Channel_List[i].min_volume = volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4160 alSourcef(ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4161 AL_MIN_GAIN, volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4162 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4163 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4164 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4165 alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4166 retval = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4167 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4168 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4169 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4170 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4171 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4172 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4173
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4174 static ALint Internal_SetMaxVolumeSource(ALuint source, ALfloat volume)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4175 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4176 ALint channel;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4177 if(0 == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4178 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4179 return Internal_SetMaxVolumeChannel(-1, volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4180 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4181
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4182 channel = Internal_GetChannel(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4183 if(-1 == channel)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4184 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4185 ALmixer_SetError("Cannot SetMaxVolume: %s", ALmixer_GetError());
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4186 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4187 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4188 return Internal_SetMaxVolumeChannel(channel, volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4189 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4190
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4191 static ALfloat Internal_GetMaxVolumeChannel(ALint channel)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4192 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4193 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4194 ALfloat value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4195 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4196 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4197 ALfloat running_total = 0.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4198 ALfloat retval = 0.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4199
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4200 if(channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4201 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4202 ALmixer_SetError("Requested channel (%d) exceeds maximum channel (%d) because only %d channels are allocated", channel, Number_of_Channels_global-1, Number_of_Channels_global);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4203 return -1.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4204 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4205
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4206 if(channel >= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4207 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4208 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4209 alGetSourcef(ALmixer_Channel_List[channel].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4210 AL_GAIN, &value);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4211 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4212 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4213 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4214 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4215 retval = -1.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4216 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4217 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4218 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4219 retval = value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4220 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4221 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4222 retval = ALmixer_Channel_List[channel].max_volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4223
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4224 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4225 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4226 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4227 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4228 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4229 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4230 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4231 alGetSourcef(ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4232 AL_GAIN, &value);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4233 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4234 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4235 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4236 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4237 retval = -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4238 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4239 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4240 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4241 running_total += value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4242 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4243 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4244 running_total += ALmixer_Channel_List[i].max_volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4245 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4246 if(0 == Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4247 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4248 ALmixer_SetError("No channels are allocated");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4249 retval = -1.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4250 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4251 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4252 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4253 retval = running_total / Number_of_Channels_global;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4254 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4255 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4256 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4257 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4258
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4259 static ALfloat Internal_GetMaxVolumeSource(ALuint source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4260 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4261 ALint channel;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4262 if(0 == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4263 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4264 return Internal_GetMaxVolumeChannel(-1);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4265 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4266
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4267 channel = Internal_GetChannel(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4268 if(-1 == channel)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4269 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4270 ALmixer_SetError("Cannot GetVolume: %s", ALmixer_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4271 return -1.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4272 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4273
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4274 return Internal_GetMaxVolumeChannel(channel);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4275 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4276
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4277
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4278 /* Set a volume regardless if it's in use or not.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4279 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4280 static ALboolean Internal_SetMinVolumeChannel(ALint channel, ALfloat volume)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4281 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4282 ALenum error;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4283 ALboolean retval = AL_TRUE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4284
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4285 if(channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4286 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4287 ALmixer_SetError("Requested channel (%d) exceeds maximum channel (%d) because only %d channels are allocated", channel, Number_of_Channels_global-1, Number_of_Channels_global);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4288 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4289 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4290
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4291 if(channel >= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4292 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4293 if(volume < 0.0f)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4294 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4295 volume = 0.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4296 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4297 else if(volume > 1.0f)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4298 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4299 volume = 1.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4300 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4301 ALmixer_Channel_List[channel].min_volume = volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4302 alSourcef(ALmixer_Channel_List[channel].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4303 AL_MIN_GAIN, volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4304 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4305 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4306 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4307 alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4308 retval = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4309 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4310 if(ALmixer_Channel_List[channel].max_volume < ALmixer_Channel_List[channel].min_volume)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4311 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4312 ALmixer_Channel_List[channel].max_volume = volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4313 alSourcef(ALmixer_Channel_List[channel].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4314 AL_MAX_GAIN, volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4315 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4316 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4317 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4318 alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4319 retval = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4320 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4321 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4322 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4323 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4324 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4325 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4326 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4327 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4328 if(volume < 0.0f)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4329 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4330 volume = 0.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4331 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4332 else if(volume > 1.0f)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4333 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4334 volume = 1.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4335 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4336 ALmixer_Channel_List[i].min_volume = volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4337 alSourcef(ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4338 AL_MIN_GAIN, volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4339 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4340 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4341 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4342 alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4343 retval = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4344 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4345 if(ALmixer_Channel_List[i].max_volume < ALmixer_Channel_List[i].min_volume)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4346 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4347 ALmixer_Channel_List[i].max_volume = volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4348 alSourcef(ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4349 AL_MAX_GAIN, volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4350 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4351 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4352 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4353 alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4354 retval = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4355 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4356 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4357 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4358 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4359 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4360 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4361
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4362 static ALboolean Internal_SetMinVolumeSource(ALuint source, ALfloat volume)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4363 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4364 ALint channel;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4365 if(0 == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4366 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4367 return Internal_SetMinVolumeChannel(-1, volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4368 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4369
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4370 channel = Internal_GetChannel(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4371 if(-1 == channel)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4372 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4373 ALmixer_SetError("Cannot SetMaxVolume: %s", ALmixer_GetError());
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4374 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4375 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4376 return Internal_SetMinVolumeChannel(channel, volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4377 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4378
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4379 static ALfloat Internal_GetMinVolumeChannel(ALint channel)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4380 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4381 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4382 ALfloat value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4383 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4384 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4385 ALfloat running_total = 0.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4386 ALfloat retval = 0.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4387
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4388 if(channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4389 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4390 ALmixer_SetError("Requested channel (%d) exceeds maximum channel (%d) because only %d channels are allocated", channel, Number_of_Channels_global-1, Number_of_Channels_global);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4391 return -1.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4392 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4393
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4394 if(channel >= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4395 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4396 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4397 alGetSourcef(ALmixer_Channel_List[channel].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4398 AL_GAIN, &value);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4399 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4400 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4401 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4402 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4403 retval = -1.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4404 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4405 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4406 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4407 retval = value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4408 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4409 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4410 retval = ALmixer_Channel_List[channel].min_volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4411
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4412 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4413 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4414 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4415 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4416 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4417 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4418 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4419 alGetSourcef(ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4420 AL_GAIN, &value);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4421 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4422 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4423 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4424 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4425 retval = -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4426 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4427 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4428 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4429 running_total += value;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4430 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4431 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4432 running_total += ALmixer_Channel_List[i].min_volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4433 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4434 if(0 == Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4435 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4436 ALmixer_SetError("No channels are allocated");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4437 retval = -1.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4438 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4439 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4440 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4441 retval = running_total / Number_of_Channels_global;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4442 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4443 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4444 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4445 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4446
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4447 static ALfloat Internal_GetMinVolumeSource(ALuint source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4448 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4449 ALint channel;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4450 if(0 == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4451 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4452 return Internal_GetMinVolumeChannel(-1);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4453 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4454
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4455 channel = Internal_GetChannel(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4456 if(-1 == channel)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4457 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4458 ALmixer_SetError("Cannot GetVolume: %s", ALmixer_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4459 return -1.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4460 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4461
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4462 return Internal_GetMinVolumeChannel(channel);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4463 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4464
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4465
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4466 /* Changes the listener volume */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4467 static ALboolean Internal_SetMasterVolume(ALfloat volume)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4468 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4469 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4470 alListenerf(AL_GAIN, volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4471 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4472 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4473 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4474 alGetString(error) );
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4475 return AL_FALSE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4476 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4477 return AL_TRUE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4478 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4479
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4480 static ALfloat Internal_GetMasterVolume()
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4481 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4482 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4483 ALfloat volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4484 alGetListenerf(AL_GAIN, &volume);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4485 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4486 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4487 ALmixer_SetError("%s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4488 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4489 return -1.0f;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4490 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4491 return volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4492 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4493
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4494
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4495
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4496
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4497 /* Will fade out currently playing channels.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4498 * It starts at the current volume level and goes down */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4499 static ALint Internal_ExpireChannel(ALint channel, ALint ticks)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4500 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4501 ALuint current_time = ALmixer_GetTicks();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4502 ALuint counter = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4503
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4504 /* We can't accept 0 as a value because of div-by-zero.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4505 * If zero, just call Halt at normal
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4506 * volume
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4507 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4508 if(0 == ticks)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4509 {
10
c808684660a7 Bug fix: Moved Invoke_Callback before CleanChannel because I was trying to get the ALmixer_Data pointer, but it was cleared:
Eric Wing <ewing . public |-at-| gmail . com>
parents: 6
diff changeset
4510 return Internal_HaltChannel(channel, AL_FALSE);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4511 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4512 if(ticks < -1)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4513 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4514 ticks = -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4515 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4516
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4517
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4518 if(channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4519 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4520 ALmixer_SetError("Requested channel (%d) exceeds maximum channel (%d) because only %d channels are allocated", channel, Number_of_Channels_global-1, Number_of_Channels_global);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4521 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4522 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4523
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4524 if(channel >= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4525 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4526 if(ALmixer_Channel_List[channel].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4527 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4528 /* Set expire start time */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4529 ALmixer_Channel_List[channel].start_time = current_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4530 /* Set the expire ticks */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4531 ALmixer_Channel_List[channel].expire_ticks = ticks;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4532
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4533 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4534 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4535 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4536 /* Else need to fade out all channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4537 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4538 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4539 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4540 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4541 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4542 if(ALmixer_Channel_List[i].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4543 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4544 /* Set expire start time */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4545 ALmixer_Channel_List[i].start_time = current_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4546 /* Set the expire ticks */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4547 ALmixer_Channel_List[i].expire_ticks = ticks;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4548
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4549 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4550 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4551 } /* End for loop */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4552 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4553 return counter;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4554 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4555
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4556
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4557 static ALint Internal_ExpireSource(ALuint source, ALint ticks)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4558 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4559 ALint channel;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4560 if(0 == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4561 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4562 return Internal_ExpireChannel(-1, ticks);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4563 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4564
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4565 channel = Internal_GetChannel(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4566 if(-1 == channel)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4567 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4568 ALmixer_SetError("Cannot Expire source: %s", ALmixer_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4569 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4570 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4571 return Internal_ExpireChannel(channel, ticks);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4572 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4573
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4574
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4575 static ALint Internal_QueryChannel(ALint channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4576 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4577 ALint i;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4578 ALint counter = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4579 if(channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4580 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4581 ALmixer_SetError("Invalid channel: %d", channel);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4582 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4583 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4584
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4585 if(channel >= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4586 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4587 return ALmixer_Channel_List[channel].channel_in_use;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4588 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4589
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4590 /* Else, return the number of channels in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4591 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4592 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4593 if(ALmixer_Channel_List[i].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4594 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4595 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4596 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4597 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4598 return counter;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4599 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4600
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4601
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4602 static ALint Internal_QuerySource(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4603 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4604 ALint channel;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4605 if(0 == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4606 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4607 return Internal_QueryChannel(-1);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4608 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4609
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4610 channel = Internal_GetChannel(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4611 if(-1 == channel)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4612 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4613 ALmixer_SetError("Cannot query source: %s", ALmixer_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4614 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4615 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4616
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4617 return Internal_QueryChannel(channel);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4618 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4619
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4620
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4621 static ALuint Internal_CountUnreservedUsedChannels()
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4622 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4623 ALint i;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4624 ALuint counter = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4625
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4626
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4627 /* Else, return the number of channels in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4628 for(i=Number_of_Reserve_Channels_global; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4629 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4630 if(ALmixer_Channel_List[i].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4631 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4632 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4633 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4634 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4635 return counter;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4636 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4637
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4638 static ALuint Internal_CountUnreservedFreeChannels()
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4639 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4640 ALint i;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4641 ALuint counter = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4642
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4643
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4644 /* Else, return the number of channels in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4645 for(i=Number_of_Reserve_Channels_global; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4646 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4647 if( ! ALmixer_Channel_List[i].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4648 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4649 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4650 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4651 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4652 return counter;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4653 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4654
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4655 static ALuint Internal_CountAllUsedChannels()
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4656 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4657 ALint i;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4658 ALuint counter = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4659
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4660
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4661 /* Else, return the number of channels in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4662 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4663 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4664 if(ALmixer_Channel_List[i].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4665 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4666 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4667 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4668 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4669 return counter;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4670 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4671
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4672 static ALuint Internal_CountAllFreeChannels()
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4673 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4674 ALint i;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4675 ALuint counter = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4676
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4677
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4678 /* Else, return the number of channels in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4679 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4680 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4681 if( ! ALmixer_Channel_List[i].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4682 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4683 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4684 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4685 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4686 return counter;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4687 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4688
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4689
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4690 static ALint Internal_PlayingChannel(ALint channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4691 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4692 ALint i;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4693 ALint counter = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4694 ALint state;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4695
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4696 if(channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4697 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4698 ALmixer_SetError("Invalid channel: %d", channel);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4699 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4700 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4701
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4702 if(channel >= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4703 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4704 if(ALmixer_Channel_List[channel].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4705 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4706 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4707 ALmixer_Channel_List[channel].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4708 AL_SOURCE_STATE, &state
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4709 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4710 if(AL_PLAYING == state)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4711 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4712 return 1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4713 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4714 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4715 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4716 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4717
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4718 /* Else, return the number of channels in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4719 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4720 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4721 if(ALmixer_Channel_List[i].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4722 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4723 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4724 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4725 AL_SOURCE_STATE, &state
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4726 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4727 if(AL_PLAYING == state)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4728 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4729 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4730 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4731 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4732 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4733 return counter;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4734 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4735
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4736
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4737 static ALint Internal_PlayingSource(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4738 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4739 ALint channel;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4740 if(0 == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4741 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4742 return Internal_PlayingChannel(-1);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4743 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4744
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4745 channel = Internal_GetChannel(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4746 if(-1 == channel)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4747 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4748 ALmixer_SetError("Cannot query source: %s", ALmixer_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4749 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4750 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4751
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4752 return Internal_PlayingChannel(channel);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4753 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4754
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4755
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4756 static ALint Internal_PausedChannel(ALint channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4757 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4758 ALint i;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4759 ALint counter = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4760 ALint state;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4761
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4762 if(channel >= Number_of_Channels_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4763 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4764 ALmixer_SetError("Invalid channel: %d", channel);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4765 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4766 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4767
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4768 if(channel >= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4769 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4770 if(ALmixer_Channel_List[channel].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4771 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4772 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4773 ALmixer_Channel_List[channel].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4774 AL_SOURCE_STATE, &state
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4775 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4776 if(AL_PAUSED == state)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4777 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4778 return 1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4779 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4780 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4781 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4782 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4783
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4784 /* Else, return the number of channels in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4785 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4786 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4787 if(ALmixer_Channel_List[i].channel_in_use)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4788 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4789 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4790 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4791 AL_SOURCE_STATE, &state
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4792 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4793 if(AL_PAUSED == state)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4794 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4795 counter++;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4796 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4797 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4798 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4799 return counter;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4800 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4801
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4802
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4803 static ALint Internal_PausedSource(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4804 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4805 ALint channel;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4806 if(0 == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4807 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4808 return Internal_PausedChannel(-1);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4809 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4810
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4811 channel = Internal_GetChannel(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4812 if(-1 == channel)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4813 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4814 ALmixer_SetError("Cannot query source: %s", ALmixer_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4815 return -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4816 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4817
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4818 return Internal_PausedChannel(channel);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4819 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4820
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4821
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4822
37
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4823 static void Internal_FreeData(ALmixer_Data* data)
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4824 {
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4825 ALenum error;
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4826 if(NULL == data)
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4827 {
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4828 return;
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4829 }
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4830
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4831 if(data->decoded_all)
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4832 {
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4833 /* If access_data was enabled, then the Sound_Sample*
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4834 * still exists. We need to free it
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4835 */
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4836 if(data->sample != NULL)
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4837 {
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4838 Sound_FreeSample(data->sample);
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4839 }
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4840 alDeleteBuffers(1, data->buffer);
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4841 if((error = alGetError()) != AL_NO_ERROR)
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4842 {
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4843 fprintf(stderr, "ALmixer_FreeData: alDeleteBuffers failed. %s\n", alGetString(error));
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4844 }
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4845 }
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4846 else
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4847 {
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4848 ALuint i;
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4849
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4850 /* Delete buffer copies if access_data was enabled */
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4851 if(data->buffer_map_list != NULL)
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4852 {
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4853 for(i=0; i<data->max_queue_buffers; i++)
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4854 {
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4855 free(data->buffer_map_list[i].data);
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4856 }
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4857 free(data->buffer_map_list);
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4858 }
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4859 if(data->circular_buffer_queue != NULL)
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4860 {
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4861 CircularQueueUnsignedInt_FreeQueue(data->circular_buffer_queue);
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4862 }
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4863
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4864 Sound_FreeSample(data->sample);
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4865 alDeleteBuffers(data->max_queue_buffers, data->buffer);
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4866 if((error = alGetError()) != AL_NO_ERROR)
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4867 {
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4868 fprintf(stderr, "ALmixer_FreeData: alDeleteBuffers failed. %s\n", alGetString(error));
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4869 }
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4870 }
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4871 free(data->buffer);
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4872
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4873 LinkedList_Remove(s_listOfALmixerData,
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4874 LinkedList_Find(s_listOfALmixerData, data, NULL)
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4875 );
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4876
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4877 free(data);
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4878 }
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4879
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4880
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
4881
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4882
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4883
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4884
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4885 /* Private function for Updating ALmixer.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4886 * This is a very big and ugly function.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4887 * It should return the number of buffers that were
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4888 * queued during the call. The value might be
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4889 * used to guage how long you might wait to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4890 * call the next update loop in case you are worried
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4891 * about preserving CPU cycles. The idea is that
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4892 * when a buffer is queued, there was probably some
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4893 * CPU intensive looping which took awhile.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4894 * It's mainly provided as a convenience.
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4895 * Timing the call with ALmixer_GetTicks() would produce
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4896 * more accurate information.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4897 * Returns a negative value if there was an error,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4898 * the value being the number of errors.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4899 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4900 static ALint Update_ALmixer(void* data)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4901 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4902 ALint retval = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4903 ALint error_flag = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4904 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4905 ALint state;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4906 ALint i=0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4907
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4908 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4909 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4910 #endif
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
4911 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4912 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4913 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4914 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4915 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4916 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4917 }
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
4918
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
4919 /* Bypass if in interruption event */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
4920 if(NULL == alcGetCurrentContext())
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
4921 {
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
4922 #ifdef ENABLE_ALMIXER_THREADS
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
4923 SDL_UnlockMutex(s_simpleLock);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
4924 #endif
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
4925 return 0;
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
4926 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4927
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4928 /* Check the quick flag to see if anything needs updating */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4929 /* If anything is playing, then we have to do work */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4930 if( 0 == Is_Playing_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4931 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4932 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4933 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4934 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4935 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4936 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4937 /* Clear error */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4938 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4939 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4940 fprintf(stderr, "08Testing errpr before unqueue because getting stuff, for OS X this is expected: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4941 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4942 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4943 alGetError();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4944
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4945 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4946 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4947 if( ALmixer_Channel_List[i].channel_in_use )
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4948 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4949
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4950 /* For simplicity, before we do anything else,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4951 * we can check the timeout and fading values
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4952 * and do the appropriate things
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4953 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4954 ALuint current_time = ALmixer_GetTicks();
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4955
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4956 /* Check to see if we need to halt due to Timed play */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4957 if(ALmixer_Channel_List[i].expire_ticks != -1)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4958 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4959 ALuint target_time = (ALuint)ALmixer_Channel_List[i].expire_ticks
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4960 + ALmixer_Channel_List[i].start_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4961 alGetSourcei(ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4962 AL_SOURCE_STATE, &state);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4963 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4964 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4965 fprintf(stderr, "06Testing errpr before unqueue because getting stuff, for OS X this is expected: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4966 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4967 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4968
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4969 /* Check the time, and also make sure that it is not
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4970 * paused (if paused, we don't want to make the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4971 * evaluation because when resumed, we will adjust
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4972 * the times to compensate for the pause).
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4973 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4974 if( (current_time >= target_time)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4975 && (state != AL_PAUSED) )
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4976 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4977 /* Stop the playback */
10
c808684660a7 Bug fix: Moved Invoke_Callback before CleanChannel because I was trying to get the ALmixer_Data pointer, but it was cleared:
Eric Wing <ewing . public |-at-| gmail . com>
parents: 6
diff changeset
4978 Internal_HaltChannel(i, AL_FALSE);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4979 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4980 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4981 fprintf(stderr, "07Testing errpr before unqueue because getting stuff, for OS X this is expected: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4982 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4983 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4984
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4985 /* Everything should be done so go on to the next loop */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4986 continue;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4987 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4988 } /* End if time expired check */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4989
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4990 /* Check to see if we need to adjust the volume for fading */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4991 if( ALmixer_Channel_List[i].fade_enabled )
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4992 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
4993 ALuint target_time = ALmixer_Channel_List[i].fade_expire_ticks
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4994 + ALmixer_Channel_List[i].fade_start_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4995 alGetSourcei(ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4996 AL_SOURCE_STATE, &state);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4997 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4998 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4999 fprintf(stderr, "05Testing errpr before unqueue because getting stuff, for OS X this is expected: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5000 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5001 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5002
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5003 /* Check the time, and also make sure that it is not
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5004 * paused (if paused, we don't want to make the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5005 * evaluation because when resumed, we will adjust
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5006 * the times to compensate for the pause).
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5007 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5008 if(state != AL_PAUSED)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5009 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5010 ALfloat t;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5011 ALuint delta_time;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5012 ALfloat current_volume;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5013 if(current_time >= target_time)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5014 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5015 /* Need to constrain value to the end time
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5016 * (can't go pass the value for calculations)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5017 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5018 current_time = target_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5019 /* We can disable the fade flag now */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5020 ALmixer_Channel_List[i].fade_enabled = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5021 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5022 /* Use the linear interpolation formula:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5023 * X = (1-t)x0 + tx1
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5024 * where x0 would be the start value
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5025 * and x1 is the final value
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5026 * and t is delta_time*inv_time (adjusts 0 <= time <= 1)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5027 * delta_time = current_time-start_time
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5028 * inv_time = 1/ (end_time-start_time)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5029 * so t = current_time-start_time / (end_time-start_time)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5030 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5031 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5032 delta_time = current_time - ALmixer_Channel_List[i].fade_start_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5033 t = (ALfloat) delta_time * ALmixer_Channel_List[i].fade_inv_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5034 current_volume = (1.0f-t) * ALmixer_Channel_List[i].fade_start_volume
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5035 + t * ALmixer_Channel_List[i].fade_end_volume;
20
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
5036 /*
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
5037 fprintf(stderr, "start_vol=%f, end_vol:%f, current_volume: %f\n", ALmixer_Channel_List[i].fade_start_volume, ALmixer_Channel_List[i].fade_end_volume, current_volume);
20
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
5038 */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5039 /* Set the volume */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5040 alSourcef(ALmixer_Channel_List[i].alsource,
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
5041 AL_GAIN, current_volume);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5042 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5043 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5044 fprintf(stderr, "04Testing errpr before unqueue because getting stuff, for OS X this is expected: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5045 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5046 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5047
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5048 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5049 fprintf(stderr, "Current time =%d\n", current_time);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5050 fprintf(stderr, "Current vol=%f on channel %d\n", current_volume, i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5051 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5052 } /* End if not PAUSED */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5053 } /* End if fade_enabled */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5054
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5055
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5056 /* Okay, now that the time expired and fading stuff
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5057 * is done, do the rest of the hard stuff
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5058 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5059
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5060
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5061 /* For predecoded, check to see if done */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5062 if( ALmixer_Channel_List[i].almixer_data->decoded_all )
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5063 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5064
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5065 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5066 /********* Remove this **********/
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5067 ALint buffers_processed;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5068 ALint buffers_still_queued;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5069 fprintf(stderr, "For Predecoded\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5070
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5071 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5072 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5073 AL_SOURCE_STATE, &state
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5074 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5075 switch(state) {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5076 case AL_PLAYING:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5077 fprintf(stderr, "Channel '%d' is PLAYING\n", i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5078 break;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5079 case AL_PAUSED:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5080 fprintf(stderr, "Channel '%d' is PAUSED\n",i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5081 break;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5082 case AL_STOPPED:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5083 fprintf(stderr, "Channel '%d' is STOPPED\n",i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5084 break;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5085 case AL_INITIAL:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5086 fprintf(stderr, "Channel '%d' is INITIAL\n",i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5087 break;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5088 default:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5089 fprintf(stderr, "Channel '%d' is UNKNOWN\n",i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5090 break;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5091 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5092
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5093 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5094 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5095 AL_BUFFERS_PROCESSED, &buffers_processed
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5096 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5097 fprintf(stderr, "Buffers processed = %d\n", buffers_processed);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5098
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5099 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5100 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5101 AL_BUFFERS_QUEUED, &buffers_still_queued
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5102 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5103
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5104 /******** END REMOVE *******/
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5105 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5106 /* FIXME: Ugh! Somewhere an alError is being thrown ("Invalid Enum Value"), but I can't
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5107 * find it. It only seems to be thrown for OS X. I placed error messages after every al*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5108 * command I could find in the above loops, but the error doesn't seem to show
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5109 * up until around here. I mistook it for a get queued buffers
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5110 * error in OS X. I don't think there's an error down there.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5111 * For now, I'm clearing the error here.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5112 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5113
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5114 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5115 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5116 fprintf(stderr, "03Testing errpr before unqueue because getting stuff, for OS X this is expected: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5117 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5118 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5119
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5120
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5121 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5122 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5123 AL_SOURCE_STATE, &state
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5124 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5125 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5126 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5127 fprintf(stderr, "02Testing errpr before unqueue because getting stuff, for OS X this is expected: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5128 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5129 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5130
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5131
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5132 if(AL_STOPPED == state)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5133 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5134 /* Playback has ended.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5135 * Loop if necessary, or launch callback
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5136 * and clear channel (or clear channel and
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5137 * then launch callback?)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5138 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5139
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5140
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5141 /* Need to check for loops */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5142 if(ALmixer_Channel_List[i].loops != 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5143 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5144 /* Corner Case: If the buffer has
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5145 * been modified using Seek,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5146 * the loop will start at the seek
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5147 * position.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5148 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5149 if(ALmixer_Channel_List[i].loops != -1)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5150 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5151 ALmixer_Channel_List[i].loops--;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5152 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5153 alSourcePlay(ALmixer_Channel_List[i].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5154 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5155 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5156 fprintf(stderr, "50Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5157 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5158 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5159 continue;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5160 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5161 /* No loops. End play. */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5162 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5163 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5164 /* Problem: It seems that when mixing
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5165 * streamed and predecoded sources,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5166 * the previous instance lingers,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5167 * so we need to force remove
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5168 * the data from the source.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5169 * The sharing problem
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5170 * occurs when a previous predecoded buffer is played on
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5171 * a source, and then a streamed source is played later
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5172 * on that same source. OpenAL isn't consistently
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5173 * removing the previous buffer so both get played.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5174 * (Different dists seem to have different quirks.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5175 * The problem might lead to crashes in the worst case.)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5176 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5177 /* Additional problem: There is another
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5178 * inconsistency among OpenAL distributions.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5179 * Both Loki and Creative Windows seem to keep
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5180 * the buffer queued which requires removing.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5181 * But the Creative Macintosh version does
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5182 * not have any buffer queued after play
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5183 * and it returns the error: Invalid Enum Value
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5184 * if I try to unqueue it.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5185 * So I'm going to put in a check to see if I
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5186 * can detect any buffers queued first
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5187 * and then unqueue them if I can see them.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5188 * Additional note: The new CoreAudio based
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5189 * implementation leaves it's buffer queued
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5190 * like Loki and Creative Windows. But
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5191 * considering all the problems I'm having
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5192 * with the different distributions, this
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5193 * check seems reasonable.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5194 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5195 ALint buffers_still_queued;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5196 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5197 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5198 fprintf(stderr, "01Testing errpr before unqueue because getting stuff, for OS X this is expected: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5199 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5200 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5201
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5202 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5203 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5204 AL_BUFFERS_QUEUED, &buffers_still_queued
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5205 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5206 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5207 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5208 fprintf(stderr, "Error with unqueue, for OS X this is expected: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5209 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5210 ALmixer_SetError("Failed detecting unqueued predecoded buffer (expected with OS X): %s",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5211 alGetString(error) );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5212 error_flag--;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5213 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5214 if(buffers_still_queued > 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5215 {
48
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
5216 ALboolean clear_succeeded = Internal_DetachBuffersFromSource(ALmixer_Channel_List[i].alsource, ALmixer_Channel_List[i].almixer_data->decoded_all);
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
5217 if(AL_FALSE == clear_succeeded)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5218 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5219 error_flag--;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5220 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5221 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5222
10
c808684660a7 Bug fix: Moved Invoke_Callback before CleanChannel because I was trying to get the ALmixer_Data pointer, but it was cleared:
Eric Wing <ewing . public |-at-| gmail . com>
parents: 6
diff changeset
5223 /* Launch callback */
c808684660a7 Bug fix: Moved Invoke_Callback before CleanChannel because I was trying to get the ALmixer_Data pointer, but it was cleared:
Eric Wing <ewing . public |-at-| gmail . com>
parents: 6
diff changeset
5224 Invoke_Channel_Done_Callback(i, AL_TRUE);
c808684660a7 Bug fix: Moved Invoke_Callback before CleanChannel because I was trying to get the ALmixer_Data pointer, but it was cleared:
Eric Wing <ewing . public |-at-| gmail . com>
parents: 6
diff changeset
5225
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5226 Clean_Channel(i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5227 /* Subtract counter */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5228 Is_Playing_global--;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5229
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5230
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5231 /* We're done for this loop.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5232 * Go to next channel
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5233 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5234 continue;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5235 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5236 continue;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5237 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5238 } /* End if decoded_all */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5239 /* For streamed */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5240 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5241 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5242 ALint buffers_processed;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5243 ALint buffers_still_queued;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5244 ALint current_buffer_id;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5245
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5246 ALuint unqueued_buffer_id;
28
60500a33735a Initial backend changes to decouple assumption of 1 buffer queued per channel / per pass. API will eventually be changed/broken to support this.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 27
diff changeset
5247 ALuint number_of_buffers_to_queue_this_pass = ALmixer_Channel_List[i].almixer_data->num_target_buffers_per_pass;
60500a33735a Initial backend changes to decouple assumption of 1 buffer queued per channel / per pass. API will eventually be changed/broken to support this.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 27
diff changeset
5248 ALuint current_count_of_buffer_queue_passes = 0;
60500a33735a Initial backend changes to decouple assumption of 1 buffer queued per channel / per pass. API will eventually be changed/broken to support this.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 27
diff changeset
5249
44
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
5250 /* fprintf(stderr, "For Streamed\n"); */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5251
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5252 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5253 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5254 AL_SOURCE_STATE, &state
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5255 );
44
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
5256 #if 0
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
5257 /********* Remove this **********/
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
5258 switch(state)
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
5259 {
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5260 case AL_PLAYING:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5261 fprintf(stderr, "Channel '%d' is PLAYING\n", i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5262 break;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5263 case AL_PAUSED:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5264 fprintf(stderr, "Channel '%d' is PAUSED\n",i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5265 break;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5266 case AL_STOPPED:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5267 fprintf(stderr, "Channel '%d' is STOPPED\n",i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5268 break;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5269 case AL_INITIAL:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5270 fprintf(stderr, "Channel '%d' is INITIAL\n",i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5271 break;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5272 default:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5273 fprintf(stderr, "Channel '%d' is UNKNOWN\n",i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5274 break;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5275 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5276 /******** END REMOVE *******/
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5277 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5278 /* Get the number of buffers still queued */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5279 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5280 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5281 AL_BUFFERS_QUEUED, &buffers_still_queued
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5282 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5283 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5284 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5285 fprintf(stderr, "51Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5286 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5287 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5288 /* Get the number of buffers processed
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5289 * so we know if we need to refill
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5290 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5291 /* WARNING: It looks like Snow Leopard some times crashes on this call under x86_64
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5292 * typically when I suffer a lot of buffer underruns.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5293 */
47
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5294 /* fprintf(stderr, "calling AL_BUFFERS_PROCESSED on source:%d", ALmixer_Channel_List[i].alsource); */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5295 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5296 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5297 AL_BUFFERS_PROCESSED, &buffers_processed
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5298 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5299 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5300 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5301 fprintf(stderr, "52Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5302 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5303 }
47
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5304 /* fprintf(stderr, "finished AL_BUFFERS_PROCESSED, buffers_processed=%d", buffers_processed); */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5305
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5306 /* WTF!!! The Nvidia distribution is failing on the alGetSourcei(source, AL_BUFFER, buf_id) call.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5307 * I need this call to figure out which buffer OpenAL is currently playing.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5308 * It keeps returning an "Invalid Enum" error.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5309 * This is totally inane! It's a basic query.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5310 * By the spec, this functionality is not explicitly defined so Nvidia refuses to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5311 * fix this behavior, even though all other distributions work fine with this.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5312 * The only workaround for this is for
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5313 * a significant rewrite of my code which requires me to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5314 * duplicate the OpenAL queued buffers state with my own
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5315 * code and try to derive what the current playing buffer is by indirect observation of
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5316 * looking at buffers_processed. But of course this has a ton of downsides since my
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5317 * queries do not give me perfect timing of what OpenAL is actually doing and
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5318 * the fact that some of the distributions seem to have buffer queuing problems
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5319 * with their query results (CoreAudio). This also means a ton of extra code
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5320 * on my side. The lack of support of a 1 line call has required me to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5321 * implement yet another entire state machine. <sigh>
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5322 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5323 #if 0 /* This code will not work until possibly OpenAL 1.1 because of Nvidia */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5324 /* Get the id to the current buffer playing */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5325 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5326 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5327 AL_BUFFER, &current_buffer_id
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5328 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5329 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5330 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5331 fprintf(stderr, "53Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5332 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5333 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5334
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5335 /* Before the hard stuff, check to see if the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5336 * current queued AL buffer has changed.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5337 * If it has, we should launch a data callback if
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5338 * necessary
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5339 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5340 if( ((ALuint)current_buffer_id) !=
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5341 ALmixer_Channel_List[i].almixer_data->current_buffer)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5342 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5343 ALmixer_Channel_List[i].almixer_data->current_buffer
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5344 = (ALuint)current_buffer_id;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5345
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5346 Invoke_Streamed_Channel_Data_Callback(i, ALmixer_Channel_List[i].almixer_data, current_buffer_id);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5347 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5348 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5349 /* Only do this if "access_data" was requested (i.e. the circular_buffer!=NULL)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5350 * And if one of the two are true:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5351 * Either buffers_processed > 0 (because the current_buffer might have changed)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5352 * or if the current_buffer==0 (because we are in an initial state or recovering from
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5353 * a buffer underrun)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5354 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5355 if((ALmixer_Channel_List[i].almixer_data->circular_buffer_queue != NULL)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5356 && (
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5357 (buffers_processed > 0) || (0 == ALmixer_Channel_List[i].almixer_data->current_buffer)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5358 )
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5359 )
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5360 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5361 ALint k;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5362 ALuint queue_ret_flag;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5363 ALubyte is_out_of_sync = 0;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5364 ALuint my_queue_size = CircularQueueUnsignedInt_Size(ALmixer_Channel_List[i].almixer_data->circular_buffer_queue);
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
5365 /* Ugh, I have to deal with signed/unsigned mismatch here. */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
5366 ALint buffers_unplayed_int = buffers_still_queued - buffers_processed;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5367 ALuint unplayed_buffers;
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
5368 if(buffers_unplayed_int < 0)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
5369 {
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
5370 unplayed_buffers = 0;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
5371 }
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
5372 else
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
5373 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5374 unplayed_buffers = (ALuint)buffers_unplayed_int;
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
5375 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5376 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5377 fprintf(stderr, "Queue in processed check, before pop, buffers_processed=%d\n", buffers_processed);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5378 CircularQueueUnsignedInt_Print(ALmixer_Channel_List[i].almixer_data->circular_buffer_queue);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5379 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5380 /* We can't make any determinations solely based on the number of buffers_processed
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5381 * because currently, we only unqueue 1 buffer per loop. That means if 2 or more
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5382 * buffers became processed in one loop, the following loop, we would have
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5383 * at least that_many-1 buffers_processed (plus possible new processed).
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5384 * If we tried to just remove 1 buffer from our queue, we would be incorrect
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5385 * because we would not actually reflect the current playing buffer.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5386 * So the solution seems to be to make sure our queue is the same size
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5387 * as the number of buffers_queued-buffers_processed, and return the head of our queue
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5388 * as the current playing buffer.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5389 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5390 /* Also, we have a corner case. When we first start playing or if we have
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5391 * a buffer underrun, we have not done a data callback.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5392 * In this case, we need to see if there is any new data in our queue
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5393 * and if so, launch that data callback.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5394 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5395 /* Warning, this code risks the possibility of no data callback being fired if
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5396 * the system is really late (or skipped buffers).
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5397 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5398
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5399 /* First, let's syncronize our queue with the OpenAL queue */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5400 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5401 fprintf(stderr, "inside, Buffers processed=%d, Buffers queued=%d, my queue=%d\n",
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5402 buffers_processed, buffers_still_queued, my_queue_size);
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
5403 #endif
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5404 is_out_of_sync = 1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5405 for(k=0; k<buffers_processed; k++)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5406 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5407 queue_ret_flag = CircularQueueUnsignedInt_PopFront(
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5408 ALmixer_Channel_List[i].almixer_data->circular_buffer_queue);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5409 if(0 == queue_ret_flag)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5410 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5411 fprintf(stderr, "53 Error popping queue\n");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5412 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
5413 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5414 my_queue_size = CircularQueueUnsignedInt_Size(ALmixer_Channel_List[i].almixer_data->circular_buffer_queue);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5415 /* We have several possibilities we need to handle:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5416 * 1) We are in an initial state or underrun and need to do a data callback on the head.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5417 * 2) We were out of sync and need to do a new data callback on the new head.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5418 * 3) We were not out of sync but just had left over processed buffers which caused us to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5419 * fall in this block of code. (Don't do anything.)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5420 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5421 if( (0 == ALmixer_Channel_List[i].almixer_data->current_buffer) || (1 == is_out_of_sync) )
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5422 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5423 if(my_queue_size > 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5424 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5425 current_buffer_id = CircularQueueUnsignedInt_Front(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5426 ALmixer_Channel_List[i].almixer_data->circular_buffer_queue);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5427 if(0 == current_buffer_id)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5428 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5429 fprintf(stderr, "53a Internal Error, current_buffer_id=0 when it shouldn't be 0\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5430 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5431 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5432 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5433 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5434 fprintf(stderr, "Queue in processed check, after pop\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5435 CircularQueueUnsignedInt_Print(ALmixer_Channel_List[i].almixer_data->circular_buffer_queue);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5436 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5437 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5438 ALmixer_Channel_List[i].almixer_data->current_buffer
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5439 = (ALuint)current_buffer_id;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5440
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5441 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5442 /* Remove me...only for checking...doesn't work on Nvidia */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5443 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5444 ALuint real_id;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5445 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5446 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5447 AL_BUFFER, &real_id
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5448 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5449 alGetError();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5450 fprintf(stderr, "Callback fired on data buffer=%d, real_id shoud be=%d\n", current_buffer_id, real_id);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5451 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5452 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5453 Invoke_Streamed_Channel_Data_Callback(i, ALmixer_Channel_List[i].almixer_data, current_buffer_id);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5454 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5455 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5456 {
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
5457 /*
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5458 fprintf(stderr, "53b, Notice/Warning:, OpenAL queue has been depleted.\n");
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
5459 PrintQueueStatus(ALmixer_Channel_List[i].alsource);
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
5460 */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5461 /* In this case, we might either be in an underrun or finished with playback */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5462 ALmixer_Channel_List[i].almixer_data->current_buffer = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5463 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5464 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5465 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5466 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5467
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5468
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5469
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5470 /* Just a test - remove
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5471 if( ALmixer_Channel_List[i].loops > 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5472 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5473 fprintf(stderr, ">>>>>>>>>>>>>>>Loops = %d\n",
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5474 ALmixer_Channel_List[i].loops);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5475 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5476 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5477 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5478 fprintf(stderr, "Buffers processed = %d\n", buffers_processed);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5479 fprintf(stderr, "Buffers queued= %d\n", buffers_still_queued);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5480 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5481 /* We've used up a buffer so we need to unqueue and replace */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5482 /* Okay, it gets more complicated here:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5483 * We need to Queue more data
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5484 * if buffers_processed > 0 or
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5485 * if num_of_buffers_in_use < NUMBER_OF_QUEUE_BUFFERS
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5486 * but we don't do this if at EOF,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5487 * except when there is looping
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5488 */
28
60500a33735a Initial backend changes to decouple assumption of 1 buffer queued per channel / per pass. API will eventually be changed/broken to support this.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 27
diff changeset
5489
60500a33735a Initial backend changes to decouple assumption of 1 buffer queued per channel / per pass. API will eventually be changed/broken to support this.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 27
diff changeset
5490 /* NEW FEATURE: Try to queue up more buffers per pass, allowing the size of the buffer to be decoupled. */
60500a33735a Initial backend changes to decouple assumption of 1 buffer queued per channel / per pass. API will eventually be changed/broken to support this.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 27
diff changeset
5491 /* TODO: Optimization: If number of available buffers (max_buffers-buffers_in_use), adjust the number of buffers to queue for this pass. */
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5492 /* I would benefit from a clearer flag that tells me whether we're in an underrun.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5493 * I think current_buffer only works if data callbacks are enabled.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5494 * So I'll look at for AL_STOPPED which might give me false positives, depending on the code above.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5495 * But I think/hope the code below will deal with it correctly.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5496 * If in an underrun, queue up at least startup_buffers.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5497 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5498 if(AL_STOPPED == state)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5499 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5500 number_of_buffers_to_queue_this_pass = ALmixer_Channel_List[i].almixer_data->num_startup_buffers;
47
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5501 /* fprintf(stderr, "assuming underrun condition, using num_startup_buffers=%d\n", number_of_buffers_to_queue_this_pass); */
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5502 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5503
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5504 /* Don't bother to check to make sure the number_of_buffers_to_queue_this_pass does not exceed the maximum number of buffers because of the logic hack bug. */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5505 /* Logic Hack/Bug: In adding the number_of_buffers_to_queue_this_pass, I discovered the for-loop needs to be more decoupled.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5506 * The loop still needs to be entered because unqueuing and completion callbacks and possibly other state processing are also done.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5507 * So we always need to claim to queue one buffer. (The code already checks for max_queue_buffers.)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5508 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5509 if(0 == number_of_buffers_to_queue_this_pass)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5510 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5511 number_of_buffers_to_queue_this_pass = 1;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5512 }
28
60500a33735a Initial backend changes to decouple assumption of 1 buffer queued per channel / per pass. API will eventually be changed/broken to support this.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 27
diff changeset
5513 for(current_count_of_buffer_queue_passes=0; current_count_of_buffer_queue_passes<number_of_buffers_to_queue_this_pass; current_count_of_buffer_queue_passes++)
60500a33735a Initial backend changes to decouple assumption of 1 buffer queued per channel / per pass. API will eventually be changed/broken to support this.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 27
diff changeset
5514 {
47
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5515 /* fprintf(stderr, "current_count_of_buffer_queue_passes:%d\n", current_count_of_buffer_queue_passes); */
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5516
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5517 /* Because I introduced this for-loop, I think I need to regrab the number of processed buffers because
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5518 * the number may now be stale from previous iterations. I suppose I could do it at the end of the loop,
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5519 * but the logic flow is already too complicated to ensure that the block is being hit.
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5520 */
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5521 /* Get the number of buffers processed
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5522 */
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5523 alGetSourcei(
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5524 ALmixer_Channel_List[i].alsource,
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5525 AL_BUFFERS_PROCESSED,
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5526 &buffers_processed
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5527 );
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5528 if((error = alGetError()) != AL_NO_ERROR)
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5529 {
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5530 fprintf(stderr, "59aTestingError, Can't get buffers_processed: %s\n",
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5531 alGetString(error));
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5532 }
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5533
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5534
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5535 /* For this to work, we must rely on EVERYTHING
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5536 * else to unset the EOF if there is looping.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5537 * Remember, even Play() must do this
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5538 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5539
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5540 /* If not EOF, then we are still playing.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5541 * Inside, we might find num_of_buffers < NUM...QUEUE_BUF..
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5542 * or buffers_process > 0
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5543 * in which case we queue up.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5544 * We also might find no buffers we need to fill,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5545 * in which case we just keep going
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5546 */
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5547 if( ! ALmixer_Channel_List[i].almixer_data->eof)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5548 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5549 ALuint bytes_returned;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5550 /* We have a priority. We first must assign
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5551 * unused buffers in reserve. If there is nothing
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5552 * left, then we may unqueue buffers. We can't
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5553 * do it the other way around because we will
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5554 * lose the pointer to the unqueued buffer
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5555 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5556 if(ALmixer_Channel_List[i].almixer_data->num_buffers_in_use
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5557 < ALmixer_Channel_List[i].almixer_data->max_queue_buffers)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5558 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5559 #if 0
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5560 fprintf(stderr, "Getting more data in NOT_EOF and num_buffers_in_use (%d) < max_queue (%d)\n",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5561 ALmixer_Channel_List[i].almixer_data->num_buffers_in_use,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5562 ALmixer_Channel_List[i].almixer_data->max_queue_buffers);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5563 #endif
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5564 /* Going to add an unused packet.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5565 * Grab next packet */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5566 bytes_returned = GetMoreData(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5567 ALmixer_Channel_List[i].almixer_data,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5568 ALmixer_Channel_List[i].almixer_data->buffer[
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5569 ALmixer_Channel_List[i].almixer_data->num_buffers_in_use]
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5570 );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5571 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5572 /* For processed > 0 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5573 else if(buffers_processed > 0)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5574 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5575 /* Unqueue only 1 buffer for now.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5576 * If there are more than one,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5577 * let the next Update pass deal with it
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5578 * so we don't stall the program for too long.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5579 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5580 #if 0
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5581 fprintf(stderr, "About to Unqueue, Buffers processed = %d\n", buffers_processed);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5582 fprintf(stderr, "Buffers queued= %d\n", buffers_still_queued);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5583 fprintf(stderr, "Unqueuing a buffer\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5584 #endif
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5585 alSourceUnqueueBuffers(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5586 ALmixer_Channel_List[i].alsource,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5587 1, &unqueued_buffer_id
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5588 );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5589 if((error = alGetError()) != AL_NO_ERROR)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5590 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5591 fprintf(stderr, "Error with unqueue: %s, buffer id is %d",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5592 alGetString(error), unqueued_buffer_id);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5593 ALmixer_SetError("Unqueue buffer failed: %s",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5594 alGetString(error) );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5595 error_flag--;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5596 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5597 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5598 fprintf(stderr, "Right after unqueue...");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5599 PrintQueueStatus(ALmixer_Channel_List[i].alsource);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5600 fprintf(stderr, "Getting more data for NOT_EOF, max_buffers filled\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5601 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5602 /* Grab unqueued packet */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5603 bytes_returned = GetMoreData(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5604 ALmixer_Channel_List[i].almixer_data,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5605 unqueued_buffer_id);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5606 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5607 /* We are still streaming, but currently
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5608 * don't need to fill any buffers */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5609 else
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5610 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5611 /* Might want to check state */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5612 /* In case the playback stopped,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5613 * we need to resume
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5614 * a.k.a. buffer underrun
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5615 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5616 #if 1
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5617 /* Try not refetching the state here because I'm getting a duplicate
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5618 buffer playback (hiccup) */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5619 alGetSourcei(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5620 ALmixer_Channel_List[i].alsource,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5621 AL_SOURCE_STATE, &state
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5622 );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5623 if((error = alGetError()) != AL_NO_ERROR)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5624 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5625 fprintf(stderr, "54bTesting error: %s\n",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5626 alGetString(error));
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5627 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5628 /* Get the number of buffers processed
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5629 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5630 alGetSourcei(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5631 ALmixer_Channel_List[i].alsource,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5632 AL_BUFFERS_PROCESSED,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5633 &buffers_processed
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5634 );
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5635 if((error = alGetError()) != AL_NO_ERROR)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5636 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5637 fprintf(stderr, "54cError, Can't get buffers_processed: %s\n",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5638 alGetString(error));
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5639 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5640 #endif
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5641 if(AL_STOPPED == state)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5642 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5643 /* Resuming in not eof, but nothing to buffer */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5644
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5645 /* Okay, here's another lately discovered problem:
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5646 * I can't find it in the spec, but for at least some of the
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5647 * implementations, if I call play on a stopped source that
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5648 * has processed buffers, all those buffers get marked as unprocessed
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5649 * on alSourcePlay. So if I had a queue of 25 with 24 of the buffers
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5650 * processed, on resume, the earlier 24 buffers will get replayed,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5651 * causing a "hiccup" like sound in the playback.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5652 * To avoid this, I must unqueue all processed buffers before
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5653 * calling play. But to complicate things, I need to worry about resyncing
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5654 * the circular queue with this since I designed this thing
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5655 * with some correlation between the two. However, I might
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5656 * have already handled this, so I will try writing this code without
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5657 * syncing for now.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5658 * There is currently an assumption that a buffer
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5659 * was queued above so I actually have something
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5660 * to play.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5661 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5662 ALint temp_count;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5663 #if 0
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5664 fprintf(stderr, "STOPPED1, need to clear processed=%d, status is:\n", buffers_processed);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5665 PrintQueueStatus(ALmixer_Channel_List[i].alsource);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5666 #endif
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5667 for(temp_count=0; temp_count<buffers_processed; temp_count++)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5668 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5669 alSourceUnqueueBuffers(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5670 ALmixer_Channel_List[i].alsource,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5671 1, &unqueued_buffer_id
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5672 );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5673 if((error = alGetError()) != AL_NO_ERROR)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5674 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5675 fprintf(stderr, "55aTesting error: %s\n",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5676 alGetString(error));
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5677 error_flag--;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5678 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5679 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5680 #if 0
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5681 fprintf(stderr, "After unqueue clear...:\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5682 PrintQueueStatus(ALmixer_Channel_List[i].alsource);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5683 #endif
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5684 /* My assertion: We are STOPPED but not EOF.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5685 * This means we have a buffer underrun.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5686 * We just cleared out the unqueued buffers.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5687 * So we need to reset the mixer_data to reflect we have
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5688 * no buffers in queue.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5689 * We need to GetMoreData and then queue up the data.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5690 * Then we need to resume playing.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5691 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5692 #if 0
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5693 int buffers_queued;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5694 alGetSourcei(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5695 ALmixer_Channel_List[i].alsource,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5696 AL_BUFFERS_QUEUED,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5697 &buffers_queued
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5698 );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5699
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5700 if((error = alGetError()) != AL_NO_ERROR)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5701 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5702 fprintf(stderr, "Error in PrintQueueStatus, Can't get buffers_queued: %s\n",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5703 alGetString(error));
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5704 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5705 assert(buffers_queued == 0);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5706 fprintf(stderr, "buffer underrun: buffers_queued:%d\n", buffers_queued);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5707 #endif
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5708
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5709 /* Reset the number of buffers in use to 0 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5710 ALmixer_Channel_List[i].almixer_data->num_buffers_in_use = 0;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5711
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5712 /* Get more data and put it in the first buffer */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5713 bytes_returned = GetMoreData(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5714 ALmixer_Channel_List[i].almixer_data,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5715 ALmixer_Channel_List[i].almixer_data->buffer[0]
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5716 );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5717 /* NOTE: We might want to look for EOF and handle it here.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5718 * Currently, I just let the next loop handle it which seems to be working.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5719 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5720 if(bytes_returned > 0)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5721 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5722 /* Queue up the new data */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5723 alSourceQueueBuffers(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5724 ALmixer_Channel_List[i].alsource,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5725 1,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5726 &ALmixer_Channel_List[i].almixer_data->buffer[0]
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5727 );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5728 if((error = alGetError()) != AL_NO_ERROR)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5729 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5730 fprintf(stderr, "56e alSourceQueueBuffers error: %s\n",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5731 alGetString(error));
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5732 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5733 /* Increment the number of buffers in use */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5734 ALmixer_Channel_List[i].almixer_data->num_buffers_in_use++;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5735
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5736
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5737 /* We need to empty and update the circular buffer queue if it is in use */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5738 if(ALmixer_Channel_List[i].almixer_data->circular_buffer_queue != NULL)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5739 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5740 ALuint queue_ret_flag;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5741 CircularQueueUnsignedInt_Clear(ALmixer_Channel_List[i].almixer_data->circular_buffer_queue);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5742 queue_ret_flag = CircularQueueUnsignedInt_PushBack(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5743 ALmixer_Channel_List[i].almixer_data->circular_buffer_queue,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5744 ALmixer_Channel_List[i].almixer_data->buffer[0]
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5745 );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5746 if(0 == queue_ret_flag)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5747 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5748 fprintf(stderr, "56fSerious internal error: CircularQueue could not push into queue.\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5749 ALmixer_SetError("Serious internal error: CircularQueue failed to push into queue");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5750 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5751 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5752
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5753
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5754
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5755
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5756 /* Resume playback from underrun */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5757 alSourcePlay(ALmixer_Channel_List[i].alsource);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5758 if((error = alGetError()) != AL_NO_ERROR)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5759 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5760 fprintf(stderr, "55Tbesting error: %s\n",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5761 alGetString(error));
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5762 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5763 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5764
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5765 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5766 /* Let's escape to the next loop.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5767 * All code below this point is for queuing up
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5768 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5769 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5770 fprintf(stderr, "Entry: Nothing to do...continue\n\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5771 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5772 continue;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5773 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5774 /* We now know we have to fill an available
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5775 * buffer.
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5776 */
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5777
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5778 /* In the previous branch, we just grabbed more data.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5779 * Let's check it to make sure it's okay,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5780 * and then queue it up
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5781 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5782 /* This check doesn't work anymore because it is now ALuint */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5783 #if 0
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5784 if(-1 == bytes_returned)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5785 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5786 /* Problem occurred...not sure what to do */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5787 /* Go to next loop? */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5788 error_flag--;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5789 /* Set the eof flag to force a quit so
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5790 * we don't get stuck in an infinite loop
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5791 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5792 ALmixer_Channel_List[i].almixer_data->eof = 1;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5793 continue;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5794 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5795 #endif
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5796 /* This is a special case where we've run
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5797 * out of data. We should check for loops
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5798 * and get more data. If there is no loop,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5799 * then do nothing and wait for future
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5800 * update passes to handle the EOF.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5801 * The advantage of handling the loop here
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5802 * instead of waiting for play to stop is
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5803 * that we should be able to keep the buffer
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5804 * filled.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5805 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5806 #if 0
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5807 else if(0 == bytes_returned)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5808 #endif
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5809 if(0 == bytes_returned)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5810 {
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5811 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5812 fprintf(stderr, "We got 0 bytes from reading. Checking for loops\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5813 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5814 /* Check for loops */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5815 if( ALmixer_Channel_List[i].loops != 0 )
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5816 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5817 /* We have to loop, so rewind
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5818 * and fetch more data
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5819 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5820 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5821 fprintf(stderr, "Rewinding data\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5822 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5823 if(0 == Sound_Rewind(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5824 ALmixer_Channel_List[i].almixer_data->sample))
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5825 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5826 fprintf(stderr, "Rewinding failed\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5827 ALmixer_SetError( Sound_GetError() );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5828 ALmixer_Channel_List[i].loops = 0;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5829 error_flag--;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5830 /* We'll continue on because we do have some valid data */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5831 continue;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5832 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5833 /* Remember to reset the data->eof flag */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5834 ALmixer_Channel_List[i].almixer_data->eof = 0;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5835 if(ALmixer_Channel_List[i].loops > 0)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5836 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5837 ALmixer_Channel_List[i].loops--;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5838 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5839 /* Try grabbing another packet now.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5840 * Since we may have already unqueued a
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5841 * buffer, we don't want to lose it.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5842 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5843 if(ALmixer_Channel_List[i].almixer_data->num_buffers_in_use
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5844 < ALmixer_Channel_List[i].almixer_data->max_queue_buffers)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5845 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5846 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5847 fprintf(stderr, "We got %d bytes from reading loop. Filling unused packet\n", bytes_returned);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5848 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5849 /* Grab next packet */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5850 bytes_returned = GetMoreData(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5851 ALmixer_Channel_List[i].almixer_data,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5852 ALmixer_Channel_List[i].almixer_data->buffer[
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5853 ALmixer_Channel_List[i].almixer_data->num_buffers_in_use]
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5854 );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5855 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5856 fprintf(stderr, "We reread %d bytes into unused packet\n", bytes_returned);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5857 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5858 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5859 /* Refilling unqueued packet */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5860 else
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5861 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5862 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5863 fprintf(stderr, "We got %d bytes from reading loop. Filling unqueued packet\n", bytes_returned);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5864 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5865 /* Grab next packet */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5866 bytes_returned = GetMoreData(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5867 ALmixer_Channel_List[i].almixer_data,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5868 unqueued_buffer_id);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5869 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5870 fprintf(stderr, "We reread %d bytes into unqueued packet\n", bytes_returned);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5871 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5872 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5873 /* Another error check */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5874 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5875 if(bytes_returned <= 0)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5876 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5877 if(0 == bytes_returned)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5878 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5879 fprintf(stderr, "??????????ERROR\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5880 ALmixer_SetError("Could not loop because after rewind, no data could be retrieved");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5881 /* Problem occurred...not sure what to do */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5882 /* Go to next loop? */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5883 error_flag--;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5884 /* Set the eof flag to force a quit so
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5885 * we don't get stuck in an infinite loop
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5886 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5887 ALmixer_Channel_List[i].almixer_data->eof = 1;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5888 continue;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5889 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5890 /* We made it to the end. We still need
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5891 * to BufferData, so let this branch
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5892 * fall into the next piece of
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5893 * code below which will handle that
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5894 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5895
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5896
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5897 } /* END loop check */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5898 else
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5899 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5900 /* No more loops to do.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5901 * EOF flag should be set.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5902 * Just go to next loop and
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5903 * let things be handled correctly
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5904 * in future update calls
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5905 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5906 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5907 fprintf(stderr, "SHOULD BE EOF\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5908
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5909 PrintQueueStatus(ALmixer_Channel_List[i].alsource);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5910 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5911 continue;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5912 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5913 } /* END if bytes_returned == 0 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5914 /********* Possible trouble point. I might be queueing empty buffers on the mac.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5915 * This check doesn't say if the buffer is valid. Only the EOF assumption is a clue at this point
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5916 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5917 /* Fall here */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5918 /* Everything is normal. We aren't
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5919 * at an EOF, but need to simply
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5920 * queue more data. The data is already checked for good,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5921 * so queue it up */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5922 if(ALmixer_Channel_List[i].almixer_data->num_buffers_in_use
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5923 < ALmixer_Channel_List[i].almixer_data->max_queue_buffers)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5924 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5925 /* Keep count of how many buffers we have
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5926 * to queue so we can return the value
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5927 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5928 retval++;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5929 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5930 fprintf(stderr, "NOT_EOF???, about to Queue more data for num_buffers (%d) < max_queue (%d)\n",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5931 ALmixer_Channel_List[i].almixer_data->num_buffers_in_use,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5932 ALmixer_Channel_List[i].almixer_data->max_queue_buffers);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5933 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5934 alSourceQueueBuffers(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5935 ALmixer_Channel_List[i].alsource,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5936 1,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5937 &ALmixer_Channel_List[i].almixer_data->buffer[
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5938 ALmixer_Channel_List[i].almixer_data->num_buffers_in_use]
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5939 );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5940 if((error = alGetError()) != AL_NO_ERROR)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5941 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5942 fprintf(stderr, "56Testing error: %s\n",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5943 alGetString(error));
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5944 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5945 /* This is part of the hideous Nvidia workaround. In order to figure out
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5946 * which buffer to show during callbacks (for things like
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5947 * o-scopes), I must keep a copy of the buffers that are queued in my own
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5948 * data structure. This code will be called only if
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5949 * "access_data" was set, indicated by whether the queue is NULL.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5950 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5951 if(ALmixer_Channel_List[i].almixer_data->circular_buffer_queue != NULL)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5952 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5953 ALuint queue_ret_flag;
47
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
5954 /* fprintf(stderr, "56d: CircularQueue_PushBack.\n"); */
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5955 queue_ret_flag = CircularQueueUnsignedInt_PushBack(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5956 ALmixer_Channel_List[i].almixer_data->circular_buffer_queue,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5957 ALmixer_Channel_List[i].almixer_data->buffer[ALmixer_Channel_List[i].almixer_data->num_buffers_in_use]
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5958 );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5959 if(0 == queue_ret_flag)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5960 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5961 fprintf(stderr, "56aSerious internal error: CircularQueue could not push into queue.\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5962 ALmixer_SetError("Serious internal error: CircularQueue failed to push into queue");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5963 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5964 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5965 else
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5966 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5967 CircularQueueUnsignedInt_Print(ALmixer_Channel_List[i].almixer_data->circular_buffer_queue);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5968 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5969 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5970 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5971 }
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5972 /* for processed > 0 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5973 else
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5974 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5975 /* Keep count of how many buffers we have
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5976 * to queue so we can return the value
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5977 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5978 retval++;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5979 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5980 fprintf(stderr, "NOT_EOF, about to Queue more data for filled max_queue (%d)\n",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5981 ALmixer_Channel_List[i].almixer_data->max_queue_buffers);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5982 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5983 alSourceQueueBuffers(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5984 ALmixer_Channel_List[i].alsource,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5985 1, &unqueued_buffer_id);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5986 if((error = alGetError()) != AL_NO_ERROR)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5987 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5988 ALmixer_SetError("Could not QueueBuffer: %s",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5989 alGetString(error) );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5990 error_flag--;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5991 continue;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5992 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5993 /* This is part of the hideous Nvidia workaround. In order to figure out
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5994 * which buffer to show during callbacks (for things like
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5995 * o-scopes), I must keep a copy of the buffers that are queued in my own
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5996 * data structure. This code will be called only if
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5997 * "access_data" was set, indicated by whether the queue is NULL.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5998 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
5999 if(ALmixer_Channel_List[i].almixer_data->circular_buffer_queue != NULL)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6000 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6001 ALuint queue_ret_flag;
47
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
6002 /* fprintf(stderr, "56e: CircularQueue_PushBack.\n"); */
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6003 queue_ret_flag = CircularQueueUnsignedInt_PushBack(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6004 ALmixer_Channel_List[i].almixer_data->circular_buffer_queue,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6005 unqueued_buffer_id
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6006 );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6007 if(0 == queue_ret_flag)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6008 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6009 fprintf(stderr, "56bSerious internal error: CircularQueue could not push into queue.\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6010 ALmixer_SetError("Serious internal error: CircularQueue failed to push into queue");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6011 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6012 #if 0
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6013 else
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6014 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6015 CircularQueueUnsignedInt_Print(ALmixer_Channel_List[i].almixer_data->circular_buffer_queue);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6016 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6017 #endif
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6018 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6019 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6020 /* If we used an available buffer queue,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6021 * then we need to update the number of them in use
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6022 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6023 if(ALmixer_Channel_List[i].almixer_data->num_buffers_in_use
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6024 < ALmixer_Channel_List[i].almixer_data->max_queue_buffers)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6025 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6026 /* Increment the number of buffers in use */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6027 ALmixer_Channel_List[i].almixer_data->num_buffers_in_use++;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6028 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6029 /* Might want to check state */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6030 /* In case the playback stopped,
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6031 * we need to resume */
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6032 #if 1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6033 /* Try not refetching the state here because I'm getting a duplicate
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6034 buffer playback (hiccup) */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6035 alGetSourcei(
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6036 ALmixer_Channel_List[i].alsource,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6037 AL_SOURCE_STATE, &state
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6038 );
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6039 if((error = alGetError()) != AL_NO_ERROR)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6040 {
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6041 fprintf(stderr, "57bTesting error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6042 alGetString(error));
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6043 }
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6044 /* Get the number of buffers processed
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6045 */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6046 alGetSourcei(
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6047 ALmixer_Channel_List[i].alsource,
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6048 AL_BUFFERS_PROCESSED,
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6049 &buffers_processed
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6050 );
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6051 if((error = alGetError()) != AL_NO_ERROR)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6052 {
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6053 fprintf(stderr, "57cError, Can't get buffers_processed: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6054 alGetString(error));
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6055 }
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6056 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6057 if(AL_STOPPED == state)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6058 {
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6059 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6060 fprintf(stderr, "Resuming in not eof\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6061 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6062 /* Okay, here's another lately discovered problem:
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6063 * I can't find it in the spec, but for at least some of the
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6064 * implementations, if I call play on a stopped source that
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6065 * has processed buffers, all those buffers get marked as unprocessed
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6066 * on alSourcePlay. So if I had a queue of 25 with 24 of the buffers
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6067 * processed, on resume, the earlier 24 buffers will get replayed,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6068 * causing a "hiccup" like sound in the playback.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6069 * To avoid this, I must unqueue all processed buffers before
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6070 * calling play. But to complicate things, I need to worry about resyncing
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6071 * the circular queue with this since I designed this thing
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6072 * with some correlation between the two. However, I might
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6073 * have already handled this, so I will try writing this code without
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6074 * syncing for now.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6075 * There is currently an assumption that a buffer
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6076 * was queued above so I actually have something
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6077 * to play.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6078 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6079 ALint temp_count;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6080 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6081 fprintf(stderr, "STOPPED2, need to clear processed, status is:\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6082 PrintQueueStatus(ALmixer_Channel_List[i].alsource);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6083 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6084
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6085 for(temp_count=0; temp_count<buffers_processed; temp_count++)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6086 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6087 alSourceUnqueueBuffers(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6088 ALmixer_Channel_List[i].alsource,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6089 1, &unqueued_buffer_id
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6090 );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6091 if((error = alGetError()) != AL_NO_ERROR)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6092 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6093 fprintf(stderr, "58aTesting error: %s\n",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6094 alGetString(error));
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6095 error_flag--;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6096 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6097 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6098 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6099 fprintf(stderr, "After unqueue clear...:\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6100 PrintQueueStatus(ALmixer_Channel_List[i].alsource);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6101 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6102
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6103 alSourcePlay(ALmixer_Channel_List[i].alsource);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6104 if((error = alGetError()) != AL_NO_ERROR)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6105 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6106 fprintf(stderr, "55Tbesting 8rror: %s\n",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6107 alGetString(error));
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6108 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6109 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6110 continue;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6111 } /* END if( ! eof) */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6112 /* We have hit EOF in the SDL_Sound sample and there
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6113 * are no more loops. However, there may still be
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6114 * buffers in the OpenAL queue which still need to
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6115 * be played out. The following body of code will
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6116 * determine if play is still happening or
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6117 * initiate the stop/cleanup sequenece.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6118 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6119 else
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6120 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6121 /* Let's continue to remove the used up
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6122 * buffers as they come in. */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6123 if(buffers_processed > 0)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6124 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6125 ALint temp_count;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6126 /* Do as a for-loop because I don't want
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6127 * to have to create an array for the
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6128 * unqueued_buffer_id's
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6129 */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6130 for(temp_count=0; temp_count<buffers_processed; temp_count++)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6131 {
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6132 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6133 fprintf(stderr, "unqueuing remainder, %d\n", temp_count);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6134 */
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6135 alSourceUnqueueBuffers(
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6136 ALmixer_Channel_List[i].alsource,
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6137 1, &unqueued_buffer_id
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6138 );
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6139 if((error = alGetError()) != AL_NO_ERROR)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6140 {
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6141 fprintf(stderr, "59Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6142 alGetString(error));
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6143 }
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6144 }
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
6145 /*
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6146 fprintf(stderr, "done unqueuing remainder for this loop, %d\n", temp_count);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6147 */
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6148
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6149 /* Need to update counts since we removed everything.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6150 * If we don't update the counts here, we end up in the
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6151 * "Shouldn't be here section, but maybe it's okay due to race conditions"
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6152 */
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6153 alGetSourcei(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6154 ALmixer_Channel_List[i].alsource,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6155 AL_BUFFERS_QUEUED, &buffers_still_queued
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6156 );
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6157 if((error = alGetError()) != AL_NO_ERROR)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6158 {
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6159 fprintf(stderr, "5100Testing error: %s\n",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6160 alGetString(error));
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6161 }
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6162 /* Get the number of buffers processed
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6163 * so we know if we need to refill
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6164 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6165 alGetSourcei(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6166 ALmixer_Channel_List[i].alsource,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6167 AL_BUFFERS_PROCESSED, &buffers_processed
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6168 );
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6169 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6170 {
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6171 fprintf(stderr, "5200Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6172 alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6173 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6174 }
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6175
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6176
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6177 /* Else if buffers_processed == 0
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6178 * and buffers_still_queued == 0.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6179 * then we check to see if the source
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6180 * is still playing. Quit if stopped
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6181 * We shouldn't need to worry about
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6182 * looping because that should have
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6183 * been handled above.
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6184 */
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6185 if(0 == buffers_still_queued)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6186 {
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6187 /* Make sure playback has stopped before
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6188 * we shutdown.
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6189 */
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6190 alGetSourcei(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6191 ALmixer_Channel_List[i].alsource,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6192 AL_SOURCE_STATE, &state
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6193 );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6194 if((error = alGetError()) != AL_NO_ERROR)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6195 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6196 fprintf(stderr, "60Testing error: %s\n",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6197 alGetString(error));
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6198 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6199 if(AL_STOPPED == state)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6200 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6201 ALmixer_Channel_List[i].almixer_data->num_buffers_in_use = 0;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6202 /* Playback has ended.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6203 * Loop if necessary, or launch callback
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6204 * and clear channel (or clear channel and
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6205 * then launch callback?)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6206 * Update: Need to do callback first because I reference the mixer_data and source
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6207 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6208
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6209 /* Launch callback */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6210 Invoke_Channel_Done_Callback(i, AL_TRUE);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6211
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6212 Clean_Channel(i);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6213 /* Subtract counter */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6214 Is_Playing_global--;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6215
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6216
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6217 /* We're done for this loop.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6218 * Go to next channel
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6219 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6220
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6221 /* I used to call continue here, but continue isn't safe anymore because we are in the number_of_queue_buffers_per_pass loop now.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6222 * We should break, but we need to be careful that there is no code that is run once we break that wasn't run before.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6223 * We want to make sure we go immediately to the next iteration in the channel loop.
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6224 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6225 break;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6226 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6227 } /* End end-playback */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6228 else
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6229 {
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6230 /* Need to run out buffer */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6231 #if 1
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6232 /* Might want to check state */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6233 /* In case the playback stopped,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6234 * we need to resume */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6235 alGetSourcei(
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6236 ALmixer_Channel_List[i].alsource,
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6237 AL_SOURCE_STATE, &state
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6238 );
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6239 if((error = alGetError()) != AL_NO_ERROR)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6240 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6241 fprintf(stderr, "61Testing error: %s\n",
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6242 alGetString(error));
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6243 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6244 if(AL_STOPPED == state)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6245 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6246 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6247 fprintf(stderr, "Shouldn't be here. %d Buffers still in queue, but play stopped. This might be correct though because race conditions could have caused the STOP to happen right after our other tests...Checking queue status...\n", buffers_still_queued);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6248 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6249 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6250 PrintQueueStatus(ALmixer_Channel_List[i].alsource);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6251 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6252 /* Rather than force unqueuing the buffer, let's see if
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6253 * setting the buffer to none works (the OpenAL 1.0
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6254 * Reference Annotation suggests this should work).
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6255 */
48
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
6256 ALboolean clear_succeeded = Internal_DetachBuffersFromSource(ALmixer_Channel_List[i].alsource, ALmixer_Channel_List[i].almixer_data->decoded_all);
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
6257 if(AL_FALSE == clear_succeeded)
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
6258 {
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
6259 error_flag--;
00b770b0d2aa Workaround: There is a terrible OpenAL regression bug in iOS 5 dealing with streaming sources. alSourcei(source_id, AL_BUFFER, AL_NONE); fails to clear queued buffer queues on a streaming source. The workaround involves manually dequeuing the individual buffers before calling alSourcei(source_id, AL_BUFFER, AL_NONE);. But there is an additional race condition bug where the unqueue fails to take, so the included workaround keeps looping until the buffers finally report as cleared.
Eric Wing <ewing@anscamobile.com>
parents: 47
diff changeset
6260 }
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6261 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6262 PrintQueueStatus(ALmixer_Channel_List[i].alsource);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6263 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6264 /* This doesn't work because in some cases, I think
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6265 * it causes the sound to be replayed
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6266 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6267 /*
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6268 fprintf(stderr, "Resuming in eof (trying to run out buffers\n");
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6269 alSourcePlay(ALmixer_Channel_List[i].alsource);
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6270 */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6271 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6272 #endif
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6273 } /* End trap section */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6274 } /* End POST-EOF use-up buffer section */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6275
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
6276 } /* END NEW number of queue buffers per pass */
28
60500a33735a Initial backend changes to decouple assumption of 1 buffer queued per channel / per pass. API will eventually be changed/broken to support this.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 27
diff changeset
6277
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6278 } /* END Streamed section */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6279 } /* END channel in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6280 } /* END for-loop for each channel */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6281
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6282 #ifdef ENABLE_ALMIXER_ALC_SYNC
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6283 alcProcessContext(alcGetCurrentContext());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6284 if((error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6285 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6286 fprintf(stderr, "62Testing error: %s\n",
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6287 alGetString(error));
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6288 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6289 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6290
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6291 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6292 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6293 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6294 /* Return the number of errors */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6295 if(error_flag < 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6296 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6297 return error_flag;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6298 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6299 /* Return the number of buffers that were queued */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6300 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6301 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6302
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6303 #ifdef ENABLE_PARANOID_SIGNEDNESS_CHECK
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6304 /* This is only here so we can call SDL_OpenAudio() */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6305 static void my_dummy_audio_callback(void* userdata, ALbyte* stream, int len)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6306 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6307 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6308 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6309
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6310
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6311
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6312
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6313 #ifdef ENABLE_ALMIXER_THREADS
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6314 /* We might need threads. We
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6315 * must constantly poll OpenAL to find out
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6316 * if sound is being streamed, if play has
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6317 * ended, etc. Without threads, this must
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6318 * be explicitly done by the user.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6319 * We could try to do it for them if we
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6320 * finish the threads.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6321 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6322
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6323 static int Stream_Data_Thread_Callback(void* data)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6324 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6325 ALint retval;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6326
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
6327 while(AL_TRUE == g_StreamThreadEnabled)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6328 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6329 retval = Update_ALmixer(data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6330 /* 0 means that nothing needed updating and
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6331 * the function returned quickly
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6332 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6333 if(0 == retval)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6334 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6335 /* Let's be nice and make the thread sleep since
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6336 * little work was done in update
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6337 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6338 /* Make sure times are multiples of 10
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6339 * for optimal performance and accuracy in Linux
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6340 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6341 ALmixer_Delay(10);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6342 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6343 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6344 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6345 /* should I also be sleeping/yielding here? */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6346 ALmixer_Delay(0);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6347 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6348 }
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
6349 /*
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6350 fprintf(stderr, "Thread is closing\n");
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
6351 */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6352 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6353 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6354 #endif /* End of ENABLE_ALMIXER_THREADS */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6355
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6356
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6357 /* SDL/SDL_mixer returns -1 on error and 0 on success.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6358 * I actually prefer false/true conventions (SDL_Sound/OpenAL/GL)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6359 * so SDL_mixer porting people beware.
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6360 * Warning: SDL_QuitSubSystem(SDL_INIT_AUDIO) is called which
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6361 * means the SDL audio system will be disabled. It will not
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6362 * be restored (in case SDL is not actually being used) so
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6363 * the user will need to restart it if they need it after
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6364 * OpenAL shuts down.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6365 */
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6366 ALboolean ALmixer_Init(ALuint frequency, ALuint num_sources, ALuint refresh)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6367 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6368 ALCdevice* dev;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6369 ALCcontext* context;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6370 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6371 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6372 ALuint* source;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6373
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6374 #ifdef USING_LOKI_AL_DIST
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6375 /* The Loki dist requires that I set both the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6376 * device and context frequency values separately
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6377 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6378 /* Hope this won't overflow */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6379 char device_string[256];
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6380 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6381
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6382 /* (Venting frustration) Damn it! Nobody bothered
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6383 * documenting how you're supposed to use an attribute
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6384 * list. In fact, the not even the Loki test program
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6385 * writers seem to know because they use it inconsistently.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6386 * For example, how do you terminate that attribute list?
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6387 * The Loki test code does it 3 different ways. They
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6388 * set the last value to 0, or they set it to ALC_INVALID,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6389 * or they set two final values: ALC_INVALID, 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6390 * In Loki, 0 and ALC_INVALID happen to be the same,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6391 * but with Creative Labs ALC_INVALID is -1.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6392 * So something's going to break. Loki's source
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6393 * code says to terminate with ALC_INVALID. But I
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6394 * don't know if that's really true, or it happens
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6395 * to be a coinicidence because it's defined to 0.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6396 * Creative provides no source code, so I can't look at how
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6397 * they terminate it.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6398 * So this is really, really ticking me off...
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6399 * For now, I'm going to use ALC_INVALID.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6400 * (Update...after further review of the API spec,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6401 * it seems that a NULL terminated string is the correct
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6402 * termination value to use, so 0 it is.)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6403 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6404 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6405 ALint attrlist[] = {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6406 ALC_FREQUENCY, ALMIXER_DEFAULT_FREQUENCY,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6407 /* Don't know anything about these values.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6408 * Trust defaults? */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6409 /* Supposed to be the refresh rate in Hz.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6410 * I think 15-120 are supposed to be good
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6411 * values. Though I haven't gotten any effect except
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6412 * for one strange instance on a Mac. But it was
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6413 * unrepeatable.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6414 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6415 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6416 ALC_REFRESH, 15,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6417 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6418 /* Sync requires a alcProcessContext() call
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6419 * for every cycle. By default, this is
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6420 * not used and the value is AL_FALSE
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6421 * because it will probably perform
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6422 * pretty badly for me.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6423 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6424 #ifdef ENABLE_ALMIXER_ALC_SYNC
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6425 ALC_SYNC, AL_TRUE,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6426 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6427 ALC_SYNC, AL_FALSE,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6428 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6429 /* Looking at the API spec, it implies
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6430 * that the list be a NULL terminated string
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6431 * so it's probably not safe to use ALC_INVALID
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6432 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6433 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6434 ALC_INVALID };
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6435 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6436 '\0'};
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6437 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6438 /* Redo: I'm going to allow ALC_REFRESH to be set.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6439 * However, if no value is specified, I don't
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6440 * want it in the list so I can get the OpenAL defaults
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6441 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6442 ALint attrlist[7];
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6443 ALsizei current_attrlist_index = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6444
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6445 #ifdef ENABLE_PARANOID_SIGNEDNESS_CHECK
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6446 /* More problems: I'm getting bit by endian/signedness issues on
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6447 * different platforms. I can find the endianess easily enough,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6448 * but I don't know how to determine what the correct signedness
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6449 * is (if such a thing exists). I do know that if I try using
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6450 * unsigned on OSX with an originally signed sample, I get
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6451 * distortion. However, I don't have any native unsigned samples
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6452 * to test. But I'm assuming that the platform must be in the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6453 * correct signedness no matter what.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6454 * I can either assume everybody is signed, or I can try to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6455 * determine the value. If I try to determine the values,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6456 * I think my only ability to figure it out will be to open
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6457 * SDL_Audio, and read what the obtained settings were.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6458 * Then shutdown everything. However, I don't even know how
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6459 * reliable this is.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6460 * Update: I think I resolved the issues...forgot to update
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6461 * these comments when it happened. I should check the revision control
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6462 * log... Anyway, I think the issue was partly related to me not
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6463 * doing something correctly with the AudioInfo or some kind
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6464 * of stupid endian bug in my code, and weirdness ensued. Looking at the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6465 * revision control, I think I might have assumed that SDL_Sound would
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6466 * do the right thing with a NULL AudioInfo, but I was incorrect,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6467 * and had to fill one out myself.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6468 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6469 SDL_AudioSpec desired;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6470 SDL_AudioSpec obtained;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6471 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6472
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6473
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6474 /* Make sure ALmixer isn't already initialized */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6475 if(ALmixer_Initialized)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6476 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6477 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6478 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6479
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6480 #ifdef ALMIXER_COMPILE_WITHOUT_SDL
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6481 ALmixer_InitTime();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6482
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6483 /* Note: The pool may have been created on previous Init's */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6484 /* I leave the pool allocated allocated in case the user wants
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6485 * to read the pool in case of a failure (such as in this function).
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6486 * This is not actually a leak.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6487 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6488 if(NULL == s_ALmixerErrorPool)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6489 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6490 s_ALmixerErrorPool = TError_CreateErrorPool();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6491 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6492 if(NULL == s_ALmixerErrorPool)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6493 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6494 return AL_FALSE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6495 }
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
6496 /*
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6497 fprintf(stderr, "tError Test0\n");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6498 ALmixer_SetError("Initing (and testing SetError)");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6499 fprintf(stderr, "tError Test1: %s\n", ALmixer_GetError());
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6500 fprintf(stderr, "tError Test2: %s\n", ALmixer_GetError());
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
6501 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6502 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6503
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6504
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6505 /* Set the defaults */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6506 /*
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6507 attrlist[0] = ALC_FREQUENCY;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6508 attrlist[1] = ALMIXER_DEFAULT_FREQUENCY;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6509 attrlist[2] = ALC_SYNC;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6510 #ifdef ENABLE_ALMIXER_ALC_SYNC
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6511 attrlist[3] = ALC_TRUE;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6512 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6513 attrlist[3] = ALC_FALSE;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6514 #endif
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6515 */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6516 /* Set frequency value if it is not 0 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6517 if(0 != frequency)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6518 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6519 attrlist[current_attrlist_index] = ALC_FREQUENCY;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6520 current_attrlist_index++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6521 attrlist[current_attrlist_index] = (ALint)frequency;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6522 current_attrlist_index++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6523 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6524
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6525 #ifdef ENABLE_ALMIXER_ALC_SYNC
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6526 attrlist[current_attrlist_index] = ALC_SYNC;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6527 current_attrlist_index++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6528 attrlist[current_attrlist_index] = ALC_TRUE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6529 current_attrlist_index++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6530 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6531
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6532 /* If the user specifies a refresh value,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6533 * make room for it
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6534 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6535 if(0 != refresh)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6536 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6537 attrlist[current_attrlist_index] = (ALint)ALC_REFRESH;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6538 current_attrlist_index++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6539 attrlist[current_attrlist_index] = refresh;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6540 current_attrlist_index++;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6541 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6542
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6543 /* End attribute list */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6544 attrlist[current_attrlist_index] = '\0';
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6545
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6546
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6547 /* Initialize SDL_Sound */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6548 if(! Sound_Init() )
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6549 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6550 ALmixer_SetError(Sound_GetError());
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6551 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6552 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6553 #ifdef ENABLE_PARANOID_SIGNEDNESS_CHECK
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6554 /* Here is the paranoid check that opens
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6555 * SDL audio in an attempt to find the correct
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6556 * system values.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6557 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6558 /* Doesn't have to be the actual value I think
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6559 * (as long as it doesn't influence format, in
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6560 * which case I'm probably screwed anyway because OpenAL
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6561 * may easily choose to do something else).
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6562 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6563 desired.freq = 44100;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6564 desired.channels = 2;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6565 desired.format = AUDIO_S16SYS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6566 desired.callback = my_dummy_audio_callback;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6567 if(SDL_OpenAudio(&desired, &obtained) >= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6568 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6569 SIGN_TYPE_16BIT_FORMAT = obtained.format;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6570 /* Now to get really paranoid, we should probably
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6571 * also assume that the 8bit format is also the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6572 * same sign type and set that value
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6573 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6574 if(AUDIO_S16SYS == obtained.format)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6575 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6576 SIGN_TYPE_8BIT_FORMAT = AUDIO_S8;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6577 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6578 /* Should be AUDIO_U16SYS */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6579 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6580 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6581 SIGN_TYPE_8BIT_FORMAT = AUDIO_U8;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6582 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6583 SDL_CloseAudio();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6584 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6585 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6586 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6587 /* Well, I guess I'm in trouble. I guess it's my best guess
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6588 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6589 SIGN_TYPE_16_BIT_FORMAT = AUDIO_S16SYS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6590 SIGN_TYPE_8_BIT_FORMAT = AUDIO_S8;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6591 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6592 #endif
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6593
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6594 #ifndef ALMIXER_COMPILE_WITHOUT_SDL
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6595 /* Weirdness: It seems that SDL_Init(SDL_INIT_AUDIO)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6596 * causes OpenAL and SMPEG to conflict. For some reason
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6597 * if SDL_Init on audio is active, then all the SMPEG
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6598 * decoded sound comes out silent. Unfortunately,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6599 * Sound_Init() invokes SDL_Init on audio. I'm
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6600 * not sure why it actually needs it...
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6601 * But we'll attempt to disable it here after the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6602 * SDL_Sound::Init call and hope it doesn't break SDL_Sound.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6603 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6604 SDL_QuitSubSystem(SDL_INIT_AUDIO);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6605 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6606
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6607 /* I'm told NULL will call the default string
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6608 * and hopefully do the right thing for each platform
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6609 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6610 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6611 dev = alcOpenDevice( NULL );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6612 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6613 /* Now I'm told I need to set both the device and context
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6614 * to have the same sampling rate, so I must pass a string
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6615 * to OpenDevice(). I don't know how portable these strings are.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6616 * I don't even know if the format for strings is
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6617 * compatible
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6618 * From the testattrib.c in the Loki test section
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6619 * dev = alcOpenDevice( (const ALubyte *) "'((sampling-rate 22050))" );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6620 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6621
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6622 #ifdef USING_LOKI_AL_DIST
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6623 sprintf(device_string, "'((sampling-rate %d))", attrlist[1]);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6624 dev = alcOpenDevice( (const ALubyte *) device_string );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6625 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6626 dev = alcOpenDevice( NULL );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6627 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6628 if(NULL == dev)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6629 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6630 ALmixer_SetError("Cannot open sound device for OpenAL");
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6631 return AL_FALSE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6632 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6633
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6634 #ifdef __APPLE__
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6635 /* The ALC_FREQUENCY attribute is ignored with Apple's implementation. */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6636 /* This extension must be called before the context is created. */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6637 if(0 != frequency)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6638 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6639 Internal_alcMacOSXMixerOutputRate((ALdouble)frequency);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6640 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6641 ALmixer_Frequency_global = (ALuint)Internal_alcMacOSXGetMixerOutputRate();
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
6642 /*
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6643 fprintf(stderr, "Internal_alcMacOSXMixerOutputRate is: %lf", Internal_alcMacOSXGetMixerOutputRate());
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
6644 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6645 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6646
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6647 context = alcCreateContext(dev, attrlist);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6648 if(NULL == context)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6649 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6650 ALmixer_SetError("Cannot create a context OpenAL");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6651 alcCloseDevice(dev);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6652 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6653 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6654
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6655
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6656 /* Hmmm, OSX is returning 1 on alcMakeContextCurrent,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6657 * but ALC_NO_ERROR is defined to ALC_FALSE.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6658 * According to Garin Hiebert, this is actually an inconsistency
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6659 * in the Loki version. The function should return a boolean.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6660 * instead of ALC_NO_ERROR. Garin suggested I check via
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6661 * alcGetError().
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6662 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6663 /* clear the error */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6664 alcGetError(dev);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6665 alcMakeContextCurrent(context);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6666
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6667 error = alcGetError(dev);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6668 if( (ALC_NO_ERROR != error) )
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6669 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6670 ALmixer_SetError("Could not MakeContextCurrent");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6671 alcDestroyContext(context);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6672 alcCloseDevice(dev);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6673 return AL_FALSE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6674 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6675
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6676 /* It looks like OpenAL won't let us ask it what
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6677 * the set frequency is, so we need to save our
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6678 * own copy. Yuck.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6679 * Update: J. Valenzuela just updated the Loki
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6680 * dist (2003/01/02) to handle this.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6681 * The demo is in testattrib.c.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6682 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6683 /*
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6684 ALmixer_Frequency_global = frequency;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6685 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6686 #ifndef __APPLE__
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6687 alcGetIntegerv(dev, ALC_FREQUENCY, 1, &ALmixer_Frequency_global);
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
6688 /*
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6689 fprintf(stderr, "alcGetIntegerv ALC_FREQUENCY is: %d", ALmixer_Frequency_global);
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
6690 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6691 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6692
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6693
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6694 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6695 /* OSX is failing on alcMakeContextCurrent(). Try checking it first? */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6696 if(alcGetCurrentContext() != context)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6697 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6698 /* Hmmm, OSX is returning 1 on alcMakeContextCurrent,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6699 * but ALC_NO_ERROR is defined to ALC_FALSE.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6700 * I think this is a bug in the OpenAL implementation.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6701 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6702 fprintf(stderr,"alcMakeContextCurrent returns %d\n", alcMakeContextCurrent(context));
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6703
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6704 fprintf(stderr, "Making context current\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6705 #ifndef __APPLE__
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6706 if(alcMakeContextCurrent(context) != ALC_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6707 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6708 if(!alcMakeContextCurrent(context))
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6709 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6710 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6711 ALmixer_SetError("Could not MakeContextCurrent");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6712 alcDestroyContext(context);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6713 alcCloseDevice(dev);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6714 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6715 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6716 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6717 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6718
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6719
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6720 /* #endif */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6721 /* Saw this in the README with the OS X OpenAL distribution.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6722 * It looked interesting and simple, so I thought I might
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6723 * try it out.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6724 * ***** ALC_CONVERT_DATA_UPON_LOADING
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6725 * This extension allows the caller to tell OpenAL to preconvert to the native Core
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6726 * Audio format, the audio data passed to the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6727 * library with the alBufferData() call. Preconverting the audio data, reduces CPU
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6728 * usage by removing an audio data conversion
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6729 * (per source) at render timem at the expense of a larger memory footprint.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6730 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6731 * This feature is toggled on/off by using the alDisable() & alEnable() APIs. This
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6732 * setting will be applied to all subsequent
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6733 * calls to alBufferData().
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6734 *
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6735 * Update: Some people keep reporting that they see the enable fail on Mac, but I can't reproduce it myself.
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6736 * Rather than deal with it right now, I think I am going to make it an opt-in thing.
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6737 */
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6738 #if defined(__APPLE__) && defined(ALMIXER_USE_OSX_CONVERT_DATA_UPON_LOADING)
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6739 /*
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6740 iPhone is getting this enum, but is failing on the enable, so I guess I'll define it out.
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6741 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6742 #if (TARGET_OS_IPHONE == 1) || (TARGET_IPHONE_SIMULATOR == 1)
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6743
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6744 #else
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6745 /* iOS reports this enum exists, but loading it always fails, so make it Mac only. */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6746 ALenum convert_data_enum = alcGetEnumValue(dev, "ALC_MAC_OSX_CONVERT_DATA_UPON_LOADING");
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6747 /*
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6748 fprintf(stderr, "ALC_MAC_OSX_CONVERT_DATA_UPON_LOADING=0x%x", convert_data_enum);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6749 */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6750 if(0 != convert_data_enum)
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6751 {
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6752 alEnable(convert_data_enum);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6753 }
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6754 if( (AL_NO_ERROR != alGetError()) )
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6755 {
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6756 fprintf(stderr, "ALC_MAC_OSX_CONVERT_DATA_UPON_LOADING attempted but failed");
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6757 ALmixer_SetError("ALC_MAC_OSX_CONVERT_DATA_UPON_LOADING attempted but failed");
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6758 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6759 #endif
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6760
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6761 #endif /* __APPLE__ */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6762
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6763
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6764
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6765
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
6766 ALmixer_Initialized = AL_TRUE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6767
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6768 if(num_sources == 0)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6769 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6770 Number_of_Channels_global = ALMIXER_DEFAULT_NUM_CHANNELS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6771 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6772 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6773 {
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6774 /* probably should make Number_of_Channels_global an ALuint, but need to cast which_channel all the time */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
6775 Number_of_Channels_global = (ALint)num_sources;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6776 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6777 Number_of_Reserve_Channels_global = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6778 Is_Playing_global = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6779 /* Set to Null in case system quit and was reinitialized */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6780 Channel_Done_Callback = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6781 Channel_Done_Callback_Userdata = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6782 Channel_Data_Callback = NULL;
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
6783 Channel_Data_Callback_Userdata = NULL;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6784
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6785 /* Allocate memory for linked list of ALmixerData. */
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6786 s_listOfALmixerData = LinkedList_Create();
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6787 if(NULL == s_listOfALmixerData)
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6788 {
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6789 ALmixer_SetError("Couldn't create linked list");
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6790 alcDestroyContext(context);
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6791 alcCloseDevice(dev);
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
6792 ALmixer_Initialized = AL_FALSE;
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6793 Number_of_Channels_global = 0;
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6794 return AL_FALSE;
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6795 }
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6796
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6797 /* Allocate memory for the list of channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6798 ALmixer_Channel_List = (struct ALmixer_Channel*) malloc(Number_of_Channels_global * sizeof(struct ALmixer_Channel));
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6799 if(NULL == ALmixer_Channel_List)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6800 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6801 ALmixer_SetError("Out of Memory for Channel List");
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6802 LinkedList_Free(s_listOfALmixerData);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6803 alcDestroyContext(context);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6804 alcCloseDevice(dev);
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
6805 ALmixer_Initialized = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6806 Number_of_Channels_global = 0;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6807 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6808 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6809
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6810 /* Allocate memory for the list of sources that map to the channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6811 Source_Map_List = (Source_Map*) malloc(Number_of_Channels_global * sizeof(Source_Map));
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6812 if(NULL == Source_Map_List)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6813 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6814 ALmixer_SetError("Out of Memory for Source Map List");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6815 free(ALmixer_Channel_List);
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6816 LinkedList_Free(s_listOfALmixerData);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6817 alcDestroyContext(context);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6818 alcCloseDevice(dev);
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
6819 ALmixer_Initialized = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6820 Number_of_Channels_global = 0;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6821 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6822 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6823
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6824 /* Create array that will hold the sources */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6825 source = (ALuint*)malloc(Number_of_Channels_global * sizeof(ALuint));
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6826 if(NULL == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6827 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6828 ALmixer_SetError("Out of Memory for sources");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6829 free(Source_Map_List);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6830 free(ALmixer_Channel_List);
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6831 LinkedList_Free(s_listOfALmixerData);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6832 alcDestroyContext(context);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6833 alcCloseDevice(dev);
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
6834 ALmixer_Initialized = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6835 Number_of_Channels_global = 0;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6836 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6837 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6838
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6839 /* Clear the error state */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6840 alGetError();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6841 /* Generate the OpenAL sources */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6842 alGenSources(Number_of_Channels_global, source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6843 if( (error=alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6844 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6845 ALmixer_SetError("Couldn't generate sources: %s\n", alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6846 free(ALmixer_Channel_List);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6847 free(Source_Map_List);
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6848 LinkedList_Free(s_listOfALmixerData);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6849 alcDestroyContext(context);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6850 alcCloseDevice(dev);
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
6851 ALmixer_Initialized = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6852 Number_of_Channels_global = 0;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6853 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6854 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6855
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6856 /* Initialize each channel and associate one source to one channel */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6857 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6858 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6859 if(0 == source[i])
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6860 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6861 fprintf(stderr, "SDL_ALmixer serious problem. This OpenAL implementation allowed 0 to be a valid source id which is in conflict with assumptions made in this library.\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6862 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6863
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6864 Init_Channel(i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6865 /* Keeping the source allocation out of the Init function
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6866 * in case I want to reuse the Init
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6867 * function for resetting data
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6868 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6869 ALmixer_Channel_List[i].alsource = source[i];
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6870 /* Now also keep a copy of the source to channel mapping
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6871 * in case we need to look up a channel from the source
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6872 * instead of a source from a channel
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6873 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6874 Source_Map_List[i].source = source[i];
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6875 Source_Map_List[i].channel = i;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6876 /* Clean the channel because there are some things that need to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6877 * be done that can't happen until the source is set
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6878 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6879 Clean_Channel(i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6880 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6881
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6882 /* The Source_Map_List must be sorted by source for binary searches
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6883 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6884 qsort(Source_Map_List, Number_of_Channels_global, sizeof(Source_Map), Compare_Source_Map);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6885
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
6886 /*
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6887 ALmixer_OutputDecoders();
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
6888 */
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6889
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6890
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6891
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6892 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6893 s_simpleLock = SDL_CreateMutex();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6894 if(NULL == s_simpleLock)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6895 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6896 /* SDL sets the error message already? */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6897 free(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6898 free(ALmixer_Channel_List);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6899 free(Source_Map_List);
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6900 LinkedList_Free(s_listOfALmixerData);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6901 alcDestroyContext(context);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6902 alcCloseDevice(dev);
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
6903 ALmixer_Initialized = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6904 Number_of_Channels_global = 0;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6905 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6906 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6907
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
6908 g_StreamThreadEnabled = AL_TRUE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6909 Stream_Thread_global = SDL_CreateThread(Stream_Data_Thread_Callback, NULL);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6910 if(NULL == Stream_Thread_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6911 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6912 /* SDL sets the error message already? */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6913 SDL_DestroyMutex(s_simpleLock);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6914 free(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6915 free(ALmixer_Channel_List);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6916 free(Source_Map_List);
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
6917 LinkedList_Free(s_listOfALmixerData);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6918 alcDestroyContext(context);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6919 alcCloseDevice(dev);
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
6920 ALmixer_Initialized = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6921 Number_of_Channels_global = 0;
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
6922 g_StreamThreadEnabled = AL_FALSE;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6923 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6924 }
24
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
6925
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
6926 /* Note: Only a few platforms change the priority. See implementation for notes. */
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
6927 Internal_LowerThreadPriority(Stream_Thread_global);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6928
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
6929 /*
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6930 fprintf(stderr, "Using threads\n");
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
6931 */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6932 #endif /* End of ENABLE_ALMIXER_THREADS */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6933
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6934 /* We don't need this array any more because all the sources
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6935 * are connected to channels
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6936 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6937 free(source);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6938 return AL_TRUE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6939 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6940
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6941
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
6942 ALboolean ALmixer_InitContext(ALuint frequency, ALuint refresh)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6943 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6944 ALCdevice* dev;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6945 ALCcontext* context;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6946 ALCenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6947
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6948 #ifdef USING_LOKI_AL_DIST
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6949 /* The Loki dist requires that I set both the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6950 * device and context frequency values separately
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6951 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6952 /* Hope this won't overflow */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6953 char device_string[256];
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6954 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6955
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6956 /* (Venting frustration) Damn it! Nobody bothered
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6957 * documenting how you're supposed to use an attribute
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6958 * list. In fact, the not even the Loki test program
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6959 * writers seem to know because they use it inconsistently.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6960 * For example, how do you terminate that attribute list?
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6961 * The Loki test code does it 3 different ways. They
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6962 * set the last value to 0, or they set it to ALC_INVALID,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6963 * or they set two final values: ALC_INVALID, 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6964 * In Loki, 0 and ALC_INVALID happen to be the same,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6965 * but with Creative Labs ALC_INVALID is -1.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6966 * So something's going to break. Loki's source
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6967 * code says to terminate with ALC_INVALID. But I
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6968 * don't know if that's really true, or it happens
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6969 * to be a coinicidence because it's defined to 0.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6970 * Creative provides no source code, so I can't look at how
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6971 * they terminate it.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6972 * So this is really, really ticking me off...
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6973 * For now, I'm going to use ALC_INVALID.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6974 * (Update...after further review of the API spec,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6975 * it seems that a NULL terminated string is the correct
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6976 * termination value to use, so 0 it is.)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6977 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6978 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6979 ALint attrlist[] = {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6980 ALC_FREQUENCY, ALMIXER_DEFAULT_FREQUENCY,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6981 /* Don't know anything about these values.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6982 * Trust defaults? */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6983 /* Supposed to be the refresh rate in Hz.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6984 * I think 15-120 are supposed to be good
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6985 * values. Though I haven't gotten any effect except
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6986 * for one strange instance on a Mac. But it was
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6987 * unrepeatable.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6988 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6989 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6990 ALC_REFRESH, 15,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6991 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6992 /* Sync requires a alcProcessContext() call
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6993 * for every cycle. By default, this is
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6994 * not used and the value is AL_FALSE
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6995 * because it will probably perform
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6996 * pretty badly for me.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6997 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6998 #ifdef ENABLE_ALMIXER_ALC_SYNC
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6999 ALC_SYNC, AL_TRUE,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7000 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7001 ALC_SYNC, AL_FALSE,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7002 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7003 /* Looking at the API spec, it implies
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7004 * that the list be a NULL terminated string
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7005 * so it's probably not safe to use ALC_INVALID
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7006 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7007 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7008 ALC_INVALID };
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7009 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7010 '\0'};
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7011 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7012 /* Redo: I'm going to allow ALC_REFRESH to be set.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7013 * However, if no value is specified, I don't
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7014 * want it in the list so I can get the OpenAL defaults
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7015 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7016 ALint attrlist[7];
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7017 ALsizei current_attrlist_index = 0;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7018
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7019 #ifdef ENABLE_PARANOID_SIGNEDNESS_CHECK
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7020 /* More problems: I'm getting bit by endian/signedness issues on
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7021 * different platforms. I can find the endianess easily enough,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7022 * but I don't know how to determine what the correct signedness
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7023 * is (if such a thing exists). I do know that if I try using
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7024 * unsigned on OSX with an originally signed sample, I get
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7025 * distortion. However, I don't have any native unsigned samples
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7026 * to test. But I'm assuming that the platform must be in the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7027 * correct signedness no matter what.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7028 * I can either assume everybody is signed, or I can try to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7029 * determine the value. If I try to determine the values,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7030 * I think my only ability to figure it out will be to open
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7031 * SDL_Audio, and read what the obtained settings were.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7032 * Then shutdown everything. However, I don't even know how
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7033 * reliable this is.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7034 * Update: I think I resolved the issues...forgot to update
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7035 * these comments when it happened. I should check the revision control
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7036 * log... Anyway, I think the issue was partly related to me not
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7037 * doing something correctly with the AudioInfo or some kind
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7038 * of stupid endian bug in my code, and weirdness ensued. Looking at the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7039 * revision control, I think I might have assumed that SDL_Sound would
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7040 * do the right thing with a NULL AudioInfo, but I was incorrect,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7041 * and had to fill one out myself.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7042 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7043 SDL_AudioSpec desired;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7044 SDL_AudioSpec obtained;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7045 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7046
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7047
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7048
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7049
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7050 /* Make sure ALmixer isn't already initialized */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7051 if(ALmixer_Initialized)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7052 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7053 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7054 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7055
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7056 /* Set the defaults */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7057 attrlist[0] = ALC_FREQUENCY;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7058 attrlist[1] = ALMIXER_DEFAULT_FREQUENCY;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7059 attrlist[2] = ALC_SYNC;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7060 #ifdef ENABLE_ALMIXER_ALC_SYNC
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7061 attrlist[3] = ALC_TRUE;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7062 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7063 attrlist[3] = ALC_FALSE;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7064 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7065 /* Set frequency value if it is not 0 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7066 if(0 != frequency)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7067 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7068 attrlist[current_attrlist_index] = ALC_FREQUENCY;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7069 current_attrlist_index++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7070 attrlist[current_attrlist_index] = (ALint)frequency;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7071 current_attrlist_index++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7072 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7073
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7074 #ifdef ENABLE_ALMIXER_ALC_SYNC
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7075 attrlist[current_attrlist_index] = ALC_SYNC;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7076 current_attrlist_index++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7077 attrlist[current_attrlist_index] = ALC_TRUE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7078 current_attrlist_index++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7079 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7080
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7081 /* If the user specifies a refresh value,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7082 * make room for it
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7083 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7084 if(0 != refresh)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7085 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7086 attrlist[current_attrlist_index] = (ALint)ALC_REFRESH;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7087 current_attrlist_index++;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7088 attrlist[current_attrlist_index] = refresh;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7089 current_attrlist_index++;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7090 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7091
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7092 /* End attribute list */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7093 attrlist[current_attrlist_index] = '\0';
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7094
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7095
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7096
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7097 /* Initialize SDL_Sound */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7098 if(! Sound_Init() )
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7099 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7100 ALmixer_SetError(Sound_GetError());
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7101 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7102 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7103 #ifdef ENABLE_PARANOID_SIGNEDNESS_CHECK
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7104 /* Here is the paranoid check that opens
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7105 * SDL audio in an attempt to find the correct
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7106 * system values.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7107 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7108 /* Doesn't have to be the actual value I think
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7109 * (as long as it doesn't influence format, in
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7110 * which case I'm probably screwed anyway because OpenAL
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7111 * may easily choose to do something else).
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7112 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7113 desired.freq = 44100;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7114 desired.channels = 2;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7115 desired.format = AUDIO_S16SYS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7116 desired.callback = my_dummy_audio_callback;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7117 if(SDL_OpenAudio(&desired, &obtained) >= 0)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7118 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7119 SIGN_TYPE_16BIT_FORMAT = obtained.format;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7120 /* Now to get really paranoid, we should probably
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7121 * also assume that the 8bit format is also the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7122 * same sign type and set that value
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7123 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7124 if(AUDIO_S16SYS == obtained.format)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7125 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7126 SIGN_TYPE_8BIT_FORMAT = AUDIO_S8;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7127 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7128 /* Should be AUDIO_U16SYS */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7129 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7130 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7131 SIGN_TYPE_8BIT_FORMAT = AUDIO_U8;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7132 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7133 SDL_CloseAudio();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7134 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7135 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7136 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7137 /* Well, I guess I'm in trouble. I guess it's my best guess
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7138 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7139 SIGN_TYPE_16_BIT_FORMAT = AUDIO_S16SYS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7140 SIGN_TYPE_8_BIT_FORMAT = AUDIO_S8;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7141 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7142 #endif
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7143
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7144 #ifndef ALMIXER_COMPILE_WITHOUT_SDL
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7145 /* Weirdness: It seems that SDL_Init(SDL_INIT_AUDIO)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7146 * causes OpenAL and SMPEG to conflict. For some reason
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7147 * if SDL_Init on audio is active, then all the SMPEG
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7148 * decoded sound comes out silent. Unfortunately,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7149 * Sound_Init() invokes SDL_Init on audio. I'm
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7150 * not sure why it actually needs it...
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7151 * But we'll attempt to disable it here after the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7152 * SDL_Sound::Init call and hope it doesn't break SDL_Sound.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7153 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7154 SDL_QuitSubSystem(SDL_INIT_AUDIO);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7155 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7156
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7157 /* I'm told NULL will call the default string
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7158 * and hopefully do the right thing for each platform
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7159 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7160 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7161 dev = alcOpenDevice( NULL );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7162 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7163 /* Now I'm told I need to set both the device and context
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7164 * to have the same sampling rate, so I must pass a string
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7165 * to OpenDevice(). I don't know how portable these strings are.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7166 * I don't even know if the format for strings is
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7167 * compatible
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7168 * From the testattrib.c in the Loki test section
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7169 * dev = alcOpenDevice( (const ALubyte *) "'((sampling-rate 22050))" );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7170 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7171
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7172 #ifdef USING_LOKI_AL_DIST
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7173 sprintf(device_string, "'((sampling-rate %d))", attrlist[1]);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7174 dev = alcOpenDevice( (const ALubyte *) device_string );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7175 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7176 dev = alcOpenDevice( NULL );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7177 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7178 if(NULL == dev)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7179 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7180 ALmixer_SetError("Cannot open sound device for OpenAL");
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7181 return AL_FALSE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7182 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7183
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7184 #ifdef __APPLE__
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7185 /* The ALC_FREQUENCY attribute is ignored with Apple's implementation. */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7186 /* This extension must be called before the context is created. */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7187 if(0 != frequency)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7188 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7189 Internal_alcMacOSXMixerOutputRate((ALdouble)frequency);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7190 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7191 ALmixer_Frequency_global = (ALuint)Internal_alcMacOSXGetMixerOutputRate();
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
7192 /*
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7193 fprintf(stderr, "Internal_alcMacOSXMixerOutputRate is: %lf", Internal_alcMacOSXGetMixerOutputRate());
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
7194 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7195 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7196
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7197
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7198 context = alcCreateContext(dev, attrlist);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7199 if(NULL == context)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7200 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7201 ALmixer_SetError("Cannot create a context OpenAL");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7202 alcCloseDevice(dev);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7203 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7204 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7205
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7206
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7207 /* Hmmm, OSX is returning 1 on alcMakeContextCurrent,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7208 * but ALC_NO_ERROR is defined to ALC_FALSE.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7209 * According to Garin Hiebert, this is actually an inconsistency
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7210 * in the Loki version. The function should return a boolean.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7211 * instead of ALC_NO_ERROR. Garin suggested I check via
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7212 * alcGetError().
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7213 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7214 /* clear the error */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7215 alcGetError(dev);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7216 alcMakeContextCurrent(context);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7217
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7218 error = alcGetError(dev);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7219 if( (ALC_NO_ERROR != error) )
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7220 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7221 ALmixer_SetError("Could not MakeContextCurrent");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7222 alcDestroyContext(context);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7223 alcCloseDevice(dev);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7224 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7225 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7226
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7227
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7228 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7229 /* OSX is failing on alcMakeContextCurrent(). Try checking it first? */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7230 if(alcGetCurrentContext() != context)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7231 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7232 /* Hmmm, OSX is returning 1 on alcMakeContextCurrent,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7233 * but ALC_NO_ERROR is defined to ALC_FALSE.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7234 * I think this is a bug in the OpenAL implementation.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7235 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7236 fprintf(stderr,"alcMakeContextCurrent returns %d\n", alcMakeContextCurrent(context));
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7237
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7238 fprintf(stderr, "Making context current\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7239 #ifndef __APPLE__
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7240 if(alcMakeContextCurrent(context) != ALC_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7241 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7242 if(!alcMakeContextCurrent(context))
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7243 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7244 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7245 ALmixer_SetError("Could not MakeContextCurrent");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7246 alcDestroyContext(context);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7247 alcCloseDevice(dev);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7248 return AL_FALSE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7249 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7250
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7251 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7252 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7253
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7254 /* It looks like OpenAL won't let us ask it what
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7255 * the set frequency is, so we need to save our
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7256 * own copy. Yuck.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7257 * Update: J. Valenzuela just updated the Loki
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7258 * dist (2003/01/02) to handle this.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7259 * The demo is in testattrib.c.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7260 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7261 #ifndef __APPLE__
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7262 alcGetIntegerv(dev, ALC_FREQUENCY, 1, &ALmixer_Frequency_global);
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
7263 /*
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7264 fprintf(stderr, "alcGetIntegerv ALC_FREQUENCY is: %d", ALmixer_Frequency_global);
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
7265 */
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
7266 #endif
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
7267
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
7268
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7269
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7270 /* Saw this in the README with the OS X OpenAL distribution.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7271 * It looked interesting and simple, so I thought I might
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7272 * try it out.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7273 * ***** ALC_CONVERT_DATA_UPON_LOADING
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7274 * This extension allows the caller to tell OpenAL to preconvert to the native Core
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7275 * Audio format, the audio data passed to the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7276 * library with the alBufferData() call. Preconverting the audio data, reduces CPU
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7277 * usage by removing an audio data conversion
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7278 * (per source) at render timem at the expense of a larger memory footprint.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7279 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7280 * This feature is toggled on/off by using the alDisable() & alEnable() APIs. This
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7281 * setting will be applied to all subsequent
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7282 * calls to alBufferData().
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7283 * Update: Some people keep reporting that they see the enable fail on Mac, but I can't reproduce it myself.
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7284 * Rather than deal with it right now, I think I am going to make it an opt-in thing.
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7285 */
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7286 #if defined(__APPLE__) && defined(ALMIXER_USE_OSX_CONVERT_DATA_UPON_LOADING)
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
7287 /*
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7288 iPhone is getting this enum, but is failing on the enable, so I guess I'll define it out.
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7289 */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7290 #if (TARGET_OS_IPHONE == 1) || (TARGET_IPHONE_SIMULATOR == 1)
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7291
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7292 #else
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7293 /* iOS reports this enum exists, but loading it always fails, so make it Mac only. */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7294 ALenum convert_data_enum = alcGetEnumValue(dev, "ALC_MAC_OSX_CONVERT_DATA_UPON_LOADING");
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7295 /*
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7296 fprintf(stderr, "ALC_MAC_OSX_CONVERT_DATA_UPON_LOADING=0x%x", convert_data_enum);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7297 */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7298 if(0 != convert_data_enum)
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7299 {
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7300 alEnable(convert_data_enum);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7301 }
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7302 if( (AL_NO_ERROR != alGetError()) )
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7303 {
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7304 fprintf(stderr, "ALC_MAC_OSX_CONVERT_DATA_UPON_LOADING attempted but failed");
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7305 ALmixer_SetError("ALC_MAC_OSX_CONVERT_DATA_UPON_LOADING attempted but failed");
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7306 }
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7307 #endif
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7308 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7309
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7310 return AL_TRUE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7311 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7312
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7313
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7314 ALboolean ALmixer_InitMixer(ALuint num_sources)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7315 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7316 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7317 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7318 ALuint* source;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7319
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7320
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7321 ALmixer_Initialized = AL_TRUE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7322
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7323
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7324 #ifdef ALMIXER_COMPILE_WITHOUT_SDL
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7325 ALmixer_InitTime();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7326
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7327 /* Note: The pool may have been created on previous Init's */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7328 /* I leave the pool allocated allocated in case the user wants
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7329 * to read the pool in case of a failure (such as in this function).
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7330 * This is not actually a leak.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7331 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7332 if(NULL == s_ALmixerErrorPool)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7333 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7334 s_ALmixerErrorPool = TError_CreateErrorPool();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7335 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7336 if(NULL == s_ALmixerErrorPool)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7337 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7338 return AL_FALSE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7339 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7340 /*
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7341 fprintf(stderr, "tError Test0\n");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7342 ALmixer_SetError("Initing (and testing SetError)");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7343 fprintf(stderr, "tError Test1: %s\n", ALmixer_GetError());
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7344 fprintf(stderr, "tError Test2: %s\n", ALmixer_GetError());
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7345 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7346 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7347
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7348 if(num_sources == 0)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7349 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7350 Number_of_Channels_global = ALMIXER_DEFAULT_NUM_CHANNELS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7351 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7352 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7353 {
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7354 Number_of_Channels_global = (ALint)num_sources;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7355 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7356 Number_of_Reserve_Channels_global = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7357 Is_Playing_global = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7358 /* Set to Null in case system quit and was reinitialized */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7359 Channel_Done_Callback = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7360 Channel_Done_Callback_Userdata = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7361 Channel_Data_Callback = NULL;
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
7362 Channel_Data_Callback_Userdata = NULL;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7363
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7364 /* Allocate memory for linked list of ALmixerData. */
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7365 s_listOfALmixerData = LinkedList_Create();
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7366 if(NULL == s_listOfALmixerData)
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7367 {
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7368 ALmixer_SetError("Couldn't create linked list");
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7369 ALmixer_Initialized = AL_FALSE;
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7370 Number_of_Channels_global = 0;
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7371 return AL_FALSE;
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7372 }
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7373
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7374
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7375 /* Allocate memory for the list of channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7376 ALmixer_Channel_List = (struct ALmixer_Channel*) malloc(Number_of_Channels_global * sizeof(struct ALmixer_Channel));
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7377 if(NULL == ALmixer_Channel_List)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7378 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7379 ALmixer_SetError("Out of Memory for Channel List");
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7380 LinkedList_Free(s_listOfALmixerData);
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7381 ALmixer_Initialized = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7382 Number_of_Channels_global = 0;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7383 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7384 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7385
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7386 /* Allocate memory for the list of sources that map to the channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7387 Source_Map_List = (Source_Map*) malloc(Number_of_Channels_global * sizeof(Source_Map));
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7388 if(NULL == Source_Map_List)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7389 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7390 ALmixer_SetError("Out of Memory for Source Map List");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7391 free(ALmixer_Channel_List);
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7392 LinkedList_Free(s_listOfALmixerData);
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7393 ALmixer_Initialized = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7394 Number_of_Channels_global = 0;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7395 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7396 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7397
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7398 /* Create array that will hold the sources */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7399 source = (ALuint*)malloc(Number_of_Channels_global * sizeof(ALuint));
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7400 if(NULL == source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7401 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7402 ALmixer_SetError("Out of Memory for sources");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7403 free(Source_Map_List);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7404 free(ALmixer_Channel_List);
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7405 LinkedList_Free(s_listOfALmixerData);
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7406 ALmixer_Initialized = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7407 Number_of_Channels_global = 0;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7408 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7409 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7410
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7411 /* Clear the error state */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7412 alGetError();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7413 /* Generate the OpenAL sources */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7414 alGenSources(Number_of_Channels_global, source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7415 if( (error=alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7416 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7417 ALmixer_SetError("Couldn't generate sources: %s\n", alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7418 free(ALmixer_Channel_List);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7419 free(Source_Map_List);
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7420 LinkedList_Free(s_listOfALmixerData);
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7421 ALmixer_Initialized = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7422 Number_of_Channels_global = 0;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7423 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7424 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7425
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7426 /* Initialize each channel and associate one source to one channel */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7427 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7428 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7429 Init_Channel(i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7430 /* Keeping the source allocation out of the Init function
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7431 * in case I want to reuse the Init
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7432 * function for resetting data
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7433 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7434 ALmixer_Channel_List[i].alsource = source[i];
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7435 /* Now also keep a copy of the source to channel mapping
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7436 * in case we need to look up a channel from the source
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7437 * instead of a source from a channel
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7438 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7439 Source_Map_List[i].source = source[i];
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7440 Source_Map_List[i].channel = i;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7441 /* Clean the channel because there are some things that need to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7442 * be done that can't happen until the source is set
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7443 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7444 Clean_Channel(i);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7445 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7446
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7447 /* The Source_Map_List must be sorted by source for binary searches
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7448 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7449 qsort(Source_Map_List, Number_of_Channels_global, sizeof(Source_Map), Compare_Source_Map);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7450
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7451
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7452 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7453 s_simpleLock = SDL_CreateMutex();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7454 if(NULL == s_simpleLock)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7455 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7456 /* SDL sets the error message already? */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7457 free(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7458 free(ALmixer_Channel_List);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7459 free(Source_Map_List);
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7460 ALmixer_Initialized = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7461 Number_of_Channels_global = 0;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7462 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7463 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7464
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7465
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7466 g_StreamThreadEnabled = AL_TRUE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7467 Stream_Thread_global = SDL_CreateThread(Stream_Data_Thread_Callback, NULL);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7468 if(NULL == Stream_Thread_global)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7469 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7470 /* SDL sets the error message already? */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7471 SDL_DestroyMutex(s_simpleLock);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7472 free(source);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7473 free(ALmixer_Channel_List);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7474 free(Source_Map_List);
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7475 ALmixer_Initialized = AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7476 Number_of_Channels_global = 0;
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7477 g_StreamThreadEnabled = AL_FALSE;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7478 return AL_FALSE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7479 }
24
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
7480
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
7481 /* Note: Only a few platforms change the priority. See implementation for notes. */
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
7482 Internal_LowerThreadPriority(Stream_Thread_global);
e085cbc573cf iOS optimization/bug/workaround.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 22
diff changeset
7483
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
7484 /*
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7485 fprintf(stderr, "Using threads\n");
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
7486 */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7487 #endif /* End of ENABLE_ALMIXER_THREADS */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7488
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7489 /* We don't need this array any more because all the sources
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7490 * are connected to channels
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7491 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7492 free(source);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7493 return AL_TRUE;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7494 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7495
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7496 void ALmixer_BeginInterruption()
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7497 {
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7498 if((AL_TRUE == g_inInterruption) || (AL_FALSE == ALmixer_Initialized))
29
1c23805d5ce9 Optimization to destroy bookkeeping thread on BeginInterruption() and recreate it on EndInterruption(). I'm concerned that Android may be running this thread and eating up unnecessary sleep cycles, particularly on certain devices that may have pathological sleep disorders. (There is a report about Samsung Galaxy Tab.)
Eric Wing <ewing . public |-at-| gmail . com>
parents: 28
diff changeset
7499 {
1c23805d5ce9 Optimization to destroy bookkeeping thread on BeginInterruption() and recreate it on EndInterruption(). I'm concerned that Android may be running this thread and eating up unnecessary sleep cycles, particularly on certain devices that may have pathological sleep disorders. (There is a report about Samsung Galaxy Tab.)
Eric Wing <ewing . public |-at-| gmail . com>
parents: 28
diff changeset
7500 return;
1c23805d5ce9 Optimization to destroy bookkeeping thread on BeginInterruption() and recreate it on EndInterruption(). I'm concerned that Android may be running this thread and eating up unnecessary sleep cycles, particularly on certain devices that may have pathological sleep disorders. (There is a report about Samsung Galaxy Tab.)
Eric Wing <ewing . public |-at-| gmail . com>
parents: 28
diff changeset
7501 }
44
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7502
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7503 ALmixer_SuspendUpdates();
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7504
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7505 s_interruptionContext = alcGetCurrentContext();
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7506 if(NULL != s_interruptionContext)
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7507 {
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7508 /* iOS alcSuspendContext is a no-op */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7509 alcSuspendContext(s_interruptionContext);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7510 alcMakeContextCurrent(NULL);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7511 }
29
1c23805d5ce9 Optimization to destroy bookkeeping thread on BeginInterruption() and recreate it on EndInterruption(). I'm concerned that Android may be running this thread and eating up unnecessary sleep cycles, particularly on certain devices that may have pathological sleep disorders. (There is a report about Samsung Galaxy Tab.)
Eric Wing <ewing . public |-at-| gmail . com>
parents: 28
diff changeset
7512
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
7513 g_inInterruption = AL_TRUE;
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7514 }
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7515
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7516 void ALmixer_EndInterruption()
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7517 {
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7518 if((AL_FALSE == g_inInterruption) || (AL_FALSE == ALmixer_Initialized))
29
1c23805d5ce9 Optimization to destroy bookkeeping thread on BeginInterruption() and recreate it on EndInterruption(). I'm concerned that Android may be running this thread and eating up unnecessary sleep cycles, particularly on certain devices that may have pathological sleep disorders. (There is a report about Samsung Galaxy Tab.)
Eric Wing <ewing . public |-at-| gmail . com>
parents: 28
diff changeset
7519 {
1c23805d5ce9 Optimization to destroy bookkeeping thread on BeginInterruption() and recreate it on EndInterruption(). I'm concerned that Android may be running this thread and eating up unnecessary sleep cycles, particularly on certain devices that may have pathological sleep disorders. (There is a report about Samsung Galaxy Tab.)
Eric Wing <ewing . public |-at-| gmail . com>
parents: 28
diff changeset
7520 return;
1c23805d5ce9 Optimization to destroy bookkeeping thread on BeginInterruption() and recreate it on EndInterruption(). I'm concerned that Android may be running this thread and eating up unnecessary sleep cycles, particularly on certain devices that may have pathological sleep disorders. (There is a report about Samsung Galaxy Tab.)
Eric Wing <ewing . public |-at-| gmail . com>
parents: 28
diff changeset
7521 }
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7522
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7523 /* Note: iOS, you need to set the AudioSession active.
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7524 * But if the AudioSession is not initialized, this SetActive
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7525 * call fails.
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7526 * So this is probably better if calling app sets this.
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7527 */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7528 /*
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7529 #if (TARGET_OS_IPHONE == 1) || (TARGET_IPHONE_SIMULATOR == 1)
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7530 OSStatus the_error = AudioSessionSetActive(true);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7531 if(noErr != the_error)
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7532 {
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7533 fprintf(stderr, "Error setting audio session active! %d\n", the_error);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7534 }
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7535 #endif
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7536 */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7537
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7538 if(NULL != s_interruptionContext)
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7539 {
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7540 alcMakeContextCurrent(s_interruptionContext);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7541 alcProcessContext(s_interruptionContext);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7542 s_interruptionContext = NULL;
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7543 }
44
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7544
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7545 ALmixer_ResumeUpdates();
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7546 g_inInterruption = AL_FALSE;
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7547 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7548
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
7549
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
7550 ALboolean ALmixer_IsInInterruption()
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
7551 {
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
7552 if(AL_FALSE == ALmixer_Initialized)
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
7553 {
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
7554 return AL_FALSE;
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
7555 }
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
7556 return g_inInterruption;
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
7557 }
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
7558
44
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7559 void ALmixer_SuspendUpdates()
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7560 {
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7561 if(AL_TRUE == ALmixer_AreUpdatesSuspended())
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7562 {
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7563 return;
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7564 }
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7565 #ifdef ENABLE_ALMIXER_THREADS
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7566 /* Kill bookkeeping thread to help minimize wasted CPU resources */
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7567
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7568 /* Is locking really necessary here? */
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7569 /* SDL_LockMutex(s_simpleLock); */
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7570 g_StreamThreadEnabled = AL_FALSE;
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7571 /* SDL_UnlockMutex(s_simpleLock); */
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7572
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7573 SDL_WaitThread(Stream_Thread_global, NULL);
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7574 Stream_Thread_global = NULL;
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7575 #endif
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7576 }
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7577
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7578 void ALmixer_ResumeUpdates()
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7579 {
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7580 if(AL_FALSE == ALmixer_AreUpdatesSuspended())
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7581 {
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7582 return;
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7583 }
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7584
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7585 #ifdef ENABLE_ALMIXER_THREADS
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7586 /* This must be set before the thread is created to prevent the thread from exiting. */
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7587 g_StreamThreadEnabled = AL_TRUE;
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7588
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7589 Stream_Thread_global = SDL_CreateThread(Stream_Data_Thread_Callback, NULL);
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7590 if(NULL == Stream_Thread_global)
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7591 {
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7592 fprintf(stderr, "Critical Error: Could not create bookkeeping thread in EndInterruption\n");
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7593 }
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7594 /* Note: Only a few platforms change the priority. See implementation for notes. */
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7595 Internal_LowerThreadPriority(Stream_Thread_global);
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7596 #endif
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7597 }
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7598
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7599 ALboolean ALmixer_AreUpdatesSuspended()
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7600 {
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7601 #ifdef ENABLE_ALMIXER_THREADS
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7602 if(AL_FALSE == g_StreamThreadEnabled)
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7603 {
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7604 return AL_TRUE;
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7605 }
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7606 else
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7607 {
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7608 return AL_FALSE;
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7609 }
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7610 #else
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7611 return AL_FALSE;
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7612 #endif
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7613 }
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
7614
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7615 /* Keep the return value void to allow easy use with
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7616 * atexit()
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7617 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7618 void ALmixer_Quit()
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7619 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7620 ALCcontext* context;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7621 ALCdevice* dev;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7622 ALint i;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7623
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7624 if( ! ALmixer_Initialized)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7625 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7626 return;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7627 }
29
1c23805d5ce9 Optimization to destroy bookkeeping thread on BeginInterruption() and recreate it on EndInterruption(). I'm concerned that Android may be running this thread and eating up unnecessary sleep cycles, particularly on certain devices that may have pathological sleep disorders. (There is a report about Samsung Galaxy Tab.)
Eric Wing <ewing . public |-at-| gmail . com>
parents: 28
diff changeset
7628
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7629 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7630 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7631 #endif
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7632
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7633 /* Several things we need to do:
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7634 First, we need to check if we are in an interruption.
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7635 If so, we need to reactivate the alcContext so we can call OpenAL functions.
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7636 Next, we should delete the OpenAL sources.
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7637 Next, we need to free all the sound data via ALmixer_FreeData().
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7638 Finally, we can delete the OpenAL context.
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7639 */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7640
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7641 context = alcGetCurrentContext();
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7642 if(NULL == context)
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7643 {
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7644 /* We might have an interruption event where the current context is NULL */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7645 if(NULL == s_interruptionContext)
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7646 {
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7647 /* Nothing left to try. I think we're done. */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7648 fprintf(stderr, "ALmixer_Quit: Assertion Error. Expecting to find an OpenAL context, but could not find one.\n");
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7649 return;
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7650 }
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7651 else
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7652 {
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7653 context = s_interruptionContext;
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7654 /* reactivate the context so we can call OpenAL functions */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7655 alcMakeContextCurrent(context);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7656 s_interruptionContext = NULL;
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7657 }
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7658 }
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7659
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7660 /* Shutdown everything before closing context */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7661 Internal_HaltChannel(-1, AL_FALSE);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7662
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7663 /* This flag will cause the thread to terminate */
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7664 ALmixer_Initialized = AL_FALSE;
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7665 #ifdef ENABLE_ALMIXER_THREADS
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7666 g_StreamThreadEnabled = AL_FALSE;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7667 SDL_UnlockMutex(s_simpleLock);
29
1c23805d5ce9 Optimization to destroy bookkeeping thread on BeginInterruption() and recreate it on EndInterruption(). I'm concerned that Android may be running this thread and eating up unnecessary sleep cycles, particularly on certain devices that may have pathological sleep disorders. (There is a report about Samsung Galaxy Tab.)
Eric Wing <ewing . public |-at-| gmail . com>
parents: 28
diff changeset
7668 /* This is safe to call with NULL thread, so we don't need to do anything special for interruptions. */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7669 SDL_WaitThread(Stream_Thread_global, NULL);
29
1c23805d5ce9 Optimization to destroy bookkeeping thread on BeginInterruption() and recreate it on EndInterruption(). I'm concerned that Android may be running this thread and eating up unnecessary sleep cycles, particularly on certain devices that may have pathological sleep disorders. (There is a report about Samsung Galaxy Tab.)
Eric Wing <ewing . public |-at-| gmail . com>
parents: 28
diff changeset
7670 Stream_Thread_global = NULL;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7671
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7672 SDL_DestroyMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7673 #endif
31
ad4eb4330fb0 Added initialized check in Begin/End interruption.
Eric Wing <ewing@anscamobile.com>
parents: 30
diff changeset
7674 g_inInterruption = AL_FALSE;
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7675
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7676 /* Delete all the OpenAL sources */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7677 for(i=0; i<Number_of_Channels_global; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7678 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7679 alDeleteSources(1, &ALmixer_Channel_List[i].alsource);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7680 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7681 /* Delete all the channels */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7682 free(ALmixer_Channel_List);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7683 free(Source_Map_List);
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7684
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7685 /* Reset the Number_of_Channels just in case somebody
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7686 * tries using a ALmixer function.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7687 * I probably should put "Initialized" checks everywhere,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7688 * but I'm too lazy at the moment.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7689 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7690 Number_of_Channels_global = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7691
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7692
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7693 /* Delete the list of ALmixerData's before Sound_Quit deletes
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7694 * its own underlying information and I potentially have dangling pointers.
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7695 */
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7696 while(LinkedList_Size(s_listOfALmixerData) > 0)
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7697 {
16
038baa026db3 Fixed bug in LinkedList delete. Shouldn't have both popped list and then called FreeData which would check the list again for the data. Instead, I should just get the data and then call FreeData to let it manipulate the list.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 13
diff changeset
7698 /* Note that ALmixer_FreeData will remove the data from the linked list for us so don't pop the list here. */
33
28cf14726606 Fixed infinite loop bug for delete.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 32
diff changeset
7699 ALmixer_Data* almixer_data = LinkedList_PopBack(s_listOfALmixerData);
37
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
7700 /* Watch out: ALmixer_FreeData used to escape because ALmixer_Initialized is now false. */
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
7701 Internal_FreeData(almixer_data);
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7702 }
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7703 LinkedList_Free(s_listOfALmixerData);
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
7704 s_listOfALmixerData = NULL;
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7705
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7706
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7707 /* Need to get the device before I close the context */
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7708 dev = alcGetContextsDevice(context);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7709
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7710 alcMakeContextCurrent(NULL);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7711 alcDestroyContext(context);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7712
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7713 if(NULL == dev)
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7714 {
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7715 return;
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7716 }
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7717 alcCloseDevice(dev);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
7718
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7719 Sound_Quit();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7720
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7721 #ifdef ALMIXER_COMPILE_WITHOUT_SDL
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7722 /* Remember: ALmixer_SetError/GetError calls will not work while this is gone. */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7723 TError_FreeErrorPool(s_ALmixerErrorPool);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7724 s_ALmixerErrorPool = NULL;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7725 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7726 return;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7727 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7728
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7729 ALboolean ALmixer_IsInitialized()
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7730 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7731 return ALmixer_Initialized;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7732 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7733
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7734 ALuint ALmixer_GetFrequency()
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7735 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7736 return ALmixer_Frequency_global;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7737 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7738
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7739 const ALmixer_version* ALmixer_GetLinkedVersion()
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7740 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7741 static ALmixer_version linked_mixver;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7742 ALMIXER_GET_COMPILED_VERSION(&linked_mixver);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7743 return(&linked_mixver);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7744 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7745
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7746 #ifdef ALMIXER_COMPILE_WITHOUT_SDL
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7747
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7748 const char* ALmixer_GetError()
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7749 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7750 const char* error_string = NULL;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7751 if(NULL == s_ALmixerErrorPool)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7752 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7753 return "Error: You should not call ALmixer_GetError while ALmixer is not initialized";
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7754 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7755 error_string = TError_GetLastErrorStr(s_ALmixerErrorPool);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7756 /* SDL returns empty strings instead of NULL */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7757 if(NULL == error_string)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7758 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7759 return "";
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7760 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7761 else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7762 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7763 return error_string;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7764 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7765 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7766
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7767 void ALmixer_SetError(const char* err_str, ...)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7768 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7769 if(NULL == s_ALmixerErrorPool)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7770 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7771 fprintf(stderr, "Error: You should not call ALmixer_SetError while ALmixer is not initialized\n");
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7772 return;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7773 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7774 va_list argp;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7775 va_start(argp, err_str);
47
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
7776 /* SDL_SetError which I'm emulating has no number parameter. */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7777 TError_SetErrorv(s_ALmixerErrorPool, 1, err_str, argp);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7778 va_end(argp);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7779 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7780
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7781 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7782
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7783
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7784
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7785
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7786 #if 0
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7787 void ALmixer_OutputAttributes()
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7788 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7789 ALint num_flags = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7790 ALint* flags = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7791 int i;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7792 ALCdevice* dev = alcGetContextsDevice( alcGetCurrentContext() );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7793
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7794
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7795 printf("custom context\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7796
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7797 alcGetIntegerv(dev, ALC_ATTRIBUTES_SIZE,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7798 sizeof num_flags, &num_flags );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7799
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7800 printf("Number of Flags: %d\n", num_flags);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7801
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7802 if(num_flags)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7803 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7804 flags = malloc(sizeof(num_flags) * sizeof(ALint));
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7805
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7806 alcGetIntegerv(dev, ALC_ALL_ATTRIBUTES,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7807 sizeof num_flags * sizeof(ALint),
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7808 flags );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7809 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7810 for(i = 0; i < num_flags-1; i += 2)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7811 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7812 printf("key 0x%x : value %d\n",
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7813 flags[i], flags[i+1]);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7814 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7815 free(flags);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7816 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7817 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7818
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7819
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7820 void ALmixer_OutputDecoders()
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7821 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7822 Sound_Version sound_compile_version;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7823 Sound_Version sound_link_version;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7824
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7825 const Sound_DecoderInfo **rc = Sound_AvailableDecoders();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7826 const Sound_DecoderInfo **i;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7827 const char **ext;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7828 FILE* stream = stdout;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7829
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7830
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7831 fprintf(stream, "SDL_sound Information:\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7832
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7833 SOUND_VERSION(&sound_compile_version);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7834 fprintf(stream, "\tCompiled with SDL_sound version: %d.%d.%d\n",
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7835 sound_compile_version.major,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7836 sound_compile_version.minor,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7837 sound_compile_version.patch);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7838
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7839 Sound_GetLinkedVersion(&sound_link_version);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7840 fprintf(stream, "\tRunning (linked) with SDL_sound version: %d.%d.%d\n",
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7841 sound_link_version.major,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7842 sound_link_version.minor,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7843 sound_link_version.patch);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7844
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7845 fprintf(stream, "Supported sound formats:\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7846 if (rc == NULL)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7847 fprintf(stream, " * Apparently, NONE!\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7848 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7849 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7850 for (i = rc; *i != NULL; i++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7851 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7852 fprintf(stream, " * %s\n", (*i)->description);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7853
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7854 for (ext = (*i)->extensions; *ext != NULL; ext++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7855 fprintf(stream, " File extension \"%s\"\n", *ext);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7856
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7857 fprintf(stream, " Written by %s.\n %s\n\n",
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7858 (*i)->author, (*i)->url);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7859 } /* for */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7860 } /* else */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7861
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7862 fprintf(stream, "\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7863 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7864
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7865 void ALmixer_OutputOpenALInfo()
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7866 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7867 ALmixer_version mixer_compile_version;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7868 const ALmixer_version * mixer_link_version=ALmixer_GetLinkedVersion();
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7869 FILE* stream = stdout;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7870
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7871 fprintf(stream, "OpenAL Information:\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7872 fprintf(stream, "\tAL_VENDOR: %s\n", alGetString( AL_VENDOR ) );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7873 fprintf(stream, "\tAL_VERSION: %s\n", alGetString( AL_VERSION ) );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7874 fprintf(stream, "\tAL_RENDERER: %s\n", alGetString( AL_RENDERER ) );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7875 fprintf(stream, "\tAL_EXTENSIONS: %s\n", alGetString( AL_EXTENSIONS ) );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7876
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7877 ALMIXER_GET_COMPILED_VERSION(&mixer_compile_version);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7878 fprintf(stream, "\nSDL_ALmixer Information:\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7879 fprintf(stream, "\tCompiled with SDL_ALmixer version: %d.%d.%d\n",
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7880 mixer_compile_version.major,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7881 mixer_compile_version.minor,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7882 mixer_compile_version.patch);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7883
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7884 fprintf(stream, "\tRunning (linked) with SDL_ALmixer version: %d.%d.%d\n",
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7885 mixer_link_version->major,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7886 mixer_link_version->minor,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7887 mixer_link_version->patch);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7888
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7889 fprintf(stream, "\tCompile flags: ");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7890 #ifdef ENABLE_LOKI_QUEUE_FIX_HACK
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7891 fprintf(stream, "ENABLE_LOKI_QUEUE_FIX_HACK ");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7892 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7893 #ifdef ENABLE_ALMIXER_THREADS
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7894 fprintf(stream, "ENABLE_ALMIXER_THREADS ");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7895 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7896 #ifdef ENABLE_ALC_SYNC
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7897 fprintf(stream, "ENABLE_ALC_SYNC ");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7898 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7899 fprintf(stream, "\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7900 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7901
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7902
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7903 ALint ALmixer_AllocateChannels(ALint numchans)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7904 {
36
b65ad8b6ccf3 Moved two variable declarations to the top to make old C89/90 compilers happy.
Eric Wing <ewing@anscamobile.com>
parents: 35
diff changeset
7905 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
7906 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
7907 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
7908 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
7909 }
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
7910
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7911 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7912 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7913 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7914 retval = Internal_AllocateChannels(numchans);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7915 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7916 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7917 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7918 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7919 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7920
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7921
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7922 ALint ALmixer_ReserveChannels(ALint num)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7923 {
36
b65ad8b6ccf3 Moved two variable declarations to the top to make old C89/90 compilers happy.
Eric Wing <ewing@anscamobile.com>
parents: 35
diff changeset
7924 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
7925 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
7926 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
7927 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
7928 }
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
7929
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7930 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7931 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7932 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7933 retval = Internal_ReserveChannels(num);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7934 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7935 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7936 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7937 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7938 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7939
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7940
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7941
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7942
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
7943 static ALmixer_Data* DoLoad(Sound_Sample* sample, ALuint buffersize, ALboolean decode_mode_is_predecoded, ALuint max_queue_buffers, ALuint num_startup_buffers, ALuint suggested_number_of_buffers_to_queue_per_update_pass, ALuint access_data)
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7944 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
7945 ALuint bytes_decoded;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7946 ALmixer_Data* ret_data;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7947 ALenum error;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7948
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7949 /* Allocate memory */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7950 ret_data = (ALmixer_Data *)malloc(sizeof(ALmixer_Data));
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7951 if (NULL == ret_data)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7952 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7953 ALmixer_SetError("Out of memory");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7954 return(NULL);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7955 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7956
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7957 /* Initialize the data fields */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7958
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7959 /* Set the Sound_Sample pointer */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7960 ret_data->sample = sample;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7961
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7962 /* Flag the data to note that it is not in use */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7963 ret_data->in_use = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7964
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7965 /* Initialize remaining flags */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7966 ret_data->total_time = -1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7967 ret_data->eof = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7968
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7969 /* Just initialize */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7970 ret_data->num_buffers_in_use = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7971
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7972 /* Just initialize */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7973 ret_data->total_bytes = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7974
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7975 /* Just initialize */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7976 ret_data->loaded_bytes = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7977
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7978 /* Set the max queue buffers (minimum must be 2) */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7979 if(max_queue_buffers < 2)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7980 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7981 max_queue_buffers = ALMIXER_DEFAULT_QUEUE_BUFFERS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7982 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7983 ret_data->max_queue_buffers = max_queue_buffers;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7984 /* Set up the start up buffers */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7985 if(0 == num_startup_buffers)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7986 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7987 num_startup_buffers = ALMIXER_DEFAULT_STARTUP_BUFFERS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7988 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7989 /* Make sure start up buffers is less or equal to max_queue_buffers */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7990 if(num_startup_buffers > max_queue_buffers)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7991 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7992 num_startup_buffers = max_queue_buffers;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7993 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7994 ret_data->num_startup_buffers = num_startup_buffers;
35
76a881923cfc Bug fix for starvation problem due to for-loop using uninitialized variable.
Eric Wing <ewing@anscamobile.com>
parents: 34
diff changeset
7995
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
7996 /* Set up the update pass buffers */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
7997 if(0 == suggested_number_of_buffers_to_queue_per_update_pass)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
7998 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
7999 suggested_number_of_buffers_to_queue_per_update_pass = ALMIXER_DEFAULT_BUFFERS_TO_QUEUE_PER_UPDATE_PASS;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
8000 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
8001 /* Make sure update pass up buffers is less or equal to max_queue_buffers */
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
8002 if(suggested_number_of_buffers_to_queue_per_update_pass > max_queue_buffers)
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
8003 {
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
8004 suggested_number_of_buffers_to_queue_per_update_pass = max_queue_buffers;
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
8005 }
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
8006 ret_data->num_target_buffers_per_pass = suggested_number_of_buffers_to_queue_per_update_pass;
35
76a881923cfc Bug fix for starvation problem due to for-loop using uninitialized variable.
Eric Wing <ewing@anscamobile.com>
parents: 34
diff changeset
8007
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8008 ret_data->buffer_map_list = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8009 ret_data->current_buffer = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8010
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8011 ret_data->circular_buffer_queue = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8012
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8013 /* Now decode and load the data into a data chunk */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8014 /* Different cases for Streamed and Predecoded
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8015 * Streamed might turn into a predecoded if buffersize
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8016 * is large enough */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8017 if(AL_FALSE == decode_mode_is_predecoded)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8018 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8019 bytes_decoded = Sound_Decode(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8020 if(sample->flags & SOUND_SAMPLEFLAG_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8021 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8022 ALmixer_SetError(Sound_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8023 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8024 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8025 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8026 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8027
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8028 /* If no data, return an error */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8029 if(0 == bytes_decoded)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8030 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8031 ALmixer_SetError("File has no data");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8032 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8033 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8034 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8035 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8036
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8037 /* Note, currently, my Ogg conservative modifications
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8038 * prevent EOF from being detected in the first read
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8039 * because of the weird packet behavior of ov_read().
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8040 * The EAGAIN will get set, but not the EOF.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8041 * I don't know the best way to handle this,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8042 * so for now, Ogg's can only be explicitly
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8043 * predecoded.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8044 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8045
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8046 /* Correction: Since we no longer actually keep the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8047 * streamed data we read here (we rewind and throw
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8048 * it away, and start over on Play), it is
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8049 * safe to read another chunk to see if we've hit EOF
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8050 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8051 if(sample->flags & SOUND_SAMPLEFLAG_EAGAIN)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8052 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8053 bytes_decoded = Sound_Decode(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8054 if(sample->flags & SOUND_SAMPLEFLAG_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8055 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8056 ALmixer_SetError(Sound_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8057 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8058 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8059 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8060 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8061 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8062
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8063
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8064 /* If we found an EOF, the entire file was
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8065 * decoded, so we can treat it like one.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8066 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8067
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8068 if(sample->flags & SOUND_SAMPLEFLAG_EOF)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8069 {
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
8070 /*
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8071 fprintf(stderr, "We got LUCKY! File is predecoded even though STREAM was requested\n");
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
8072 */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8073 ret_data->decoded_all = 1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8074 /* Need to keep this information around for
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8075 * seek and rewind abilities.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8076 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8077 ret_data->total_bytes = bytes_decoded;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8078 /* For now, the loaded bytes is the same as total bytes, but
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8079 * this could change during a seek operation
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8080 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8081 ret_data->loaded_bytes = bytes_decoded;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8082
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8083 /* Let's compute the total playing time
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8084 * SDL_sound does not yet provide this (we're working on
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8085 * that at the moment...)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8086 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8087 ret_data->total_time = Compute_Total_Time(&sample->desired, bytes_decoded);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8088
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8089 /* Create one element in the buffer array for data for OpanAL */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8090 ret_data->buffer = (ALuint*)malloc( sizeof(ALuint) );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8091 if(NULL == ret_data->buffer)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8092 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8093 ALmixer_SetError("Out of Memory");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8094 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8095 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8096 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8097 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8098 /* Clear the error code */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8099 alGetError();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8100 /* Now generate an OpenAL buffer using that first element */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8101 alGenBuffers(1, ret_data->buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8102 if( (error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8103 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8104 ALmixer_SetError("alGenBuffers failed: %s\n", alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8105 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8106 free(ret_data->buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8107 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8108 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8109 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8110
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8111
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8112 /* Now copy the data to the OpenAL buffer */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8113 /* We can't just set a pointer because the API needs
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8114 * its own copy to assist hardware acceleration */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8115 alBufferData(ret_data->buffer[0],
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8116 TranslateFormat(&sample->desired),
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8117 sample->buffer,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8118 bytes_decoded,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8119 sample->desired.rate
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8120 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8121 if( (error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8122 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8123 ALmixer_SetError("alBufferData failed: %s\n", alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8124 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8125 alDeleteBuffers(1, ret_data->buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8126 free(ret_data->buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8127 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8128 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8129 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8130
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8131 /* We should be done with the sample since it's all
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8132 * predecoded. So we can free the memory */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8133
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8134 /* Additional notes:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8135 * We need to keep data around in case Seek() is needed
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8136 * or other Sound_AudioInfo is needed.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8137 * This can either be done by not deleting the sample,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8138 * or it can be done by dynamically recreating it
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8139 * when we need it.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8140 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8141 /* Since OpenAL won't let us retrieve it
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8142 * (aka dynamically), we have to keep the Sample
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8143 * around because since the user requested
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8144 * streamed and we offered predecoded,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8145 * we don't want to mess up the user who
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8146 * was expecting seek support
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8147 * So Don't Do anything
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8148 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8149 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8150 if(0 == access_data)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8151 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8152 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8153 ret_data->sample = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8154 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8155 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8156 /* Else, We keep a copy of the sample around.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8157 * so don't do anything.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8158 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8159
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8160 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8161 #if defined(DISABLE_PREDECODED_SEEK)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8162 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8163 ret_data->sample = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8164 #elif !defined(DISABLE_SEEK_MEMORY_OPTIMIZATION)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8165 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8166 ret_data->sample = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8167 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8168 /* We keep a copy of the sample around.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8169 * so don't do anything.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8170 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8171 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8172 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8173 /* okay we're done here */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8174
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8175 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8176 /* Else, we need to stream the data, so we'll
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8177 * create multple buffers for queuing */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8178 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8179 {
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
8180 /*
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8181 fprintf(stderr, "Loading streamed data (not lucky)\n");
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
8182 */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8183 ret_data->decoded_all = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8184
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8185 /* This information is for predecoded.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8186 * Set to 0, since we don't know.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8187 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8188 ret_data->total_bytes = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8189
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
8190 ret_data->total_time = Sound_GetDuration(sample);
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
8191
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8192 /* Create buffers for data
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8193 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8194 ret_data->buffer = (ALuint*)malloc( sizeof(ALuint) * max_queue_buffers);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8195 if(NULL == ret_data->buffer)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8196 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8197 ALmixer_SetError("Out of Memory");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8198 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8199 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8200 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8201 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8202
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8203 /* Clear the error code */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8204 alGetError();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8205 /* Now generate an OpenAL buffer using that first element */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8206 alGenBuffers(max_queue_buffers, ret_data->buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8207 if( (error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8208 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8209 ALmixer_SetError("alGenBuffers failed: %s\n", alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8210 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8211 free(ret_data->buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8212 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8213 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8214 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8215
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8216 /* Redesign: Okay, because of the unqueuing problems and such,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8217 * I've decided to redesign where and how queuing is handled.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8218 * Before, everything was queued up here. However, this
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8219 * placed a penalty on load and made performance inconsistent
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8220 * when samples had to be rewound. It did make things easier
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8221 * to queue because I could let OpenAL decide which buffer
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8222 * needed to be queued next.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8223 * Now, I'm going to push off the queuing to the actual
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8224 * Play() command. I'm going to add some book keeping,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8225 * and allow for additional buffers to be filled at later
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8226 * times.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8227 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8228
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8229
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8230 /* So first of all, because of I already decoded the sample
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8231 * for testing, I need to decide what to do with it.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8232 * The best thing would be be to alBufferData() it.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8233 * The problem is it may conflict with the rest of
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8234 * the system because everything now assumes buffers
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8235 * are entirely stripped (because of the unqueing
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8236 * problem).
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8237 * So it looks like I have to do the crappy thing
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8238 * and throw away the data, and rewind.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8239 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8240
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8241 if(0 == Sound_Rewind(ret_data->sample))
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8242 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8243 ALmixer_SetError("Cannot use sample for streamed data because it must be rewindable: %s", Sound_GetError() );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8244 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8245 free(ret_data->buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8246 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8247 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8248 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8249
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8250
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8251 /* If the user has selected access_data, we need to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8252 * keep copies of the queuing buffers around because
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8253 * OpenAL won't let us access the data.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8254 * Allocate the memory for the buffers here
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8255 * and initialize the albuffer-index map
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8256 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8257 if(access_data)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8258 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8259 ALuint j;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8260 /* Create buffers for data access
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8261 * Should be the same number as the number of queue buffers
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8262 */
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8263 ret_data->buffer_map_list = (ALmixer_Buffer_Map*)malloc( sizeof(ALmixer_Buffer_Map) * max_queue_buffers);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8264 if(NULL == ret_data->buffer_map_list)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8265 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8266 ALmixer_SetError("Out of Memory");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8267 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8268 free(ret_data->buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8269 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8270 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8271 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8272
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8273 ret_data->circular_buffer_queue = CircularQueueUnsignedInt_CreateQueue(max_queue_buffers);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8274 if(NULL == ret_data->circular_buffer_queue)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8275 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8276 ALmixer_SetError("Out of Memory");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8277 free(ret_data->buffer_map_list);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8278 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8279 free(ret_data->buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8280 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8281 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8282 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8283
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8284
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8285 for(j=0; j<max_queue_buffers; j++)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8286 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8287 ret_data->buffer_map_list[j].albuffer = ret_data->buffer[j];
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8288 ret_data->buffer_map_list[j].index = j;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8289 ret_data->buffer_map_list[j].num_bytes = 0;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8290 ret_data->buffer_map_list[j].data = (ALbyte*)malloc( sizeof(ALbyte) * buffersize);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8291 if(NULL == ret_data->buffer_map_list[j].data)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8292 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8293 ALmixer_SetError("Out of Memory");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8294 break;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8295 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8296 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8297 /* If an error happened, we have to clean up the memory */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8298 if(j < max_queue_buffers)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8299 {
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8300 ALmixer_SetError("################## Buffer allocation failed");
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8301 fprintf(stderr, "################## Buffer allocation failed\n");
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8302 while(j>0)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8303 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8304 free(ret_data->buffer_map_list[j].data);
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8305 j--;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8306 }
47
9b772c81b550 Added addition query to get the current number of buffers processed in the new inner buffer decoupling loop because I've been seeing a lot of 59TestingError warnings. I think it is possible the value may become stale after the first iteration of the loop resulting in assumption failures which result in triggering this error.
Eric Wing <ewing@anscamobile.com>
parents: 44
diff changeset
8307 /* Delete for j=0 because the while loop misses the last one */
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8308 free(ret_data->buffer_map_list[j].data);
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8309
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8310 free(ret_data->buffer_map_list);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8311 CircularQueueUnsignedInt_FreeQueue(ret_data->circular_buffer_queue);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8312 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8313 free(ret_data->buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8314 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8315 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8316 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8317
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8318 /* The Buffer_Map_List must be sorted by albuffer for binary searches
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8319 */
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8320 qsort(ret_data->buffer_map_list, max_queue_buffers, sizeof(ALmixer_Buffer_Map), Compare_Buffer_Map);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8321 } /* End if access_data==true */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8322
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8323
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8324 } /* End of do stream */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8325 } /* end of DECODE_STREAM */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8326 /* User requested decode all (easy, nothing to figure out) */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8327 else if(AL_TRUE == decode_mode_is_predecoded)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8328 {
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
8329 #ifdef ALMIXER_DISABLE_PREDECODED_PRECOMPUTE_BUFFER_SIZE_OPTIMIZATION
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8330 /* SDL_sound (behind the scenes) seems to loop on buffer_size chunks
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8331 * until the buffer is filled. It seems like we can
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8332 * do much better and precompute the size of the buffer
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8333 * so looping isn't needed.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8334 * WARNING: Due to the way SDL_sound is currently implemented,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8335 * this may waste a lot of memory up front.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8336 * SDL_sound seems to pre-create a buffer of the requested size,
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8337 * but on DecodeAll, an entirely new buffer is created and
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8338 * everything is memcpy'd into the new buffer in read chunks
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8339 * of the buffer_size. This means we need roughly twice the memory
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8340 * to load a file.
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8341 */
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8342 ALint sound_duration = Sound_GetDuration(sample);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8343 if(sound_duration > 0)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8344 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8345 size_t total_bytes = Compute_Total_Bytes_With_Frame_Padding(&sample->desired, (ALuint)sound_duration);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8346 int buffer_resize_succeeded = Sound_SetBufferSize(sample, total_bytes);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8347 if(0 == buffer_resize_succeeded)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8348 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8349 ALmixer_SetError(Sound_GetError());
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8350 Sound_FreeSample(sample);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8351 free(ret_data);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8352 return NULL;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8353 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8354 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8355 #endif /* ALMIXER_DISABLE_PREDECODED_PRECOMPUTE_BUFFER_SIZE_OPTIMIZATION */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8356 bytes_decoded = Sound_DecodeAll(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8357 if(sample->flags & SOUND_SAMPLEFLAG_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8358 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8359 ALmixer_SetError(Sound_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8360 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8361 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8362 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8363 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8364
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8365 /* If no data, return an error */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8366 if(0 == bytes_decoded)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8367 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8368 ALmixer_SetError("File has no data");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8369 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8370 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8371 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8372 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8373
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8374
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8375 ret_data->decoded_all = 1;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8376 /* Need to keep this information around for
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8377 * seek and rewind abilities.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8378 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8379 ret_data->total_bytes = bytes_decoded;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8380 /* For now, the loaded bytes is the same as total bytes, but
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8381 * this could change during a seek operation
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8382 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8383 ret_data->loaded_bytes = bytes_decoded;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8384
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8385 /* Let's compute the total playing time
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8386 * SDL_sound does not yet provide this (we're working on
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8387 * that at the moment...)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8388 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8389 ret_data->total_time = Compute_Total_Time(&sample->desired, bytes_decoded);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8390
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8391 /* Create one element in the buffer array for data for OpanAL */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8392 ret_data->buffer = (ALuint*)malloc( sizeof(ALuint) );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8393 if(NULL == ret_data->buffer)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8394 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8395 ALmixer_SetError("Out of Memory");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8396 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8397 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8398 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8399 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8400 /* Clear the error code */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8401 alGetError();
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8402 /* Now generate an OpenAL buffer using that first element */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8403 alGenBuffers(1, ret_data->buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8404 if( (error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8405 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8406 ALmixer_SetError("alGenBuffers failed: %s\n", alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8407 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8408 free(ret_data->buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8409 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8410 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8411 }
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
8412 /*
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8413 fprintf(stderr, "Actual rate=%d, desired=%d\n", sample->actual.rate, sample->desired.rate);
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
8414 */
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8415 /* Now copy the data to the OpenAL buffer */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8416 /* We can't just set a pointer because the API needs
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8417 * its own copy to assist hardware acceleration */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8418 alBufferData(ret_data->buffer[0],
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8419 TranslateFormat(&sample->desired),
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8420 sample->buffer,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8421 bytes_decoded,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8422 sample->desired.rate
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8423 );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8424 if( (error = alGetError()) != AL_NO_ERROR)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8425 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8426 ALmixer_SetError("alBufferData failed: %s\n", alGetString(error));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8427 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8428 alDeleteBuffers(1, ret_data->buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8429 free(ret_data->buffer);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8430 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8431 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8432 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8433
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8434 /* We should be done with the sample since it's all
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8435 * predecoded. So we can free the memory */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8436 /* Need to keep around because Seek() needs it */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8437
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8438 /* Additional notes:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8439 * We need to keep data around in case Seek() is needed
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8440 * or other Sound_AudioInfo is needed.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8441 * This can either be done by not deleting the sample,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8442 * or it can be done by dynamically recreating it
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8443 * when we need it.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8444 * Update: I think now it's up to the user by passing the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8445 * access_data flag. If they set the flag, then they get
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8446 * data callbacks and seek support. If not, then they can
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8447 * get all that stuff at the expense of keeping extra memory
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8448 * around.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8449 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8450 if(0 == access_data)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8451 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8452 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8453 ret_data->sample = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8454 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8455
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8456 /* Else, We keep a copy of the sample around.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8457 * so don't do anything.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8458 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8459 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8460 #if defined(DISABLE_PREDECODED_SEEK)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8461 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8462 ret_data->sample = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8463 #elif !defined(DISABLE_SEEK_MEMORY_OPTIMIZATION)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8464 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8465 ret_data->sample = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8466 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8467 /* We keep a copy of the sample around.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8468 * so don't do anything.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8469 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8470 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8471 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8472
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8473 /* okay we're done here */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8474 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8475 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8476 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8477 /* Shouldn't get here */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8478 ALmixer_SetError("Unknown decode mode");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8479 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8480 free(ret_data);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8481 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8482 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8483
13
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
8484 /* Add the ALmixerData to an internal linked list so we can delete it on
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
8485 * quit and avoid messy dangling issues with Sound_Quit
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
8486 */
54aa96ae8912 Added LinkedList class to project.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 12
diff changeset
8487 LinkedList_PushBack(s_listOfALmixerData, ret_data);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8488 return ret_data;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8489 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8490
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8491
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8492 /* This will load a sample for us. Most of the uglyness is
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8493 * error checking and the fact that streamed/predecoded files
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8494 * must be treated differently.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8495 * I don't like the AudioInfo parameter. I removed it once,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8496 * but the system will fail on RAW samples because the user
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8497 * must specify it, so I had to bring it back.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8498 * Remember I must close the rwops if there is an error before NewSample()
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8499 */
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
8500 ALmixer_Data* ALmixer_LoadSample_RW(ALmixer_RWops* rwops, const char* fileext, ALuint buffersize, ALboolean decode_mode_is_predecoded, ALuint max_queue_buffers, ALuint num_startup_buffers, ALuint suggested_number_of_buffers_to_queue_per_update_pass, ALuint access_data)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8501 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8502 Sound_Sample* sample = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8503 Sound_AudioInfo target;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8504
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8505 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8506 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8507 return NULL;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8508 }
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8509
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8510 /* Initialize target values to defaults
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8511 * 0 tells SDL_sound to use the "actual" values
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8512 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8513 target.channels = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8514 target.rate = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8515 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8516 /* This requires my new additions to SDL_sound. It will
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8517 * convert the sample to the proper endian order.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8518 * If the actual is 8-bit, it will do unsigned, if
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8519 * the actual is 16-bit, it will do signed.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8520 * I'm told by Ryan Gordon that OpenAL prefers the signedness
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8521 * in this way.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8522 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8523 target.format = AUDIO_U8S16SYS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8524 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8525 target.format = AUDIO_S16SYS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8526 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8527
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8528 /* Set a default buffersize if needed */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8529 if(0 == buffersize)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8530 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8531 buffersize = ALMIXER_DEFAULT_BUFFERSIZE;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8532 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8533
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8534 sample = Sound_NewSample(rwops, fileext, &target, buffersize);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8535 if(NULL == sample)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8536 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8537 ALmixer_SetError(Sound_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8538 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8539 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8540
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
8541 return( DoLoad(sample, buffersize, decode_mode_is_predecoded, max_queue_buffers, num_startup_buffers, suggested_number_of_buffers_to_queue_per_update_pass, access_data));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8542 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8543
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8544
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8545
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8546 /* This will load a sample for us from
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8547 * a file (instead of RWops). Most of the uglyness is
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8548 * error checking and the fact that streamed/predecoded files
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8549 * must be treated differently.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8550 */
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
8551 ALmixer_Data* ALmixer_LoadSample(const char* filename, ALuint buffersize, ALboolean decode_mode_is_predecoded, ALuint max_queue_buffers, ALuint num_startup_buffers, ALuint suggested_number_of_buffers_to_queue_per_update_pass, ALuint access_data)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8552 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8553 Sound_Sample* sample = NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8554 Sound_AudioInfo target;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8555
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8556 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8557 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8558 return NULL;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8559 }
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8560
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8561 /* Initialize target values to defaults
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8562 * 0 tells SDL_sound to use the "actual" values
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8563 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8564 target.channels = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8565 target.rate = 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8566
44
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
8567 if(0 == buffersize)
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
8568 {
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
8569 buffersize = ALMIXER_DEFAULT_BUFFERSIZE;
56855942fdc6 Split off background thread (threads only) termination and creation into separate functions from Interruption handling to make it easier to avoid race condition bug with Apple rdar://10081775 w.r.t. setting the OpenAL context. New APIs to suspend and resume update threads. Interruption handling calls these automatically.
Eric Wing <ewing@anscamobile.com>
parents: 42
diff changeset
8570 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8571 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8572 /* This requires my new additions to SDL_sound. It will
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8573 * convert the sample to the proper endian order.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8574 * If the actual is 8-bit, it will do unsigned, if
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8575 * the actual is 16-bit, it will do signed.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8576 * I'm told by Ryan Gordon that OpenAL prefers the signedness
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8577 * in this way.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8578 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8579 target.format = AUDIO_U8S16SYS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8580 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8581 target.format = AUDIO_S16SYS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8582 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8583
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8584 #if 0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8585 /* Okay, here's a messy hack. The problem is that we need
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8586 * to convert the sample to have the correct bitdepth,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8587 * endian order, and signedness values.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8588 * The bit depth is 8 or 16.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8589 * The endian order is the native order of the system.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8590 * The signedness depends on what the original value
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8591 * of the sample. Unfortunately, we can't specify these
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8592 * values until we after we already know what the original
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8593 * values were for bitdepth and signedness.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8594 * So we must open the file once to get the values,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8595 * then close it, and then reopen it with the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8596 * correct desired target values.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8597 * I tried changing the sample->desired field after
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8598 * the NewSample call, but it had no effect, so
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8599 * it looks like it must be set on open.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8600 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8601 /* Pick a small buffersize for the first open to not
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8602 * waste much time allocating memory */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8603 sample = Sound_NewSampleFromFile(filename, NULL, 512);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8604 if(NULL == sample)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8605 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8606 ALmixer_SetError(Sound_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8607 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8608 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8609
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8610 bit_depth = GetBitDepth(sample->actual.format);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8611 signedness_value = GetSignednessValue(sample->actual.format);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8612 if(8 == bit_depth)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8613 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8614 /* If 8 bit, then we don't have to worry about
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8615 * endian issues. We can just use the actual format
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8616 * value and it should do the right thing
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8617 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8618 target.format = sample->actual.format;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8619 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8620 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8621 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8622 /* We'll assume it's 16-bit, and if it's not
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8623 * hopefully SDL_sound will return an error,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8624 * or let us convert to 16-bit
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8625 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8626 /* Now we need to get the correct signedness */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8627 if(ALMIXER_UNSIGNED_VALUE == signedness_value)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8628 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8629 /* Set to Unsigned 16-bit, system endian order */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8630 target.format = AUDIO_U16SYS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8631 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8632 else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8633 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8634 /* Again, we'll assume it's Signed 16-bit system order
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8635 * or force the conversion and hope it works out
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8636 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8637 target.format = AUDIO_S16SYS;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8638 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8639 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8640
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8641 /* Now we have the correct info. We need to close and reopen */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8642 Sound_FreeSample(sample);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8643 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8644
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8645 sample = Sound_NewSampleFromFile(filename, &target, buffersize);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8646 if(NULL == sample)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8647 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8648 ALmixer_SetError(Sound_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8649 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8650 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8651
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
8652 /*
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8653 fprintf(stderr, "Correction test: Actual rate=%d, desired=%d, actual format=%d, desired format=%d\n", sample->actual.rate, sample->desired.rate, sample->actual.format, sample->desired.format);
6
4b1048af7e55 Disabled some of the debugging printfs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 3
diff changeset
8654 */
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
8655 return( DoLoad(sample, buffersize, decode_mode_is_predecoded, max_queue_buffers, num_startup_buffers, suggested_number_of_buffers_to_queue_per_update_pass, access_data));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8656 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8657
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8658
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8659 /* This is a back door for RAW samples or if you need the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8660 * AudioInfo field. Use at your own risk.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8661 */
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
8662 ALmixer_Data* ALmixer_LoadSample_RAW_RW(ALmixer_RWops* rwops, const char* fileext, ALmixer_AudioInfo* desired, ALuint buffersize, ALboolean decode_mode_is_predecoded, ALuint max_queue_buffers, ALuint num_startup_buffers, ALuint suggested_number_of_buffers_to_queue_per_update_pass, ALuint access_data)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8663 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8664 Sound_Sample* sample = NULL;
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8665 Sound_AudioInfo sound_desired;
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8666
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8667 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8668 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8669 return NULL;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8670 }
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8671
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8672 /* Rather than copying the data from struct to struct, I could just
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8673 * cast the thing since the structs are meant to be identical.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8674 * But if SDL_sound changes it's implementation, bad things
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8675 * will probably happen. (Or if I change my implementation and
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8676 * forget about the cast, same bad scenario.) Since this is a load
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8677 * function, performance of this is negligible.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8678 */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8679 if(NULL == desired)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8680 {
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8681 sample = Sound_NewSample(rwops, fileext, NULL, buffersize);
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8682 }
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8683 else
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8684 {
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8685 sound_desired.format = desired->format;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8686 sound_desired.channels = desired->channels;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8687 sound_desired.rate = desired->rate;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8688 sample = Sound_NewSample(rwops, fileext, &sound_desired, buffersize);
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8689 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8690 if(NULL == sample)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8691 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8692 ALmixer_SetError(Sound_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8693 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8694 }
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
8695 return( DoLoad(sample, buffersize, decode_mode_is_predecoded, max_queue_buffers, num_startup_buffers,suggested_number_of_buffers_to_queue_per_update_pass, access_data));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8696 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8697
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8698
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8699
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8700
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8701 /* This is a back door for RAW samples or if you need the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8702 * AudioInfo field. Use at your own risk.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8703 */
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
8704 ALmixer_Data* ALmixer_LoadSample_RAW(const char* filename, ALmixer_AudioInfo* desired, ALuint buffersize, ALboolean decode_mode_is_predecoded, ALuint max_queue_buffers, ALuint num_startup_buffers, ALuint suggested_number_of_buffers_to_queue_per_update_pass, ALuint access_data)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8705 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8706 Sound_Sample* sample = NULL;
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8707 Sound_AudioInfo sound_desired;
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8708
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8709 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8710 {
34
7709c2145435 Fixed for omitted return value.
Eric Wing <ewing@anscamobile.com>
parents: 33
diff changeset
8711 return NULL;
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8712 }
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8713
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8714 /* Rather than copying the data from struct to struct, I could just
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8715 * cast the thing since the structs are meant to be identical.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8716 * But if SDL_sound changes it's implementation, bad things
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8717 * will probably happen. (Or if I change my implementation and
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8718 * forget about the cast, same bad scenario.) Since this is a load
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8719 * function, performance of this is negligible.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8720 */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8721 if(NULL == desired)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8722 {
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8723 sample = Sound_NewSampleFromFile(filename, NULL, buffersize);
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8724 }
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8725 else
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8726 {
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8727 sound_desired.format = desired->format;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8728 sound_desired.channels = desired->channels;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8729 sound_desired.rate = desired->rate;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8730 sample = Sound_NewSampleFromFile(filename, &sound_desired, buffersize);
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8731 }
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8732
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8733 if(NULL == sample)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8734 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8735 ALmixer_SetError(Sound_GetError());
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8736 return NULL;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8737 }
42
05e5dc4817a4 Warning: Breaking API/ABI changes. New optimizations to decouple update loop from number of buffers queued in audio streaming to allow more for more and smaller buffers to be processed in a loop. This also has the benefit for access_data callback buffer sizes not to be dictated by the performance tuning.
Eric Wing <ewing@anscamobile.com>
parents: 41
diff changeset
8738 return( DoLoad(sample, buffersize, decode_mode_is_predecoded, max_queue_buffers, num_startup_buffers, suggested_number_of_buffers_to_queue_per_update_pass, access_data));
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8739 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8740
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8741
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8742 void ALmixer_FreeData(ALmixer_Data* data)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8743 {
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8744 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8745 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8746 return;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8747 }
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8748
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
8749 /* Bypass if in interruption event */
37
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
8750 /* FIXME: Buffers are connected to devices, sources are connected to contexts. I should still be able to delete the buffers even if there is no context. */
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
8751 if(NULL == alcGetCurrentContext())
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
8752 {
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
8753 fprintf(stderr, "ALmixer_FreeData: Programmer Error. You cannot delete data when the OpenAL content is currently NULL. You may have already called ALmixer_Quit() or are in an interruption event\n");
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
8754 return;
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
8755 }
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8756
37
b346b6608eab Fixed memory leak in Quit due to changes related to background thread removal. FreeData was quick escaping because it checked for ALmixer_Initialized which is now false by the time the code is reached.
Eric Wing <ewing@anscamobile.com>
parents: 36
diff changeset
8757 Internal_FreeData(data);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8758 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8759
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8760 ALint ALmixer_GetTotalTime(ALmixer_Data* data)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8761 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8762 if(NULL == data)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8763 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8764 return -1;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8765 }
22
58f03008ea05 - Added Seek APIs
Eric Wing <ewing . public |-at-| gmail . com>
parents: 16
diff changeset
8766
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8767 return data->total_time;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8768 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8769
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8770 /* This function will look up the source for the corresponding channel */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8771 /* Must return 0 on error instead of -1 because of unsigned int */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8772 ALuint ALmixer_GetSource(ALint channel)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8773 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8774 ALuint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8775 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8776 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8777 return 0;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8778 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8779 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8780 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8781 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8782 retval = Internal_GetSource(channel);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8783 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8784 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8785 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8786 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8787 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8788
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8789 /* This function will look up the channel for the corresponding source */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8790 ALint ALmixer_GetChannel(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8791 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8792 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8793 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8794 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8795 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8796 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8797 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8798 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8799 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8800 retval = Internal_GetChannel(source);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8801 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8802 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8803 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8804 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8805 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8806
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8807 ALint ALmixer_FindFreeChannel(ALint start_channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8808 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8809 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8810 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8811 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8812 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8813 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8814 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8815 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8816 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8817 retval = Internal_FindFreeChannel(start_channel);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8818 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8819 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8820 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8821 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8822 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8823
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8824
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8825
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8826 /* API update function.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8827 * It should return the number of buffers that were
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8828 * queued during the call. The value might be
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8829 * used to guage how long you might wait to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8830 * call the next update loop in case you are worried
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8831 * about preserving CPU cycles. The idea is that
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8832 * when a buffer is queued, there was probably some
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8833 * CPU intensive looping which took awhile.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8834 * It's mainly provided as a convenience.
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8835 * Timing the call with ALmixer_GetTicks() would produce
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8836 * more accurate information.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8837 * Returns a negative value if there was an error,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8838 * the value being the number of errors.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8839 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8840 ALint ALmixer_Update()
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8841 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8842 #ifdef ENABLE_ALMIXER_THREADS
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8843 /* The thread will handle all updates by itself.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8844 * Don't allow the user to explicitly call update.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8845 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8846 return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8847 #else
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8848 return( Update_ALmixer(NULL) );
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8849 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8850 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8851
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8852
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8853
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8854 void ALmixer_SetPlaybackFinishedCallback(void (*playback_finished_callback)(ALint which_channel, ALuint al_source, ALmixer_Data* almixer_data, ALboolean finished_naturally, void* user_data), void* user_data)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8855 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8856 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8857 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8858 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8859 Channel_Done_Callback = playback_finished_callback;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8860 Channel_Done_Callback_Userdata = user_data;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8861 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8862 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8863 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8864 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8865
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8866
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8867 void ALmixer_SetPlaybackDataCallback(void (*playback_data_callback)(ALint which_chan, ALuint al_source, ALbyte* data, ALuint num_bytes, ALuint frequency, ALubyte channels, ALubyte bit_depth, ALboolean is_unsigned, ALboolean decode_mode_is_predecoded, ALuint length_in_msec, void* user_data), void* user_data)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8868 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8869 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8870 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8871 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8872 Channel_Data_Callback = playback_data_callback;
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
8873 Channel_Data_Callback_Userdata = user_data;
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8874 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8875 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8876 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8877 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8878
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8879
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8880
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8881
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8882
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8883 ALint ALmixer_PlayChannelTimed(ALint channel, ALmixer_Data* data, ALint loops, ALint ticks)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8884 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8885 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8886 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8887 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8888 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8889 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8890 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8891 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8892 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8893 retval = Internal_PlayChannelTimed(channel, data, loops, ticks);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8894 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8895 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8896 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8897 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8898 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8899
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8900
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8901 /* In case the user wants to specify a source instead of a channel,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8902 * they may use this function. This function will look up the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8903 * source-to-channel map, and convert the call into a
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8904 * PlayChannelTimed() function call.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8905 * Returns the channel it's being played on.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8906 * Note: If you are prefer this method, then you need to be careful
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8907 * about using PlayChannel, particularly if you request the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8908 * first available channels because source and channels have
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8909 * a one-to-one mapping in this API. It is quite easy for
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8910 * a channel/source to already be in use because of this.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8911 * In this event, an error message will be returned to you.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8912 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8913 ALuint ALmixer_PlaySourceTimed(ALuint source, ALmixer_Data* data, ALint loops, ALint ticks)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8914 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8915 ALuint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8916 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8917 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8918 return 0;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8919 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8920 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8921 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8922 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8923 retval = Internal_PlaySourceTimed(source, data, loops, ticks);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8924 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8925 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8926 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8927 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8928 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8929
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8930
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8931 /* Will return the number of channels halted
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8932 * or -1 for error
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8933 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8934 ALint ALmixer_HaltChannel(ALint channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8935 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8936 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8937 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8938 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8939 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8940 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8941 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8942 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8943 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8944 retval = Internal_HaltChannel(channel, AL_FALSE);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8945 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8946 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8947 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8948 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8949 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8950
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8951 /* Will return the number of channels halted
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8952 * or 0 for error
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8953 */
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8954 ALint ALmixer_HaltSource(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8955 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8956 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8957 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8958 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8959 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8960 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8961 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8962 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8963 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8964 retval = Internal_HaltSource(source, AL_FALSE);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8965 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8966 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8967 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8968 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8969 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8970
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8971
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8972 /* This will rewind the SDL_Sound sample for streamed
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8973 * samples and start buffering up the data for the next
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8974 * playback. This may require samples to be halted
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8975 */
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
8976 ALboolean ALmixer_RewindData(ALmixer_Data* data)
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
8977 {
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
8978 ALboolean retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8979 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8980 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8981 return AL_FALSE;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8982 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8983 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8984 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8985 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8986 retval = Internal_RewindData(data);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8987 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8988 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8989 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8990 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8991 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8992
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8993 ALint ALmixer_RewindChannel(ALint channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8994 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
8995 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
8996 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8997 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8998 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
8999 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9000 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9001 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9002 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9003 retval = Internal_RewindChannel(channel);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9004 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9005 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9006 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9007 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9008 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9009
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9010 ALint ALmixer_RewindSource(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9011 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9012 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9013 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9014 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9015 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9016 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9017 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9018 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9019 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9020 retval = Internal_RewindSource(source);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9021 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9022 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9023 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9024 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9025 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9026
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9027 ALint ALmixer_PauseChannel(ALint channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9028 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9029 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9030 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9031 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9032 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9033 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9034 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9035 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9036 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9037 retval = Internal_PauseChannel(channel);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9038 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9039 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9040 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9041 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9042 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9043
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9044 ALint ALmixer_PauseSource(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9045 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9046 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9047 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9048 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9049 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9050 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9051 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9052 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9053 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9054 retval = Internal_PauseSource(source);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9055 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9056 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9057 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9058 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9059 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9060
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9061 ALint ALmixer_ResumeChannel(ALint channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9062 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9063 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9064 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9065 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9066 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9067 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9068 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9069 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9070 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9071 retval = Internal_ResumeChannel(channel);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9072 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9073 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9074 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9075 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9076 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9077
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9078 ALint ALmixer_ResumeSource(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9079 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9080 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9081 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9082 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9083 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9084 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9085 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9086 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9087 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9088 retval = Internal_ResumeSource(source);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9089 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9090 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9091 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9092 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9093 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9094
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9095 /* Might consider setting eof to 0 as a "feature"
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9096 * This will allow seek to end to stay there because
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9097 * Play automatically rewinds if at the end */
12
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
9098 ALboolean ALmixer_SeekData(ALmixer_Data* data, ALuint msec)
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
9099 {
bfe90b4f3d87 Bug fixes to FadeIn.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 10
diff changeset
9100 ALboolean retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9101 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9102 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9103 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9104 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9105 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9106 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9107 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9108 retval = Internal_SeekData(data, msec);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9109 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9110 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9111 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9112 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9113 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9114
20
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9115 ALint ALmixer_SeekChannel(ALint channel, ALuint msec)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9116 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9117 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9118 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9119 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9120 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9121 }
20
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9122 #ifdef ENABLE_ALMIXER_THREADS
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9123 SDL_LockMutex(s_simpleLock);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9124 #endif
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9125 retval = Internal_SeekChannel(channel, msec);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9126 #ifdef ENABLE_ALMIXER_THREADS
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9127 SDL_UnlockMutex(s_simpleLock);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9128 #endif
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9129 return retval;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9130 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9131
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9132 ALint ALmixer_SeekSource(ALuint source, ALuint msec)
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9133 {
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9134 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9135 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9136 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9137 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9138 }
20
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9139 #ifdef ENABLE_ALMIXER_THREADS
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9140 SDL_LockMutex(s_simpleLock);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9141 #endif
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9142 retval = Internal_SeekSource(source, msec);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9143 #ifdef ENABLE_ALMIXER_THREADS
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9144 SDL_UnlockMutex(s_simpleLock);
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9145 #endif
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9146 return retval;
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9147 }
9365e714fc4b Added SeekChannel, SeekSource.
Eric Wing <ewing@anscamobile.com>
parents: 16
diff changeset
9148
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9149 ALint ALmixer_FadeInChannelTimed(ALint channel, ALmixer_Data* data, ALint loops, ALuint fade_ticks, ALint expire_ticks)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9150 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9151 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9152 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9153 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9154 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9155 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9156 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9157 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9158 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9159 retval = Internal_FadeInChannelTimed(channel, data, loops, fade_ticks, expire_ticks);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9160 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9161 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9162 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9163 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9164 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9165
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9166 ALuint ALmixer_FadeInSourceTimed(ALuint source, ALmixer_Data* data, ALint loops, ALuint fade_ticks, ALint expire_ticks)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9167 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9168 ALuint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9169 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9170 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9171 return 0;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9172 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9173 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9174 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9175 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9176 retval = Internal_FadeInSourceTimed(source, data, loops, fade_ticks, expire_ticks);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9177 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9178 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9179 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9180 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9181 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9182
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9183 ALint ALmixer_FadeOutChannel(ALint channel, ALuint ticks)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9184 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9185 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9186 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9187 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9188 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9189 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9190 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9191 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9192 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9193 retval = Internal_FadeOutChannel(channel, ticks);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9194 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9195 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9196 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9197 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9198 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9199
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9200 ALint ALmixer_FadeOutSource(ALuint source, ALuint ticks)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9201 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9202 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9203 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9204 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9205 return 0;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9206 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9207 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9208 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9209 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9210 retval = Internal_FadeOutSource(source, ticks);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9211 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9212 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9213 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9214 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9215 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9216
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9217 ALint ALmixer_FadeChannel(ALint channel, ALuint ticks, ALfloat volume)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9218 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9219 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9220 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9221 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9222 return 0;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9223 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9224 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9225 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9226 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9227 retval = Internal_FadeChannel(channel, ticks, volume);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9228 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9229 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9230 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9231 return retval;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9232 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9233
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9234 ALint ALmixer_FadeSource(ALuint source, ALuint ticks, ALfloat volume)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9235 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9236 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9237 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9238 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9239 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9240 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9241 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9242 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9243 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9244 retval = Internal_FadeSource(source, ticks, volume);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9245 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9246 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9247 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9248 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9249 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9250
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9251
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9252 ALboolean ALmixer_SetVolumeChannel(ALint channel, ALfloat volume)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9253 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9254 ALboolean retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9255 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9256 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9257 return AL_FALSE;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9258 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9259 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9260 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9261 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9262 retval = Internal_SetVolumeChannel(channel, volume);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9263 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9264 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9265 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9266 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9267 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9268
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9269 ALboolean ALmixer_SetVolumeSource(ALuint source, ALfloat volume)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9270 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9271 ALboolean retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9272 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9273 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9274 return AL_FALSE;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9275 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9276 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9277 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9278 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9279 retval = Internal_SetVolumeSource(source, volume);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9280 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9281 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9282 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9283 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9284 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9285
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9286 ALfloat ALmixer_GetVolumeChannel(ALint channel)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9287 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9288 ALfloat retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9289 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9290 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9291 return -1.0f;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9292 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9293 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9294 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9295 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9296 retval = Internal_GetVolumeChannel(channel);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9297 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9298 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9299 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9300 return retval;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9301 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9302
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9303 ALfloat ALmixer_GetVolumeSource(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9304 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9305 ALfloat retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9306 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9307 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9308 return -1.0f;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9309 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9310 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9311 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9312 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9313 retval = Internal_GetVolumeSource(source);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9314 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9315 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9316 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9317 return retval;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9318 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9319
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9320 ALboolean ALmixer_SetMaxVolumeChannel(ALint channel, ALfloat volume)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9321 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9322 ALboolean retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9323 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9324 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9325 return AL_FALSE;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9326 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9327 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9328 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9329 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9330 retval = Internal_SetMaxVolumeChannel(channel, volume);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9331 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9332 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9333 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9334 return retval;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9335 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9336
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9337 ALboolean ALmixer_SetMaxVolumeSource(ALuint source, ALfloat volume)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9338 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9339 ALboolean retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9340 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9341 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9342 return AL_FALSE;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9343 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9344 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9345 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9346 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9347 retval = Internal_SetMaxVolumeSource(source, volume);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9348 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9349 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9350 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9351 return retval;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9352 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9353
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9354 ALfloat ALmixer_GetMaxVolumeChannel(ALint channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9355 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9356 ALfloat retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9357 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9358 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9359 return -1.0f;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9360 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9361 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9362 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9363 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9364 retval = Internal_GetMaxVolumeChannel(channel);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9365 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9366 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9367 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9368 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9369 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9370
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9371 ALfloat ALmixer_GetMaxVolumeSource(ALuint source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9372 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9373 ALfloat retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9374 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9375 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9376 return -1.0f;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9377 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9378 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9379 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9380 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9381 retval = Internal_GetMaxVolumeSource(source);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9382 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9383 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9384 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9385 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9386 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9387
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9388
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9389 ALboolean ALmixer_SetMinVolumeChannel(ALint channel, ALfloat volume)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9390 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9391 ALboolean retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9392 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9393 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9394 return AL_FALSE;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9395 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9396 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9397 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9398 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9399 retval = Internal_SetMinVolumeChannel(channel, volume);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9400 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9401 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9402 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9403 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9404 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9405
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9406 ALboolean ALmixer_SetMinVolumeSource(ALuint source, ALfloat volume)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9407 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9408 ALboolean retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9409 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9410 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9411 return AL_FALSE;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9412 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9413 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9414 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9415 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9416 retval = Internal_SetMinVolumeSource(source, volume);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9417 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9418 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9419 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9420 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9421 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9422
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9423 ALfloat ALmixer_GetMinVolumeChannel(ALint channel)
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9424 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9425 ALfloat retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9426 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9427 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9428 return -1.0f;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9429 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9430 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9431 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9432 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9433 retval = Internal_GetMinVolumeChannel(channel);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9434 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9435 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9436 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9437 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9438 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9439
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9440 ALfloat ALmixer_GetMinVolumeSource(ALuint source)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9441 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9442 ALfloat retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9443 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9444 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9445 return -1.0f;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9446 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9447 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9448 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9449 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9450 retval = Internal_GetMinVolumeSource(source);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9451 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9452 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9453 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9454 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9455 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9456
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9457
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9458
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9459 ALboolean ALmixer_SetMasterVolume(ALfloat volume)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9460 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9461 ALboolean retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9462 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9463 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9464 return AL_FALSE;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9465 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9466 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9467 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9468 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9469 retval = Internal_SetMasterVolume(volume);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9470 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9471 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9472 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9473 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9474 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9475
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9476 ALfloat ALmixer_GetMasterVolume()
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9477 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9478 ALfloat retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9479 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9480 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9481 return -1.0f;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9482 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9483 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9484 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9485 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9486 retval = Internal_GetMasterVolume();
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9487 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9488 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9489 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9490 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9491 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9492
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9493 ALint ALmixer_ExpireChannel(ALint channel, ALint ticks)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9494 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9495 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9496 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9497 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9498 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9499 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9500 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9501 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9502 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9503 retval = Internal_ExpireChannel(channel, ticks);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9504 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9505 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9506 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9507 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9508 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9509
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9510 ALint ALmixer_ExpireSource(ALuint source, ALint ticks)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9511 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9512 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9513 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9514 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9515 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9516 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9517 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9518 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9519 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9520 retval = Internal_ExpireSource(source, ticks);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9521 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9522 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9523 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9524 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9525 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9526
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9527 ALint ALmixer_IsActiveChannel(ALint channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9528 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9529 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9530 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9531 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9532 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9533 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9534 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9535 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9536 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9537 retval = Internal_QueryChannel(channel);
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9538 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9539 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9540 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9541 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9542 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9543
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9544 ALint ALmixer_IsActiveSource(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9545 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9546 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9547 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9548 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9549 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9550 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9551 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9552 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9553 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9554 retval = Internal_QuerySource(source);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9555 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9556 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9557 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9558 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9559 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9560
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9561
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9562 ALint ALmixer_IsPlayingChannel(ALint channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9563 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9564 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9565 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9566 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9567 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9568 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9569 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9570 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9571 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9572 retval = Internal_PlayingChannel(channel);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9573 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9574 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9575 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9576 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9577 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9578
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9579 ALint ALmixer_IsPlayingSource(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9580 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9581 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9582 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9583 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9584 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9585 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9586 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9587 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9588 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9589 retval = Internal_PlayingSource(source);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9590 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9591 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9592 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9593 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9594 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9595
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9596
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9597 ALint ALmixer_IsPausedChannel(ALint channel)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9598 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9599 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9600 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9601 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9602 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9603 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9604 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9605 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9606 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9607 retval = Internal_PausedChannel(channel);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9608 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9609 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9610 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9611 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9612 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9613
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9614 ALint ALmixer_IsPausedSource(ALuint source)
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9615 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9616 ALint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9617 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9618 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9619 return -1;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9620 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9621 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9622 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9623 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9624 retval = Internal_PausedSource(source);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9625 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9626 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9627 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9628 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9629 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9630
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9631
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9632 ALuint ALmixer_CountAllFreeChannels()
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9633 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9634 ALuint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9635 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9636 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9637 return 0;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9638 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9639 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9640 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9641 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9642 retval = Internal_CountAllFreeChannels();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9643 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9644 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9645 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9646 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9647 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9648
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9649 ALuint ALmixer_CountUnreservedFreeChannels()
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9650 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9651 ALuint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9652 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9653 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9654 return 0;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9655 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9656 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9657 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9658 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9659 retval = Internal_CountUnreservedFreeChannels();
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9660 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9661 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9662 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9663 return retval;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9664 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9665
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9666 ALuint ALmixer_CountAllUsedChannels()
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9667 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9668 ALuint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9669 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9670 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9671 return 0;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9672 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9673 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9674 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9675 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9676 retval = Internal_CountAllUsedChannels();
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9677 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9678 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9679 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9680 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9681 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9682
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9683 ALuint ALmixer_CountUnreservedUsedChannels()
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9684 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9685 ALuint retval;
41
e10dd3056782 Added API to check if in interruption.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 37
diff changeset
9686 if( (AL_FALSE == ALmixer_Initialized) || (AL_TRUE == g_inInterruption) )
27
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9687 {
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9688 return 0;
9cf93a099f75 Added initialization checks to all API functions.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 26
diff changeset
9689 }
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9690 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9691 SDL_LockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9692 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9693 retval = Internal_CountUnreservedUsedChannels();
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9694 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9695 SDL_UnlockMutex(s_simpleLock);
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9696 #endif
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9697 return retval;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9698 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9699
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9700 ALboolean ALmixer_IsPredecoded(ALmixer_Data* data)
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
9701 {
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
9702 if(NULL == data)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
9703 {
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9704 return AL_FALSE;
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
9705 }
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
9706 return data->decoded_all;
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
9707 }
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
9708
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9709 ALboolean ALmixer_CompiledWithThreadBackend()
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9710 {
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9711 #ifdef ENABLE_ALMIXER_THREADS
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9712 return AL_TRUE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9713 #else
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9714 return AL_FALSE;
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9715 #endif
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9716 }
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9717
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9718
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9719
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
9720