/*
- * The Ursary Audio Controls
+ * The Ursary Control Panel
*
- * (c) 2014 Martin Mares <mj@ucw.cz>
+ * (c) 2014--2022 Martin Mares <mj@ucw.cz>
*/
+#include <pulse/pulseaudio.h>
+
+#define SET_STRING(_field, _val) do { if (!_field || strcmp(_field, _val)) { xfree(_field); _field = xstrdup(_val); } } while (0)
+
/* ursary.c */
void schedule_update(void);
void notify_rotary(int rotary, int delta);
+void notify_touch(int rotary, int on);
void notify_button(int button, int on);
+void notify_mqtt(const char *topic, const char *val);
/* nocturn.c */
bool noct_is_ready(void);
void noct_set_ring(int ring, int mode, int val);
void noct_set_button(int button, int val);
+void noct_clear(void);
+
+extern char noct_rotary_touched[10]; // 8=center, 9=slider
+extern char noct_button_pressed[16];
enum ring_mode {
RING_MODE_LEFT,
RING_MODE_SINGLE_OFF,
};
-/* pulse.c */
+/* dmx.c */
-enum pulse_state {
- PS_OFFLINE,
- PS_SUBSCRIBE,
- PS_GET_CLIENTS,
- PS_GET_SINKS,
- PS_GET_SINK_INPUTS,
- PS_ONLINE,
-};
+void dmx_init(void);
+void dmx_set_pwm(uint index, uint val);
+bool dmx_is_ready(void);
-extern enum pulse_state pulse_state;
+/* pulse.c */
+
+extern char *pulse_default_sink_name;
struct pulse_client {
cnode n;
char *host;
};
+struct pulse_source {
+ cnode n;
+ int idx;
+ char *name;
+ uint channels;
+ uint volume;
+ uint base_volume;
+ bool mute;
+ bool suspended;
+ char *active_port;
+};
+
struct pulse_sink {
cnode n;
int idx;
char *name;
- uns channels;
- uns volume;
- uns base_volume;
- int mute;
+ uint channels;
+ uint volume;
+ uint base_volume;
+ bool mute;
+ bool suspended;
+ char *active_port;
};
struct pulse_sink_input {
char *name;
int client_idx;
int sink_idx;
- uns channels;
- uns volume;
- uns mute;
- int noct_client_idx; // Used by the high-level logic below
+ uint channels;
+ uint volume;
+ bool mute;
+ int noct_group_idx; // Used by the high-level logic below
};
-extern clist pulse_client_list, pulse_sink_list, pulse_sink_input_list;
+extern clist pulse_client_list, pulse_source_list, pulse_sink_list, pulse_sink_input_list;
void pulse_init(void);
void pulse_dump(void);
+bool pulse_is_ready(void);
+struct pulse_source *pulse_source_by_name(const char *name);
+struct pulse_source *pulse_source_by_idx(int idx);
+void pulse_source_set_volume(int idx, pa_cvolume *cvol);
+void pulse_source_set_mute(int idx, bool mute);
+void pulse_source_set_port(int idx, const char *port);
struct pulse_sink *pulse_sink_by_name(const char *name);
+struct pulse_sink *pulse_sink_by_idx(int idx);
void pulse_sink_set_volume(int idx, pa_cvolume *cvol);
void pulse_sink_set_mute(int idx, bool mute);
+void pulse_sink_set_port(int idx, const char *port);
void pulse_sink_input_set_volume(int idx, pa_cvolume *cvol);
void pulse_sink_input_set_mute(int idx, bool mute);
+void pulse_sink_input_move(int input_idx, int sink_idx);
struct pulse_client *pulse_client_by_idx(int idx);
+void pulse_server_set_default_sink(const char *name);
/* pulse-ucw.c */
extern struct pa_mainloop_api pmain_api;
void pmain_init(void);
+
+/* mpd.c */
+
+enum mpd_state {
+ MPD_OFFLINE,
+ MPD_CONNECTING,
+ MPD_WAIT_GREETING,
+ MPD_ONLINE,
+};
+
+extern enum mpd_state mpd_state;
+
+void mpd_init(void);
+const char *mpd_get_player_state(void);
+void mpd_play(void);
+void mpd_stop(void);
+void mpd_pause(int arg);
+void mpd_next(void);
+void mpd_prev(void);
+
+/* mqtt.c */
+
+void mqtt_init(void);
+void mqtt_publish(const char *topic, const char *fmt, ...);