3
* KMix -- KDE's full featured mini mixer
6
* Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de>
7
* 1996-2000 Christian Esken <esken@kde.org>
8
* Sven Fischer <herpes@kawo2.rwth-aachen.de>
9
* 2002 - Helio Chissini de Castro <helio@conectiva.com.br>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26
#ifndef RANDOMPREFIX_MIXER_H
27
#define RANDOMPREFIX_MIXER_H
36
#include "mixdevice.h"
41
class Mixer : public QObject
46
enum MixerError { ERR_PERM=1, ERR_WRITE, ERR_READ,
47
ERR_OPEN, ERR_LASTERR };
49
Mixer( QString& ref_driverName, int device );
52
static int numDrivers();
53
QString getDriverName();
55
MixDevice* find(const QString& devPK);
57
void volumeSave( KConfig *config );
58
void volumeLoad( KConfig *config );
60
/// Tells the number of the mixing devices
61
unsigned int size() const;
64
/// Returns a pointer to the mix device with the given number
65
MixDevice* operator[](int val_i_num);
67
/// Returns a pointer to the mix device whose type matches the value
68
/// given by the parameter and the array MixerDevNames given in
69
/// mixer_oss.cpp (0 is Volume, 4 is PCM, etc.)
70
MixDevice *getMixdeviceById( const QString& deviceID );
72
/// Open/grab the mixer for further intraction
75
/// Returns whether the card is open/operational
78
/// Close/release the mixer
81
/// Returns a detailed state message after errors. Only for diagnostic purposes, no i18n.
82
QString& stateMessage() const;
84
/// Returns the name of the card/chip/hardware, as given by the driver. The name is NOT instance specific,
85
/// so if you install two identical soundcards, two of them will deliver the same mixerName().
86
/// Use this method if you need an instance-UNspecific name, e.g. for finding an appropriate
87
/// mixer layout for this card, or as a prefix for constructing instance specific ID's like in id().
88
virtual QString baseName();
90
/// Wrapper to Mixer_Backend
91
QString translateKernelToWhatsthis(const QString &kernelName);
93
/// Return the name of the card/chip/hardware, which is suitable for humans
94
virtual QString readableName();
96
// Returns the name of the driver, e.g. "OSS" or "ALSA0.9"
97
static QString driverName(int num);
99
/// Returns an unique ID of the Mixer. It currently looks like "<soundcard_descr>:<hw_number>@<driver>"
102
/// Returns an Universal Device Identifaction of the Mixer. This is an ID that relates to the underlying operating system.
103
// For OSS and ALSA this is taken from Solid (actually HAL). For Solaris this is just the device name.
105
// ALSA: /org/freedesktop/Hal/devices/usb_device_d8c_1_noserial_if0_sound_card_0_2_alsa_control__1
106
// OSS: /org/freedesktop/Hal/devices/usb_device_d8c_1_noserial_if0_sound_card_0_2_oss_mixer__1
107
// Solaris: /dev/audio
110
/// The owner/creator of the Mixer can set an unique name here. This key should never displayed to
111
/// the user, but can be used for referencing configuration items and such.
112
void setID(QString& ref_id);
114
/******************************************
115
The KMix GLOBAL master card. Please note that KMix and KMixPanelApplet can have a
116
different MasterCard's at the moment (but actually KMixPanelApplet does not read/save this yet).
117
At the moment it is only used for selecting the Mixer to use in KMix's DockIcon.
118
******************************************/
119
static void setGlobalMaster(QString& ref_card, QString& ref_control);
120
static MixDevice* getGlobalMasterMD();
121
static MixDevice* getGlobalMasterMD(bool fallbackAllowed);
122
static Mixer* getGlobalMasterMixer();
123
static Mixer* getGlobalMasterMixerNoFalback();
125
/******************************************
126
The recommended master of this Mixer.
127
******************************************/
128
MixDevice* getLocalMasterMD();
129
void setLocalMasterMD(QString&);
131
/// get the actual MixSet
135
/// DCOP oriented methods (look at mixerIface.h for the descriptions)
136
virtual void setVolume( const QString& mixdeviceID, int percentage );
137
virtual void setAbsoluteVolume( const QString& mixdeviceID, long absoluteVolume );
138
virtual void setMasterVolume( int percentage );
140
virtual void increaseVolume( const QString& mixdeviceID );
141
virtual void decreaseVolume( const QString& mixdeviceID );
143
virtual long absoluteVolume( const QString& mixdeviceID );
144
virtual long absoluteVolumeMin( const QString& mixdeviceID );
145
virtual long absoluteVolumeMax( const QString& mixdeviceID );
146
virtual int volume( const QString& mixdeviceID );
147
virtual int masterVolume();
149
virtual QString masterDeviceIndex();
151
virtual void setMute( const QString& mixdeviceID, bool on );
152
virtual bool mute( const QString& mixdeviceID );
153
virtual void toggleMute( const QString& mixdeviceID );
154
virtual bool isRecordSource( const QString& mixdeviceID );
156
virtual bool isAvailableDevice( const QString& mixdeviceID );
158
void commitVolumeChange( MixDevice* md );
161
void readSetFromHWforceUpdate() const;
162
virtual void setRecordSource( const QString& controlID, bool on );
164
virtual void setBalance(int balance); // sets the m_balance (see there)
167
void newBalance( Volume& );
168
void controlChanged(void);
171
int m_balance; // from -100 (just left) to 100 (just right)
172
static QList<Mixer *> s_mixers;
175
void controlChangedForwarder();
178
static QList<Mixer *>& mixers();
181
void setBalanceInternal(Volume& vol);
182
Mixer_Backend *_mixerBackend;
184
QString _masterDevicePK;
185
static QString _globalMasterCard;
186
static QString _globalMasterCardDevice;