root/branches/libfreebob-2.0/src/libstreaming/FreebobThread.h

Revision 199, 2.2 kB (checked in by pieterpalmers, 18 years ago)

- start of a new streaming API implementation, C++ based

Line 
1 /*
2 Modifications for Freebob (C) 2006, Pieter Palmers
3
4 Copied from the jackd/jackdmp sources
5 function names changed in order to avoid naming problems when using this in
6 a jackd backend.
7
8 Copyright (C) 2001 Paul Davis
9 Copyright (C) 2004-2006 Grame
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
25 */
26
27 #ifndef __FreebobThread__
28 #define __FreebobThread__
29
30 #include "FreebobAtomic.h"
31 #include <pthread.h>
32
33 namespace FreebobStreaming
34 {
35
36 /*!
37 \brief The base class for runnable objects, that have an <B> Init </B> and <B> Execute </B> method to be called in a thread.
38 */
39
40 class FreebobRunnableInterface
41 {
42
43     public:
44
45         FreebobRunnableInterface()
46         {}
47         virtual ~FreebobRunnableInterface()
48         {}
49
50         virtual bool Init()          /*! Called once when the thread is started */
51         {
52             return true;
53         }
54         virtual bool Execute() = 0;  /*! Must be implemented by subclasses */
55 };
56
57 /*!
58 \brief The thread base class.
59 */
60
61 class FreebobThread
62 {
63
64     protected:
65
66         FreebobRunnableInterface* fRunnable;
67
68     public:
69
70         FreebobThread(FreebobRunnableInterface* runnable): fRunnable(runnable)
71         {}
72         virtual ~FreebobThread()
73         {}
74
75         virtual int Start() = 0;
76         virtual int Kill() = 0;
77                 virtual int Stop() = 0;
78
79         virtual int AcquireRealTime() = 0;
80         virtual int AcquireRealTime(int priority) = 0;
81         virtual int DropRealTime() = 0;
82
83         virtual void SetParams(UInt64 period, UInt64 computation, UInt64 constraint) // Empty implementation, will only make sense on OSX...
84         {}
85
86         virtual pthread_t GetThreadID() = 0;
87 };
88
89 } // end of namespace
90
91 #endif
Note: See TracBrowser for help on using the browser.