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
33
#include "core/volume.h"
36
#include "core/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);
56
static Mixer* findMixer( const QString& mixer_id);
58
void volumeSave( KConfig *config );
59
void volumeLoad( KConfig *config );
61
/// Tells the number of the mixing devices
62
unsigned int size() const;
65
/// Returns a pointer to the mix device with the given number
66
MixDevice* operator[](int val_i_num);
68
/// Returns a pointer to the mix device whose type matches the value
69
/// given by the parameter and the array MixerDevNames given in
70
/// mixer_oss.cpp (0 is Volume, 4 is PCM, etc.)
71
MixDevice *getMixdeviceById( const QString& deviceID );
73
/// Open/grab the mixer for further intraction
76
/// Returns whether the card is open/operational
79
/// Close/release the mixer
82
/// Returns a detailed state message after errors. Only for diagnostic purposes, no i18n.
83
QString& stateMessage() const;
85
/// Returns the name of the card/chip/hardware, as given by the driver. The name is NOT instance specific,
86
/// so if you install two identical soundcards, two of them will deliver the same mixerName().
87
/// Use this method if you need an instance-UNspecific name, e.g. for finding an appropriate
88
/// mixer layout for this card, or as a prefix for constructing instance specific ID's like in id().
89
virtual QString getBaseName();
91
/// Wrapper to Mixer_Backend
92
QString translateKernelToWhatsthis(const QString &kernelName);
94
/// Return the name of the card/chip/hardware, which is suitable for humans
95
virtual QString readableName();
97
// Returns the name of the driver, e.g. "OSS" or "ALSA0.9"
98
static QString driverName(int num);
100
/// Returns an unique ID of the Mixer. It currently looks like "<soundcard_descr>::<hw_number>:<driver>"
102
/// The owner/creator of the Mixer can set an unique name here. This key should never displayed to
103
/// the user, but can be used for referencing configuration items and such.
105
void setCardInstance(int cardInstance);
106
int getCardInstance() const { return _cardInstance; }
108
//void setID(QString& ref_id);
111
/// Returns an Universal Device Identifaction of the Mixer. This is an ID that relates to the underlying operating system.
112
// For OSS and ALSA this is taken from Solid (actually HAL). For Solaris this is just the device name.
114
// ALSA: /org/freedesktop/Hal/devices/usb_device_d8c_1_noserial_if0_sound_card_0_2_alsa_control__1
115
// OSS: /org/freedesktop/Hal/devices/usb_device_d8c_1_noserial_if0_sound_card_0_2_oss_mixer__1
116
// Solaris: /dev/audio
119
static QList<Mixer*> & mixers();
121
/******************************************
122
The KMix GLOBAL master card. Please note that KMix and KMixPanelApplet can have a
123
different MasterCard's at the moment (but actually KMixPanelApplet does not read/save this yet).
124
At the moment it is only used for selecting the Mixer to use in KMix's DockIcon.
125
******************************************/
126
static void setGlobalMaster(QString& ref_card, QString& ref_control);
127
static MixDevice* getGlobalMasterMD();
128
static MixDevice* getGlobalMasterMD(bool fallbackAllowed);
129
static Mixer* getGlobalMasterMixer();
130
static Mixer* getGlobalMasterMixerNoFalback();
132
/******************************************
133
The recommended master of this Mixer.
134
******************************************/
135
MixDevice* getLocalMasterMD();
136
void setLocalMasterMD(QString&);
138
/// get the actual MixSet
142
/// DCOP oriented methods (look at mixerIface.h for the descriptions)
143
virtual void setVolume( const QString& mixdeviceID, int percentage );
144
virtual void setAbsoluteVolume( const QString& mixdeviceID, long absoluteVolume );
145
virtual void setMasterVolume( int percentage );
147
virtual void increaseVolume( const QString& mixdeviceID );
148
virtual void decreaseVolume( const QString& mixdeviceID );
150
virtual long absoluteVolume( const QString& mixdeviceID );
151
virtual long absoluteVolumeMin( const QString& mixdeviceID );
152
virtual long absoluteVolumeMax( const QString& mixdeviceID );
153
virtual int volume( const QString& mixdeviceID );
154
virtual int masterVolume();
156
virtual QString masterDeviceIndex();
158
virtual void setMute( const QString& mixdeviceID, bool on );
159
virtual bool mute( const QString& mixdeviceID );
160
virtual void toggleMute( const QString& mixdeviceID );
161
virtual bool isRecordSource( const QString& mixdeviceID );
163
virtual bool isAvailableDevice( const QString& mixdeviceID );
165
/// Says if we are dynamic (e.g. widgets can come and go)
166
virtual void setDynamic( bool dynamic = true );
167
virtual bool dynamic();
169
virtual bool moveStream( const QString id, const QString& destId );
171
void commitVolumeChange( MixDevice* md );
174
void readSetFromHWforceUpdate() const;
175
virtual void setRecordSource(const QString & controlID, bool on);
176
virtual void setBalance(int balance); // sets the m_balance (see there)
179
void newBalance(Volume& );
180
void controlChanged(void);
181
void controlsReconfigured(const QString & mixer_ID);
184
int m_balance; // from -100 (just left) to 100 (just right)
185
static QList<Mixer*> s_mixers;
188
void controlChangedForwarder();
189
void controlsReconfiguredForwarder(const QString & mixer_ID);
192
void setBalanceInternal(Volume& vol);
196
Mixer_Backend *_mixerBackend;
198
QString _masterDevicePK;
200
static QString _globalMasterCard;
201
static QString _globalMasterCardDevice;