~q3cpma/mus

ref: cf29c2237d0c99e5240a55895c07564ef4635392 mus/mus_player/ipc.h -rw-r--r-- 860 bytes
cf29c223q3cpma Add a #pragma once to the new xoshiro128plus.h header 1 year, 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once

#include <pthread.h>

#include "track_info.h"


/* To signal to main() what to do */
typedef enum
{
	ACTION_PLAY,
	ACTION_PAUSE,
	ACTION_QUIT,
	ACTION_TRACK_NEXT,
	ACTION_TRACK_PREV,
	ACTION_TRACK_REWIND,
	ACTION_TRACK_FIRST,
	ACTION_NONE
} Action;

typedef enum
{
	STATE_PLAYING,
	STATE_PAUSED,
} _Atomic Player_state;

/* Share stuff around between main thread and IPC thread */
typedef struct
{
	Track_info *tinfo;
	Player_state *pstate;
	_Atomic Action action;

	int udsockfd;
	const char *udsock_path;
	pthread_mutex_t track_lock; /* To avoid processing commands during track
                                 * changes */
	pthread_mutex_t pause_lock;
	pthread_cond_t pause_cond;
	pthread_t tid;
} Ipc_ctx;


/* Easy wrapper to spawn the IPC thread */
Ipc_ctx * ipc_thread_spawn(const char *udsock_path);

void ipc_thread_join(Ipc_ctx *ctx);