Fix crash in audioinput and audiooutput examples.
Do not call tr while initializing static objects. Change-Id: Ia75ddd53ae22b0e4179f174da7d933156744e261 Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
4af40afe46
commit
1c81d25e4f
@@ -52,10 +52,10 @@
|
|||||||
|
|
||||||
#include "audioinput.h"
|
#include "audioinput.h"
|
||||||
|
|
||||||
const QString InputTest::PushModeLabel(tr("Enable push mode"));
|
#define PUSH_MODE_LABEL "Enable push mode"
|
||||||
const QString InputTest::PullModeLabel(tr("Enable pull mode"));
|
#define PULL_MODE_LABEL "Enable pull mode"
|
||||||
const QString InputTest::SuspendLabel(tr("Suspend recording"));
|
#define SUSPEND_LABEL "Suspend recording"
|
||||||
const QString InputTest::ResumeLabel(tr("Resume recording"));
|
#define RESUME_LABEL "Resume recording"
|
||||||
|
|
||||||
const int BufferSize = 4096;
|
const int BufferSize = 4096;
|
||||||
|
|
||||||
@@ -242,12 +242,12 @@ void InputTest::initializeWindow()
|
|||||||
layout->addWidget(m_volumeSlider);
|
layout->addWidget(m_volumeSlider);
|
||||||
|
|
||||||
m_modeButton = new QPushButton(this);
|
m_modeButton = new QPushButton(this);
|
||||||
m_modeButton->setText(PushModeLabel);
|
m_modeButton->setText(tr(PUSH_MODE_LABEL));
|
||||||
connect(m_modeButton, SIGNAL(clicked()), SLOT(toggleMode()));
|
connect(m_modeButton, SIGNAL(clicked()), SLOT(toggleMode()));
|
||||||
layout->addWidget(m_modeButton);
|
layout->addWidget(m_modeButton);
|
||||||
|
|
||||||
m_suspendResumeButton = new QPushButton(this);
|
m_suspendResumeButton = new QPushButton(this);
|
||||||
m_suspendResumeButton->setText(SuspendLabel);
|
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
||||||
connect(m_suspendResumeButton, SIGNAL(clicked()), SLOT(toggleSuspend()));
|
connect(m_suspendResumeButton, SIGNAL(clicked()), SLOT(toggleSuspend()));
|
||||||
layout->addWidget(m_suspendResumeButton);
|
layout->addWidget(m_suspendResumeButton);
|
||||||
|
|
||||||
@@ -318,17 +318,17 @@ void InputTest::toggleMode()
|
|||||||
m_audioInput->stop();
|
m_audioInput->stop();
|
||||||
|
|
||||||
if (m_pullMode) {
|
if (m_pullMode) {
|
||||||
m_modeButton->setText(PullModeLabel);
|
m_modeButton->setText(tr(PULL_MODE_LABEL));
|
||||||
m_input = m_audioInput->start();
|
m_input = m_audioInput->start();
|
||||||
connect(m_input, SIGNAL(readyRead()), SLOT(readMore()));
|
connect(m_input, SIGNAL(readyRead()), SLOT(readMore()));
|
||||||
m_pullMode = false;
|
m_pullMode = false;
|
||||||
} else {
|
} else {
|
||||||
m_modeButton->setText(PushModeLabel);
|
m_modeButton->setText(tr(PUSH_MODE_LABEL));
|
||||||
m_pullMode = true;
|
m_pullMode = true;
|
||||||
m_audioInput->start(m_audioInfo);
|
m_audioInput->start(m_audioInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_suspendResumeButton->setText(SuspendLabel);
|
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputTest::toggleSuspend()
|
void InputTest::toggleSuspend()
|
||||||
@@ -337,15 +337,15 @@ void InputTest::toggleSuspend()
|
|||||||
if(m_audioInput->state() == QAudio::SuspendedState) {
|
if(m_audioInput->state() == QAudio::SuspendedState) {
|
||||||
qWarning() << "status: Suspended, resume()";
|
qWarning() << "status: Suspended, resume()";
|
||||||
m_audioInput->resume();
|
m_audioInput->resume();
|
||||||
m_suspendResumeButton->setText(SuspendLabel);
|
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
||||||
} else if (m_audioInput->state() == QAudio::ActiveState) {
|
} else if (m_audioInput->state() == QAudio::ActiveState) {
|
||||||
qWarning() << "status: Active, suspend()";
|
qWarning() << "status: Active, suspend()";
|
||||||
m_audioInput->suspend();
|
m_audioInput->suspend();
|
||||||
m_suspendResumeButton->setText(ResumeLabel);
|
m_suspendResumeButton->setText(tr(RESUME_LABEL));
|
||||||
} else if (m_audioInput->state() == QAudio::StoppedState) {
|
} else if (m_audioInput->state() == QAudio::StoppedState) {
|
||||||
qWarning() << "status: Stopped, resume()";
|
qWarning() << "status: Stopped, resume()";
|
||||||
m_audioInput->resume();
|
m_audioInput->resume();
|
||||||
m_suspendResumeButton->setText(SuspendLabel);
|
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
||||||
} else if (m_audioInput->state() == QAudio::IdleState) {
|
} else if (m_audioInput->state() == QAudio::IdleState) {
|
||||||
qWarning() << "status: IdleState";
|
qWarning() << "status: IdleState";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,11 +131,6 @@ private:
|
|||||||
QIODevice *m_input;
|
QIODevice *m_input;
|
||||||
bool m_pullMode;
|
bool m_pullMode;
|
||||||
QByteArray m_buffer;
|
QByteArray m_buffer;
|
||||||
|
|
||||||
static const QString PushModeLabel;
|
|
||||||
static const QString PullModeLabel;
|
|
||||||
static const QString SuspendLabel;
|
|
||||||
static const QString ResumeLabel;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -47,11 +47,11 @@
|
|||||||
#include <QtCore/qendian.h>
|
#include <QtCore/qendian.h>
|
||||||
#include "audiooutput.h"
|
#include "audiooutput.h"
|
||||||
|
|
||||||
const QString AudioTest::PushModeLabel(tr("Enable push mode"));
|
#define PUSH_MODE_LABEL "Enable push mode"
|
||||||
const QString AudioTest::PullModeLabel(tr("Enable pull mode"));
|
#define PULL_MODE_LABEL "Enable pull mode"
|
||||||
const QString AudioTest::SuspendLabel(tr("Suspend playback"));
|
#define SUSPEND_LABEL "Suspend playback"
|
||||||
const QString AudioTest::ResumeLabel(tr("Resume playback"));
|
#define RESUME_LABEL "Resume playback"
|
||||||
const QString AudioTest::VolumeLabel(tr("Volume:"));
|
#define VOLUME_LABEL "Volume:"
|
||||||
|
|
||||||
const int DurationSeconds = 1;
|
const int DurationSeconds = 1;
|
||||||
const int ToneFrequencyHz = 600;
|
const int ToneFrequencyHz = 600;
|
||||||
@@ -182,18 +182,18 @@ void AudioTest::initializeWindow()
|
|||||||
layout->addWidget(m_deviceBox);
|
layout->addWidget(m_deviceBox);
|
||||||
|
|
||||||
m_modeButton = new QPushButton(this);
|
m_modeButton = new QPushButton(this);
|
||||||
m_modeButton->setText(PushModeLabel);
|
m_modeButton->setText(tr(PUSH_MODE_LABEL));
|
||||||
connect(m_modeButton, SIGNAL(clicked()), SLOT(toggleMode()));
|
connect(m_modeButton, SIGNAL(clicked()), SLOT(toggleMode()));
|
||||||
layout->addWidget(m_modeButton);
|
layout->addWidget(m_modeButton);
|
||||||
|
|
||||||
m_suspendResumeButton = new QPushButton(this);
|
m_suspendResumeButton = new QPushButton(this);
|
||||||
m_suspendResumeButton->setText(SuspendLabel);
|
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
||||||
connect(m_suspendResumeButton, SIGNAL(clicked()), SLOT(toggleSuspendResume()));
|
connect(m_suspendResumeButton, SIGNAL(clicked()), SLOT(toggleSuspendResume()));
|
||||||
layout->addWidget(m_suspendResumeButton);
|
layout->addWidget(m_suspendResumeButton);
|
||||||
|
|
||||||
QHBoxLayout *volumeBox = new QHBoxLayout;
|
QHBoxLayout *volumeBox = new QHBoxLayout;
|
||||||
m_volumeLabel = new QLabel;
|
m_volumeLabel = new QLabel;
|
||||||
m_volumeLabel->setText(VolumeLabel);
|
m_volumeLabel->setText(tr(VOLUME_LABEL));
|
||||||
m_volumeSlider = new QSlider(Qt::Horizontal);
|
m_volumeSlider = new QSlider(Qt::Horizontal);
|
||||||
m_volumeSlider->setMinimum(0);
|
m_volumeSlider->setMinimum(0);
|
||||||
m_volumeSlider->setMaximum(100);
|
m_volumeSlider->setMaximum(100);
|
||||||
@@ -296,17 +296,17 @@ void AudioTest::toggleMode()
|
|||||||
m_audioOutput->stop();
|
m_audioOutput->stop();
|
||||||
|
|
||||||
if (m_pullMode) {
|
if (m_pullMode) {
|
||||||
m_modeButton->setText(PullModeLabel);
|
m_modeButton->setText(tr(PULL_MODE_LABEL));
|
||||||
m_output = m_audioOutput->start();
|
m_output = m_audioOutput->start();
|
||||||
m_pullMode = false;
|
m_pullMode = false;
|
||||||
m_pullTimer->start(20);
|
m_pullTimer->start(20);
|
||||||
} else {
|
} else {
|
||||||
m_modeButton->setText(PushModeLabel);
|
m_modeButton->setText(tr(PUSH_MODE_LABEL));
|
||||||
m_pullMode = true;
|
m_pullMode = true;
|
||||||
m_audioOutput->start(m_generator);
|
m_audioOutput->start(m_generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_suspendResumeButton->setText(SuspendLabel);
|
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioTest::toggleSuspendResume()
|
void AudioTest::toggleSuspendResume()
|
||||||
@@ -314,15 +314,15 @@ void AudioTest::toggleSuspendResume()
|
|||||||
if (m_audioOutput->state() == QAudio::SuspendedState) {
|
if (m_audioOutput->state() == QAudio::SuspendedState) {
|
||||||
qWarning() << "status: Suspended, resume()";
|
qWarning() << "status: Suspended, resume()";
|
||||||
m_audioOutput->resume();
|
m_audioOutput->resume();
|
||||||
m_suspendResumeButton->setText(SuspendLabel);
|
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
||||||
} else if (m_audioOutput->state() == QAudio::ActiveState) {
|
} else if (m_audioOutput->state() == QAudio::ActiveState) {
|
||||||
qWarning() << "status: Active, suspend()";
|
qWarning() << "status: Active, suspend()";
|
||||||
m_audioOutput->suspend();
|
m_audioOutput->suspend();
|
||||||
m_suspendResumeButton->setText(ResumeLabel);
|
m_suspendResumeButton->setText(tr(RESUME_LABEL));
|
||||||
} else if (m_audioOutput->state() == QAudio::StoppedState) {
|
} else if (m_audioOutput->state() == QAudio::StoppedState) {
|
||||||
qWarning() << "status: Stopped, resume()";
|
qWarning() << "status: Stopped, resume()";
|
||||||
m_audioOutput->resume();
|
m_audioOutput->resume();
|
||||||
m_suspendResumeButton->setText(SuspendLabel);
|
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
||||||
} else if (m_audioOutput->state() == QAudio::IdleState) {
|
} else if (m_audioOutput->state() == QAudio::IdleState) {
|
||||||
qWarning() << "status: IdleState";
|
qWarning() << "status: IdleState";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,13 +107,6 @@ private:
|
|||||||
|
|
||||||
bool m_pullMode;
|
bool m_pullMode;
|
||||||
QByteArray m_buffer;
|
QByteArray m_buffer;
|
||||||
|
|
||||||
static const QString PushModeLabel;
|
|
||||||
static const QString PullModeLabel;
|
|
||||||
static const QString SuspendLabel;
|
|
||||||
static const QString ResumeLabel;
|
|
||||||
static const QString VolumeLabel;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void notified();
|
void notified();
|
||||||
void pullTimerExpired();
|
void pullTimerExpired();
|
||||||
|
|||||||
Reference in New Issue
Block a user