Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1211832
  • 博文数量: 261
  • 博客积分: 4196
  • 博客等级: 上校
  • 技术积分: 3410
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-17 17:05
文章分类

全部博文(261)

文章存档

2018年(1)

2017年(22)

2016年(2)

2015年(8)

2014年(27)

2013年(40)

2012年(161)

分类: C/C++

2012-12-05 13:10:31

头文件
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);
    }
}



阅读(1744) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~