diff --git a/DSP_API/SmartSDR_Interface/sched_waveform.c b/DSP_API/SmartSDR_Interface/sched_waveform.c index 9d32fe6..e625841 100644 --- a/DSP_API/SmartSDR_Interface/sched_waveform.c +++ b/DSP_API/SmartSDR_Interface/sched_waveform.c @@ -485,6 +485,7 @@ static void * _sched_waveform_thread( void * param ) { memset( float_in_24k, 0, MEM_24 * sizeof( float ) ); memset( float_in_8k, 0, MEM_8 * sizeof( float ) ); + thumbDV_flushLists(); /* Requires us to set initial_rx to FALSE which we do at the end of * the first loop */ @@ -582,6 +583,8 @@ static void * _sched_waveform_thread( void * param ) { memset( tx_float_in_24k, 0, MEM_24 * sizeof( float ) ); memset( tx_float_in_8k, 0, MEM_8 * sizeof( float ) ); + thumbDV_flushLists(); + /* Requires us to set initial_rx to FALSE which we do at the end of * the first loop */ diff --git a/DSP_API/ThumbDV/thumbDV.c b/DSP_API/ThumbDV/thumbDV.c index 0ce1b3a..173ea18 100644 --- a/DSP_API/ThumbDV/thumbDV.c +++ b/DSP_API/ThumbDV/thumbDV.c @@ -76,7 +76,7 @@ static pthread_t _read_thread; BOOL _readThreadAbort = FALSE; -static uint32 _buffering_target = 4; +static uint32 _buffering_target = 1; static pthread_rwlock_t _encoded_list_lock; static BufferDescriptor _encoded_root; @@ -218,6 +218,26 @@ static void delay( unsigned int delay ) { nanosleep( &tim, &tim2 ); }; +void thumbDV_flushLists(void) +{ + BufferDescriptor buf_desc = NULL; + + do + { + buf_desc = _thumbDVEncodedList_UnlinkHead(); + if ( buf_desc != NULL ) + hal_BufferRelease(&buf_desc); + } while (buf_desc != NULL ); + + + do + { + buf_desc = _thumbDVDecodedList_UnlinkHead(); + if ( buf_desc != NULL ) + hal_BufferRelease(&buf_desc); + } while (buf_desc != NULL ); +} + void thumbDV_dump( char * text, unsigned char * data, unsigned int length ) { unsigned int offset = 0U; unsigned int i; @@ -555,7 +575,8 @@ int thumbDV_decode( int serial_fd, unsigned char * packet_in, short * speech_out if ( samples_returned != 160 ) output( "Rate Mismatch expected %d got %d\n", 160, samples_returned ); - safe_free( desc ); +// safe_free( desc ); + hal_BufferRelease(&desc); } else { /* Do nothing for now */ } @@ -622,7 +643,8 @@ int thumbDV_encode( int serial_fd, short * speech_in, unsigned char * packet_out if ( desc != NULL ) { memcpy( packet_out, desc->buf_ptr + 6, desc->sample_size * ( desc->num_samples - 6 ) ); samples_returned = desc->num_samples - 6; - safe_free( desc ); + //safe_free( desc ); + hal_BufferRelease(&desc); //thumbDV_dump(ANSI_BLUE "Coded Packet" ANSI_WHITE, packet_out, desc->num_samples - 6); } else { diff --git a/DSP_API/ThumbDV/thumbDV.h b/DSP_API/ThumbDV/thumbDV.h index aa19dd4..6241e78 100644 --- a/DSP_API/ThumbDV/thumbDV.h +++ b/DSP_API/ThumbDV/thumbDV.h @@ -44,4 +44,5 @@ int thumbDV_encode( int serial_fd, short * speech_in, unsigned char * packet_out int thumbDV_decode( int serial_fd, unsigned char * packet_in, short * speech_out, uint8 bytes_in_packet ); void thumbDV_dump( char * text, unsigned char * data, unsigned int length ); +void thumbDV_flushLists(void); #endif /* THUMBDV_THUMBDV_ */