Remove FreeBoB backend (superseded by FFADO)
[jack2.git] / android / JackAndroidSemaphore.h
blobdd8afdb9436acd0fac0aef4e1a4658acaf37c8bc
1 /*
2 Copyright (C) 2004-2008 Grame
3 Copyright (C) 2013 Samsung Electronics
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #ifndef __JackAndroidSemaphore__
22 #define __JackAndroidSemaphore__
24 #include "JackSynchro.h"
25 #include "JackCompilerDeps.h"
26 #include <semaphore.h>
27 #include <time.h>
28 #include <assert.h>
30 #include <binder/IMemory.h>
31 #include <binder/MemoryHeapBase.h>
32 #include <utils/RefBase.h>
34 namespace Jack
37 /*!
38 \brief Inter process synchronization using POSIX semaphore.
41 class SERVER_EXPORT JackAndroidSemaphore : public detail::JackSynchro
44 private:
46 sem_t* fSemaphore;
47 android::sp<android::IMemoryHeap> fSemaphoreMemory;
48 static pthread_mutex_t mutex;
50 protected:
52 void BuildName(const char* name, const char* server_name, char* res, int size);
54 public:
56 JackAndroidSemaphore():JackSynchro(), fSemaphore(NULL)
59 bool Signal();
60 bool SignalAll();
61 bool Wait();
62 bool TimedWait(long usec);
64 bool Allocate(const char* name, const char* server_name, int value);
65 bool Connect(const char* name, const char* server_name);
66 bool ConnectInput(const char* name, const char* server_name);
67 bool ConnectOutput(const char* name, const char* server_name);
68 bool Disconnect();
69 void Destroy();
72 } // end of namespace
75 #endif