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_CAPABILITIES_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_CAPABILITIES_REQ); \ 120 bool HasSubscriptions();
156 virtual bool Wait(
double TimeOut=0.0);
159 int AddFileWatch(
int fd,
bool ReadWatch =
true,
bool WriteWatch =
false,
bool ExceptWatch =
true);
162 int RemoveFileWatch(
int fd,
bool ReadWatch =
true,
bool WriteWatch =
false,
bool ExceptWatch =
true);
174 virtual void Lock(
void);
176 virtual void Unlock(
void);
179 virtual void SubscriptionLock(
void);
181 virtual void SubscriptionUnlock(
void);
217 double* timestamp=NULL,
238 double* timestamp=NULL,
309 bool overwrite_cmds =
true,
377 virtual int Terminate();
402 void ProcessMessages(
int maxmsgs);
408 void ProcessMessages(
void);
425 this->ProcessMessages();
435 virtual int ProcessInternalMessages(
QueuePointer& resp_queue,
446 virtual bool RegisterProperty(
const char *key,
458 virtual bool RegisterProperty(
Property *property,
463 typedef enum player_thread_state
465 PLAYER_THREAD_STATE_STOPPED,
466 PLAYER_THREAD_STATE_RUNNING,
467 PLAYER_THREAD_STATE_STOPPING,
468 PLAYER_THREAD_STATE_RESTARTING
469 } player_thread_state_t;
476 pthread_mutex_init(&barrierMutex,NULL);
477 pthread_cond_init(&barrierCond,NULL);
482 pthread_mutex_destroy(&barrierMutex);
483 pthread_cond_destroy(&barrierCond);
486 int SetValue(
int Value)
488 return barrierValue = Value;
493 pthread_mutex_lock(&barrierMutex);
494 assert(barrierValue);
496 pthread_cond_wait(&barrierCond,&barrierMutex);
498 pthread_cond_broadcast(&barrierCond);
499 pthread_mutex_unlock(&barrierMutex);
509 pthread_cond_t barrierCond;
560 virtual void StartThread(
void);
566 virtual void StopThread(
void);
570 static void* DummyMain(
void *driver);
574 static void DummyMainQuit(
void *driver);
585 bool SetupSuccessful;
620 bool overwrite_cmds =
true,
655 virtual void Main(
void) = 0;
675 bool Wait(
double TimeOut=0.0);
Class for loading configuration file information.
Definition: configfile.h:196
Generic message header.
Definition: player.h:161
int GetError()
Get last error value.
Definition: driver.h:317
virtual void TestCancel()
enable thread cancellation and test for cancellation
Definition: driver.h:186
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:76
PlayerBarrier SetupBarrier
Barrier to synchronise threads on setup.
Definition: driver.h:588
virtual void Update()
Update non-threaded drivers.
Definition: driver.h:677
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:658
virtual void Update()
Update non-threaded drivers.
Definition: driver.h:423
A device address.
Definition: player.h:145
virtual int Terminate()
Terminate the driver.
virtual int Shutdown()
Finalize the driver.
Definition: driver.h:393
Base class for drivers which oeprate with a thread.
Definition: driver.h:552
pthread_mutex_t subscriptionMutex
Mutex used to protect the subscription count for the driver.
Definition: driver.h:170
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:664
virtual int Setup()
Initialize the driver.
Definition: driver.h:386
int entries
Total number of entries in the device table using this driver.
Definition: driver.h:273
bool alwayson
Always on flag.
Definition: driver.h:282
pthread_mutex_t accessMutex
Mutex used to lock access, via Lock() and Unlock(), to driver internals, like the list of subscribed ...
Definition: driver.h:168
QueuePointer InQueue
Queue for all incoming messages for this driver.
Definition: driver.h:285
void SetError(int code)
Set/reset error code.
Definition: driver.h:145
player_thread_state_t ThreadState
TODO: insert state machine here.
Definition: driver.h:584
Base class for all drivers.
Definition: driver.h:108
pthread_mutex_t barrierMutex
barrier to make sure StartThread doesnt return until cleanup handlers etc have been installed...
Definition: driver.h:501
pthread_t driverthread
The driver's thread.
Definition: driver.h:580
Property base class.
Definition: property.h:59
virtual int Subscribe(QueuePointer &, player_devaddr_t)
Subscribe to this driver.
Definition: driver.h:343
int subscriptions
Number of subscriptions to this driver.
Definition: driver.h:118
virtual int Unsubscribe(QueuePointer &, player_devaddr_t)
Unsubscribe from this driver.
Definition: driver.h:369
Property bag class: stores registered properties.
Definition: property.h:207
player_devaddr_t device_addr
Default device address (single-interface drivers)
Definition: driver.h:269