QAudioInput/Output documentation: Fix slot naming in snippets

Having a code snippet use a slot (stateChanged) with a name
identical to a signal in QAudioInput / QAudioOutput classes causes
problems (incorrect links) in class documentation that refer to
the snippet code.

This change renames the slots according to standard Qt convention.
Same change is applied to example applications as well.

Task-number: QTBUG-26688
Change-Id: I0c6181240237d0c642b73fe18f3ddb5137b7f207
Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@gmail.com>
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
This commit is contained in:
Topi Reinio
2013-01-14 12:11:09 +01:00
committed by The Qt Project
parent 101c78983a
commit 52ad3219f0
5 changed files with 18 additions and 18 deletions

View File

@@ -313,7 +313,7 @@ void InputTest::createAudioInput()
{ {
m_audioInput = new QAudioInput(m_device, m_format, this); m_audioInput = new QAudioInput(m_device, m_format, this);
connect(m_audioInput, SIGNAL(notify()), SLOT(notified())); connect(m_audioInput, SIGNAL(notify()), SLOT(notified()));
connect(m_audioInput, SIGNAL(stateChanged(QAudio::State)), SLOT(stateChanged(QAudio::State))); connect(m_audioInput, SIGNAL(stateChanged(QAudio::State)), SLOT(handleStateChanged(QAudio::State)));
m_volumeSlider->setValue(m_audioInput->volume() * 100); m_volumeSlider->setValue(m_audioInput->volume() * 100);
m_audioInfo->start(); m_audioInfo->start();
m_audioInput->start(m_audioInfo); m_audioInput->start(m_audioInfo);
@@ -377,7 +377,7 @@ void InputTest::toggleSuspend()
} }
} }
void InputTest::stateChanged(QAudio::State state) void InputTest::handleStateChanged(QAudio::State state)
{ {
qWarning() << "state = " << state; qWarning() << "state = " << state;
} }

View File

@@ -114,7 +114,7 @@ private slots:
void readMore(); void readMore();
void toggleMode(); void toggleMode();
void toggleSuspend(); void toggleSuspend();
void stateChanged(QAudio::State state); void handleStateChanged(QAudio::State state);
void deviceChanged(int index); void deviceChanged(int index);
void sliderChanged(int value); void sliderChanged(int value);

View File

@@ -241,7 +241,7 @@ void AudioTest::createAudioOutput()
m_audioOutput = 0; m_audioOutput = 0;
m_audioOutput = new QAudioOutput(m_device, m_format, this); m_audioOutput = new QAudioOutput(m_device, m_format, this);
connect(m_audioOutput, SIGNAL(notify()), SLOT(notified())); connect(m_audioOutput, SIGNAL(notify()), SLOT(notified()));
connect(m_audioOutput, SIGNAL(stateChanged(QAudio::State)), SLOT(stateChanged(QAudio::State))); connect(m_audioOutput, SIGNAL(stateChanged(QAudio::State)), SLOT(handleStateChanged(QAudio::State)));
m_generator->start(); m_generator->start();
m_audioOutput->start(m_generator); m_audioOutput->start(m_generator);
m_volumeSlider->setValue(int(m_audioOutput->volume()*100.0f)); m_volumeSlider->setValue(int(m_audioOutput->volume()*100.0f));
@@ -328,7 +328,7 @@ void AudioTest::toggleSuspendResume()
} }
} }
void AudioTest::stateChanged(QAudio::State state) void AudioTest::handleStateChanged(QAudio::State state)
{ {
qWarning() << "state = " << state; qWarning() << "state = " << state;
} }

View File

@@ -114,7 +114,7 @@ private slots:
void pullTimerExpired(); void pullTimerExpired();
void toggleMode(); void toggleMode();
void toggleSuspendResume(); void toggleSuspendResume();
void stateChanged(QAudio::State state); void handleStateChanged(QAudio::State state);
void deviceChanged(int index); void deviceChanged(int index);
void volumeChanged(int); void volumeChanged(int);
}; };

View File

