~ubuntu-branches/ubuntu/natty/kdemultimedia/natty-updates

« back to all changes in this revision

Viewing changes to .pc/kubuntu_03_kmix_pulseaudio_fixes.diff/kmix/core/mixer.h

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-04-19 16:01:21 UTC
  • Revision ID: james.westby@ubuntu.com-20110419160121-jw7ffrspt26u3kt2
Tags: 4:4.6.2-0ubuntu2
* Add kubuntu_03_kmix_pulseaudio_fixes.diff: Cherry-pick several PulseAudio
  related KMix fixes that will be part of KDE 4.6.3.
  - Fixes very high CPU usage. (LP: #720882)
  - Fixes memory leaks. (LP: #676780)

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 <QList>
 
30
#include <QObject>
 
31
#include <QString>
 
32
 
 
33
#include "core/volume.h"
 
34
class Mixer_Backend;
 
35
#include "mixset.h"
 
36
#include "core/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
    static Mixer* findMixer( const QString& mixer_id);
 
57
 
 
58
    void volumeSave( KConfig *config );
 
59
    void volumeLoad( KConfig *config );
 
60
 
 
61
    /// Tells the number of the mixing devices
 
62
    unsigned int size() const;
 
63
 
 
64
 
 
65
    /// Returns a pointer to the mix device with the given number
 
66
    MixDevice* operator[](int val_i_num);
 
67
 
 
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 );
 
72
 
 
73
    /// Open/grab the mixer for further intraction
 
74
    bool openIfValid();
 
75
 
 
76
    /// Returns whether the card is open/operational
 
77
    bool isOpen() const;
 
78
 
 
79
    /// Close/release the mixer
 
80
    virtual int close();
 
81
 
 
82
    /// Returns a detailed state message after errors. Only for diagnostic purposes, no i18n.
 
83
    QString& stateMessage() const;
 
84
 
 
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();
 
90
 
 
91
    /// Wrapper to Mixer_Backend
 
92
    QString translateKernelToWhatsthis(const QString &kernelName);
 
93
 
 
94
    /// Return the name of the card/chip/hardware, which is suitable for humans
 
95
    virtual QString readableName();
 
96
 
 
97
    // Returns the name of the driver, e.g. "OSS" or "ALSA0.9"
 
98
    static QString driverName(int num);
 
99
 
 
100
    /// Returns an unique ID of the Mixer. It currently looks like "<soundcard_descr>::<hw_number>:<driver>"
 
101
    QString& id();
 
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.
 
104
 
 
105
    void setCardInstance(int cardInstance);
 
106
    int getCardInstance() const      {          return _cardInstance;      }
 
107
 
 
108
    //void setID(QString& ref_id);
 
109
 
 
110
 
 
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.
 
113
    // Examples:
 
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
 
117
    QString& udi();
 
118
 
 
119
    static QList<Mixer*> & mixers();
 
120
 
 
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();
 
131
 
 
132
    /******************************************
 
133
    The recommended master of this Mixer.
 
134
    ******************************************/
 
135
    MixDevice* getLocalMasterMD();
 
136
    void setLocalMasterMD(QString&);
 
137
 
 
138
    /// get the actual MixSet
 
139
    MixSet getMixSet();
 
140
 
 
141
 
 
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 );
 
146
 
 
147
    virtual void increaseVolume( const QString& mixdeviceID );
 
148
    virtual void decreaseVolume( const QString& mixdeviceID );
 
149
 
 
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();
 
155
 
 
156
    virtual QString masterDeviceIndex();
 
157
 
 
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 );
 
162
 
 
163
    virtual bool isAvailableDevice( const QString& mixdeviceID );
 
164
 
 
165
    /// Says if we are dynamic (e.g. widgets can come and go)
 
166
    virtual void setDynamic( bool dynamic = true );
 
167
    virtual bool dynamic();
 
168
 
 
169
    virtual bool moveStream( const QString id, const QString& destId );
 
170
 
 
171
    void commitVolumeChange( MixDevice* md );
 
172
 
 
173
public slots:
 
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)
 
177
    
 
178
signals:
 
179
    void newBalance(Volume& );
 
180
    void controlChanged(void);
 
181
    void controlsReconfigured(const QString & mixer_ID);
 
182
 
 
183
protected:
 
184
    int m_balance; // from -100 (just left) to 100 (just right)
 
185
    static QList<Mixer*> s_mixers;
 
186
 
 
187
private slots:
 
188
    void controlChangedForwarder();
 
189
    void controlsReconfiguredForwarder(const QString & mixer_ID);
 
190
 
 
191
private:
 
192
    void setBalanceInternal(Volume& vol);
 
193
    void recreateId();
 
194
 
 
195
 
 
196
    Mixer_Backend *_mixerBackend;
 
197
    QString _id;
 
198
    QString _masterDevicePK;
 
199
    int    _cardInstance;
 
200
    static QString _globalMasterCard;
 
201
    static QString _globalMasterCardDevice;
 
202
 
 
203
    QString m_dbusName;
 
204
    bool m_dynamic;
 
205
};
 
206
 
 
207
#endif