aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-01-29 16:54:28 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2017-02-18 21:01:18 +0100
commit5026e161aa61096e7f172131466e04966c340431 (patch)
tree6acec60a793ef8bac694f8a2b5c8a38c42175a3c /src
parent8cb0187133c496175cb90eefa8cfb347678b4d88 (diff)
Open audio device for call (headset) after everything is prepared
It is not allowed to stall after trigger reading of audio device.
Diffstat (limited to 'src')
-rw-r--r--src/common/call.c32
-rw-r--r--src/common/call.h1
-rw-r--r--src/common/main_common.c4
3 files changed, 26 insertions, 11 deletions
diff --git a/src/common/call.c b/src/common/call.c
index ce4a3bd..09f4a1e 100644
--- a/src/common/call.c
+++ b/src/common/call.c
@@ -181,8 +181,10 @@ typedef struct call {
int disc_cause; /* cause that has been sent by transceiver instance for release */
char station_id[16];
char dialing[16];
+ char audiodev[64]; /* headphone interface, if used */
+ int samplerate; /* sample rate of headphone interface */
void *sound; /* headphone interface */
- int latspl; /* sample latency at sound interface */
+ int latspl; /* sample latency at headphone interface */
samplerate_t srstate; /* patterns/announcement upsampling */
jitter_t dejitter; /* headphone audio dejittering */
int audio_pos; /* position when playing patterns */
@@ -486,6 +488,8 @@ int call_init(const char *station_id, const char *audiodev, int samplerate, int
call.use_mncc_sock = use_mncc_sock;
call.send_patterns = send_patterns;
call.release_on_disconnect = release_on_disconnect;
+ call.samplerate = samplerate;
+ strncpy(call.audiodev, audiodev, sizeof(call.audiodev) - 1);
if (call.use_mncc_sock)
return 0;
@@ -493,16 +497,6 @@ int call_init(const char *station_id, const char *audiodev, int samplerate, int
if (!audiodev[0])
return 0;
- /* open sound device for call control */
- /* use +3.17 dBm0 (factor 1.44) for complete range of sound card */
- call.sound = sound_open(audiodev, NULL, NULL, 1, 0.0, samplerate, 1.44, 4000.0);
- if (!call.sound) {
- PDEBUG(DSENDER, DEBUG_ERROR, "No sound device!\n");
-
- rc = -EIO;
- goto error;
- }
-
rc = init_samplerate(&call.srstate, samplerate);
if (rc < 0) {
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to init sample rate conversion!\n");
@@ -522,6 +516,22 @@ error:
return rc;
}
+int call_open_audio(void)
+{
+ if (!call.audiodev[0])
+ return 0;
+
+ /* open sound device for call control */
+ /* use factor 1.4 of speech level for complete range of sound card */
+ call.sound = sound_open(call.audiodev, NULL, NULL, 1, 0.0, call.samplerate, 1.4, 4000.0);
+ if (!call.sound) {
+ PDEBUG(DSENDER, DEBUG_ERROR, "No sound device!\n");
+ return -EIO;
+ }
+
+ return 0;
+}
+
void call_cleanup(void)
{
if (call.use_mncc_sock)
diff --git a/src/common/call.h b/src/common/call.h
index fe3a32a..11b0a9c 100644
--- a/src/common/call.h
+++ b/src/common/call.h
@@ -11,6 +11,7 @@ enum number_type {
int call_init(const char *station_id, const char *audiodev, int samplerate, int latency, int dial_digits, int loopback, int use_mncc_sock, int send_patterns, int release_on_disconnect);
void call_cleanup(void);
+int call_open_audio(void);
void process_call(int c);
void clear_console_text(void);
void print_console_text(void);
diff --git a/src/common/main_common.c b/src/common/main_common.c
index c644996..bf6c46d 100644
--- a/src/common/main_common.c
+++ b/src/common/main_common.c
@@ -435,6 +435,10 @@ void main_common(int *quit, int latency, int interval, void (*myhandler)(void))
if (sender_open_audio())
return;
+ /* afterwards open call audio, because we cannot wait for SDR to open */
+ if (call_open_audio())
+ return;
+
/* real time priority */
if (rt_prio > 0) {
struct sched_param schedp;