diff options
author | Gareth Stockwell <ext-gareth.stockwell@nokia.com> | 2010-02-16 13:24:14 (GMT) |
---|---|---|
committer | Gareth Stockwell <ext-gareth.stockwell@nokia.com> | 2010-02-16 17:57:42 (GMT) |
commit | 658a559c918bd16b4e3f5af3e25242086a781220 (patch) | |
tree | 6560be4029ed3ff622ba4bf35f7bf8edb44b5342 /examples | |
parent | 84f129eb53532c85f4803e97837e61cea20469d1 (diff) | |
download | Qt-658a559c918bd16b4e3f5af3e25242086a781220.zip Qt-658a559c918bd16b4e3f5af3e25242086a781220.tar.gz Qt-658a559c918bd16b4e3f5af3e25242086a781220.tar.bz2 |
Removed redundant strings from audio output example
Reviewed-by: trustme
Diffstat (limited to 'examples')
-rw-r--r-- | examples/multimedia/audiooutput/audiooutput.cpp | 32 | ||||
-rw-r--r-- | examples/multimedia/audiooutput/audiooutput.h | 5 |
2 files changed, 24 insertions, 13 deletions
diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp index 5e90b41..f60d7b6 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -48,11 +48,17 @@ #include <QtCore/qendian.h> #include "audiooutput.h" -#define SECONDS 1 -#define FREQ 600 -#define SYSTEM_FREQ 44100 +const QString AudioTest::PushModeLabel(tr("Enable push mode")); +const QString AudioTest::PullModeLabel(tr("Enable pull mode")); +const QString AudioTest::SuspendLabel(tr("Suspend playback")); +const QString AudioTest::ResumeLabel(tr("Resume playback")); + +const int DurationSeconds = 1; +const int ToneFrequencyHz = 600; +const int DataFrequencyHz = 44100; const int BufferSize = 32768; + Generator::Generator(const QAudioFormat &format, qint64 durationUs, int frequency, @@ -175,12 +181,12 @@ void AudioTest::initializeWindow() layout->addWidget(m_deviceBox); m_modeButton = new QPushButton(this); - m_modeButton->setText(tr("Click for Push Mode")); + m_modeButton->setText(PushModeLabel); connect(m_modeButton,SIGNAL(clicked()),SLOT(toggle())); layout->addWidget(m_modeButton); m_suspendResumeButton = new QPushButton(this); - m_suspendResumeButton->setText(tr("Click To Suspend")); + m_suspendResumeButton->setText(SuspendLabel); connect(m_suspendResumeButton,SIGNAL(clicked()),SLOT(togglePlay())); layout->addWidget(m_suspendResumeButton); @@ -198,7 +204,7 @@ void AudioTest::initializeAudio() m_pullMode = true; - m_format.setFrequency(SYSTEM_FREQ); + m_format.setFrequency(DataFrequencyHz); m_format.setChannels(1); m_format.setSampleSize(16); m_format.setCodec("audio/pcm"); @@ -211,7 +217,7 @@ void AudioTest::initializeAudio() m_format = info.nearestFormat(m_format); } - m_generator = new Generator(m_format, SECONDS*1000000, FREQ, this); + m_generator = new Generator(m_format, DurationSeconds*1000000, ToneFrequencyHz, this); createAudioOutput(); } @@ -277,17 +283,17 @@ void AudioTest::toggle() m_audioOutput->stop(); if (m_pullMode) { - m_modeButton->setText("Click for Pull Mode"); + m_modeButton->setText(PullModeLabel); m_output = m_audioOutput->start(); m_pullMode = false; m_timer->start(20); } else { - m_modeButton->setText("Click for Push Mode"); + m_modeButton->setText(PushModeLabel); m_pullMode = true; m_audioOutput->start(m_generator); } - m_suspendResumeButton->setText("Click To Suspend"); + m_suspendResumeButton->setText(SuspendLabel); } void AudioTest::togglePlay() @@ -296,15 +302,15 @@ void AudioTest::togglePlay() if (m_audioOutput->state() == QAudio::SuspendedState) { qWarning() << "status: Suspended, resume()"; m_audioOutput->resume(); - m_suspendResumeButton->setText("Click To Suspend"); + m_suspendResumeButton->setText(SuspendLabel); } else if (m_audioOutput->state() == QAudio::ActiveState) { qWarning() << "status: Active, suspend()"; m_audioOutput->suspend(); - m_suspendResumeButton->setText("Click To Resume"); + m_suspendResumeButton->setText(ResumeLabel); } else if (m_audioOutput->state() == QAudio::StoppedState) { qWarning() << "status: Stopped, resume()"; m_audioOutput->resume(); - m_suspendResumeButton->setText("Click To Suspend"); + m_suspendResumeButton->setText(SuspendLabel); } else if (m_audioOutput->state() == QAudio::IdleState) { qWarning() << "status: IdleState"; } diff --git a/examples/multimedia/audiooutput/audiooutput.h b/examples/multimedia/audiooutput/audiooutput.h index 5bf8091..ea47e8b 100644 --- a/examples/multimedia/audiooutput/audiooutput.h +++ b/examples/multimedia/audiooutput/audiooutput.h @@ -102,6 +102,11 @@ private: bool m_pullMode; QByteArray m_buffer; + static const QString PushModeLabel; + static const QString PullModeLabel; + static const QString SuspendLabel; + static const QString ResumeLabel; + private slots: void status(); void writeMore(); |