~ubuntu-branches/ubuntu/natty/kdemultimedia/natty-proposed

« back to all changes in this revision

Viewing changes to kmix/mixer_hpux.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Debian Qt/KDE Maintainers
  • Date: 2011-05-26 02:41:36 UTC
  • mfrom: (0.2.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 108.
  • Revision ID: james.westby@ubuntu.com-20110526024136-jjwsigfy402jhupm
Tags: upstream-4.6.3
ImportĀ upstreamĀ versionĀ 4.6.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *              KMix -- KDE's full featured mini mixer
3
 
 *
4
 
 *
5
 
 *              Copyright (C) 1996-2000 Christian Esken <esken@kde.org>
6
 
 * HP/UX-Port:  Copyright (C) 1999 by Helge Deller <deller@gmx.de>
7
 
 *
8
 
 * This program is free software; you can redistribute it and/or
9
 
 * modify it under the terms of the GNU Library General Public
10
 
 * License as published by the Free Software Foundation; either
11
 
 * version 2 of the License, or (at your option) any later version.
12
 
 *
13
 
 * This program is distributed in the hope that it will be useful,
14
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 
 * Library General Public License for more details.
17
 
 *
18
 
 * You should have received a copy of the GNU Library General Public
19
 
 * License along with this program; if not, write to the Free
20
 
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21
 
 */
22
 
 
23
 
#include "mixer_hpux.h"
24
 
 
25
 
#error "The HP/UX port is not maintained anymore, an no official part of KMix / KDE at this point of time! Please contact the current KMix maintainer if you would like to maintain the port."
26
 
 
27
 
#define HPUX_ERROR_OFFSET 1024
28
 
 
29
 
#define myGain  AUnityGain      /* AUnityGain or AZeroGain */
30
 
 
31
 
#define GAIN_OUT_DIFF   ((long) ((int)aMaxOutputGain(audio) - (int)aMinOutputGain(audio)))
32
 
#define GAIN_OUT_MIN    ((long) aMinOutputGain(audio))
33
 
#define GAIN_IN_DIFF    ((long) ((int)aMaxInputGain(audio)  - (int)aMinInputGain(audio)))
34
 
#define GAIN_IN_MIN     ((long) aMinOutputGain(audio))
35
 
 
36
 
/* standard */
37
 
#define ID_PCM                  4
38
 
 
39
 
/* AInputSrcType: */         /*OSS:*/
40
 
#define ID_IN_MICROPHONE        7       /* AISTMonoMicrophone */
41
 
#define ID_IN_AUX               6       /* AISTLeftAuxiliary, AISTRightAuxiliary */
42
 
 
43
 
/* AOutputDstType: */
44
 
#define ID_OUT_INT_SPEAKER      0       /* AODTMonoIntSpeaker */
45
 
 
46
 
/* not yet implemented:
47
 
    AODTLeftJack,    AODTRightJack,
48
 
    AODTLeftLineOut,  AODTRightLineOut,
49
 
    AODTLeftHeadphone, AODTRightHeadphone
50
 
 
51
 
const char* MixerDevNames[32]={"Volume"  , "Bass"    , "Treble"    , "Synth"   , "Pcm"  ,    \
52
 
                               "Speaker" , "Line"    , "Microphone", "CD"      , "Mix"  ,    \
53
 
                               "Pcm2"    , "RecMon"  , "IGain"     , "OGain"   , "Line1",    \
54
 
                               "Line2"   , "Line3"   , "Digital1"  , "Digital2", "Digital3", \
55
 
                               "PhoneIn" , "PhoneOut", "Video"     , "Radio"   , "Monitor",  \
56
 
                               "3D-depth", "3D-center", "unknown"  , "unknown" , "unknown",  \
57
 
                               "unknown" , "unused" };
58
 
*/
59
 
 
60
 
 
61
 
 
62
 
Mixer_HPUX::Mixer_HPUX(int devnum) : Mixer_Backend(devnum)
63
 
{
64
 
  char ServerName[10];
65
 
  ServerName[0] = 0;
66
 
  audio = AOpenAudio(ServerName,NULL);
67
 
}
68
 
 
69
 
Mixer_HPUX::~Mixer_HPUX()
70
 
{
71
 
  if (audio) {
72
 
      ACloseAudio(audio,0);
73
 
      audio = 0;
74
 
  }
75
 
}
76
 
 
77
 
 
78
 
int Mixer_HPUX::open()
79
 
{
80
 
  if (audio==0) {
81
 
    return Mixer::ERR_OPEN;
82
 
  }
83
 
  else
84
 
  {
85
 
    /* Mixer is open. Now define properties */
86
 
    stereodevs = devmask = (1<<ID_PCM); /* activate pcm */
87
 
    recmask = 0;
88
 
 
89
 
    /* check Input devices... */
90
 
    if (AInputSources(audio) & AMonoMicrophoneMask) {
91
 
            devmask     |= (1<<ID_IN_MICROPHONE);
92
 
            recmask     |= (1<<ID_IN_MICROPHONE);
93
 
    }
94
 
    if (AInputSources(audio) & (ALeftAuxiliaryMask|ARightAuxiliaryMask)) {
95
 
            devmask     |= (1<<ID_IN_AUX);
96
 
            recmask     |= (1<<ID_IN_AUX);
97
 
            stereodevs  |= (1<<ID_IN_AUX);
98
 
    }
99
 
 
100
 
    /* check Output devices... */
101
 
    if (AOutputDestinations(audio) & AMonoIntSpeakerMask) {
102
 
            devmask     |= (1<<ID_OUT_INT_SPEAKER);
103
 
            stereodevs  |= (1<<ID_OUT_INT_SPEAKER);
104
 
    }
105
 
 
106
 
/*  implement later:
107
 
    ----------------
108
 
    if (AOutputDestinations(audio) & AMonoLineOutMask)  devmask |= 64; // Line
109
 
    if (AOutputDestinations(audio) & AMonoJackMask)     devmask |= (1<<14); // Line1
110
 
    if (AOutputDestinations(audio) & AMonoHeadphoneMask)        devmask |= (1<<15); // Line2
111
 
*/
112
 
 
113
 
    MaxVolume = 255;
114
 
 
115
 
    long error = 0;
116
 
    ASetSystemPlayGain(audio, myGain, &error);
117
 
    if (error) errorText(error + HPUX_ERROR_OFFSET);
118
 
    ASetSystemRecordGain(audio, myGain, &error);
119
 
    if (error) errorText(error + HPUX_ERROR_OFFSET);
120
 
 
121
 
    i_recsrc = 0;
122
 
    m_isOpen = true;
123
 
 
124
 
    m_mixerName = "HP Mixer"; /* AAudioString(audio); */
125
 
    return 0;
126
 
  }
127
 
}
128
 
 
129
 
int Mixer_HPUX::close()
130
 
{
131
 
  _pollingTimer->stop();
132
 
  m_isOpen = false;
133
 
  m_mixDevices.clear();
134
 
  return 0;
135
 
}
136
 
 
137
 
 
138
 
/*
139
 
void Mixer_HPUX::setDevNumName_I(int devnum)
140
 
{
141
 
  devname = "HP Mixer";
142
 
}
143
 
*/
144
 
bool Mixer_HPUX::setRecsrcHW( int devnum, bool on )
145
 
{
146
 
    return false;
147
 
}
148
 
 
149
 
bool Mixer_HPUX::isRecsrcHW( int devnum )
150
 
{
151
 
    return false;
152
 
}
153
 
 
154
 
int Mixer_HPUX::readVolumeFromHW( int devnum, Volume &vol, Volume & )
155
 
{
156
 
    long Gain;
157
 
    long error = 0;
158
 
    int  vl,vr;
159
 
 
160
 
    switch (devnum) {
161
 
    case ID_OUT_INT_SPEAKER:    /* AODTMonoIntSpeaker */
162
 
        AGetSystemChannelGain(audio, ASGTPlay, ACTMono, &Gain, &error );
163
 
        vl = vr = (Gain-GAIN_OUT_MIN)*255 / GAIN_OUT_DIFF;
164
 
        vol.setVolume( Volume::LEFT, vl);
165
 
        vol.setVolume( Volume::RIGHT, vr);
166
 
printf("READ - Devnum: %d, Left: %d, Right: %d\n", devnum, vl, vr );
167
 
        break;
168
 
 
169
 
    case ID_IN_AUX:             /* AISTLeftAuxiliary, AISTRightAuxiliary */
170
 
    case ID_IN_MICROPHONE:      /* AISTMonoMicrophone */
171
 
        AGetSystemChannelGain(audio, ASGTRecord, ACTMono, &Gain, &error );
172
 
        vl = vr = (Gain-GAIN_IN_MIN)*255 / GAIN_IN_DIFF;
173
 
        vol.setVolume( Volume::LEFT, vl);
174
 
        vol.setVolume( Volume::RIGHT, vr);
175
 
        break;
176
 
 
177
 
    default:
178
 
        error = Mixer::ERR_READ - HPUX_ERROR_OFFSET;
179
 
        break;
180
 
    };
181
 
 
182
 
  return (error ? (error+HPUX_ERROR_OFFSET) : 0);
183
 
}
184
 
 
185
 
/*
186
 
        ASystemGainType         =     ASGTPlay, ASGTRecord, ASGTMonitor
187
 
        AChType                 =     ACTMono, ACTLeft, ACTRight
188
 
*/
189
 
 
190
 
int Mixer_HPUX::writeVolumeToHW( int devnum, Volume& vol, Volume & )
191
 
{
192
 
    long Gain;
193
 
    long error = 0;
194
 
    int vl = vol.getVolume(Volume::LEFT);
195
 
    int vr = vol.getVolume(Volume::RIGHT);
196
 
 
197
 
    switch (devnum) {
198
 
    case ID_OUT_INT_SPEAKER:    /* AODTMonoIntSpeaker */
199
 
printf("WRITE - Devnum: %d, Left: %d, Right: %d\n", devnum, vl, vr);
200
 
        Gain = vl;      // only left Volume
201
 
        Gain = (Gain*GAIN_OUT_DIFF) / 255 - GAIN_OUT_MIN;
202
 
        ASetSystemChannelGain(audio, ASGTPlay, ACTMono, (AGainDB) Gain, &error );
203
 
        break;
204
 
 
205
 
    case ID_IN_MICROPHONE:      /* AISTMonoMicrophone */
206
 
        Gain = vl;      // only left Volume
207
 
        Gain = (Gain*GAIN_IN_DIFF) / 255 - GAIN_IN_MIN;
208
 
        ASetSystemChannelGain(audio, ASGTRecord, ACTMono, (AGainDB) Gain, &error );
209
 
        break;
210
 
 
211
 
    case ID_IN_AUX:             /* AISTLeftAuxiliary, AISTRightAuxiliary */
212
 
        Gain = (vl*GAIN_IN_DIFF) / 255 - GAIN_IN_MIN;
213
 
        ASetSystemChannelGain(audio, ASGTRecord, ACTLeft, (AGainDB) Gain, &error );
214
 
        Gain = (vr*GAIN_IN_DIFF) / 255 - GAIN_IN_MIN;
215
 
        ASetSystemChannelGain(audio, ASGTRecord, ACTRight, (AGainDB) Gain, &error );
216
 
        break;
217
 
 
218
 
    default:
219
 
        error = Mixer::ERR_READ - HPUX_ERROR_OFFSET;
220
 
        break;
221
 
    };
222
 
  return (error ? (error+HPUX_ERROR_OFFSET) : 0);
223
 
}
224
 
 
225
 
 
226
 
QString Mixer_HPUX::errorText(int mixer_error)
227
 
{
228
 
  QString l_s_errmsg;
229
 
  if (mixer_error >= HPUX_ERROR_OFFSET) {
230
 
      char errorstr[200];
231
 
      AGetErrorText(audio, (AError) (mixer_error-HPUX_ERROR_OFFSET),
232
 
                            errorstr, sizeof(errorstr));
233
 
      printf("kmix: %s: %s\n",mixerName().data(), errorstr);
234
 
      l_s_errmsg = errorstr;
235
 
  } else
236
 
  switch (mixer_error)
237
 
    {
238
 
    case Mixer::ERR_OPEN:
239
 
                // should use i18n...
240
 
      l_s_errmsg = "kmix: HP-UX Alib-Mixer cannot be found.\n" \
241
 
                        "Please check that you have:\n" \
242
 
                        "  1. Installed the libAlib package  and\n" \
243
 
                        "  2. started the Aserver program from the /opt/audio/bin directory\n";
244
 
      break;
245
 
    default:
246
 
      l_s_errmsg = Mixer_Backend::errorText(mixer_error);
247
 
      break;
248
 
    }
249
 
  return l_s_errmsg;
250
 
}
251
 
 
252
 
QString HPUX_getDriverName() {
253
 
        return "HPUX";
254
 
}
255
 
 
256
 
QString Mixer_HPUX::getDriverName()
257
 
{
258
 
        return "HPUX";
259
 
}
260