1 /* This file is part of the KDE project
2 Copyright (C) 2006 Matthias Kretz <kretz@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
20 #ifndef PHONON_AUDIODEVICE_H
21 #define PHONON_AUDIODEVICE_H
23 #include "kaudiodevicelist_export.h"
24 #include <solid/audiointerface.h>
25 #include <ksharedconfig.h>
26 #include <QtCore/QDebug>
27 #include <QtCore/QSharedData>
28 #include <QtCore/QStringList>
39 class AudioDevicePrivate
;
41 /** \class AudioDevice audiodevice.h Phonon/AudioDevice
42 * \brief Information about a soundcard of the computer.
44 * This class encapsulates some useful information about a soundcard of the computer. Don't
45 * instanciate this class in your code, use AudioDeviceEnumerator::availableDevices().
47 * \see AudioDeviceEnumerator
49 * \author Matthias Kretz <kretz@kde.org>
51 class KAUDIODEVICELIST_EXPORT AudioDevice
53 friend class AudioDevicePrivate
;
54 friend class AudioDeviceEnumerator
;
55 friend class AudioDeviceEnumeratorPrivate
;
58 //static QStringList addSoftVolumeMixerControl(const AudioDevice &device, const QStringList &mixerControlNames);
62 * Creates an invalid and empty instance.
66 * Copy constructor. The data is implicitly shared, so copying is cheap.
68 AudioDevice(const AudioDevice
&rhs
);
70 * Destroys the object.
75 * Assignment operator. The data is implicitly shared, so copying is cheap.
77 AudioDevice
&operator=(const AudioDevice
&rhs
);
81 bool operator==(const AudioDevice
&rhs
) const;
83 * Inequality operator.
85 bool operator!=(const AudioDevice
&rhs
) const { return !operator==(rhs
); }
88 * Returns the name of the soundcard. This string
89 * should be shown to the user to select from multiple soundcards.
91 QString
cardName() const;
94 * Returns a list of device identifiers that your code can use in a snd_pcm_open call.
95 * If the code wants to open the soundcard identified by this object it should try all
96 * the device strings from start to end (they are sorted for preference).
98 QStringList
deviceIds() const;
101 * Returns an icon name used to identify the type of soundcard. Simply use
103 * KIcon icon(audioDevice.iconName());
107 QString
iconName() const;
110 * Retrieves the audio driver that should be used to access the device.
112 * @return the driver needed to access the device
113 * @see Solid::AudioInterface::AudioDriver
115 Solid::AudioInterface::AudioDriver
driver() const;
118 * Unique index to identify the device.
123 * Returns the initial preference for this device.
125 * The higher the number the more preferred the device is.
127 int initialPreference() const;
130 * Returns whether the device is available.
132 * An external device can be unavailable when it's unplugged. Every device can be
133 * unavailable when its driver is not loaded.
135 bool isAvailable() const;
138 * Removes an unavailable device from the persistent store.
140 * \return \c true if the device was removed
141 * \return \c false if the device could not be removed
146 * Devices that ceased to exist are invalid.
148 bool isValid() const;
151 * Returns whether the device is a capture device.
153 bool isCaptureDevice() const;
156 * Returns whether the device is a playback device.
158 bool isPlaybackDevice() const;
161 * Returns whether the device is a non-standard device mostly only interesting for
164 bool isAdvancedDevice() const;
167 AudioDevice(Solid::Device audioHw
, KSharedConfig::Ptr config
);
168 AudioDevice(KConfigGroup
&deviceGroup
);
169 AudioDevice(const QString
&alsaDeviceName
, const QString
&description
, KSharedConfig::Ptr config
);
171 QExplicitlySharedDataPointer
<AudioDevicePrivate
> d
;
173 } // namespace Phonon
175 inline QDebug
operator<<(QDebug
&s
, const Phonon::AudioDevice
&dev
)
177 s
.space() << "\n-" << dev
.cardName() << dev
.driver() << dev
.deviceIds() << "index:" << dev
.index() << "preference:" << dev
.initialPreference() << "avail:" << dev
.isAvailable() << "advanced:" << dev
.isAdvancedDevice();
181 #endif // PHONON_AUDIODEVICE_H