2
* MixerWorkerThread.h - declaration of class MixerWorkerThread
4
* Copyright (c) 2009-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
6
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
8
* This program is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU General Public
10
* License as published by the Free Software Foundation; either
11
* version 2 of the License, or (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* General Public License for more details.
18
* You should have received a copy of the GNU General Public
19
* License along with this program (see COPYING); if not, write to the
20
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21
* Boston, MA 02110-1301 USA.
25
#ifndef _MIXER_WORKER_THREAD_H
26
#define _MIXER_WORKER_THREAD_H
28
#include <QtCore/QAtomicPointer>
29
#include <QtCore/QThread>
31
#include "ThreadableJob.h"
35
class MixerWorkerThread : public QThread
38
// internal representation of the job queue - all functions are thread-safe
44
Static, // no jobs added while processing queue
45
Dynamic // jobs can be added while processing queue
56
void reset( OperationMode _opMode );
58
void addJob( ThreadableJob * _job );
60
void run( sampleFrame * _buffer );
64
#define JOB_QUEUE_SIZE 1024
65
QAtomicPointer<ThreadableJob> m_items[JOB_QUEUE_SIZE];
66
QAtomicInt m_queueSize;
67
QAtomicInt m_itemsDone;
68
OperationMode m_opMode;
73
MixerWorkerThread( Mixer* mixer );
74
virtual ~MixerWorkerThread();
78
static void resetJobQueue( JobQueue::OperationMode _opMode =
81
globalJobQueue.reset( _opMode );
84
static void addJob( ThreadableJob * _job )
86
globalJobQueue.addJob( _job );
89
// a convenient helper function allowing to pass a container with pointers
90
// to ThreadableJob objects
92
static void fillJobQueue( const T & _vec,
93
JobQueue::OperationMode _opMode = JobQueue::Static )
95
resetJobQueue( _opMode );
96
for( typename T::ConstIterator it = _vec.begin(); it != _vec.end(); ++it )
102
static void startAndWaitForJobs();
108
static JobQueue globalJobQueue;
109
static QWaitCondition * queueReadyWaitCond;
110
static QList<MixerWorkerThread *> workerThreads;
112
sampleFrame * m_workingBuf;
113
volatile bool m_quit;