/usr/include/SndObj/SndThread.h is in libsndobj-dev 2.6.6.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
////////////////////////////////////////////////////////////////////////
// This file is part of the SndObj library
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Copyright (c)Victor Lazzarini and Rory Walsh, 1997-2006
// See License.txt for a disclaimer of all warranties
// and licensing information
//
// SndThread.h
// Class SndThread:
// Multithreading support for the SndObj Library
//
// Victor Lazzarini, 2001
// Win32 thread code by Rory Walsh, 2006
#ifndef _SNDTHREAD_H
#define _SNDTHREAD_H
#include "SndObj.h"
#include "SndIO.h"
#ifdef WINPTHREAD
#include <wpthread.h>
#elif USE_WIN32THREADS
#include <process.h>
#include <windows.h>
#else
#include <pthread.h>
#endif
template<class s>
struct SndLink{ // SndObj / SndIO lists links
SndLink<s>* next; // next link
s* obj; // object pointed at by the link
};
enum { SNDIO_IN, SNDIO_OUT }; // IO list names
enum { OFF=0, ON }; // processing status
#ifdef PYTHON_WRAP
struct pycallbackdata {
PyObject *func;
PyObject *data;
};
#endif
class SndThread {
protected:
// three circular lists are declared:
// one for processing and two for IO
SndLink<SndObj>* last; // pointer to last element
SndLink<SndIO>* input; // input list
SndLink<SndIO>* output; // output list
int SndObjNo; // number of SndObjs in the list
int InputNo; // etc inputs
int OutputNo; // etc outputs
// used to control the processing loop
int status; // processing status ON, OFF
void (*ProcessCallback)(void *callbackdata);
void (*SndProcessThread)(void *data);
void *callbackdata;
bool processing;
// pthread-related member variables
#ifndef USE_WIN32THREADS
pthread_attr_t attrib;
pthread_t thread;
#else
uintptr_t hThread;
#endif
int m_vecsize;
int m_vecsize_max;
float m_sr;
bool m_changed;
bool m_parid[4];
void UpdateSr();
void UpdateVecsize();
void UpdateLimit();
void UpdateRestore();
void Update(){ if(m_changed){
if(m_parid[0]){
UpdateSr(); m_parid[0] = false;
}
if(m_parid[1]){
UpdateVecsize(); m_parid[1] = false;
}
if(m_parid[2]){
UpdateLimit(); m_parid[2] = false;
}
if(m_parid[3]){
UpdateRestore(); m_parid[3] = false;
}
m_changed = false;
}
}
public:
#ifdef PYTHON_WRAP
PyThreadState *_tstate;
pycallbackdata pydata;
#endif
void *GetProcessCallback() { return (void *)ProcessCallback; }
SndThread();
SndThread(int n, SndObj** objlist, SndIO *out, SndIO *in=0);
virtual ~SndThread();
int AddObj(SndObj *obj); // add to lists
int AddObj(SndIO *obj, int iolist);
// insert after a particular SndObj
int Insert(SndObj *obj, SndObj* prev);
int DeleteObj(SndObj *obj); // delete from lists
int DeleteObj(SndIO *obj, int iolist);
void SetProcessCallback(void (*Callback)(void *), void *cbdata){
ProcessCallback = Callback;
callbackdata = cbdata;
}
int GetStatus() { return status; }
int GetSndObjNo() { return SndObjNo; }
int GetInputNo() { return InputNo; }
int GetOutputNo() { return OutputNo; }
#ifndef USE_WIN32THREADS
pthread_attr_t GetAttrib() { return attrib; }
void SetAttrib(pthread_attr_t att) { attrib = att; }
#endif
void SetVectorSize(int vecsize){
m_vecsize_max = vecsize;
m_changed = m_parid[1] = true;
if(status==OFF) Update();
}
void LimitVectorSize(int limit){
m_vecsize = limit;
m_changed = m_parid[2] = true;
if(status==OFF) Update();
}
void RestoreVectorSize(){
m_changed = m_parid[3] = true;
if(status==OFF) Update();
}
void SetSr(float sr){
m_sr = sr;
m_changed = m_parid[0] = true;
if(status==OFF) Update();
};
int ProcOn(); // start processing thread
int ProcOff(); // kill processing thread
// external thread function
friend void threadfunc(void* sndthread);
};
void threadfunc(void* sndthread);
#endif
|