51 #if defined (PLAYER_STATIC)
52 #define PLAYERCORE_EXPORT
53 #elif defined (playercore_EXPORTS)
54 #define PLAYERCORE_EXPORT __declspec (dllexport)
56 #define PLAYERCORE_EXPORT __declspec (dllimport)
59 #define PLAYERCORE_EXPORT
64 #include <libplayercommon/playercommon.h>
65 #include <libplayercore/message.h>
66 #include <libplayerinterface/player.h>
67 #include <libplayercore/property.h>
86 #define HANDLE_CAPABILITY_REQUEST(device_addr, queue, hdr, data, cap_type, cap_subtype) \
87 if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, PLAYER_CAPABILTIES_REQ, device_addr)) \
89 player_capabilities_req_t & cap_req = * reinterpret_cast<player_capabilities_req_t *> (data);\
90 if (cap_req.type == cap_type && cap_req.subtype == cap_subtype) \
92 Publish(device_addr, queue, PLAYER_MSGTYPE_RESP_ACK, PLAYER_CAPABILTIES_REQ); \
120 bool HasSubscriptions();
153 virtual bool Wait(
double TimeOut=0.0);
156 int AddFileWatch(
int fd,
bool ReadWatch =
true,
bool WriteWatch =
false,
bool ExceptWatch =
true);
159 int RemoveFileWatch(
int fd,
bool ReadWatch =
true,
bool WriteWatch =
false,
bool ExceptWatch =
true);
171 virtual void Lock(
void);
173 virtual void Unlock(
void);
176 virtual void SubscriptionLock(
void);
178 virtual void SubscriptionUnlock(
void);
214 double* timestamp=NULL,
235 double* timestamp=NULL,
306 bool overwrite_cmds =
true,
374 virtual int Terminate();
399 void ProcessMessages(
int maxmsgs);
405 void ProcessMessages(
void);
422 this->ProcessMessages();
432 virtual int ProcessInternalMessages(
QueuePointer& resp_queue,
443 virtual bool RegisterProperty(
const char *key,
Property *prop,
ConfigFile* cf,
int section);
455 typedef enum player_thread_state
457 PLAYER_THREAD_STATE_STOPPED,
458 PLAYER_THREAD_STATE_RUNNING,
459 PLAYER_THREAD_STATE_STOPPING,
460 PLAYER_THREAD_STATE_RESTARTING
461 } player_thread_state_t;
468 pthread_mutex_init(&barrierMutex,NULL);
469 pthread_cond_init(&barrierCond,NULL);
474 pthread_mutex_destroy(&barrierMutex);
475 pthread_cond_destroy(&barrierCond);
478 int SetValue(
int Value)
480 return barrierValue = Value;
485 pthread_mutex_lock(&barrierMutex);
486 assert(barrierValue);
488 pthread_cond_wait(&barrierCond,&barrierMutex);
490 pthread_cond_broadcast(&barrierCond);
491 pthread_mutex_unlock(&barrierMutex);
497 pthread_mutex_t barrierMutex;
501 pthread_cond_t barrierCond;
552 virtual void StartThread(
void);
558 virtual void StopThread(
void);
562 static void* DummyMain(
void *driver);
566 static void DummyMainQuit(
void *driver);
577 bool SetupSuccessful;
612 bool overwrite_cmds =
true,
647 virtual void Main(
void) = 0;
667 bool Wait(
double TimeOut=0.0);
Class for loading configuration file information.
Definition: configfile.h:196
Generic message header.
Definition: player.h:157
int GetError()
Get last error value.
Definition: driver.h:314
virtual void TestCancel()
enable thread cancellation and test for cancellation
Definition: driver.h:183
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:72
PlayerBarrier SetupBarrier
Barrier to synchronise threads on setup.
Definition: driver.h:580
virtual void Update()
Update non-threaded drivers.
Definition: driver.h:669
virtual bool Wait(double TimeOut=0.0)
Wait for new data to arrive on the driver's queue.
virtual int MainSetup(void)
Sets up the resources needed by the driver thread.
Definition: driver.h:650
virtual void Update()
Update non-threaded drivers.
Definition: driver.h:420
A device address.
Definition: player.h:141
virtual int Terminate()
Terminate the driver.
virtual int Subscribe(QueuePointer &queue, player_devaddr_t addr)
Subscribe to this driver.
Definition: driver.h:340
virtual int Shutdown()
Finalize the driver.
Definition: driver.h:390
Base class for drivers which oeprate with a thread.
Definition: driver.h:544
pthread_mutex_t subscriptionMutex
Mutex used to protect the subscription count for the driver.
Definition: driver.h:167
An autopointer for the message queue.
Definition: message.h:73
virtual void MainQuit(void)
Cleanup method for driver thread (called when main exits)
Definition: driver.h:656
virtual int Setup()
Initialize the driver.
Definition: driver.h:383
int entries
Total number of entries in the device table using this driver.
Definition: driver.h:270
bool alwayson
Always on flag.
Definition: driver.h:279
pthread_mutex_t accessMutex
Mutex used to lock access, via Lock() and Unlock(), to driver internals, like the list of subscribed ...
Definition: driver.h:165
QueuePointer InQueue
Queue for all incoming messages for this driver.
Definition: driver.h:282
void SetError(int code)
Set/reset error code.
Definition: driver.h:142
virtual int Unsubscribe(QueuePointer &queue, player_devaddr_t addr)
Unsubscribe from this driver.
Definition: driver.h:366
player_thread_state_t ThreadState
TODO: insert state machine here
Definition: driver.h:576
Base class for all drivers.
Definition: driver.h:108
pthread_t driverthread
The driver's thread.
Definition: driver.h:572
Property base class.
Definition: property.h:59
int subscriptions
Number of subscriptions to this driver.
Definition: driver.h:118
Property bag class: stores registered properties.
Definition: property.h:207
player_devaddr_t device_addr
Default device address (single-interface drivers)
Definition: driver.h:266