summaryrefslogtreecommitdiffstats
path: root/kmix/mixer_irix.cpp
blob: eb40756757040a3abeacc855011a174f8d8c274a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 *              KMix -- KDE's full featured mini mixer
 *
 *
 *              Copyright (C) 1996-2000 Christian Esken
 *                        esken@kde.org
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this program; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include "mixer_irix.h"

Mixer_Backend* IRIX_getMixer(int devnum)
{
  Mixer_Backend *l_mixer;
  l_mixer = new Mixer_IRIX( devnum);
  l_mixer->init(devnum);
  return l_mixer;
}



Mixer_IRIX::Mixer_IRIX(int devnum) : Mixer_Backend(devnum)
{
  close();
}

int Mixer_IRIX::open()
{
  // Create config
  m_config = ALnewconfig();
  if (m_config == (ALconfig)0) {
    cerr << "OpenAudioDevice(): ALnewconfig() failed\n";
    return Mixer::ERR_OPEN;
  }
  // Open audio device
  m_port = ALopenport("XVDOPlayer", "w", m_config);
  if (m_port == (ALport)0) {
    return Mixer::ERR_OPEN;
  }
  else {
    // Mixer is open. Now define properties
    devmask	= 1+128+2048;
    recmask	= 128;
    i_recsrc    = 128;
    stereodevs	= 1+128+2048;
    MaxVolume	= 255;

    i_s_mixer_name = "HPUX Audio Mixer";

    isOpen	= true;
    return 0;
  }
}

int Mixer_IRIX::close()
{
  m_isOpen = false;
  ALfreeconfig(m_config);
  ALcloseport(m_port);
  m_mixDevices.clear();
  return 0;
}

int Mixer_IRIX::readVolumeFromHW( int devnum, int *VolLeft, int *VolRight )
{
  long in_buf[4];
  switch( devnum() ) {
  case 0:       // Speaker Output
    in_buf[0] = AL_RIGHT_SPEAKER_GAIN;
    in_buf[2] = AL_LEFT_SPEAKER_GAIN;
    break;
  case 7:       // Microphone Input (actually selectable).
    in_buf[0] = AL_RIGHT_INPUT_ATTEN;
    in_buf[2] = AL_LEFT_INPUT_ATTEN;
    break;
  case 11:      // Record monitor
    in_buf[0] = AL_RIGHT_MONITOR_ATTEN;
    in_buf[2] = AL_LEFT_MONITOR_ATTEN;
    break;
  default:
    printf("Unknown device %d\n", MixPtr->num() );
  }
  ALgetparams(AL_DEFAULT_DEVICE, in_buf, 4);
  *VolRight = in_buf[1]*100/255;
  *VolLeft  = in_buf[3]*100/255;

  return 0;
}

int Mixer_IRIX::writeVolumeToHW( int devnum, int volLeft, int volRight )
{
  // Set volume (right&left)
  long out_buf[4] =
  {
    0, volRight,
    0, volLeft
  };
  switch( mixdevice->num() ) {
  case 0:      // Speaker
    out_buf[0] = AL_RIGHT_SPEAKER_GAIN;
    out_buf[2] = AL_LEFT_SPEAKER_GAIN;
    break;
  case 7:      // Microphone (Input)
    out_buf[0] = AL_RIGHT_INPUT_ATTEN;
    out_buf[2] = AL_LEFT_INPUT_ATTEN;
    break;
  case 11:     // Record monitor
    out_buf[0] = AL_RIGHT_MONITOR_ATTEN;
    out_buf[2] = AL_LEFT_MONITOR_ATTEN;
    break;
  }
  ALsetparams(AL_DEFAULT_DEVICE, out_buf, 4);

  return 0;
}

TQString IRIX_getDriverName() {
        return "IRIX";
}