Make sound card support (Alsa) optional

This commit is contained in:
Andreas Eversberg 2018-01-21 10:43:45 +01:00
parent 5c9964ff19
commit e7016f9f02
7 changed files with 37 additions and 1 deletions

View File

@ -8,3 +8,8 @@ libmncc_a_SOURCES = \
mncc_sock.c \
testton.c \
cause.c
if HAVE_ALSA
AM_CPPFLAGS += -DHAVE_ALSA
endif

View File

@ -33,7 +33,9 @@
#include "mncc_console.h"
#include "cause.h"
#include "../libmobile/call.h"
#ifdef HAVE_ALSA
#include "../libsound/sound.h"
#endif
static int new_callref = 0; /* toward mobile */
@ -289,11 +291,12 @@ error:
return rc;
}
int console_open_audio(int latspl)
int console_open_audio(int __attribute__((unused)) latspl)
{
if (!console.audiodev[0])
return 0;
#ifdef HAVE_ALSA
/* open sound device for call control */
/* use factor 1.4 of speech level for complete range of sound card */
console.sound = sound_open(console.audiodev, NULL, NULL, 1, 0.0, console.samplerate, latspl, 1.4, 4000.0);
@ -301,6 +304,10 @@ int console_open_audio(int latspl)
PDEBUG(DSENDER, DEBUG_ERROR, "No sound device!\n");
return -EIO;
}
#else
PDEBUG(DSENDER, DEBUG_ERROR, "No sound card support compiled in!\n");
return -ENOTSUP;
#endif
return 0;
}
@ -310,14 +317,20 @@ int console_start_audio(void)
if (!console.audiodev[0])
return 0;
#ifdef HAVE_ALSA
return sound_start(console.sound);
#else
return -EINVAL;
#endif
}
void console_cleanup(void)
{
#ifdef HAVE_ALSA
/* close sound devoice */
if (console.sound)
sound_close(console.sound);
#endif
jitter_destroy(&console.dejitter);
}
@ -428,6 +441,7 @@ void process_console(int c)
if (!console.sound)
return;
#ifdef HAVE_ALSA
/* handle audio, if sound device is used */
sample_t samples[console.latspl + 10], *samples_list[1];
uint8_t *power_list[1];
@ -487,5 +501,6 @@ void process_console(int c)
}
}
}
#endif
}

View File

@ -7,6 +7,10 @@ libmobile_a_SOURCES = \
call.c \
main_mobile.c
if HAVE_ALSA
AM_CPPFLAGS += -DHAVE_ALSA
endif
if HAVE_SDR
AM_CPPFLAGS += -DHAVE_SDR
endif

View File

@ -115,12 +115,18 @@ int sender_create(sender_t *sender, int kanal, double sendefrequenz, double empf
} else
#endif
{
#ifdef HAVE_ALSA
sender->audio_open = sound_open;
sender->audio_start = sound_start;
sender->audio_close = sound_close;
sender->audio_read = sound_read;
sender->audio_write = sound_write;
sender->audio_get_tosend = sound_get_tosend;
#else
PDEBUG(DSENDER, DEBUG_ERROR, "No sound card support compiled in!\n");
rc = -ENOTSUP;
goto error;
#endif
}
}

View File

@ -1,4 +1,6 @@
#ifdef HAVE_ALSA
#include "../libsound/sound.h"
#endif
#ifdef HAVE_SDR
#include "../libsdr/sdr.h"
#endif

View File

@ -1,4 +1,6 @@
enum paging_signal;
int sdr_start(void *inst);
void *sdr_open(const char *audiodev, double *tx_frequency, double *rx_frequency, int channels, double paging_frequency, int samplerate, int latspl, double bandwidth, double sample_deviation);
void sdr_close(void *inst);

View File

@ -4,3 +4,5 @@ noinst_LIBRARIES = libsound.a
libsound_a_SOURCES = \
sound_alsa.c
AM_CPPFLAGS += -DHAVE_ALSA