Oolite 1.91.0.7644-241112-7f5034b
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
 
OOALSoundDecoderdecoder
 
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 1 of file OOALStreamedSound.m.

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

References _buffer, and decoder.

◆ initWithDecoder:

- (id) initWithDecoder: (OOALSoundDecoder *) inDecoder

Reimplemented from OOSound.

Definition at line 1 of file OOALStreamedSound.m.

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

◆ name

- (NSString *) name
implementation

Reimplemented from OOSound.

Definition at line 1 of file OOALStreamedSound.m.

44{
45 return _name;
46}

◆ rewind

- (void) rewind
implementation

Reimplemented from OOSound.

Definition at line 1 of file OOALStreamedSound.m.

84{
85 [decoder reset];
86 _reachedEnd = NO;
87}

◆ soundBuffer

- (ALuint) soundBuffer
implementation

Reimplemented from OOSound.

Definition at line 1 of file OOALStreamedSound.m.

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

◆ soundIncomplete

- (BOOL) soundIncomplete
implementation

Reimplemented from OOSound.

Definition at line 1 of file OOALStreamedSound.m.

91{
92 return !_reachedEnd;
93}

Member Data Documentation

◆ _buffer

- (char*) _buffer
private

Definition at line 33 of file OOALStreamedSound.h.

Referenced by dealloc.

◆ _name

- (NSString*) _name
private

Definition at line 36 of file OOALStreamedSound.h.

◆ _reachedEnd

- (BOOL) _reachedEnd
private

Definition at line 39 of file OOALStreamedSound.h.

◆ _sampleRate

- (double) _sampleRate
private

Definition at line 35 of file OOALStreamedSound.h.

◆ _size

- (size_t) _size
private

Definition at line 34 of file OOALStreamedSound.h.

◆ _stereo

- (BOOL) _stereo
private

Definition at line 37 of file OOALStreamedSound.h.

◆ decoder

- (OOALSoundDecoder*) decoder
private

Definition at line 38 of file OOALStreamedSound.h.

Referenced by dealloc.


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