Oolite
Loading...
Searching...
No Matches
OOALStreamedSound Class Reference

#include <OOALStreamedSound.h>

Inheritance diagram for OOALStreamedSound:
Collaboration diagram for OOALStreamedSound:

Instance Methods

(id) - initWithDecoder:
(void) - dealloc [implementation]
(NSString *) - name [implementation]
(void) - rewind [implementation]
(BOOL) - soundIncomplete [implementation]
(ALuint) - soundBuffer [implementation]
Instance Methods inherited from OOSound
(id) - initWithContentsOfFile:
(id) - init [implementation]
(id) - initWithCustomSoundKey:
(jsval) - oo_jsValueInContext: [implementation]
(NSString *) - oo_jsDescription [implementation]
(NSString *) - oo_jsClassName [implementation]

Private Attributes

char * _buffer
size_t _size
double _sampleRate
NSString * _name
BOOL _stereo
OOALSoundDecoder * decoder
BOOL _reachedEnd

Additional Inherited Members

Class Methods inherited from OOSound
(BOOL) + setUp
(void) + update
(void) + setMasterVolume:
(float) + masterVolume
(BOOL) + isSoundOK
(id) + soundWithCustomSoundKey:

Detailed Description

Definition at line 30 of file OOALStreamedSound.h.

Method Documentation

◆ dealloc

- (void) dealloc
implementation

Definition at line 34 of file OOALStreamedSound.m.

35{
36 free(_buffer);
37 _buffer = NULL;
38 [decoder release];
39
40 [super dealloc];
41}

References _buffer, and dealloc.

Referenced by dealloc.

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

◆ initWithDecoder:

- (id) initWithDecoder: (OOALSoundDecoder*) inDecoder

Reimplemented from OOSound.

Definition at line 48 of file OOALStreamedSound.m.

48 :(OOALSoundDecoder*)inDecoder
49{
50 BOOL OK = YES;
51
52 [OOSound setUp];
53 if (![OOSound isSoundOK] || nil == inDecoder)
54 OK = NO;
55
56 if (OK) {
57 self = [super init];
58 if (nil == self)
59 OK = NO;
60 }
61
62 if (OK) {
63 _name = [[inDecoder name] copy];
64 _sampleRate = [inDecoder sampleRate];
65 _stereo = [inDecoder isStereo];
66 _reachedEnd = NO;
68 decoder = [inDecoder retain];
69 [self rewind];
70 }
71
72 if (!OK) {
73 [self release];
74 self = nil;
75 }
76 return self;
77}
#define OOAL_STREAM_CHUNK_SIZE
return nil
OOALSoundDecoder * decoder
BOOL isSoundOK()
Definition OOALSound.m:143
BOOL setUp()
Definition OOALSound.m:46

References _buffer, _name, _reachedEnd, _sampleRate, _stereo, decoder, OOSound::init, OOSound::isSoundOK, OOALSoundDecoder::isStereo, OOALSoundDecoder::name, nil, OOAL_STREAM_CHUNK_SIZE, rewind, OOALSoundDecoder::sampleRate, and OOSound::setUp.

Here is the call graph for this function:

◆ name

- (NSString *) name
implementation

Reimplemented from OOSound.

Definition at line 43 of file OOALStreamedSound.m.

44{
45 return _name;
46}

References _name, and name.

Referenced by name.

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

◆ rewind

- (void) rewind
implementation

Reimplemented from OOSound.

Definition at line 79 of file OOALStreamedSound.m.

80{
81 [decoder reset];
82 _reachedEnd = NO;
83}

References _reachedEnd, OOALSoundDecoder::reset, and rewind.

Referenced by initWithDecoder:, and rewind.

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

◆ soundBuffer

- (ALuint) soundBuffer
implementation

Reimplemented from OOSound.

Definition at line 90 of file OOALStreamedSound.m.

91{
92 size_t transferred = [decoder streamToBuffer:_buffer];
93 if (transferred < OOAL_STREAM_CHUNK_SIZE) {
94 // otherwise keep going
95 _reachedEnd = YES;
96 }
97
98 ALuint buffer;
99 ALint error;
100 OOAL(alGenBuffers(1, &buffer));
101 if ((error = alGetError()) != AL_NO_ERROR) {
102 OOLog(kOOLogSoundLoadingError, @"%@", @"Could not create OpenAL buffer");
103 return 0;
104 } else {
105 if (!_stereo) {
106 alBufferData(buffer, AL_FORMAT_MONO16, _buffer, (ALsizei)transferred, _sampleRate);
107 } else {
108 alBufferData(buffer, AL_FORMAT_STEREO16, _buffer, (ALsizei)transferred, _sampleRate);
109 }
110 return buffer;
111 }
112}
#define OOLog(class, format,...)
Definition OOLogging.h:84
static NSString *const kOOLogSoundLoadingError
#define OOAL(cmd)
Definition OOOpenAL.h:40

References _buffer, _reachedEnd, _sampleRate, _stereo, kOOLogSoundLoadingError, OOAL, OOAL_STREAM_CHUNK_SIZE, OOLog, soundBuffer, and OOALSoundDecoder::streamToBuffer:.

Referenced by soundBuffer.

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

◆ soundIncomplete

- (BOOL) soundIncomplete
implementation

Reimplemented from OOSound.

Definition at line 85 of file OOALStreamedSound.m.

86{
87 return !_reachedEnd;
88}

References _reachedEnd, and soundIncomplete.

Referenced by soundIncomplete.

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

Member Data Documentation

◆ _buffer

- (char*) _buffer
private

Definition at line 32 of file OOALStreamedSound.h.

Referenced by dealloc, initWithDecoder:, and soundBuffer.

◆ _name

- (NSString*) _name
private

Definition at line 35 of file OOALStreamedSound.h.

Referenced by initWithDecoder:, and name.

◆ _reachedEnd

- (BOOL) _reachedEnd
private

Definition at line 38 of file OOALStreamedSound.h.

Referenced by initWithDecoder:, rewind, soundBuffer, and soundIncomplete.

◆ _sampleRate

- (double) _sampleRate
private

Definition at line 34 of file OOALStreamedSound.h.

Referenced by initWithDecoder:, and soundBuffer.

◆ _size

- (size_t) _size
private

Definition at line 33 of file OOALStreamedSound.h.

◆ _stereo

- (BOOL) _stereo
private

Definition at line 36 of file OOALStreamedSound.h.

Referenced by initWithDecoder:, and soundBuffer.

◆ decoder

- (OOALSoundDecoder*) decoder
private

Definition at line 37 of file OOALStreamedSound.h.

Referenced by initWithDecoder:.


The documentation for this class was generated from the following files: