forked from marcoevang/camilladsp-setrate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setrate_signal.c
46 lines (37 loc) · 1.08 KB
/
setrate_signal.c
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
////////////////////////////////////////////////////
//
// camilladsp-setrate
// Automatic sample rate switcher for CamillaDSP
//
// setrate_signal.c
// Signal management
//
////////////////////////////////////////////////////
#include <signal.h>
#include <libwebsockets.h>
#include "setrate.h"
extern states state; // Global state
///////////////////////////////////////
// Enable/Disable signal catching
///////////////////////////////////////
void signal_control(int enable)
{
if (enable)
signal(SOUNDCARD_UP_SIG, soundcard_up_handler);
else
signal(SOUNDCARD_UP_SIG, SIG_IGN);
}
///////////////////////////////////////
// Handle incoming signal notifying
// availability of the playback device
///////////////////////////////////////
void soundcard_up_handler(int sig)
{
writelog(USER, "%20s: Playback device is up\n", decode_state(state));
// Delay to give CamillaDSP time to access
// the just appeared playback device
sleep(1);
// Trigger a transition of the finite-state machine
// as if a sample rate change had occurred
fsm_transit(RATE_CHANGE);
}