Oolite
1.91.0.7659-250410-0031890
Toggle main menu visibility
Main Page
Topics
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
z
Enumerations
g
k
m
o
r
s
t
w
Enumerator
a
b
c
d
e
g
j
k
m
n
o
p
r
s
t
u
w
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
•
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Macros
Modules
Pages
Loading...
Searching...
No Matches
src
Core
OOOpenALController.m
Go to the documentation of this file.
1
/*
2
3
OOOpenALController.m
4
5
6
Oolite
7
Copyright (C) 2004-2013 Giles C Williams and contributors
8
9
This program is free software; you can redistribute it and/or
10
modify it under the terms of the GNU General Public License
11
as published by the Free Software Foundation; either version 2
12
of the License, or (at your option) any later version.
13
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
18
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22
MA 02110-1301, USA.
23
24
*/
25
26
#import "
OOOpenALController.h
"
27
#import "
OOLogging.h
"
28
#import "
OOALSoundMixer.h
"
29
30
static
id
sSingleton
=
nil
;
31
32
@implementation
OOOpenALController
33
34
+ (
OOOpenALController
*)
sharedController
35
{
36
if
(
sSingleton
==
nil
)
37
{
38
sSingleton
= [[
self
alloc] init];
39
}
40
41
return
sSingleton
;
42
}
34
+ (
OOOpenALController
*)
sharedController
{
…
}
43
44
45
- (id)
init
46
{
47
self
= [
super
init];
48
if
(
self
!=
nil
)
49
{
50
NSArray *arguments =
nil
;
51
NSEnumerator *argEnum =
nil
;
52
NSString *arg =
nil
;
53
54
arguments = [[
NSProcessInfo
processInfo] arguments];
55
for
(argEnum = [arguments objectEnumerator]; (arg = [
argEnum
nextObject]); )
56
{
57
if
([arg isEqual:
@"-nosound"
] || [arg isEqual:
@"--nosound"
])
58
{
59
[
self
release];
60
return
nil
;
61
}
62
}
63
64
ALuint error;
65
device
= alcOpenDevice(NULL);
// default device
66
if
(!
device
)
67
{
68
OOLog
(
kOOLogSoundInitError
,
@"%@"
,
@"Failed to open default sound device"
);
69
[
self
release];
70
return
nil
;
71
}
72
context
= alcCreateContext(
device
,NULL);
// default context
73
if
(!alcMakeContextCurrent(
context
))
74
{
75
OOLog
(
kOOLogSoundInitError
,
@"%@"
,
@"Failed to create default sound context"
);
76
[
self
release];
77
return
nil
;
78
}
79
if
((error = alGetError()) != AL_NO_ERROR)
80
{
81
OOLog
(
kOOLogSoundInitError
,
@"Error %d creating sound context"
,error);
82
}
83
OOAL
(alDistanceModel(AL_NONE));
84
}
85
return
self
;
86
}
45
- (id)
init
{
…
}
87
88
89
- (void) setMasterVolume:(ALfloat) fraction
90
{
91
OOAL
(alListenerf(AL_GAIN,fraction));
92
}
89
- (void) setMasterVolume:(ALfloat) fraction {
…
}
93
94
- (ALfloat)
masterVolume
95
{
96
ALfloat fraction = 0.0;
97
OOAL
(alGetListenerf(AL_GAIN,&fraction));
98
return
fraction;
99
}
94
- (ALfloat)
masterVolume
{
…
}
100
101
// only to be called at app shutdown
102
// is there a better way to handle this?
103
- (void)
shutdown
104
{
105
[[
OOSoundMixer
sharedMixer
] shutdown];
106
OOAL
(alcMakeContextCurrent(NULL));
107
OOAL
(alcDestroyContext(
context
));
108
OOAL
(alcCloseDevice(
device
));
109
}
103
- (void)
shutdown
{
…
}
110
111
@end
OOALSoundMixer.h
sSingleton
static OODebugMonitor * sSingleton
Definition
OODebugMonitor.m:50
OOLogging.h
OOLog
#define OOLog(class, format,...)
Definition
OOLogging.h:88
OOOpenALController.h
kOOLogSoundInitError
static NSString *const kOOLogSoundInitError
Definition
OOOpenALController.h:30
OOAL
#define OOAL(cmd)
Definition
OOOpenAL.h:40
nil
return nil
Definition
OOProbabilitySet.m:449
-[OOOpenALController init]
id init()
Definition
OOOpenALController.m:45
OOOpenALController
Definition
OOOpenALController.h:36
-[OOOpenALController shutdown]
void shutdown()
Definition
OOOpenALController.m:103
OOOpenALController::context
ALCcontext * context
Definition
OOOpenALController.h:39
+[OOOpenALController sharedController]
OOOpenALController * sharedController()
Definition
OOOpenALController.m:34
OOOpenALController::device
ALCdevice * device
Definition
OOOpenALController.h:38
-[OOOpenALController masterVolume]
ALfloat masterVolume()
Definition
OOOpenALController.m:94
OOSoundMixer
Definition
OOALSoundMixer.h:44
+[OOSoundMixer sharedMixer]
id sharedMixer()
Definition
OOALSoundMixer.m:40
Generated by
1.13.2