myMPD
Internal API documentation
Loading...
Searching...
No Matches
event.h
Go to the documentation of this file.
1/*
2 SPDX-License-Identifier: GPL-3.0-or-later
3 myMPD (c) 2018-2026 Juergen Mang <mail@jcgames.de>
4 https://github.com/jcorporation/mympd
5*/
6
10
11#ifndef MYMPD_EVENT_H
12#define MYMPD_EVENT_H
13
14#include "compile_time.h"
15#include <poll.h>
16#include <stdbool.h>
17#include <sys/eventfd.h>
18
23 /* MPD connection for partitions */
24 PFD_TYPE_PARTITION = 0x1,
25 /* MPD connection for stickerdb */
26 PFD_TYPE_STICKERDB = 0x2,
27 /* myMPD timers */
28 PFD_TYPE_TIMER = 0x4,
29 /* Message queue */
30 PFD_TYPE_QUEUE = 0x8,
31 /* Timer for mpd connect and reconnect */
32 PFD_TYPE_TIMER_MPD_CONNECT = 0x10,
33 /* Scrobble timer */
34 PFD_TYPE_TIMER_SCROBBLE = 0x20,
35 /* Jukebox timer */
36 PFD_TYPE_TIMER_JUKEBOX = 0x40
37};
38
42struct mympd_pfds {
43 struct pollfd fds[POLL_FDS_MAX];
44 enum pfd_type fd_types[POLL_FDS_MAX];
45 nfds_t len;
46 struct t_partition_state *partition_states[POLL_FDS_MAX];
48};
49
50void event_pfd_init(struct mympd_pfds *pfds);
51bool event_pfd_add_fd(struct mympd_pfds *pfds, int fd, enum pfd_type type, struct t_partition_state *partition_state);
52int event_eventfd_create(void);
54bool event_eventfd_read(int fd);
55eventfd_t event_eventfd_read_number(int fd);
56bool event_eventfd_write(int fd);
57void event_fd_close(int fd);
58const char *lookup_pfd_type(enum pfd_type type);
59const char *lookup_pfd_revents(short revent);
60
61#endif
bool event_eventfd_read(int fd)
Definition event.c:100
const char * lookup_pfd_revents(short revent)
Definition event.c:161
void event_fd_close(int fd)
Definition event.c:132
int event_eventfd_create(void)
Definition event.c:56
bool event_eventfd_write(int fd)
Definition event.c:85
eventfd_t event_eventfd_read_number(int fd)
Definition event.c:117
pfd_type
Definition event.h:22
const char * lookup_pfd_type(enum pfd_type type)
Definition event.c:143
void event_pfd_init(struct mympd_pfds *pfds)
Definition event.c:24
bool event_pfd_add_fd(struct mympd_pfds *pfds, int fd, enum pfd_type type, struct t_partition_state *partition_state)
Definition event.c:36
int event_eventfd_create_simple(void)
Definition event.c:70
Definition event.h:42
bool repopulate
Repopulate the pollfd struct.
Definition event.h:47
struct t_partition_state * partition_states[POLL_FDS_MAX]
pointer to partition_state
Definition event.h:46
enum pfd_type fd_types[POLL_FDS_MAX]
fd types
Definition event.h:44
struct pollfd fds[POLL_FDS_MAX]
fds
Definition event.h:43
nfds_t len
number of mpd connection fds
Definition event.h:45
Definition partition_state.h:27