00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef PLAYTHREAD_HH
00022 #define PLAYTHREAD_HH
00023
00026 #include <alsa/asoundlib.h>
00027
00028 #include <qevent.h>
00029 #include <qobject.h>
00030 #include <qthread.h>
00031
00032 #include "common.hh"
00033
00046 #define PCM_CHUNK_SIZE 4096
00047
00060 class PlayThread : public QThread, public QObject
00061 {
00062 public:
00075 enum ThreadEvents {
00085 Stop = 2000,
00086
00096 Finished
00097 };
00098
00129 void run();
00130
00151 void initThread(QWidget *obj, snd_pcm_t *handle,
00152 QMutex *mutex, double *playpos);
00153
00170 void loadData(char *ptr, size_t size, WaveFormat f);
00171
00172 protected:
00191 void customEvent(QCustomEvent *e);
00192
00193 private:
00194 QWidget *parent;
00195 snd_pcm_t *pcm_handle;
00196 QMutex *pos_lock;
00197 double *play_position;
00198 char *data;
00199 size_t datasize;
00200 WaveFormat format;
00201 bool stop_now;
00202 };
00203
00204 #endif // PLAYTHREAD_HH