]> mj.ucw.cz Git - ursary.git/blob - ursaryd.h
Nocturn: Do not write to a missing USB device
[ursary.git] / ursaryd.h
1 /*
2  *      The Ursary Audio Controls
3  *
4  *      (c) 2014 Martin Mares <mj@ucw.cz>
5  */
6
7 #include <pulse/pulseaudio.h>
8
9 #define SET_STRING(_field, _val) do { if (!_field || strcmp(_field, _val)) { xfree(_field); _field = xstrdup(_val); } } while (0)
10
11 /* ursary.c */
12
13 void schedule_update(void);
14
15 void notify_rotary(int rotary, int delta);
16 void notify_touch(int rotary, int on);
17 void notify_button(int button, int on);
18
19 /* nocturn.c */
20
21 void noct_init(void);
22 bool noct_is_ready(void);
23 void noct_set_ring(int ring, int mode, int val);
24 void noct_set_button(int button, int val);
25
26 extern char noct_rotary_touched[10];    // 8=center, 9=slider
27 extern char noct_button_pressed[16];
28
29 enum ring_mode {
30   RING_MODE_LEFT,
31   RING_MODE_RIGHT,
32   RING_MODE_MID_RIGHT,
33   RING_MODE_MID_SYM,
34   RING_MODE_SINGLE_ON,
35   RING_MODE_SINGLE_OFF,
36 };
37
38 /* pulse.c */
39
40 enum pulse_state {
41   PS_OFFLINE,
42   PS_SUBSCRIBE,
43   PS_GET_CLIENTS,
44   PS_GET_SINKS,
45   PS_GET_SINK_INPUTS,
46   PS_GET_SERVER,
47   PS_ONLINE,
48 };
49
50 extern enum pulse_state pulse_state;
51 extern char *pulse_default_sink_name;
52
53 struct pulse_client {
54   cnode n;
55   int idx;
56   char *name;
57   char *host;
58 };
59
60 struct pulse_sink {
61   cnode n;
62   int idx;
63   char *name;
64   uint channels;
65   uint volume;
66   uint base_volume;
67   int mute;
68 };
69
70 struct pulse_sink_input {
71   cnode n;
72   int idx;
73   char *name;
74   int client_idx;
75   int sink_idx;
76   uint channels;
77   uint volume;
78   uint mute;
79   int noct_client_idx;          // Used by the high-level logic below
80 };
81
82 extern clist pulse_client_list, pulse_sink_list, pulse_sink_input_list;
83
84 void pulse_init(void);
85 void pulse_dump(void);
86 struct pulse_sink *pulse_sink_by_name(const char *name);
87 struct pulse_sink *pulse_sink_by_idx(int idx);
88 void pulse_sink_set_volume(int idx, pa_cvolume *cvol);
89 void pulse_sink_set_mute(int idx, bool mute);
90 void pulse_sink_input_set_volume(int idx, pa_cvolume *cvol);
91 void pulse_sink_input_set_mute(int idx, bool mute);
92 void pulse_sink_input_move(int input_idx, int sink_idx);
93 struct pulse_client *pulse_client_by_idx(int idx);
94 void pulse_server_set_default_sink(const char *name);
95
96 /* pulse-ucw.c */
97
98 extern struct pa_mainloop_api pmain_api;
99
100 void pmain_init(void);
101
102 /* mpd.c */
103
104 enum mpd_state {
105   MPD_OFFLINE,
106   MPD_CONNECTING,
107   MPD_WAIT_GREETING,
108   MPD_ONLINE,
109 };
110
111 extern enum mpd_state mpd_state;
112
113 void mpd_init(void);
114 const char *mpd_get_player_state(void);
115 void mpd_play(void);
116 void mpd_stop(void);
117 void mpd_pause(int arg);