]> git.vomp.tv Git - vompclient-marten.git/blob - threadpandroid.h
Fix bug in demuxer widescreen signaling
[vompclient-marten.git] / threadpandroid.h
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #ifndef THREADPANDROID_H
22 #define THREADPANDROID_H
23
24 #include <pthread.h>
25 #include <signal.h>
26
27 #include "defines.h"
28 #include "thread.h"
29
30 class ThreadPAndroid : public Thread
31 {
32   protected:
33     // Override this method in derived classes
34     virtual void threadMethod()=0;
35     virtual void threadPostStopCleanup()=0;
36
37     // Methods to use from outside the thread
38     int threadStart();    // start the thread. threadMethod() will be called in derived class
39     void threadStop();    // stop the thread nicely. thread will be stopped when it next calls threadCheckExit()
40     void threadCancel();  // stop thread immediately. thread will be stopped at the next cancellation point
41     void threadSignal();  // releases a thread that has called threadWaitForSignal
42     void threadSignalNoLock();  // same as above but without locking guarantees. probably not a good idea.
43
44     // Methods to use from inside the thread
45     void threadSetKillable();    // allows threadCancel() to work
46     void threadCheckExit();      // terminates thread if threadStop() has been called
47     void threadWaitForSignal();  // pauses thread until threadSignal() is called
48     void threadWaitForSignalTimed(struct timespec*);  // pauses thread until threadSignal() is called or timer expires
49     void threadLock();           // locks the mutex used for internal cond/signal stuff
50     void threadUnlock();         // unlocks.
51
52     // Internal bits and pieces
53
54     pthread_t pthread;
55     pthread_cond_t threadCond;
56     pthread_cond_t threadKillable;
57     pthread_mutex_t threadCondMutex;
58
59   public:
60     pthread_t getThreadID();    // returns the ID of the thread represented by this object
61
62
63     static pthread_t thisThreadID();    // Self identification - returns ID of calling thread
64     static void threadSuicide();        // Self termination
65     bool killable;
66 };
67
68 #endif