3
* KMix -- KDE's full featured mini mixer
5
* Copyright 2006-2007 Christian Esken <esken@kde.org>
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Library General Public
9
* License as published by the Free Software Foundation; either
10
* version 2 of the License, or (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Library General Public License for more details.
17
* You should have received a copy of the GNU Library General Public
18
* License along with this program; if not, write to the Free
19
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
#ifndef MIXER_BACKEND_H
23
#define MIXER_BACKEND_H
25
#include "core/mixer.h"
27
class Mixer_Backend : public QObject
33
// The Mixer Backend's may only be accessed from the Mixer class.
35
Mixer_Backend(Mixer *mixer, int devnum);
36
virtual ~Mixer_Backend();
38
/// Derived classes MUST implement this to open the mixer. Returns a KMix error code (O=OK).
39
virtual int open() = 0;
40
virtual int close() = 0;
43
* Returns the driver name, e.g. "ALSA" or "OSS". This virtual method is for looking up the
44
* driver name on instanciated objects.
46
* Please note, that there is also a static implementation of the driverName
47
* (Because there is no "virtual static" in C++, I need the method twice).
48
* The static implementation is for the Mixer Factory (who needs it *before* instanciating an object).
49
* While it is not a member function, its implementation can still be found in the corresponding
50
* Backend implementation. For example in mixer_oss.cpp there is a global function called OSS_getDriverName().
52
virtual QString getDriverName() = 0;
55
* Opens the mixer, if it constitures a valid Device. You should return "false", when
56
* the Mixer with the devnum given in the constructor is not supported by the Backend. The two
58
* (1) No such hardware installed
59
* (2) The hardware exists, but has no mixer support (e.g. external soundcard with only mechanical volume knobs)
60
* The implementation calls open(), checks the return code and whether the number of
61
* supported channels is > 0. The device remains opened if it is valid, otherwise a close() is done.
65
/** @return true, if the Mixer is open (and thus can be operated) */
68
virtual bool prepareUpdateFromHW();
69
void readSetFromHWforceUpdate() const;
72
virtual int readVolumeFromHW( const QString& id, MixDevice * ) = 0;
74
virtual int writeVolumeToHW( const QString& id, MixDevice * ) = 0;
77
virtual void setEnumIdHW(const QString& id, unsigned int);
78
virtual unsigned int enumIdHW(const QString& id);
80
/// Recording Switches
81
virtual void setRecsrcHW( const QString& id, bool on) = 0;
82
//virtual bool isRecsrcHW( const QString& id ) = 0;
84
virtual bool moveStream( const QString& id, const QString& destId );
86
/// Overwrite in the backend if the backend can see changes without polling
87
virtual bool needsPolling() { return true; }
89
MixDevice* recommendedMaster();
91
/** Return a translated error text for the given error number.
92
* Subclasses can override this method to produce platform
93
* specific error descriptions.
95
virtual QString errorText(int mixer_error);
96
/// Prints out a translated error text for the given error number on stderr
97
void errormsg(int mixer_error);
100
/// Returns translated WhatsThis messages for a control.Translates from
101
virtual QString translateKernelToWhatsthis(const QString &kernelName);
103
/// Translate ID to internal device number
104
virtual int id2num(const QString& id);
106
// Return an Universal Device Identification (suitable for the OS, especially for Hotplug and Unplug events)
107
virtual QString& udi() { return _udi; };
110
/// User friendly name of the Mixer (e.g. "IRIX Audio Mixer"). If your mixer API
111
/// gives you a usable name, use that name.
113
// All controls of this card
116
/******************************************************************************************
117
* Please don't access the next vars from the Mixer class (even though Mixer is a friend).
118
* There are proper accesor methods for them.
119
******************************************************************************************/
121
// The MixDevice that would qualify best as MasterDevice (according to the taste of the Backend developer)
122
MixDevice* m_recommendedMaster;
123
// The Mixer is stored her only for one reason: The backend creates the MixDevice's, and it has shown
124
// that it is helpful if the MixDevice's know their correspondig Mixer. KMix lived 10 years without that,
125
// but just believe me. It's *really* better, for example, you can put controls of different soundcards in
126
// one View. That is very cool! Also the MDW doesn't need to store the Mixer any longer (MDW is a GUI element,
127
// so that was 'wrong' anyhow
129
QTimer* _pollingTimer;
130
QString _udi; // Universal Device Identification
132
mutable bool _readSetFromHWforceUpdate;
135
void controlChanged( void );
136
void controlsReconfigured( const QString& mixer_ID );
139
virtual void reinit() {};
142
virtual void readSetFromHW();