aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/main_common.c
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-01-04 14:14:02 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2017-02-18 21:00:45 +0100
commit9ff8c3bb25422e100801f90c17b9c21118920cfd (patch)
tree5715f3cc08893ed86dfc2514c93797d12e24d461 /src/common/main_common.c
parentd54d3ac2654844c7b8e4ee67752941c9037d5f42 (diff)
Rework on audio interface
Sound instance is now called audio instance and uses funcation pointers. This gives a clean interface to be exchanged with other technologies, linke SDR.
Diffstat (limited to 'src/common/main_common.c')
-rw-r--r--src/common/main_common.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/common/main_common.c b/src/common/main_common.c
index 4c731f6..11fa358 100644
--- a/src/common/main_common.c
+++ b/src/common/main_common.c
@@ -36,9 +36,9 @@
/* common settings */
int num_kanal = 0;
int kanal[MAX_SENDER];
-int num_sounddev = 0;
-const char *sounddev[MAX_SENDER] = { "hw:0,0" };
-const char *call_sounddev = "";
+int num_audiodev = 0;
+const char *audiodev[MAX_SENDER] = { "hw:0,0" };
+const char *call_audiodev = "";
int samplerate = 48000;
int interval = 1;
int latency = 50;
@@ -95,7 +95,7 @@ void print_help_common(const char *arg0, const char *ext_usage)
printf(" -m --mncc-sock\n");
printf(" Disable built-in call contol and offer socket (to LCR)\n");
printf(" -c --call-device hw:<card>,<device>\n");
- printf(" Sound card and device number for headset (default = '%s')\n", call_sounddev);
+ printf(" Sound card and device number for headset (default = '%s')\n", call_audiodev);
printf(" -t --tones 0 | 1\n");
printf(" Connect call on setup/release to provide classic tones towards fixed\n");
printf(" network (default = '%d')\n", send_patterns);
@@ -208,7 +208,7 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
*skip_args += 2;
break;
case 'a':
- OPT_ARRAY(num_sounddev, sounddev, strdup(optarg))
+ OPT_ARRAY(num_audiodev, audiodev, strdup(optarg))
*skip_args += 2;
break;
case 's':
@@ -256,7 +256,7 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
*skip_args += 1;
break;
case 'c':
- call_sounddev = strdup(optarg);
+ call_audiodev = strdup(optarg);
*skip_args += 2;
break;
case 't':
@@ -322,7 +322,7 @@ static int get_char()
}
/* Loop through all transceiver instances of one network. */
-void main_loop(int *quit, int latency, int interval, void (*myhandler)(void))
+void main_common(int *quit, int latency, int interval, void (*myhandler)(void))
{
int latspl;
sender_t *sender;
@@ -330,11 +330,10 @@ void main_loop(int *quit, int latency, int interval, void (*myhandler)(void))
struct termios term, term_orig;
int c;
- /* catch signals */
- signal(SIGINT, sighandler);
- signal(SIGHUP, sighandler);
- signal(SIGTERM, sighandler);
- signal(SIGPIPE, sighandler);
+
+ /* open audio */
+ if (sender_open_audio())
+ return;
/* real time priority */
if (rt_prio > 0) {
@@ -356,6 +355,12 @@ void main_loop(int *quit, int latency, int interval, void (*myhandler)(void))
term.c_cc[VTIME]=2;
tcsetattr(0, TCSANOW, &term);
+ /* catch signals */
+ signal(SIGINT, sighandler);
+ signal(SIGHUP, sighandler);
+ signal(SIGTERM, sighandler);
+ signal(SIGPIPE, sighandler);
+
while(!(*quit)) {
/* process sound of all transceivers */
for (sender = sender_head; sender; sender = sender->next) {
@@ -408,6 +413,12 @@ next_char:
usleep(interval * 1000);
}
+ /* reset signals */
+ signal(SIGINT, SIG_DFL);
+ signal(SIGHUP, SIG_DFL);
+ signal(SIGTERM, SIG_DFL);
+ signal(SIGPIPE, SIG_DFL);
+
/* get rid of last entry */
clear_console_text();
@@ -422,11 +433,5 @@ next_char:
schedp.sched_priority = 0;
sched_setscheduler(0, SCHED_OTHER, &schedp);
}
-
- /* reset signals */
- signal(SIGINT, SIG_DFL);
- signal(SIGHUP, SIG_DFL);
- signal(SIGTERM, SIG_DFL);
- signal(SIGPIPE, SIG_DFL);
}