{
m_audioInput = new QAudioInput(m_device, m_format, this);
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_audioInfo->start();
m_audioInput->start(m_audioInfo);
}
}
-void InputTest::stateChanged(QAudio::State state)
+void InputTest::handleStateChanged(QAudio::State state)
{
qWarning() << "state = " << state;
}
m_audioOutput = 0;
m_audioOutput = new QAudioOutput(m_device, m_format, this);
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_audioOutput->start(m_generator);
m_volumeSlider->setValue(int(m_audioOutput->volume()*100.0f));
}
}
-void AudioTest::stateChanged(QAudio::State state)
+void AudioTest::handleStateChanged(QAudio::State state)
{
qWarning() << "state = " << state;
}
public Q_SLOTS:
void stopRecording();
- void stateChanged(QAudio::State newState);
+ void handleStateChanged(QAudio::State newState);
private:
//! [Audio input class members]
- QFile destinationFile; // class member.
- QAudioInput* audio; // class member.
+ QFile destinationFile; // Class member
+ QAudioInput* audio; // Class member
//! [Audio input class members]
};
destinationFile.open( QIODevice::WriteOnly | QIODevice::Truncate );
QAudioFormat format;
- // set up the format you want, eg.
+ // Set up the desired format, for example:
format.setSampleRate(8000);
format.setChannelCount(1);
format.setSampleSize(8);
QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice();
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);
}
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()));
audio->start(&destinationFile);
//! [Audio input stop recording]
//! [Audio input state changed]
-void AudioInputExample::stateChanged(QAudio::State newState)
+void AudioInputExample::handleStateChanged(QAudio::State newState)
{
switch (newState) {
case QAudio::StoppedState:
void setup();
public Q_SLOTS:
- void stateChanged(QAudio::State newState);
+ void handleStateChanged(QAudio::State newState);
private:
//! [Audio output class members]
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
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;
}
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 output setup]
//! [Audio output state changed]
-void AudioOutputExample::stateChanged(QAudio::State newState)
+void AudioOutputExample::handleStateChanged(QAudio::State newState)
{
switch (newState) {
case QAudio::IdleState:
void decode();
public Q_SLOTS:
- void stateChanged(QAudio::State newState);
+ void handleStateChanged(QAudio::State newState);
void readBuffer();
};