0
|
1 |
/* This file is part of the KDE project.
|
|
2 |
|
|
3 |
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
|
|
5 |
This library is free software: you can redistribute it and/or modify
|
|
6 |
it under the terms of the GNU Lesser General Public License as published by
|
|
7 |
the Free Software Foundation, either version 2.1 or 3 of the License.
|
|
8 |
|
|
9 |
This library is distributed in the hope that it will be useful,
|
|
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
GNU Lesser General Public License for more details.
|
|
13 |
|
|
14 |
You should have received a copy of the GNU Lesser General Public License
|
|
15 |
along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
16 |
|
|
17 |
*/
|
|
18 |
|
|
19 |
#include <e32debug.h>
|
|
20 |
|
|
21 |
#include <QCoreApplication>
|
|
22 |
|
|
23 |
#include "audiooutput.h"
|
|
24 |
#include "defs.h"
|
|
25 |
#include "mediaobject.h"
|
|
26 |
#include "utils.h"
|
|
27 |
#include "volumeobserver.h"
|
|
28 |
|
|
29 |
QT_BEGIN_NAMESPACE
|
|
30 |
|
|
31 |
using namespace Phonon;
|
|
32 |
using namespace Phonon::MMF;
|
|
33 |
|
|
34 |
/*! \class MMF::AudioOutput
|
|
35 |
\internal
|
|
36 |
*/
|
|
37 |
|
|
38 |
//-----------------------------------------------------------------------------
|
|
39 |
// Constructor / destructor
|
|
40 |
//-----------------------------------------------------------------------------
|
|
41 |
|
|
42 |
MMF::AudioOutput::AudioOutput(Backend *, QObject *parent) : MediaNode(parent)
|
|
43 |
, m_volume(InitialVolume)
|
|
44 |
, m_observer(0)
|
|
45 |
{
|
|
46 |
|
|
47 |
}
|
|
48 |
|
|
49 |
|
|
50 |
//-----------------------------------------------------------------------------
|
|
51 |
// Public API
|
|
52 |
//-----------------------------------------------------------------------------
|
|
53 |
|
|
54 |
qreal MMF::AudioOutput::volume() const
|
|
55 |
{
|
|
56 |
return m_volume;
|
|
57 |
}
|
|
58 |
|
|
59 |
void MMF::AudioOutput::setVolume(qreal volume)
|
|
60 |
{
|
|
61 |
TRACE_CONTEXT(AudioOutput::setVolume, EAudioApi);
|
|
62 |
TRACE_ENTRY("observer 0x%08x volume %f", m_observer, volume);
|
|
63 |
|
|
64 |
if (volume != m_volume) {
|
|
65 |
if (m_observer) {
|
|
66 |
m_observer->volumeChanged(volume);
|
|
67 |
}
|
|
68 |
|
|
69 |
m_volume = volume;
|
|
70 |
TRACE("emit volumeChanged(%f)", volume)
|
|
71 |
emit volumeChanged(volume);
|
|
72 |
}
|
|
73 |
|
|
74 |
TRACE_EXIT_0();
|
|
75 |
}
|
|
76 |
|
|
77 |
int MMF::AudioOutput::outputDevice() const
|
|
78 |
{
|
|
79 |
return AudioOutputDeviceID;
|
|
80 |
}
|
|
81 |
|
|
82 |
bool MMF::AudioOutput::setOutputDevice(int index)
|
|
83 |
{
|
|
84 |
Q_ASSERT_X(index == AudioOutputDeviceID, Q_FUNC_INFO,
|
|
85 |
"We only support one output device, with id 0");
|
|
86 |
return true;
|
|
87 |
}
|
|
88 |
|
|
89 |
void MMF::AudioOutput::setVolumeObserver(VolumeObserver* observer)
|
|
90 |
{
|
|
91 |
m_observer = observer;
|
|
92 |
if (m_observer) {
|
|
93 |
m_observer->volumeChanged(m_volume);
|
|
94 |
}
|
|
95 |
}
|
|
96 |
|
|
97 |
bool MMF::AudioOutput::activateOnMediaObject(MediaObject *mo)
|
|
98 |
{
|
|
99 |
setVolumeObserver(mo);
|
|
100 |
return true;
|
|
101 |
}
|
|
102 |
|
|
103 |
QHash<QByteArray, QVariant> MMF::AudioOutput::audioOutputDescription(int index)
|
|
104 |
{
|
|
105 |
QHash<QByteArray, QVariant> retval;
|
|
106 |
|
|
107 |
if (index == AudioOutputDeviceID) {
|
|
108 |
retval.insert("name", QCoreApplication::translate("Phonon::MMF", "Audio Output"));
|
|
109 |
retval.insert("description", QCoreApplication::translate("Phonon::MMF", "The audio output device"));
|
|
110 |
retval.insert("available", true);
|
|
111 |
}
|
|
112 |
|
|
113 |
return retval;
|
|
114 |
}
|
|
115 |
|
|
116 |
QT_END_NAMESPACE
|