From e2de64d6f1beb9e492daf5b886e19933c1fa41dd Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kmix/mixer.h | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 kmix/mixer.h (limited to 'kmix/mixer.h') diff --git a/kmix/mixer.h b/kmix/mixer.h new file mode 100644 index 00000000..b6d0917a --- /dev/null +++ b/kmix/mixer.h @@ -0,0 +1,174 @@ +//-*-C++-*- +/* + * KMix -- KDE's full featured mini mixer + * + * + * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de> + * 1996-2000 Christian Esken + * Sven Fischer + * 2002 - Helio Chissini de Castro + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef MIXER_H +#define MIXER_H + +#include +#include +#include +#include +#include + +#include "volume.h" +class Mixer_Backend; +#include "mixerIface.h" +#include "mixset.h" +#include "mixdevice.h" + +class Volume; +class KConfig; + +class Mixer : public QObject, virtual public MixerIface +{ + Q_OBJECT + + public: + enum MixerError { ERR_PERM=1, ERR_WRITE, ERR_READ, ERR_NODEV, ERR_NOTSUPP, + ERR_OPEN, ERR_LASTERR, ERR_NOMEM, ERR_INCOMPATIBLESET, ERR_MIXEROPEN }; + + Mixer( int driver, int device ); + virtual ~Mixer(); + + static int numDrivers(); + + MixDevice* find(QString& devPK); + + void volumeSave( KConfig *config ); + void volumeLoad( KConfig *config ); + + /// Tells the number of the mixing devices + unsigned int size() const; + + bool isValid(); + bool isOpen() const; + + /// Returns a pointer to the mix device with the given number + MixDevice* operator[](int val_i_num); + + /// Returns a pointer to the mix device whose type matches the value + /// given by the parameter and the array MixerDevNames given in + /// mixer_oss.cpp (0 is Volume, 4 is PCM, etc.) + MixDevice *mixDeviceByType( int deviceidx ); + + /// Open/grab the mixer for further intraction + virtual int open(); + /// Close/release the mixer + virtual int close(); + + /// Returns a detailed state message after errors. Only for diagnostic purposes, no i18n. + QString& stateMessage() const; + + virtual QString mixerName(); + + // Returns the name of the driver, e.g. "OSS" or "ALSA0.9" + static QString driverName(int num); + + /// Returns an unique ID of the Mixer. It currently looks like ":@" + QString& id(); + /// The owner/creator of the Mixer can set an unique name here. This key should never displayed to + /// the user, but can be used for referencing configuration items and such. + void setID(QString& ref_id); + + /// The KMix global master card. Please note that KMix and KMixPanelApplet can have a + /// different MasterCard's at the moment (but actually KMixPanelApplet does not read/save this yet). + /// At the moment it is only used for selecting the Mixer to use in KMix's DockIcon. + static void setMasterCard(QString& ref_id); + static Mixer* masterCard(); + /// The global Master Device inside the current MasterCard (as returned by masterCard()). + static void setMasterCardDevice(QString& ref_id); + static MixDevice* masterCardDevice(); + + + /// get the actual MixSet + MixSet getMixSet(); + + /// Returns the master volume device (doesn't work out :-(. See masterCard() and masterCardDevice() instead) + MixDevice* masterDevice(); + /// Sets the master volume device (doesn't work out :-(. See setMasterCard() and setMasterCardDevice() instead) + void setMasterDevice(QString&); + + /// DCOP oriented methods (look at mixerIface.h for the descriptions) + virtual void setVolume( int deviceidx, int percentage ); + virtual void setAbsoluteVolume( int deviceidx, long absoluteVolume ); + virtual void setMasterVolume( int percentage ); + + virtual void increaseVolume( int deviceidx ); + virtual void decreaseVolume( int deviceidx ); + + virtual long absoluteVolume( int deviceidx ); + virtual long absoluteVolumeMin( int deviceidx ); + virtual long absoluteVolumeMax( int deviceidx ); + virtual int volume( int deviceidx ); + virtual int masterVolume(); + virtual int masterDeviceIndex(); + + virtual void setMute( int deviceidx, bool on ); + virtual void setMasterMute( bool on ); + virtual bool mute( int deviceidx ); + virtual bool masterMute(); + virtual void toggleMute( int deviceidx ); + virtual void toggleMasterMute(); + virtual bool isRecordSource( int deviceidx ); + + virtual bool isAvailableDevice( int deviceidx ); + + void commitVolumeChange( MixDevice* md ); + + public slots: + virtual void readSetFromHW(); + void readSetFromHWforceUpdate() const; + virtual void setRecordSource( int deviceidx, bool on ); + + virtual void setBalance(int balance); // sets the m_balance (see there) + + signals: + void newBalance( Volume& ); + void newRecsrc( void ); + void newVolumeLevels(void); + + protected: + QTimer* _pollingTimer; + + int m_balance; // from -100 (just left) to 100 (just right) + + QPtrList m_profiles; + static QPtrList s_mixers; + + public: + int setupMixer( MixSet set ); + static QPtrList& mixers(); + + private: + Mixer_Backend *_mixerBackend; + mutable bool _readSetFromHWforceUpdate; + static int _dcopID; + QString _id; + QString _masterDevicePK; + static QString _masterCard; + static QString _masterCardDevice; +}; + +#endif -- cgit v1.2.1