From 7685502c9bddfd8601ea7dea6e2a2aee5e59a033 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 17 Jan 2017 13:18:14 -0800 Subject: [PATCH] reduce phase shiift between subsequent tone buffers --- audio_ptt.c | 4 ++-- config.c | 2 +- ptt.c | 14 ++++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/audio_ptt.c b/audio_ptt.c index 4c6a3bc..5188ac9 100644 --- a/audio_ptt.c +++ b/audio_ptt.c @@ -106,7 +106,7 @@ static void * ptt_thread (void *arg) if (err == 0) { short* pnData; short sample; - int nSamples = save_audio_config_p->adev[a].samples_per_sec / 5; + int nSamples = (int)( ( (double)save_audio_config_p->adev[a].samples_per_sec / (double)freq ) * ceil( (double)freq / 5.0 ) ); int nBufferLength = save_audio_config_p->adev[a].num_channels * nSamples * sizeof(short); int i; int j; @@ -198,7 +198,7 @@ static void * ptt_thread (void *arg) int i; int j; - nSamples = samples_per_sec / 5; + nSamples = (int)( ( (double)samples_per_sec / (double)freq ) * ceil( (double)freq / 5.0 ) ); nBufferLength = num_channels * nSamples * sizeof(short); pnData = (short*)malloc (nBufferLength); diff --git a/config.c b/config.c index 363d9de..166c438 100644 --- a/config.c +++ b/config.c @@ -1591,7 +1591,7 @@ void config_init (char *fname, struct audio_s *p_audio_config, dw_printf ("Config file line %d: %s with RIG is only available when hamlib support is enabled.\n", line, otname); #endif } - else if (strcasecmp( t, "CHANNEL") == 0) { + else if (strcasecmp(t, "CHANNEL") == 0) { t = split(NULL, 0); if (t == NULL) { text_color_set( DW_COLOR_ERROR ); diff --git a/ptt.c b/ptt.c index bec7a97..5ccd71b 100644 --- a/ptt.c +++ b/ptt.c @@ -1138,15 +1138,17 @@ void ptt_term (void) } for (n = 0; n < MAX_CHANS; n++) { - if (save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_method == PTT_METHOD_AUDIO) { + if (save_audio_config_p->achan[n].valid) { + if (save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_method == PTT_METHOD_AUDIO) { #ifdef __WIN32__ - SetEvent (save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_close) ; + SetEvent (save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_close) ; #else - pthread_mutex_lock (&save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_mutex); - save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_state = PTT_AUDIO_STATE_CLOSE; - pthread_cond_signal (&save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_condition); - pthread_mutex_unlock (&save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_mutex); + pthread_mutex_lock (&save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_mutex); + save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_state = PTT_AUDIO_STATE_CLOSE; + pthread_cond_signal (&save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_condition); + pthread_mutex_unlock (&save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_mutex); #endif + } } }