cleanup ptt audio thread when application closed

This commit is contained in:
Andrew 2017-01-12 22:57:53 -08:00
parent 3b59838237
commit aa5176e7b4
3 changed files with 26 additions and 3 deletions

View File

@ -40,6 +40,7 @@
#include <io.h> #include <io.h>
#include <fcntl.h> #include <fcntl.h>
#include <math.h> #include <math.h>
#include <limits.h>
#include <windows.h> #include <windows.h>
#include <mmsystem.h> #include <mmsystem.h>
@ -115,13 +116,13 @@ unsigned __stdcall ptt_thread (void *arg)
if( save_audio_config_p->adev[a].num_channels == 1 ) { if( save_audio_config_p->adev[a].num_channels == 1 ) {
for( i = 0; i < nsamples; i++ ) { for( i = 0; i < nsamples; i++ ) {
sample = (SHORT)( 32000.0 * sin( ( (double)i / (double)nsamples ) * 2.0 * M_PI ) ); sample = (SHORT)( (double)SHRT_MAX * sin( ( (double)i / (double)nsamples ) * 2.0 * M_PI ) );
pnData[i] = sample; pnData[i] = sample;
} }
} }
else { else {
for( i = 0; i < nsamples; i++ ) { for( i = 0; i < nsamples; i++ ) {
sample = (SHORT)( 32000.0 * sin( ( (double)i / (double)nsamples ) * 2.0 * M_PI ) ); sample = (SHORT)( (double)SHRT_MAX * sin( ( (double)i / (double)nsamples ) * 2.0 * M_PI ) );
if( channel == ADEVFIRSTCHAN( a ) ) { if( channel == ADEVFIRSTCHAN( a ) ) {
// Stereo, left channel. // Stereo, left channel.

View File

@ -668,6 +668,12 @@ void config_init (char *fname, struct audio_s *p_audio_config,
p_audio_config->achan[channel].octrl[ot].ptt_invert2 = 0; p_audio_config->achan[channel].octrl[ot].ptt_invert2 = 0;
p_audio_config->achan[channel].octrl[ot].ptt_channel = 0; p_audio_config->achan[channel].octrl[ot].ptt_channel = 0;
p_audio_config->achan[channel].octrl[ot].ptt_frequency = PTT_FREQ_DEFAULT; p_audio_config->achan[channel].octrl[ot].ptt_frequency = PTT_FREQ_DEFAULT;
#ifdef __WIN32__
p_audio_config->achan[channel].octrl[ot].ptt_start = NULL;
p_audio_config->achan[channel].octrl[ot].ptt_stop = NULL;
p_audio_config->achan[channel].octrl[ot].ptt_close = NULL;
#else
#endif
} }
p_audio_config->achan[channel].dwait = DEFAULT_DWAIT; p_audio_config->achan[channel].dwait = DEFAULT_DWAIT;

16
ptt.c
View File

@ -1008,11 +1008,16 @@ void ptt_set (int ot, int chan, int ptt_signal)
} }
#endif #endif
/*
* Using audio channel?
*/
if( save_audio_config_p->achan[chan].octrl[ot].ptt_method == PTT_METHOD_AUDIO ) { if( save_audio_config_p->achan[chan].octrl[ot].ptt_method == PTT_METHOD_AUDIO ) {
if( ptt_signal ) { if( ptt_signal ) {
#ifdef __WIN32__ #ifdef __WIN32__
SetEvent( save_audio_config_p->achan[chan].octrl[ot].ptt_start ); SetEvent( save_audio_config_p->achan[chan].octrl[ot].ptt_start );
#else #else
#endif #endif
} }
else else
@ -1020,6 +1025,7 @@ void ptt_set (int ot, int chan, int ptt_signal)
#ifdef __WIN32__ #ifdef __WIN32__
SetEvent( save_audio_config_p->achan[chan].octrl[ot].ptt_stop ); SetEvent( save_audio_config_p->achan[chan].octrl[ot].ptt_stop );
#else #else
#endif #endif
} }
} }
@ -1128,6 +1134,16 @@ 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) {
#ifdef __WIN32__
SetEvent (save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_close) ;
#else
#endif
}
}
#ifdef USE_HAMLIB #ifdef USE_HAMLIB
for (n = 0; n < MAX_CHANS; n++) { for (n = 0; n < MAX_CHANS; n++) {