头文件
mainwindow.h
+++++++++++++++++++++++++++++++++++++++++++++++
#include
#include
class Producer : public QThread
{
public:
Producer(const QString &prefix);
void stopThread(bool isStop);
protected:
void produceMessage(int x);
void run();
private:
QString m_prefix;
bool stopThreads;
};
+++++++++++++++++++++++++++++++++++++++++++++++++
mainwindow.cpp
+++++++++++++++++++++++++++++++++++++++++++++++++
#include
extern "C" {
#include "acr320_alsa_api.h"
char buf[]={"credit.wav"};
}
bool stopThreads = false;
Producer pa("A");
Producer::Producer(const QString &prefix) : QThread()
{
m_prefix = prefix;
stopThreads = false;
}
void Producer::stopThread(bool isStop) {
stopThreads = isStop;
}
void Producer::produceMessage(int x)
{
qDebug() << QString("Producing %1: %2").arg(m_prefix).arg(x);
if( acr320_play_sound(buf) != 0)
return;
}
void Producer::run() {
for(int i = 0; !stopThreads; i++) {
produceMessage(i);
sleep(1);
}
}
阅读(420) | 评论(0) | 转发(0) |