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

« back to all changes in this revision

Viewing changes to kmix/mixer.h

  • 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
 
//-*-C++-*-
2
 
/*
3
 
 * KMix -- KDE's full featured mini mixer
4
 
 *
5
 
 *
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>
10
 
 *
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.
15
 
 *
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.
20
 
 *
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.
24
 
 */
25
 
 
26
 
#ifndef RANDOMPREFIX_MIXER_H
27
 
#define RANDOMPREFIX_MIXER_H
28
 
 
29
 
#include <QString>
30
 
#include <QObject>
31
 
#include <qlist.h>
32
 
 
33
 
#include "volume.h"
34
 
class Mixer_Backend;
35
 
#include "mixset.h"
36
 
#include "mixdevice.h"
37
 
 
38
 
class Volume;
39
 
class KConfig;
40
 
 
41
 
class Mixer : public QObject
42
 
{
43
 
      Q_OBJECT
44
 
 
45
 
   public:
46
 
      enum MixerError { ERR_PERM=1, ERR_WRITE, ERR_READ,
47
 
                        ERR_OPEN, ERR_LASTERR };
48
 
 
49
 
      Mixer( QString& ref_driverName, int device );
50
 
      virtual ~Mixer();
51
 
 
52
 
      static int numDrivers();
53
 
      QString getDriverName();
54
 
 
55
 
      MixDevice* find(const QString& devPK);
56
 
 
57
 
      void volumeSave( KConfig *config );
58
 
      void volumeLoad( KConfig *config );
59
 
 
60
 
       /// Tells the number of the mixing devices
61
 
      unsigned int size() const;
62
 
 
63
 
 
64
 
      /// Returns a pointer to the mix device with the given number
65
 
      MixDevice* operator[](int val_i_num);
66
 
 
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 );
71
 
 
72
 
      /// Open/grab the mixer for further intraction
73
 
      bool openIfValid();
74
 
 
75
 
      /// Returns whether the card is open/operational
76
 
      bool isOpen() const;
77
 
 
78
 
      /// Close/release the mixer
79
 
      virtual int close();
80
 
 
81
 
      /// Returns a detailed state message after errors. Only for diagnostic purposes, no i18n.
82
 
      QString& stateMessage() const;
83
 
 
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();
89
 
 
90
 
      /// Wrapper to Mixer_Backend
91
 
      QString translateKernelToWhatsthis(const QString &kernelName);
92
 
 
93
 
      /// Return the name of the card/chip/hardware, which is suitable for humans
94
 
      virtual QString readableName();
95
 
 
96
 
      // Returns the name of the driver, e.g. "OSS" or "ALSA0.9"
97
 
      static QString driverName(int num);
98
 
 
99
 
      /// Returns an unique ID of the Mixer. It currently looks like "<soundcard_descr>:<hw_number>@<driver>"
100
 
      QString& id();
101
 
      
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.
104
 
      // Examples:
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
108
 
      QString& udi();
109
 
      
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);
113
 
 
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();
124
 
 
125
 
      /******************************************
126
 
        The recommended master of this Mixer.
127
 
       ******************************************/
128
 
      MixDevice* getLocalMasterMD();
129
 
      void setLocalMasterMD(QString&);
130
 
 
131
 
      /// get the actual MixSet
132
 
      MixSet getMixSet();
133
 
 
134
 
 
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 );
139
 
 
140
 
      virtual void increaseVolume( const QString& mixdeviceID );
141
 
      virtual void decreaseVolume( const QString& mixdeviceID );
142
 
 
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();
148
 
 
149
 
      virtual QString masterDeviceIndex();
150
 
 
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 );
155
 
 
156
 
      virtual bool isAvailableDevice( const QString& mixdeviceID );
157
 
 
158
 
      void commitVolumeChange( MixDevice* md );
159
 
 
160
 
   public slots:
161
 
      void readSetFromHWforceUpdate() const;
162
 
      virtual void setRecordSource( const QString& controlID, bool on );
163
 
 
164
 
      virtual void setBalance(int balance); // sets the m_balance (see there)
165
 
 
166
 
   signals:
167
 
      void newBalance( Volume& );
168
 
      void controlChanged(void);
169
 
 
170
 
   protected:
171
 
      int m_balance; // from -100 (just left) to 100 (just right)
172
 
      static QList<Mixer *> s_mixers;
173
 
 
174
 
   private slots:
175
 
      void controlChangedForwarder();
176
 
 
177
 
   public:
178
 
      static QList<Mixer *>& mixers();
179
 
 
180
 
   private:
181
 
      void setBalanceInternal(Volume& vol);
182
 
      Mixer_Backend *_mixerBackend;
183
 
      QString _id;
184
 
      QString _masterDevicePK;
185
 
      static QString _globalMasterCard;
186
 
      static QString _globalMasterCardDevice;
187
 
      
188
 
      QString m_dbusName;
189
 
};
190
 
 
191
 
#endif