@@ -58,12 +58,12 @@ public:
public Q_SLOTS: public Q_SLOTS:
void stopRecording(); void stopRecording();
void stateChanged(QAudio::State newState); void handleStateChanged(QAudio::State newState);
private: private:
//! [Audio input class members] //! [Audio input class members]
QFile destinationFile; // class member. QFile destinationFile; // Class member
QAudioInput* audio; // class member. QAudioInput* audio; // Class member
//! [Audio input class members] //! [Audio input class members]
}; };
@@ -75,7 +75,7 @@ void AudioInputExample::setup()
destinationFile.open( QIODevice::WriteOnly | QIODevice::Truncate ); destinationFile.open( QIODevice::WriteOnly | QIODevice::Truncate );
QAudioFormat format; QAudioFormat format;
// set up the format you want, eg. // Set up the desired format, for example:
format.setSampleRate(8000); format.setSampleRate(8000);
format.setChannelCount(1); format.setChannelCount(1);
format.setSampleSize(8); format.setSampleSize(8);
@@ -85,12 +85,12 @@ void AudioInputExample::setup()
QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice(); QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice();
if (!info.isFormatSupported(format)) { if (!info.isFormatSupported(format)) {
qWarning()<<"default format not supported try to use nearest"; qWarning() << "Default format not supported, trying to use the nearest.";
format = info.nearestFormat(format); format = info.nearestFormat(format);
} }
audio = new QAudioInput(format, this); audio = new QAudioInput(format, this);
connect(audio, SIGNAL(stateChanged(QAudio::State)), this, SLOT(stateChanged(QAudio::State))); connect(audio, SIGNAL(stateChanged(QAudio::State)), this, SLOT(handleStateChanged(QAudio::State)));
QTimer::singleShot(3000, this, SLOT(stopRecording())); QTimer::singleShot(3000, this, SLOT(stopRecording()));
audio->start(&destinationFile); audio->start(&destinationFile);
@@ -108,7 +108,7 @@ void AudioInputExample::stopRecording()
//! [Audio input stop recording] //! [Audio input stop recording]
//! [Audio input state changed] //! [Audio input state changed]
void AudioInputExample::stateChanged(QAudio::State newState) void AudioInputExample::handleStateChanged(QAudio::State newState)
{ {
switch (newState) { switch (newState) {
case QAudio::StoppedState: case QAudio::StoppedState:
@@ -137,7 +137,7 @@ public:
void setup(); void setup();
public Q_SLOTS: public Q_SLOTS:
void stateChanged(QAudio::State newState); void handleStateChanged(QAudio::State newState);
private: private:
//! [Audio output class members] //! [Audio output class members]
@@ -164,18 +164,18 @@ void AudioOutputExample::setup()
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
if (!info.isFormatSupported(format)) { if (!info.isFormatSupported(format)) {
qWarning() << "raw audio format not supported by backend, cannot play audio."; qWarning() << "Raw audio format not supported by backend, cannot play audio.";
return; return;
} }
audio = new QAudioOutput(format, this); audio = new QAudioOutput(format, this);
connect(audio, SIGNAL(stateChanged(QAudio::State)), this, SLOT(stateChanged(QAudio::State))); connect(audio, SIGNAL(stateChanged(QAudio::State)), this, SLOT(handleStateChanged(QAudio::State)));
audio->start(&sourceFile); audio->start(&sourceFile);
} }
//! [Audio output setup] //! [Audio output setup]
//! [Audio output state changed] //! [Audio output state changed]
void AudioOutputExample::stateChanged(QAudio::State newState) void AudioOutputExample::handleStateChanged(QAudio::State newState)
{ {
switch (newState) { switch (newState) {
case QAudio::IdleState: case QAudio::IdleState:
@@ -225,7 +225,7 @@ public:
void decode(); void decode();
public Q_SLOTS: public Q_SLOTS:
void stateChanged(QAudio::State newState); void handleStateChanged(QAudio::State newState);
void readBuffer(); void readBuffer();
}; };