Use logging macros in the sndio backend
[openal-soft/android.git] / Alc / alcDedicated.c
blob6bab83e50897f261322e4937ce41a8014280468a
1 /**
2 * OpenAL cross platform audio library
3 * Copyright (C) 2011 by Chris Robinson.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 * Or go to http://www.gnu.org/copyleft/lgpl.html
21 #include "config.h"
23 #include <stdlib.h>
25 #include "alMain.h"
26 #include "alFilter.h"
27 #include "alAuxEffectSlot.h"
28 #include "alError.h"
29 #include "alu.h"
32 typedef struct ALdedicatedState {
33 // Must be first in all effects!
34 ALeffectState state;
36 ALfloat gains[MAXCHANNELS];
37 } ALdedicatedState;
40 static ALvoid DedicatedDestroy(ALeffectState *effect)
42 ALdedicatedState *state = (ALdedicatedState*)effect;
43 free(state);
46 static ALboolean DedicatedDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
48 (void)effect;
49 (void)Device;
50 return AL_TRUE;
53 static ALvoid DedicatedDLGUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect)
55 ALdedicatedState *state = (ALdedicatedState*)effect;
56 ALCdevice *device = Context->Device;
57 const ALfloat *SpeakerGain;
58 ALint pos;
59 ALsizei s;
61 pos = aluCart2LUTpos(1.0f, 0.0f);
62 SpeakerGain = device->PanningLUT[pos];
64 for(s = 0;s < MAXCHANNELS;s++)
65 state->gains[s] = SpeakerGain[s] * Effect->Params.Dedicated.Gain;
68 static ALvoid DedicatedLFEUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect)
70 ALdedicatedState *state = (ALdedicatedState*)effect;
71 ALsizei s;
72 (void)Context;
74 for(s = 0;s < MAXCHANNELS;s++)
75 state->gains[s] = 0.0f;
76 state->gains[LFE] = Effect->Params.Dedicated.Gain;
79 static ALvoid DedicatedProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS])
81 ALdedicatedState *state = (ALdedicatedState*)effect;
82 const ALfloat *gains = state->gains;
83 ALuint i;
85 for(i = 0;i < SamplesToDo;i++)
87 ALsizei s;
88 for(s = 0;s < MAXCHANNELS;s++)
89 SamplesOut[i][s] = SamplesIn[i] * gains[s] * Slot->Gain;
93 ALeffectState *DedicatedDLGCreate(void)
95 ALdedicatedState *state;
96 ALsizei s;
98 state = malloc(sizeof(*state));
99 if(!state)
100 return NULL;
102 state->state.Destroy = DedicatedDestroy;
103 state->state.DeviceUpdate = DedicatedDeviceUpdate;
104 state->state.Update = DedicatedDLGUpdate;
105 state->state.Process = DedicatedProcess;
107 for(s = 0;s < MAXCHANNELS;s++)
108 state->gains[s] = 0.0f;
110 return &state->state;
113 ALeffectState *DedicatedLFECreate(void)
115 ALdedicatedState *state;
116 ALsizei s;
118 state = malloc(sizeof(*state));
119 if(!state)
120 return NULL;
122 state->state.Destroy = DedicatedDestroy;
123 state->state.DeviceUpdate = DedicatedDeviceUpdate;
124 state->state.Update = DedicatedLFEUpdate;
125 state->state.Process = DedicatedProcess;
127 for(s = 0;s < MAXCHANNELS;s++)
128 state->gains[s] = 0.0f;
130 return &state->state;