mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 12:40:17 +00:00
gsmopen: begin cleaning from alsa
This commit is contained in:
parent
6623420e01
commit
49a4d2126b
@ -2444,357 +2444,6 @@ int gsmopen_hangup(private_t *tech_pvt)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef GSMOPEN_ALSA
|
||||
/*! \brief ALSA pcm format, according to endianess */
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
snd_pcm_format_t gsmopen_format = SND_PCM_FORMAT_S16_LE;
|
||||
#else
|
||||
snd_pcm_format_t gsmopen_format = SND_PCM_FORMAT_S16_BE;
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* \brief Initialize the ALSA soundcard channels (capture AND playback) used by one interface (a multichannel soundcard can be used by multiple interfaces)
|
||||
* \param p the gsmopen_pvt of the interface
|
||||
*
|
||||
* This function call alsa_open_dev to initialize the ALSA soundcard for each channel (capture AND playback) used by one interface (a multichannel soundcard can be used by multiple interfaces). Called by sound_init
|
||||
*
|
||||
* \return zero on success, -1 on error.
|
||||
*/
|
||||
int alsa_init(private_t *tech_pvt)
|
||||
{
|
||||
tech_pvt->alsac = alsa_open_dev(tech_pvt, SND_PCM_STREAM_CAPTURE);
|
||||
if (!tech_pvt->alsac) {
|
||||
ERRORA("Failed opening ALSA capture device: %s\n", GSMOPEN_P_LOG, tech_pvt->alsacname);
|
||||
if (alsa_shutdown(tech_pvt)) {
|
||||
ERRORA("alsa_shutdown failed\n", GSMOPEN_P_LOG);
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
tech_pvt->alsap = alsa_open_dev(tech_pvt, SND_PCM_STREAM_PLAYBACK);
|
||||
if (!tech_pvt->alsap) {
|
||||
ERRORA("Failed opening ALSA playback device: %s\n", GSMOPEN_P_LOG, tech_pvt->alsapname);
|
||||
if (alsa_shutdown(tech_pvt)) {
|
||||
ERRORA("alsa_shutdown failed\n", GSMOPEN_P_LOG);
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* make valgrind very happy */
|
||||
snd_config_update_free_global();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Shutdown the ALSA soundcard channels (input and output) used by one interface (a multichannel soundcard can be used by multiple interfaces)
|
||||
* \param p the gsmopen_pvt of the interface
|
||||
*
|
||||
* This function shutdown the ALSA soundcard channels (input and output) used by one interface (a multichannel soundcard can be used by multiple interfaces). Called by sound_init
|
||||
*
|
||||
* \return zero on success, -1 on error.
|
||||
*/
|
||||
|
||||
int alsa_shutdown(private_t *tech_pvt)
|
||||
{
|
||||
|
||||
int err;
|
||||
|
||||
if (tech_pvt->alsap) {
|
||||
err = snd_pcm_drop(tech_pvt->alsap);
|
||||
if (err < 0) {
|
||||
ERRORA("device [%s], snd_pcm_drop failed with error '%s'\n", GSMOPEN_P_LOG, tech_pvt->alsapname, snd_strerror(err));
|
||||
return -1;
|
||||
}
|
||||
err = snd_pcm_close(tech_pvt->alsap);
|
||||
if (err < 0) {
|
||||
ERRORA("device [%s], snd_pcm_close failed with error '%s'\n", GSMOPEN_P_LOG, tech_pvt->alsapname, snd_strerror(err));
|
||||
return -1;
|
||||
}
|
||||
tech_pvt->alsap = NULL;
|
||||
}
|
||||
if (tech_pvt->alsac) {
|
||||
err = snd_pcm_drop(tech_pvt->alsac);
|
||||
if (err < 0) {
|
||||
ERRORA("device [%s], snd_pcm_drop failed with error '%s'\n", GSMOPEN_P_LOG, tech_pvt->alsacname, snd_strerror(err));
|
||||
return -1;
|
||||
}
|
||||
err = snd_pcm_close(tech_pvt->alsac);
|
||||
if (err < 0) {
|
||||
ERRORA("device [%s], snd_pcm_close failed with error '%s'\n", GSMOPEN_P_LOG, tech_pvt->alsacname, snd_strerror(err));
|
||||
return -1;
|
||||
}
|
||||
tech_pvt->alsac = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Setup and open the ALSA device (capture OR playback)
|
||||
* \param p the gsmopen_pvt of the interface
|
||||
* \param stream the ALSA capture/playback definition
|
||||
*
|
||||
* This function setup and open the ALSA device (capture OR playback). Called by alsa_init
|
||||
*
|
||||
* \return zero on success, -1 on error.
|
||||
*/
|
||||
snd_pcm_t *alsa_open_dev(private_t *tech_pvt, snd_pcm_stream_t stream)
|
||||
{
|
||||
|
||||
snd_pcm_t *handle = NULL;
|
||||
snd_pcm_hw_params_t *params;
|
||||
snd_pcm_sw_params_t *swparams;
|
||||
snd_pcm_uframes_t buffer_size;
|
||||
int err;
|
||||
size_t n;
|
||||
//snd_pcm_uframes_t xfer_align;
|
||||
unsigned int rate;
|
||||
snd_pcm_uframes_t start_threshold, stop_threshold;
|
||||
snd_pcm_uframes_t period_size = 0;
|
||||
snd_pcm_uframes_t chunk_size = 0;
|
||||
int start_delay = 0;
|
||||
int stop_delay = 0;
|
||||
snd_pcm_state_t state;
|
||||
snd_pcm_info_t *info;
|
||||
unsigned int chan_num;
|
||||
|
||||
period_size = tech_pvt->alsa_period_size;
|
||||
|
||||
snd_pcm_hw_params_alloca(¶ms);
|
||||
snd_pcm_sw_params_alloca(&swparams);
|
||||
|
||||
if (stream == SND_PCM_STREAM_CAPTURE) {
|
||||
err = snd_pcm_open(&handle, tech_pvt->alsacname, stream, 0 | SND_PCM_NONBLOCK);
|
||||
} else {
|
||||
err = snd_pcm_open(&handle, tech_pvt->alsapname, stream, 0 | SND_PCM_NONBLOCK);
|
||||
}
|
||||
if (err < 0) {
|
||||
ERRORA
|
||||
("snd_pcm_open failed with error '%s' on device '%s', if you are using a plughw:n device please change it to be a default:n device (so to allow it to be shared with other concurrent programs), or maybe you are using an ALSA voicemodem and slmodemd"
|
||||
" is running?\n", GSMOPEN_P_LOG, snd_strerror(err), stream == SND_PCM_STREAM_CAPTURE ? tech_pvt->alsacname : tech_pvt->alsapname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
snd_pcm_info_alloca(&info);
|
||||
|
||||
if ((err = snd_pcm_info(handle, info)) < 0) {
|
||||
ERRORA("info error: %s", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
err = snd_pcm_nonblock(handle, 1);
|
||||
if (err < 0) {
|
||||
ERRORA("nonblock setting error: %s", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
err = snd_pcm_hw_params_any(handle, params);
|
||||
if (err < 0) {
|
||||
ERRORA("Broken configuration for this PCM, no configurations available: %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
err = snd_pcm_hw_params_set_access(handle, params, SND_PCM_ACCESS_RW_INTERLEAVED);
|
||||
if (err < 0) {
|
||||
ERRORA("Access type not available: %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
err = snd_pcm_hw_params_set_format(handle, params, gsmopen_format);
|
||||
if (err < 0) {
|
||||
ERRORA("Sample format non available: %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
err = snd_pcm_hw_params_set_channels(handle, params, 1);
|
||||
if (err < 0) {
|
||||
DEBUGA_GSMOPEN("Channels count set failed: %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
}
|
||||
#if 1
|
||||
err = snd_pcm_hw_params_get_channels(params, &chan_num);
|
||||
if (err < 0) {
|
||||
ERRORA("Channels count non available: %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
if (chan_num < 1 || chan_num > 2) {
|
||||
ERRORA("Channels count MUST BE 1 or 2, it is: %d\n", GSMOPEN_P_LOG, chan_num);
|
||||
ERRORA("Channels count MUST BE 1 or 2, it is: %d on %s %s\n", GSMOPEN_P_LOG, chan_num, tech_pvt->alsapname, tech_pvt->alsacname);
|
||||
return NULL;
|
||||
} else {
|
||||
if (chan_num == 1) {
|
||||
if (stream == SND_PCM_STREAM_CAPTURE)
|
||||
tech_pvt->alsa_capture_is_mono = 1;
|
||||
else
|
||||
tech_pvt->alsa_play_is_mono = 1;
|
||||
} else {
|
||||
if (stream == SND_PCM_STREAM_CAPTURE)
|
||||
tech_pvt->alsa_capture_is_mono = 0;
|
||||
else
|
||||
tech_pvt->alsa_play_is_mono = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
tech_pvt->alsa_capture_is_mono = 1;
|
||||
tech_pvt->alsa_play_is_mono = 1;
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
rate = tech_pvt->gsmopen_sound_rate;
|
||||
err = snd_pcm_hw_params_set_rate_near(handle, params, &rate, 0);
|
||||
if ((float) tech_pvt->gsmopen_sound_rate * 1.05 < rate || (float) tech_pvt->gsmopen_sound_rate * 0.95 > rate) {
|
||||
WARNINGA("Rate is not accurate (requested = %iHz, got = %iHz)\n", GSMOPEN_P_LOG, tech_pvt->gsmopen_sound_rate, rate);
|
||||
}
|
||||
|
||||
if (err < 0) {
|
||||
ERRORA("Error setting rate: %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
tech_pvt->gsmopen_sound_rate = rate;
|
||||
|
||||
err = snd_pcm_hw_params_set_period_size_near(handle, params, &period_size, 0);
|
||||
|
||||
if (err < 0) {
|
||||
ERRORA("Error setting period_size: %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tech_pvt->alsa_period_size = period_size;
|
||||
|
||||
tech_pvt->alsa_buffer_size = tech_pvt->alsa_period_size * tech_pvt->alsa_periods_in_buffer;
|
||||
|
||||
err = snd_pcm_hw_params_set_buffer_size_near(handle, params, &tech_pvt->alsa_buffer_size);
|
||||
|
||||
if (err < 0) {
|
||||
ERRORA("Error setting buffer_size: %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
err = snd_pcm_hw_params(handle, params);
|
||||
if (err < 0) {
|
||||
ERRORA("Unable to install hw params: %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
snd_pcm_hw_params_get_period_size(params, &chunk_size, 0);
|
||||
snd_pcm_hw_params_get_buffer_size(params, &buffer_size);
|
||||
if (chunk_size == buffer_size) {
|
||||
ERRORA("Can't use period equal to buffer size (%lu == %lu)\n", GSMOPEN_P_LOG, chunk_size, buffer_size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
snd_pcm_sw_params_current(handle, swparams);
|
||||
|
||||
/*
|
||||
if (sleep_min)
|
||||
xfer_align = 1;
|
||||
err = snd_pcm_sw_params_set_sleep_min(handle, swparams,
|
||||
0);
|
||||
|
||||
if (err < 0) {
|
||||
ERRORA("Error setting slep_min: %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
}
|
||||
*/
|
||||
n = chunk_size;
|
||||
err = snd_pcm_sw_params_set_avail_min(handle, swparams, n);
|
||||
if (err < 0) {
|
||||
ERRORA("Error setting avail_min: %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
}
|
||||
if (stream == SND_PCM_STREAM_CAPTURE) {
|
||||
start_delay = 1;
|
||||
}
|
||||
if (start_delay <= 0) {
|
||||
start_threshold = n + (snd_pcm_uframes_t) rate *start_delay / 1000000;
|
||||
} else {
|
||||
start_threshold = (snd_pcm_uframes_t) rate *start_delay / 1000000;
|
||||
}
|
||||
if (start_threshold < 1)
|
||||
start_threshold = 1;
|
||||
if (start_threshold > n)
|
||||
start_threshold = n;
|
||||
err = snd_pcm_sw_params_set_start_threshold(handle, swparams, start_threshold);
|
||||
if (err < 0) {
|
||||
ERRORA("Error setting start_threshold: %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
}
|
||||
|
||||
if (stop_delay <= 0)
|
||||
stop_threshold = buffer_size + (snd_pcm_uframes_t) rate *stop_delay / 1000000;
|
||||
else
|
||||
stop_threshold = (snd_pcm_uframes_t) rate *stop_delay / 1000000;
|
||||
|
||||
if (stream == SND_PCM_STREAM_CAPTURE) {
|
||||
stop_threshold = -1;
|
||||
}
|
||||
|
||||
err = snd_pcm_sw_params_set_stop_threshold(handle, swparams, stop_threshold);
|
||||
|
||||
if (err < 0) {
|
||||
ERRORA("Error setting stop_threshold: %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
}
|
||||
|
||||
if (snd_pcm_sw_params(handle, swparams) < 0) {
|
||||
ERRORA("Error installing software parameters: %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
}
|
||||
|
||||
err = snd_pcm_poll_descriptors_count(handle);
|
||||
if (err <= 0) {
|
||||
ERRORA("Unable to get a poll descriptors count, error is %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (err != 1) { //number of poll descriptors
|
||||
DEBUGA_GSMOPEN("Can't handle more than one device\n", GSMOPEN_P_LOG);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
err = snd_pcm_poll_descriptors(handle, &tech_pvt->pfd, err);
|
||||
if (err != 1) {
|
||||
ERRORA("snd_pcm_poll_descriptors failed, %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
DEBUGA_GSMOPEN("Acquired fd %d from the poll descriptor\n", GSMOPEN_P_LOG, tech_pvt->pfd.fd);
|
||||
|
||||
if (stream == SND_PCM_STREAM_CAPTURE) {
|
||||
tech_pvt->gsmopen_sound_capt_fd = tech_pvt->pfd.fd;
|
||||
}
|
||||
|
||||
state = snd_pcm_state(handle);
|
||||
|
||||
if (state != SND_PCM_STATE_RUNNING) {
|
||||
if (state != SND_PCM_STATE_PREPARED) {
|
||||
err = snd_pcm_prepare(handle);
|
||||
if (err) {
|
||||
ERRORA("snd_pcm_prepare failed, %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
DEBUGA_GSMOPEN("prepared!\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
if (stream == SND_PCM_STREAM_CAPTURE) {
|
||||
err = snd_pcm_start(handle);
|
||||
if (err) {
|
||||
ERRORA("snd_pcm_start failed, %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
DEBUGA_GSMOPEN("started!\n", GSMOPEN_P_LOG);
|
||||
}
|
||||
}
|
||||
if (option_debug > 1) {
|
||||
snd_output_t *output = NULL;
|
||||
err = snd_output_stdio_attach(&output, stdout, 0);
|
||||
if (err < 0) {
|
||||
ERRORA("snd_output_stdio_attach failed: %s\n", GSMOPEN_P_LOG, snd_strerror(err));
|
||||
}
|
||||
snd_pcm_dump(handle, output);
|
||||
|
||||
}
|
||||
if (option_debug > 1)
|
||||
DEBUGA_GSMOPEN("ALSA handle = %ld\n", GSMOPEN_P_LOG, (long int) handle);
|
||||
return handle;
|
||||
|
||||
}
|
||||
|
||||
/*! \brief Write audio frames to interface */
|
||||
#endif /* GSMOPEN_ALSA */
|
||||
|
||||
int gsmopen_call(private_t *tech_pvt, char *rdest, int timeout)
|
||||
{
|
||||
|
||||
|
@ -272,15 +272,6 @@ switch_status_t gsmopen_tech_init(private_t *tech_pvt, switch_core_session_t *se
|
||||
dtmf_rx_init(&tech_pvt->dtmf_state, NULL, NULL);
|
||||
dtmf_rx_parms(&tech_pvt->dtmf_state, 0, 10, 10, -99);
|
||||
|
||||
#ifdef GSMOPEN_ALSA
|
||||
if (tech_pvt->no_sound == 0) {
|
||||
if (alsa_init(tech_pvt)) {
|
||||
ERRORA("alsa_init failed\n", GSMOPEN_P_LOG);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
||||
}
|
||||
}
|
||||
#endif // GSMOPEN_ALSA
|
||||
if (tech_pvt->no_sound == 0) {
|
||||
if (serial_audio_init(tech_pvt)) {
|
||||
ERRORA("serial_audio_init failed\n", GSMOPEN_P_LOG);
|
||||
@ -519,11 +510,6 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
|
||||
switch_core_timer_destroy(&tech_pvt->timer_read);
|
||||
switch_core_timer_destroy(&tech_pvt->timer_write);
|
||||
|
||||
#ifdef GSMOPEN_ALSA
|
||||
if (tech_pvt->no_sound == 0) {
|
||||
alsa_shutdown(tech_pvt);
|
||||
}
|
||||
#endif // GSMOPEN_ALSA
|
||||
if (tech_pvt->no_sound == 0) {
|
||||
serial_audio_shutdown(tech_pvt);
|
||||
}
|
||||
@ -699,10 +685,6 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
switch_channel_t *channel = NULL;
|
||||
private_t *tech_pvt = NULL;
|
||||
switch_byte_t *data;
|
||||
#if defined(GSMOPEN_ALSA)
|
||||
int samples;
|
||||
char digit_str[256];
|
||||
#endif // defined(GSMOPEN_ALSA)
|
||||
|
||||
int samples;
|
||||
int samples2;
|
||||
@ -733,10 +715,6 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||
if (tech_pvt->no_sound == 1) {
|
||||
goto cng;
|
||||
}
|
||||
#ifdef GSMOPEN_ALSA
|
||||
//if ((samples = snd_pcm_readi(tech_pvt->alsac, tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet)) > 0)
|
||||
if ((samples = alsa_read(tech_pvt, (short *) tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet)) > 0)
|
||||
#endif // GSMOPEN_ALSA
|
||||
// if ((samples = tech_pvt->serialPort_serial_audio->Read((char *) tech_pvt->read_frame.data, 320)) >0)
|
||||
|
||||
if ((samples = tech_pvt->serialPort_serial_audio->Read(buffer2, 640)) >= 320) {
|
||||
@ -872,9 +850,6 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
|
||||
{
|
||||
switch_channel_t *channel = NULL;
|
||||
private_t *tech_pvt = NULL;
|
||||
#if defined(GSMOPEN_ALSA)
|
||||
unsigned int sent;
|
||||
#endif // defined(GSMOPEN_ALSA)
|
||||
|
||||
unsigned int sent;
|
||||
|
||||
@ -906,16 +881,6 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
|
||||
//snd_pcm_writei(tech_pvt->alsap, (short *) frame->data, (int) (frame->datalen / 2));
|
||||
|
||||
gsmopen_sound_boost(frame->data, frame->samples, tech_pvt->playback_boost);
|
||||
#ifdef GSMOPEN_ALSA
|
||||
|
||||
switch_core_timer_next(&tech_pvt->timer_write);
|
||||
sent = alsa_write(tech_pvt, (short *) frame->data, (int) (frame->datalen));
|
||||
//DEBUGA_GSMOPEN("sent=%d \n", GSMOPEN_P_LOG, sent);
|
||||
|
||||
if (sent && sent != frame->datalen / 2 && sent != -1) {
|
||||
DEBUGA_GSMOPEN("sent %d\n", GSMOPEN_P_LOG, sent);
|
||||
}
|
||||
#endif // GSMOPEN_ALSA
|
||||
sent = tech_pvt->serialPort_serial_audio->Write((char *) frame->data, (int) (frame->datalen));
|
||||
|
||||
if (sent && sent != frame->datalen && sent != -1) {
|
||||
@ -960,10 +925,6 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
|
||||
{
|
||||
switch_channel_t *channel;
|
||||
private_t *tech_pvt;
|
||||
#if defined(GSMOPEN_ALSA)
|
||||
int samples;
|
||||
short tmp_buffer[1280];
|
||||
#endif // defined(GSMOPEN_ALSA)
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
switch_assert(channel != NULL);
|
||||
@ -984,11 +945,6 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
|
||||
switch_core_timer_sync(&tech_pvt->timer_read);
|
||||
switch_core_timer_sync(&tech_pvt->timer_write);
|
||||
|
||||
#ifdef GSMOPEN_ALSA
|
||||
while ((samples = alsa_read(tech_pvt, tmp_buffer, tech_pvt->read_codec.implementation->samples_per_packet * 4)) > 160) {
|
||||
//WARNINGA("read %d samples\n", GSMOPEN_P_LOG, samples);
|
||||
}
|
||||
#endif // GSMOPEN_ALSA
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1301,23 +1257,15 @@ static switch_status_t load_config(int reload_type)
|
||||
const char *alsa_capture_is_mono = "1";
|
||||
const char *capture_boost = "0";
|
||||
const char *playback_boost = "0";
|
||||
#if defined(GSMOPEN_ALSA)
|
||||
const char *no_sound = "0";
|
||||
#else
|
||||
const char *no_sound = "0";
|
||||
#endif // defined(GSMOPEN_ALSA)
|
||||
const char *portaudiocindex = "1";
|
||||
const char *portaudiopindex = "1";
|
||||
const char *speexecho = "1";
|
||||
const char *speexpreprocess = "1";
|
||||
|
||||
uint32_t interface_id = 0;
|
||||
#ifdef WIN32
|
||||
int controldevice_speed = 115200; //FIXME TODO
|
||||
#else
|
||||
uint32_t controldevice_speed = B115200; //FIXME TODO
|
||||
uint32_t controldevice_audio_speed = B115200; //FIXME TODO
|
||||
#endif //WIN32
|
||||
int controldevice_audio_speed = 115200; //FIXME TODO
|
||||
uint32_t controldevprotocol = PROTOCOL_AT; //FIXME TODO
|
||||
uint32_t running = 1; //FIXME TODO
|
||||
const char *gsmopen_serial_sync_period = "300"; //FIXME TODO
|
||||
@ -1654,30 +1602,14 @@ static switch_status_t load_config(int reload_type)
|
||||
switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].at_indicator_callsetupremoteringing_string,
|
||||
at_indicator_callsetupremoteringing_string);
|
||||
//switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].sms_receiving_program, sms_receiving_program);
|
||||
#ifdef GSMOPEN_ALSA
|
||||
switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].alsacname, alsacname);
|
||||
switch_set_string(globals.GSMOPEN_INTERFACES[interface_id].alsapname, alsapname);
|
||||
#endif // GSMOPEN_ALSA
|
||||
|
||||
globals.GSMOPEN_INTERFACES[interface_id].at_early_audio = atoi(at_early_audio);
|
||||
globals.GSMOPEN_INTERFACES[interface_id].at_after_preinit_pause = atoi(at_after_preinit_pause);
|
||||
globals.GSMOPEN_INTERFACES[interface_id].at_initial_pause = atoi(at_initial_pause);
|
||||
globals.GSMOPEN_INTERFACES[interface_id].at_has_clcc = atoi(at_has_clcc);
|
||||
globals.GSMOPEN_INTERFACES[interface_id].at_has_ecam = atoi(at_has_ecam);
|
||||
#ifdef GSMOPEN_ALSA
|
||||
globals.GSMOPEN_INTERFACES[interface_id].alsa_period_size = atoi(alsa_period_size);
|
||||
globals.GSMOPEN_INTERFACES[interface_id].alsa_periods_in_buffer = atoi(alsa_periods_in_buffer);
|
||||
globals.GSMOPEN_INTERFACES[interface_id].gsmopen_sound_rate = atoi(gsmopen_sound_rate);
|
||||
globals.GSMOPEN_INTERFACES[interface_id].alsa_play_is_mono = atoi(alsa_play_is_mono);
|
||||
globals.GSMOPEN_INTERFACES[interface_id].alsa_capture_is_mono = atoi(alsa_capture_is_mono);
|
||||
#endif // GSMOPEN_ALSA
|
||||
globals.GSMOPEN_INTERFACES[interface_id].capture_boost = atoi(capture_boost);
|
||||
globals.GSMOPEN_INTERFACES[interface_id].playback_boost = atoi(playback_boost);
|
||||
#if defined(GSMOPEN_ALSA)
|
||||
globals.GSMOPEN_INTERFACES[interface_id].no_sound = atoi(no_sound);
|
||||
#else
|
||||
globals.GSMOPEN_INTERFACES[interface_id].no_sound = 0;
|
||||
#endif // defined(GSMOPEN_ALSA)
|
||||
globals.GSMOPEN_INTERFACES[interface_id].gsmopen_serial_sync_period = atoi(gsmopen_serial_sync_period);
|
||||
|
||||
globals.GSMOPEN_INTERFACES[interface_id].controldevice_speed = controldevice_speed; //FIXME
|
||||
@ -1693,11 +1625,6 @@ static switch_status_t load_config(int reload_type)
|
||||
DEBUGA_GSMOPEN("destination=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[interface_id].destination);
|
||||
DEBUGA_GSMOPEN("controldevice_name=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[interface_id].controldevice_name);
|
||||
DEBUGA_GSMOPEN("controldevice_audio_name=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[interface_id].controldevice_audio_name);
|
||||
#ifdef GSMOPEN_ALSA
|
||||
DEBUGA_GSMOPEN("alsacname=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[interface_id].alsacname);
|
||||
DEBUGA_GSMOPEN("alsapname=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[interface_id].alsapname);
|
||||
#endif // GSMOPEN_ALSA
|
||||
|
||||
DEBUGA_GSMOPEN("gsmopen_serial_sync_period=%d\n", GSMOPEN_P_LOG,
|
||||
(int) globals.GSMOPEN_INTERFACES[interface_id].gsmopen_serial_sync_period);
|
||||
|
||||
@ -1744,31 +1671,6 @@ static switch_status_t load_config(int reload_type)
|
||||
}
|
||||
|
||||
if (globals.GSMOPEN_INTERFACES[interface_id].no_sound == 0) {
|
||||
#ifdef GSMOPEN_ALSA
|
||||
if (alsa_init(&globals.GSMOPEN_INTERFACES[interface_id])) {
|
||||
ERRORA("alsa_init failed\n", GSMOPEN_P_LOG);
|
||||
ERRORA("STARTING interface_id=%d FAILED\n", GSMOPEN_P_LOG, interface_id);
|
||||
//return SWITCH_STATUS_FALSE;
|
||||
globals.GSMOPEN_INTERFACES[interface_id].running = 0;
|
||||
alarm_event(&globals.GSMOPEN_INTERFACES[interface_id], ALARM_FAILED_INTERFACE, "alsa_init failed");
|
||||
globals.GSMOPEN_INTERFACES[interface_id].active = 0;
|
||||
globals.GSMOPEN_INTERFACES[interface_id].name[0] = '\0';
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
if (alsa_shutdown(&globals.GSMOPEN_INTERFACES[interface_id])) {
|
||||
ERRORA("alsa_shutdown failed\n", GSMOPEN_P_LOG);
|
||||
ERRORA("STARTING interface_id=%d FAILED\n", GSMOPEN_P_LOG, interface_id);
|
||||
//return SWITCH_STATUS_FALSE;
|
||||
globals.GSMOPEN_INTERFACES[interface_id].running = 0;
|
||||
alarm_event(&globals.GSMOPEN_INTERFACES[interface_id], ALARM_FAILED_INTERFACE, "alsa_shutdown failed");
|
||||
globals.GSMOPEN_INTERFACES[interface_id].active = 0;
|
||||
globals.GSMOPEN_INTERFACES[interface_id].name[0] = '\0';
|
||||
continue;
|
||||
|
||||
}
|
||||
#endif // GSMOPEN_ALSA
|
||||
if (serial_audio_init(&globals.GSMOPEN_INTERFACES[interface_id])) {
|
||||
ERRORA("serial_audio_init failed\n", GSMOPEN_P_LOG);
|
||||
ERRORA("STARTING interface_id=%d FAILED\n", GSMOPEN_P_LOG, interface_id);
|
||||
@ -1833,10 +1735,6 @@ static switch_status_t load_config(int reload_type)
|
||||
DEBUGA_GSMOPEN("dialplan=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[i].dialplan);
|
||||
DEBUGA_GSMOPEN("destination=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[i].destination);
|
||||
DEBUGA_GSMOPEN("controldevice_name=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[i].controldevice_name);
|
||||
#ifdef GSMOPEN_ALSA
|
||||
DEBUGA_GSMOPEN("alsacname=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[i].alsacname);
|
||||
DEBUGA_GSMOPEN("alsapname=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[i].alsapname);
|
||||
#endif // GSMOPEN_ALSA
|
||||
DEBUGA_GSMOPEN("gsmopen_serial_sync_period=%d\n", GSMOPEN_P_LOG, (int) globals.GSMOPEN_INTERFACES[i].gsmopen_serial_sync_period);
|
||||
DEBUGA_GSMOPEN("controldevice_audio_name=%s\n", GSMOPEN_P_LOG, globals.GSMOPEN_INTERFACES[i].controldevice_audio_name);
|
||||
}
|
||||
@ -2554,10 +2452,6 @@ SWITCH_STANDARD_API(gsmopen_dump_function)
|
||||
stream->write_function(stream, "controldevice_name = %s\n", tech_pvt->controldevice_name);
|
||||
snprintf(value, sizeof(value) - 1, "%d", tech_pvt->no_sound);
|
||||
stream->write_function(stream, "no_sound = %s\n", value);
|
||||
#ifdef GSMOPEN_ALSA
|
||||
stream->write_function(stream, "alsacname = %s\n", tech_pvt->alsacname);
|
||||
stream->write_function(stream, "alsapname = %s\n", tech_pvt->alsapname);
|
||||
#endif // GSMOPEN_ALSA
|
||||
snprintf(value, sizeof(value) - 1, "%f", tech_pvt->playback_boost);
|
||||
stream->write_function(stream, "playback_boost = %s\n", value);
|
||||
snprintf(value, sizeof(value) - 1, "%f", tech_pvt->capture_boost);
|
||||
@ -2616,10 +2510,6 @@ SWITCH_STANDARD_API(gsmopen_dump_function)
|
||||
stream->write_function(stream, "controldevice_name = %s\n", tech_pvt->controldevice_name);
|
||||
snprintf(value, sizeof(value) - 1, "%d", tech_pvt->no_sound);
|
||||
stream->write_function(stream, "no_sound = %s\n", value);
|
||||
#ifdef GSMOPEN_ALSA
|
||||
stream->write_function(stream, "alsacname = %s\n", tech_pvt->alsacname);
|
||||
stream->write_function(stream, "alsapname = %s\n", tech_pvt->alsapname);
|
||||
#endif // GSMOPEN_ALSA
|
||||
snprintf(value, sizeof(value) - 1, "%f", tech_pvt->playback_boost);
|
||||
stream->write_function(stream, "playback_boost = %s\n", value);
|
||||
snprintf(value, sizeof(value) - 1, "%f", tech_pvt->capture_boost);
|
||||
@ -3015,10 +2905,6 @@ int dump_event_full(private_t *tech_pvt, int is_alarm, int alarm_code, const cha
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "controldevice_name", tech_pvt->controldevice_name);
|
||||
snprintf(value, sizeof(value) - 1, "%d", tech_pvt->no_sound);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "no_sound", value);
|
||||
#ifdef GSMOPEN_ALSA
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alsacname", tech_pvt->alsacname);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alsapname", tech_pvt->alsapname);
|
||||
#endif // GSMOPEN_ALSA
|
||||
snprintf(value, sizeof(value) - 1, "%f", tech_pvt->playback_boost);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "playback_boost", value);
|
||||
snprintf(value, sizeof(value) - 1, "%f", tech_pvt->capture_boost);
|
||||
|
Loading…
x
Reference in New Issue
Block a user