driver.h
141 int AddInterface(player_devaddr_t *addr, ConfigFile * cf, int section, int code, const char * key = NULL);
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);
int AddInterface(player_devaddr_t *addr, ConfigFile *cf, int section, int code, const char *key=NULL)
Add an interface.
virtual int ProcessInternalMessages(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Internal message handler.
QueuePointer InQueue
Queue for all incoming messages for this driver.
Definition driver.h:285
virtual int Subscribe(QueuePointer &, player_devaddr_t)
Subscribe to this driver.
Definition driver.h:343
virtual void SubscriptionUnlock(void)
Unlock to protect the subscription count for the driver.
int RemoveFileWatch(int fd, bool ReadWatch=true, bool WriteWatch=false, bool ExceptWatch=true)
Remove a previously added watch, call with the same arguments as when adding the watch.
virtual bool RegisterProperty(Property *property, ConfigFile *cf, int section)
Property registration.
virtual int Unsubscribe(QueuePointer &, player_devaddr_t)
Unsubscribe from this driver.
Definition driver.h:369
virtual void Publish(player_devaddr_t addr, uint8_t type, uint8_t subtype, void *src=NULL, size_t deprecated=0, double *timestamp=NULL, bool copy=true)
Publish a message via one of this driver's interfaces.
virtual bool RegisterProperty(const char *key, Property *property, ConfigFile *cf, int section)
Property registration.
virtual void Publish(player_devaddr_t addr, QueuePointer &queue, uint8_t type, uint8_t subtype, void *src=NULL, size_t deprecated=0, double *timestamp=NULL, bool copy=true)
Publish a message via one of this driver's interfaces.
player_devaddr_t device_addr
Default device address (single-interface drivers)
Definition driver.h:269
int AddFileWatch(int fd, bool ReadWatch=true, bool WriteWatch=false, bool ExceptWatch=true)
Wake up the driver if the specified event occurs on the file descriptor.
int entries
Total number of entries in the device table using this driver.
Definition driver.h:273
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
pthread_mutex_t subscriptionMutex
Mutex used to protect the subscription count for the driver.
Definition driver.h:170
Driver(ConfigFile *cf, int section, bool overwrite_cmds, size_t queue_maxlen, int interf)
Constructor for single-interface drivers.
virtual void Publish(player_msghdr_t *hdr, void *src, bool copy=true)
Publish a message via one of this driver's interfaces.
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
virtual void Publish(QueuePointer &queue, player_msghdr_t *hdr, void *src, bool copy=true)
Publish a message via one of this driver's interfaces.
virtual void SubscriptionLock(void)
Lock to protect the subscription count for the driver.
virtual void TestCancel()
enable thread cancellation and test for cancellation
Definition driver.h:186
int subscriptions
Number of subscriptions to this driver.
Definition driver.h:118
Driver(ConfigFile *cf, int section, bool overwrite_cmds=true, size_t queue_maxlen=PLAYER_MSGQUEUE_DEFAULT_MAXLEN)
Constructor for multiple-interface drivers.
Definition driver.h:472
pthread_mutex_t barrierMutex
barrier to make sure StartThread doesnt return until cleanup handlers etc have been installed.
Definition driver.h:505
player_thread_state_t ThreadState
TODO: insert state machine here.
Definition driver.h:584
PlayerBarrier SetupBarrier
Barrier to synchronise threads on setup.
Definition driver.h:588
ThreadedDriver(ConfigFile *cf, int section, bool overwrite_cmds, size_t queue_maxlen, int interface_)
Constructor with implicit interface.
static void DummyMainQuit(void *driver)
Dummy main cleanup (just calls real main cleanup).
virtual int MainSetup(void)
Sets up the resources needed by the driver thread.
Definition driver.h:658
virtual void StopThread(void)
Cancel (and wait for termination) of the driver thread.
virtual void MainQuit(void)
Cleanup method for driver thread (called when main exits)
Definition driver.h:664
ThreadedDriver(ConfigFile *cf, int section, bool overwrite_cmds=true, size_t queue_maxlen=PLAYER_MSGQUEUE_DEFAULT_MAXLEN)
Constructor for multiple-interface drivers.
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition player.h:76