Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOALBufferedSound Class Reference

#include <OOALBufferedSound.h>

+ Inheritance diagram for OOALBufferedSound:
+ Collaboration diagram for OOALBufferedSound:

Instance Methods

(id) - initWithDecoder:
 
(void) - dealloc [implementation]
 
(NSString *) - name [implementation]
 
(ALuint) - soundBuffer [implementation]
 
- Instance Methods inherited from OOSound
(id) - initWithContentsOfFile:
 
(BOOL) - soundIncomplete
 
(void) - rewind
 
(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
 

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 OOALBufferedSound.h.

Method Documentation

◆ dealloc

- (void) dealloc
implementation

Definition at line 1 of file OOALBufferedSound.m.

35{
36 free(_buffer);
37 _buffer = NULL;
39
40 [super dealloc];
41}
#define DESTROY(x)
Definition OOCocoa.h:77

References _buffer, _name, and DESTROY.

◆ initWithDecoder:

- (id) initWithDecoder: (OOALSoundDecoder *) inDecoder

Reimplemented from OOSound.

Definition at line 1 of file OOALBufferedSound.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 OK = [inDecoder readCreatingBuffer:&_buffer withFrameCount:&_size];
68 _stereo = [inDecoder isStereo];
69 }
70
71 if (!OK)
72 {
73 [self release];
74 self = nil;
75 }
76 return self;
77}
return nil
BOOL readCreatingBuffer:withFrameCount:(char **outBuffer,[withFrameCount] size_t *outSize)
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 OOALBufferedSound.m.

44{
45 return _name;
46}

◆ soundBuffer

- (ALuint) soundBuffer
implementation

Reimplemented from OOSound.

Definition at line 1 of file OOALBufferedSound.m.

81{
82 ALuint buffer;
83 ALint error;
84 OOAL(alGenBuffers(1,&buffer));
85 if ((error = alGetError()) != AL_NO_ERROR)
86 {
87 OOLog(kOOLogSoundLoadingError, @"%@", @"Could not create OpenAL buffer");
88 return 0;
89 }
90 else
91 {
92 if (!_stereo)
93 {
94 alBufferData(buffer,AL_FORMAT_MONO16,_buffer,(ALsizei)_size,_sampleRate);
95 }
96 else
97 {
98 alBufferData(buffer,AL_FORMAT_STEREO16,_buffer,(ALsizei)_size,_sampleRate);
99 }
100 return buffer;
101 }
102}
#define OOLog(class, format,...)
Definition OOLogging.h:88
static NSString *const kOOLogSoundLoadingError
#define OOAL(cmd)
Definition OOOpenAL.h:40

Member Data Documentation

◆ _buffer

- (char*) _buffer
private

Definition at line 33 of file OOALBufferedSound.h.

Referenced by dealloc.

◆ _name

- (NSString*) _name
private

Definition at line 36 of file OOALBufferedSound.h.

Referenced by dealloc.

◆ _sampleRate

- (double) _sampleRate
private

Definition at line 35 of file OOALBufferedSound.h.

◆ _size

- (size_t) _size
private

Definition at line 34 of file OOALBufferedSound.h.

◆ _stereo

- (BOOL) _stereo
private

Definition at line 37 of file OOALBufferedSound.h.


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