Added volume property to QMediaRecorder

Change-Id: I19f727107651c9f640ca1c010a3764f05aef8820
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
Dmytro Poplavskiy
2012-05-21 12:09:50 +10:00
committed by Qt by Nokia
parent 0d0e89b1e8
commit 36ff2fe85e
14 changed files with 147 additions and 4 deletions

View File

@@ -76,6 +76,7 @@ private slots:
void testSink();
void testRecord();
void testMute();
void testVolume();
void testAudioDeviceControl();
void testAudioEncodeControl();
void testMediaFormatsControl();
@@ -373,6 +374,26 @@ void tst_QMediaRecorder::testMute()
QCOMPARE(mutedChanged.size(), 2);
}
void tst_QMediaRecorder::testVolume()
{
QSignalSpy volumeChanged(capture, SIGNAL(volumeChanged(qreal)));
QCOMPARE(capture->volume(), 1.0);
capture->setVolume(2.0);
QCOMPARE(volumeChanged.size(), 1);
QCOMPARE(volumeChanged[0][0].toReal(), 2.0);
QCOMPARE(capture->volume(), 2.0);
capture->setVolume(1.0);
QCOMPARE(volumeChanged.size(), 2);
QCOMPARE(volumeChanged[1][0].toReal(), 1.0);
QCOMPARE(capture->volume(), 1.0);
capture->setVolume(1.0);
QCOMPARE(volumeChanged.size(), 2);
}
void tst_QMediaRecorder::testAudioDeviceControl()
{
QSignalSpy readSignal(audio,SIGNAL(activeEndpointChanged(QString)));

View File

@@ -57,6 +57,7 @@ public:
m_status(QMediaRecorder::LoadedStatus),
m_position(0),
m_muted(false),
m_volume(1.0),
m_settingAppliedCount(0)
{
}
@@ -92,6 +93,11 @@ public:
return m_muted;
}
qreal volume() const
{
return m_volume;
}
void applySettings()
{
m_settingAppliedCount++;
@@ -152,12 +158,19 @@ public slots:
emit mutedChanged(m_muted = muted);
}
void setVolume(qreal volume)
{
if (!qFuzzyCompare(m_volume, volume))
emit volumeChanged(m_volume = volume);
}
public:
QUrl m_sink;
QMediaRecorder::State m_state;
QMediaRecorder::Status m_status;
qint64 m_position;
bool m_muted;
qreal m_volume;
int m_settingAppliedCount;
};