Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOSoundChannel(Private) Category Reference

Instance Methods

(BOOL) - enqueueBuffer:
 
(void) - hasStopped
 
(void) - getNextSoundBuffer
 

Detailed Description

Definition at line 33 of file OOALSoundChannel.m.

Method Documentation

◆ enqueueBuffer:

- (BOOL) enqueueBuffer: (OOSound *) sound

Extends class OOSoundChannel.

Definition at line 1 of file OOALSoundChannel.m.

224 :(OOSound *)sound
225{
226 // get sound data
227 _buffer = [sound soundBuffer];
228 // bind sound data to buffer
229 OOAL(alSourceQueueBuffers(_source, 1, &_buffer));
230 ALuint error;
231 if ((error = alGetError()) != AL_NO_ERROR)
232 {
233 OOLog(@"ov.debug", @"Error %u queueing buffers (_source: %u (%p), _buffer: %u (%p))",
234 error, _source, &_source, _buffer, &_buffer);
235 return NO;
236 }
237 ALint playing = 0;
238 OOAL(alGetSourcei(_source,AL_SOURCE_STATE,&playing));
239 if (playing != AL_PLAYING)
240 {
241 OOAL(alSourcePlay(_source));
242 if ((error = alGetError()) != AL_NO_ERROR)
243 {
244 OOLog(@"ov.debug",@"Error %d playing source",error);
245 return NO;
246 }
247 }
248 return YES;
249}
#define OOLog(class, format,...)
Definition OOLogging.h:88
#define OOAL(cmd)
Definition OOOpenAL.h:40
ALuint soundBuffer()
Definition OOALSound.m:162

◆ getNextSoundBuffer

- (void) getNextSoundBuffer

Extends class OOSoundChannel.

Definition at line 1 of file OOALSoundChannel.m.

102{
103 if (!_bigSound)
104 {
105 // we've only loaded one buffer so far
106 _bigSound = YES;
107 _lastBuffer = _buffer;
108 [self enqueueBuffer:_sound];
109 }
110 else
111 {
112 // _lastBuffer has something in it, so only queue up
113 // another one if we've finished with that
114 ALint processed = 0;
115 OOAL(alGetSourcei(_source, AL_BUFFERS_PROCESSED, &processed));
116 if (processed > 0) // slot free
117 {
118 // dequeue and delete lastBuffer
119 ALuint buffer;
120 OOAL(alSourceUnqueueBuffers(_source, 1, &buffer));
121 assert(buffer == _lastBuffer);
122 OOAL(alDeleteBuffers(1,&_lastBuffer));
123 // shuffle along, and grab the next bit
124 _lastBuffer = _buffer;
125 [self enqueueBuffer:_sound];
126 }
127 }
128}

◆ hasStopped

- (void) hasStopped

Extends class OOSoundChannel.

Definition at line 1 of file OOALSoundChannel.m.

194{
195 ALint queued;
196 OOAL(alGetSourcei(_source, AL_BUFFERS_QUEUED, &queued));
197
198 while (queued--)
199 {
200 ALuint buffer;
201 OOAL(alSourceUnqueueBuffers(_source, 1, &buffer));
202 }
203
204 OOAL(alDeleteBuffers(1,&_buffer));
205 if (_bigSound)
206 {
207 // then we have two buffers to cleanup
208 OOAL(alDeleteBuffers(1,&_lastBuffer));
209 }
210 _bigSound = NO;
211
212
213 OOSound *sound = _sound;
214 _sound = nil;
215
216 if (nil != _delegate && [_delegate respondsToSelector:@selector(channel:didFinishPlayingSound:)])
217 {
218 [_delegate channel:self didFinishPlayingSound:sound];
219 }
220 [sound release];
221}
return nil

The documentation for this category was generated from the following file: