Oolite
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 194 of file OOALSoundChannel.m.

194 :(OOSound*)sound
195{
196 // get sound data
197 _buffer = [sound soundBuffer];
198 // bind sound data to buffer
199 OOAL(alSourceQueueBuffers(_source, 1, &_buffer));
200 ALuint error;
201 if ((error = alGetError()) != AL_NO_ERROR) {
202 OOLog(@"ov.debug", @"Error %u queueing buffers (_source: %u (%p), _buffer: %u (%p))",
203 error, _source, &_source, _buffer, &_buffer);
204 return NO;
205 }
206 ALint playing = 0;
207 OOAL(alGetSourcei(_source, AL_SOURCE_STATE, &playing));
208 if (playing != AL_PLAYING) {
209 OOAL(alSourcePlay(_source));
210 if ((error = alGetError()) != AL_NO_ERROR) {
211 OOLog(@"ov.debug", @"Error %d playing source", error);
212 return NO;
213 }
214 }
215 return YES;
216}
#define OOLog(class, format,...)
Definition OOLogging.h:84
#define OOAL(cmd)
Definition OOOpenAL.h:40
ALuint soundBuffer()
Definition OOALSound.m:148

References OOAL, OOLog, and OOSound::soundBuffer.

Referenced by getNextSoundBuffer.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getNextSoundBuffer

- (void) getNextSoundBuffer

Extends class OOSoundChannel.

Definition at line 89 of file OOALSoundChannel.m.

90{
91 if (!_bigSound) {
92 // we've only loaded one buffer so far
93 _bigSound = YES;
94 _lastBuffer = _buffer;
95 [self enqueueBuffer:_sound];
96 } else {
97 // _lastBuffer has something in it, so only queue up
98 // another one if we've finished with that
99 ALint processed = 0;
100 OOAL(alGetSourcei(_source, AL_BUFFERS_PROCESSED, &processed));
101 if (processed > 0) // slot free
102 {
103 // dequeue and delete lastBuffer
104 ALuint buffer;
105 OOAL(alSourceUnqueueBuffers(_source, 1, &buffer));
106 assert(buffer == _lastBuffer);
107 OOAL(alDeleteBuffers(1, &_lastBuffer));
108 // shuffle along, and grab the next bit
109 _lastBuffer = _buffer;
110 [self enqueueBuffer:_sound];
111 }
112 }
113}

References OOSoundChannel::enqueueBuffer:, getNextSoundBuffer, and OOAL.

Referenced by getNextSoundBuffer, and OOSoundChannel::update.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasStopped

- (void) hasStopped

Extends class OOSoundChannel.

Definition at line 168 of file OOALSoundChannel.m.

169{
170 ALint queued;
171 OOAL(alGetSourcei(_source, AL_BUFFERS_QUEUED, &queued));
172
173 while (queued--) {
174 ALuint buffer;
175 OOAL(alSourceUnqueueBuffers(_source, 1, &buffer));
176 }
177
178 OOAL(alDeleteBuffers(1, &_buffer));
179 if (_bigSound) {
180 // then we have two buffers to cleanup
181 OOAL(alDeleteBuffers(1, &_lastBuffer));
182 }
183 _bigSound = NO;
184
185 OOSound* sound = _sound;
186 _sound = nil;
187
188 if (nil != _delegate && [_delegate respondsToSelector:@selector(channel:didFinishPlayingSound:)]) {
189 [_delegate channel:self didFinishPlayingSound:sound];
190 }
191 [sound release];
192}
return nil

References hasStopped, nil, and OOAL.

Referenced by OOSoundChannel::dealloc, hasStopped, OOSoundChannel::stop, and OOSoundChannel::update.

Here is the call graph for this function:
Here is the caller graph for this function:

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