2
* KMix -- KDE's full featured mini mixer
5
* Copyright (C) 1996-2000 Christian Esken
8
* HP/UX-Port: Copyright (C) 1999 by Helge Deller
11
* This program is free software; you can redistribute it and/or
12
* modify it under the terms of the GNU Library General Public
13
* License as published by the Free Software Foundation; either
14
* version 2 of the License, or (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
* Library General Public License for more details.
21
* You should have received a copy of the GNU Library General Public
22
* License along with this program; if not, write to the Free
23
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
#include "mixer_hpux.h"
28
#warning "HP/UX mixer (maybe) doesn't work yet !"
30
#define HPUX_ERROR_OFFSET 1024
32
#define myGain AUnityGain /* AUnityGain or AZeroGain */
34
#define GAIN_OUT_DIFF ((long) ((int)aMaxOutputGain(audio) - (int)aMinOutputGain(audio)))
35
#define GAIN_OUT_MIN ((long) aMinOutputGain(audio))
36
#define GAIN_IN_DIFF ((long) ((int)aMaxInputGain(audio) - (int)aMinInputGain(audio)))
37
#define GAIN_IN_MIN ((long) aMinOutputGain(audio))
42
/* AInputSrcType: */ /*OSS:*/
43
#define ID_IN_MICROPHONE 7 /* AISTMonoMicrophone */
44
#define ID_IN_AUX 6 /* AISTLeftAuxiliary, AISTRightAuxiliary */
47
#define ID_OUT_INT_SPEAKER 0 /* AODTMonoIntSpeaker */
49
/* not yet implemented:
50
AODTLeftJack, AODTRightJack,
51
AODTLeftLineOut, AODTRightLineOut,
52
AODTLeftHeadphone, AODTRightHeadphone
54
const char* MixerDevNames[32]={"Volume" , "Bass" , "Treble" , "Synth" , "Pcm" , \
55
"Speaker" , "Line" , "Microphone", "CD" , "Mix" , \
56
"Pcm2" , "RecMon" , "IGain" , "OGain" , "Line1", \
57
"Line2" , "Line3" , "Digital1" , "Digital2", "Digital3", \
58
"PhoneIn" , "PhoneOut", "Video" , "Radio" , "Monitor", \
59
"3D-depth", "3D-center", "unknown" , "unknown" , "unknown", \
60
"unknown" , "unused" };
64
Mixer* HPUX_getMixer(int devnum, int SetNum)
67
l_mixer = new Mixer_HPUX( devnum, SetNum);
68
// l_mixer->init(devnum, SetNum);
73
Mixer_HPUX::Mixer_HPUX() : Mixer()
78
Mixer_HPUX::Mixer_HPUX(int devnum, int SetNum) : Mixer(devnum, SetNum)
82
audio = AOpenAudio(ServerName,NULL);
85
Mixer_HPUX::~Mixer_HPUX()
94
int Mixer_HPUX::openMixer()
97
return Mixer::ERR_OPEN;
101
/* Mixer is open. Now define properties */
102
stereodevs = devmask = (1<<ID_PCM); /* activate pcm */
105
/* check Input devices... */
106
if (AInputSources(audio) & AMonoMicrophoneMask) {
107
devmask |= (1<<ID_IN_MICROPHONE);
108
recmask |= (1<<ID_IN_MICROPHONE);
110
if (AInputSources(audio) & (ALeftAuxiliaryMask|ARightAuxiliaryMask)) {
111
devmask |= (1<<ID_IN_AUX);
112
recmask |= (1<<ID_IN_AUX);
113
stereodevs |= (1<<ID_IN_AUX);
116
/* check Output devices... */
117
if (AOutputDestinations(audio) & AMonoIntSpeakerMask) {
118
devmask |= (1<<ID_OUT_INT_SPEAKER);
119
stereodevs |= (1<<ID_OUT_INT_SPEAKER);
124
if (AOutputDestinations(audio) & AMonoLineOutMask) devmask |= 64; // Line
125
if (AOutputDestinations(audio) & AMonoJackMask) devmask |= (1<<14); // Line1
126
if (AOutputDestinations(audio) & AMonoHeadphoneMask) devmask |= (1<<15); // Line2
132
ASetSystemPlayGain(audio, myGain, &error);
133
if (error) errorText(error + HPUX_ERROR_OFFSET);
134
ASetSystemRecordGain(audio, myGain, &error);
135
if (error) errorText(error + HPUX_ERROR_OFFSET);
140
m_mixerName = "HP Mixer"; /* AAudioString(audio); */
145
int Mixer_HPUX::releaseMixer()
152
void Mixer_HPUX::setDevNumName_I(int devnum)
154
devname = "HP Mixer";
157
bool Mixer_HPUX::setRecsrcHW( int devnum, bool on )
162
bool Mixer_HPUX::isRecsrcHW( int devnum )
168
void Mixer_HPUX::setRecsrc(unsigned int newRecsrc)
170
long error = (long) AENoError;
173
i_recsrc = newRecsrc;
176
if (newRecsrc & (1<<ID_IN_MICROPHONE))
177
Source |= (1<<AISTMonoMicrophone);
178
if (newRecsrc & (1<<ID_IN_AUX))
179
Source |= (1<<AISTLeftAuxiliary) + (1<<AISTRightAuxiliary);
181
ASetDefaultInput(audio, (AInputSrcType) Source, &error);
183
errorText(error + HPUX_ERROR_OFFSET);
185
/* Traverse through the mixer devices and set the record source flags
186
* This is especially necessary for mixer devices that sometimes do
187
* not obey blindly (because of hardware limitations)
189
unsigned int recsrcwork = i_recsrc;
191
for ( unsigned int l_i_mixDevice = 1; l_i_mixDevice <= size(); l_i_mixDevice++) {
192
MixPtr = operator[](l_i_mixDevice);
194
if (recsrcwork & (1 << (MixPtr->num()) ) )
195
MixPtr->setRecsrc(true);
197
MixPtr->setRecsrc(false);
202
int Mixer_HPUX::readVolumeFromHW( int devnum, Volume &vol )
209
case ID_OUT_INT_SPEAKER: /* AODTMonoIntSpeaker */
210
AGetSystemChannelGain(audio, ASGTPlay, ACTMono, &Gain, &error );
211
vl = vr = (Gain-GAIN_OUT_MIN)*255 / GAIN_OUT_DIFF;
212
vol.setVolume( Volume::LEFT, vl);
213
vol.setVolume( Volume::RIGHT, vr);
214
printf("READ - Devnum: %d, Left: %d, Right: %d\n", devnum, vl, vr );
217
case ID_IN_AUX: /* AISTLeftAuxiliary, AISTRightAuxiliary */
218
case ID_IN_MICROPHONE: /* AISTMonoMicrophone */
219
AGetSystemChannelGain(audio, ASGTRecord, ACTMono, &Gain, &error );
220
vl = vr = (Gain-GAIN_IN_MIN)*255 / GAIN_IN_DIFF;
221
vol.setVolume( Volume::LEFT, vl);
222
vol.setVolume( Volume::RIGHT, vr);
226
error = ERR_NODEV - HPUX_ERROR_OFFSET;
230
return (error ? (error+HPUX_ERROR_OFFSET) : 0);
234
ASystemGainType = ASGTPlay, ASGTRecord, ASGTMonitor
235
AChType = ACTMono, ACTLeft, ACTRight
238
int Mixer_HPUX::writeVolumeToHW( int devnum, Volume vol )
242
int vl = vol.getVolume(Volume::LEFT);
243
int vr = vol.getVolume(Volume::RIGHT);
246
case ID_OUT_INT_SPEAKER: /* AODTMonoIntSpeaker */
247
printf("WRITE - Devnum: %d, Left: %d, Right: %d\n", devnum, vl, vr);
248
Gain = vl; // only left Volume
249
Gain = (Gain*GAIN_OUT_DIFF) / 255 - GAIN_OUT_MIN;
250
ASetSystemChannelGain(audio, ASGTPlay, ACTMono, (AGainDB) Gain, &error );
253
case ID_IN_MICROPHONE: /* AISTMonoMicrophone */
254
Gain = vl; // only left Volume
255
Gain = (Gain*GAIN_IN_DIFF) / 255 - GAIN_IN_MIN;
256
ASetSystemChannelGain(audio, ASGTRecord, ACTMono, (AGainDB) Gain, &error );
259
case ID_IN_AUX: /* AISTLeftAuxiliary, AISTRightAuxiliary */
260
Gain = (vl*GAIN_IN_DIFF) / 255 - GAIN_IN_MIN;
261
ASetSystemChannelGain(audio, ASGTRecord, ACTLeft, (AGainDB) Gain, &error );
262
Gain = (vr*GAIN_IN_DIFF) / 255 - GAIN_IN_MIN;
263
ASetSystemChannelGain(audio, ASGTRecord, ACTRight, (AGainDB) Gain, &error );
267
error = ERR_NODEV - HPUX_ERROR_OFFSET;
270
return (error ? (error+HPUX_ERROR_OFFSET) : 0);
274
QString Mixer_HPUX::errorText(int mixer_error)
277
if (mixer_error >= HPUX_ERROR_OFFSET) {
279
AGetErrorText(audio, (AError) (mixer_error-HPUX_ERROR_OFFSET),
280
errorstr, sizeof(errorstr));
281
printf("kmix: %s: %s\n",mixerName().data(), errorstr);
282
l_s_errmsg = errorstr;
287
// should use i18n...
288
l_s_errmsg = "kmix: HP-UX Alib-Mixer cannot be found.\n" \
289
"Please check that you have:\n" \
290
" 1. Installed the libAlib package and\n" \
291
" 2. started the Aserver program from the /opt/audio/bin directory\n";
294
l_s_errmsg = Mixer::errorText(mixer_error);