mirror of
https://github.com/n5ac/smartsdr-dsp.git
synced 2026-04-21 06:03:49 +00:00
Always unlink from decoded list if there is data
This commit is contained in:
parent
7e645fdf4c
commit
d9b13d69dc
3 changed files with 46 additions and 26 deletions
|
|
@ -519,12 +519,20 @@ static void * _sched_waveform_thread( void * param ) {
|
|||
}
|
||||
|
||||
if ( ambe_packet_out == TRUE ) {
|
||||
thumbDV_decode( _dv_serial_handle, ambe_out, DV_PACKET_SAMPLES );
|
||||
}
|
||||
|
||||
if ( thumbDV_getDecodeListBuffering() == FALSE)
|
||||
{
|
||||
// There is something in the decoded list - fetch audio
|
||||
nout = 0;
|
||||
nout = thumbDV_decode( _dv_serial_handle, ambe_out, speech_out, DV_PACKET_SAMPLES );
|
||||
nout = thumbDV_unlinkAudio(speech_out);
|
||||
uint32 j = 0;
|
||||
|
||||
for ( j = 0 ; j < nout ; j++ )
|
||||
{
|
||||
cbWriteShort( RX3_cb, speech_out[j] );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,6 +212,11 @@ static void _thumbDVDecodedList_LinkTail( BufferDescriptor buf_desc ) {
|
|||
pthread_rwlock_unlock( &_decoded_list_lock );
|
||||
}
|
||||
|
||||
BOOL thumbDV_getDecodeListBuffering(void)
|
||||
{
|
||||
return _decoded_buffering;
|
||||
}
|
||||
|
||||
static void delay( unsigned int delay ) {
|
||||
struct timespec tim, tim2;
|
||||
tim.tv_sec = 0;
|
||||
|
|
@ -548,30 +553,8 @@ int thumbDV_processSerial( FT_HANDLE handle )
|
|||
return FT_OK;
|
||||
}
|
||||
|
||||
int thumbDV_decode( FT_HANDLE handle, unsigned char * packet_in, short * speech_out, uint8 bytes_in_packet ) {
|
||||
uint32 i = 0;
|
||||
|
||||
unsigned char full_packet[15] = {0};
|
||||
|
||||
if ( packet_in != NULL && handle != NULL ) {
|
||||
full_packet[0] = 0x61;
|
||||
full_packet[1] = 0x00;
|
||||
full_packet[2] = 0x0B;
|
||||
full_packet[3] = 0x01;
|
||||
full_packet[4] = 0x01;
|
||||
full_packet[5] = 0x48;
|
||||
uint32 j = 0;
|
||||
|
||||
for ( i = 0, j = 8 ; i < 9 ; i++ , j-- ) {
|
||||
full_packet[i + 6] = packet_in[i];
|
||||
}
|
||||
|
||||
// thumbDV_dump("Just AMBE", packet_in, 9);
|
||||
// thumbDV_dump("Encoded packet:", full_packet, 15);
|
||||
thumbDV_writeSerial( handle, full_packet, 15 );
|
||||
sem_post(&_read_sem);
|
||||
}
|
||||
|
||||
int thumbDV_unlinkAudio(short * speech_out)
|
||||
{
|
||||
int32 samples_returned = 0;
|
||||
BufferDescriptor desc = _thumbDVDecodedList_UnlinkHead();
|
||||
uint32 samples_in_speech_packet = 0;
|
||||
|
|
@ -607,6 +590,31 @@ int thumbDV_decode( FT_HANDLE handle, unsigned char * packet_in, short * speech_
|
|||
return samples_returned;
|
||||
}
|
||||
|
||||
void thumbDV_decode( FT_HANDLE handle, unsigned char * packet_in, uint8 bytes_in_packet ) {
|
||||
uint32 i = 0;
|
||||
|
||||
unsigned char full_packet[15] = {0};
|
||||
|
||||
if ( packet_in != NULL && handle != NULL ) {
|
||||
full_packet[0] = 0x61;
|
||||
full_packet[1] = 0x00;
|
||||
full_packet[2] = 0x0B;
|
||||
full_packet[3] = 0x01;
|
||||
full_packet[4] = 0x01;
|
||||
full_packet[5] = 0x48;
|
||||
uint32 j = 0;
|
||||
|
||||
for ( i = 0, j = 8 ; i < 9 ; i++ , j-- ) {
|
||||
full_packet[i + 6] = packet_in[i];
|
||||
}
|
||||
|
||||
// thumbDV_dump("Just AMBE", packet_in, 9);
|
||||
// thumbDV_dump("Encoded packet:", full_packet, 15);
|
||||
thumbDV_writeSerial( handle, full_packet, 15 );
|
||||
sem_post(&_read_sem);
|
||||
}
|
||||
}
|
||||
|
||||
int thumbDV_encode( FT_HANDLE handle, short * speech_in, unsigned char * packet_out, uint8 num_of_samples )
|
||||
{
|
||||
unsigned char packet[THUMBDV_MAX_PACKET_LEN];
|
||||
|
|
@ -776,6 +784,7 @@ static void * _thumbDV_readThread( void * param )
|
|||
sem_wait(&_read_sem);
|
||||
|
||||
ret = thumbDV_processSerial(handle);
|
||||
//TODO Handle reconnection
|
||||
// if ( ret != FT_OK )
|
||||
// {
|
||||
// fprintf( stderr, "ThumbDV: error from status, status=%d\n", ret );
|
||||
|
|
|
|||
|
|
@ -43,8 +43,11 @@ FT_HANDLE thumbDV_openSerial( FT_DEVICE_LIST_INFO_NODE device );
|
|||
int thumbDV_processSerial( FT_HANDLE handle );
|
||||
|
||||
int thumbDV_encode( FT_HANDLE handle, short * speech_in, unsigned char * packet_out, uint8 num_of_samples );
|
||||
int thumbDV_decode( FT_HANDLE handle, unsigned char * packet_in, short * speech_out, uint8 bytes_in_packet );
|
||||
void thumbDV_decode( FT_HANDLE handle, unsigned char * packet_in, uint8 bytes_in_packet );
|
||||
|
||||
void thumbDV_dump( char * text, unsigned char * data, unsigned int length );
|
||||
void thumbDV_flushLists(void);
|
||||
|
||||
BOOL thumbDV_getDecodeListBuffering(void);
|
||||
int thumbDV_unlinkAudio(short * speech_out);
|
||||
#endif /* THUMBDV_THUMBDV_ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue