Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit aa5176e

Browse files
committedJan 13, 2017
cleanup ptt audio thread when application closed
1 parent 3b59838 commit aa5176e

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed
 

‎audio_ptt_win.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <io.h>
4141
#include <fcntl.h>
4242
#include <math.h>
43+
#include <limits.h>
4344

4445
#include <windows.h>
4546
#include <mmsystem.h>
@@ -115,13 +116,13 @@ unsigned __stdcall ptt_thread (void *arg)
115116

116117
if( save_audio_config_p->adev[a].num_channels == 1 ) {
117118
for( i = 0; i < nsamples; i++ ) {
118-
sample = (SHORT)( 32000.0 * sin( ( (double)i / (double)nsamples ) * 2.0 * M_PI ) );
119+
sample = (SHORT)( (double)SHRT_MAX * sin( ( (double)i / (double)nsamples ) * 2.0 * M_PI ) );
119120
pnData[i] = sample;
120121
}
121122
}
122123
else {
123124
for( i = 0; i < nsamples; i++ ) {
124-
sample = (SHORT)( 32000.0 * sin( ( (double)i / (double)nsamples ) * 2.0 * M_PI ) );
125+
sample = (SHORT)( (double)SHRT_MAX * sin( ( (double)i / (double)nsamples ) * 2.0 * M_PI ) );
125126
if( channel == ADEVFIRSTCHAN( a ) ) {
126127

127128
// Stereo, left channel.

‎config.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,12 @@ void config_init (char *fname, struct audio_s *p_audio_config,
668668
p_audio_config->achan[channel].octrl[ot].ptt_invert2 = 0;
669669
p_audio_config->achan[channel].octrl[ot].ptt_channel = 0;
670670
p_audio_config->achan[channel].octrl[ot].ptt_frequency = PTT_FREQ_DEFAULT;
671+
#ifdef __WIN32__
672+
p_audio_config->achan[channel].octrl[ot].ptt_start = NULL;
673+
p_audio_config->achan[channel].octrl[ot].ptt_stop = NULL;
674+
p_audio_config->achan[channel].octrl[ot].ptt_close = NULL;
675+
#else
676+
#endif
671677
}
672678

673679
p_audio_config->achan[channel].dwait = DEFAULT_DWAIT;

‎ptt.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,18 +1008,24 @@ void ptt_set (int ot, int chan, int ptt_signal)
10081008
}
10091009
#endif
10101010

1011+
/*
1012+
* Using audio channel?
1013+
*/
1014+
10111015
if( save_audio_config_p->achan[chan].octrl[ot].ptt_method == PTT_METHOD_AUDIO ) {
10121016
if( ptt_signal ) {
10131017
#ifdef __WIN32__
10141018
SetEvent( save_audio_config_p->achan[chan].octrl[ot].ptt_start );
10151019
#else
1020+
10161021
#endif
10171022
}
10181023
else
10191024
{
10201025
#ifdef __WIN32__
10211026
SetEvent( save_audio_config_p->achan[chan].octrl[ot].ptt_stop );
10221027
#else
1028+
10231029
#endif
10241030
}
10251031
}
@@ -1110,7 +1116,7 @@ void ptt_term (void)
11101116
ptt_set (ot, n, 0);
11111117
}
11121118
}
1113-
}
1119+
}
11141120

11151121
for (n = 0; n < MAX_CHANS; n++) {
11161122
if (save_audio_config_p->achan[n].valid) {
@@ -1128,6 +1134,16 @@ void ptt_term (void)
11281134
}
11291135
}
11301136

1137+
for (n = 0; n < MAX_CHANS; n++) {
1138+
if (save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_method == PTT_METHOD_AUDIO) {
1139+
#ifdef __WIN32__
1140+
SetEvent (save_audio_config_p->achan[n].octrl[OCTYPE_PTT].ptt_close) ;
1141+
#else
1142+
1143+
#endif
1144+
}
1145+
}
1146+
11311147
#ifdef USE_HAMLIB
11321148

11331149
for (n = 0; n < MAX_CHANS; n++) {

0 commit comments

Comments
 (0)
Please sign in to comment.