mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-20 21:53:12 +00:00
Fix -Wsign-compare warnings in VoMP code
This commit is contained in:
parent
b7528412df
commit
dea46d0d8b
2
serval.h
2
serval.h
@ -569,7 +569,7 @@ struct vomp_call_state;
|
||||
void set_codec_flag(int codec, unsigned char *flags);
|
||||
int is_codec_set(int codec, unsigned char *flags);
|
||||
|
||||
struct vomp_call_state *vomp_find_call_by_session(int session_token);
|
||||
struct vomp_call_state *vomp_find_call_by_session(unsigned int session_token);
|
||||
int vomp_mdp_received(overlay_mdp_frame *mdp);
|
||||
int vomp_parse_dtmf_digit(char c);
|
||||
int vomp_dial(struct subscriber *local, struct subscriber *remote, const char *local_did, const char *remote_did);
|
||||
|
38
vomp.c
38
vomp.c
@ -172,7 +172,7 @@ struct vomp_call_state {
|
||||
time_ms_t create_time;
|
||||
time_ms_t last_activity;
|
||||
time_ms_t audio_clock;
|
||||
int remote_audio_clock;
|
||||
unsigned remote_audio_clock;
|
||||
|
||||
// last local & remote status we sent to all interested parties
|
||||
int last_sent_status;
|
||||
@ -330,7 +330,7 @@ int is_codec_set(int codec, unsigned char *flags){
|
||||
return flags[codec >> 3] & (1<<(codec & 7));
|
||||
}
|
||||
|
||||
struct vomp_call_state *vomp_find_call_by_session(int session_token)
|
||||
struct vomp_call_state *vomp_find_call_by_session(unsigned int session_token)
|
||||
{
|
||||
unsigned i;
|
||||
for(i=0;i<vomp_call_count;i++)
|
||||
@ -341,10 +341,10 @@ struct vomp_call_state *vomp_find_call_by_session(int session_token)
|
||||
|
||||
static int vomp_generate_session_id()
|
||||
{
|
||||
int session_id=0;
|
||||
unsigned int session_id=0;
|
||||
while (!session_id)
|
||||
{
|
||||
if (urandombytes((unsigned char *)&session_id,sizeof(int)))
|
||||
if (urandombytes((unsigned char *)&session_id, sizeof session_id))
|
||||
return WHY("Insufficient entropy");
|
||||
session_id&=VOMP_SESSION_MASK;
|
||||
if (config.debug.vomp) DEBUGF("session=0x%08x",session_id);
|
||||
@ -697,35 +697,33 @@ static int vomp_update(struct vomp_call_state *call)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int to_absolute_value(int short_value, int reference_value){
|
||||
short_value = (reference_value & 0xFFFF0000) | short_value;
|
||||
|
||||
if (short_value + 0x8000 < reference_value)
|
||||
short_value+=0x10000;
|
||||
|
||||
if (short_value > reference_value + 0x8000)
|
||||
short_value-=0x10000;
|
||||
|
||||
return short_value;
|
||||
static uint32_t to_absolute_value(uint16_t short_value, unsigned int reference_value)
|
||||
{
|
||||
uint32_t abs_value = (reference_value & 0xFFFF0000) | short_value;
|
||||
if (abs_value + 0x8000 < reference_value)
|
||||
abs_value += 0x10000;
|
||||
if (abs_value > reference_value + 0x8000)
|
||||
abs_value -= 0x10000;
|
||||
return abs_value;
|
||||
}
|
||||
|
||||
static int vomp_process_audio(struct vomp_call_state *call, overlay_mdp_frame *mdp, time_ms_t now)
|
||||
{
|
||||
int ofs=6;
|
||||
size_t ofs=6;
|
||||
|
||||
if(ofs>=mdp->in.payload_length)
|
||||
return 0;
|
||||
|
||||
int codec=mdp->in.payload[ofs++];
|
||||
|
||||
int time = mdp->in.payload[ofs]<<8 | mdp->in.payload[ofs+1]<<0;
|
||||
uint16_t time = mdp->in.payload[ofs]<<8 | mdp->in.payload[ofs+1]<<0;
|
||||
ofs+=2;
|
||||
int sequence = mdp->in.payload[ofs]<<8 | mdp->in.payload[ofs+1]<<0;
|
||||
uint16_t sequence = mdp->in.payload[ofs]<<8 | mdp->in.payload[ofs+1]<<0;
|
||||
ofs+=2;
|
||||
|
||||
// rebuild absolute time value from short relative time.
|
||||
int decoded_time = to_absolute_value(time, call->remote_audio_clock);
|
||||
int decoded_sequence = to_absolute_value(sequence, call->remote.sequence);
|
||||
uint32_t decoded_time = to_absolute_value(time, call->remote_audio_clock);
|
||||
uint32_t decoded_sequence = to_absolute_value(sequence, call->remote.sequence);
|
||||
|
||||
if (call->remote_audio_clock < decoded_time &&
|
||||
call->remote.sequence < decoded_sequence){
|
||||
@ -733,7 +731,7 @@ static int vomp_process_audio(struct vomp_call_state *call, overlay_mdp_frame *m
|
||||
call->remote.sequence = decoded_sequence;
|
||||
}else if (call->remote_audio_clock < decoded_time ||
|
||||
call->remote.sequence < decoded_sequence){
|
||||
WARNF("Mismatch while decoding sequence and time offset (%d, %d) + (%d, %d) = (%d, %d)",
|
||||
WARNF("Mismatch while decoding sequence and time offset (%u, %u) + (%u, %u) = (%u, %u)",
|
||||
time, sequence,
|
||||
call->remote_audio_clock, call->remote.sequence,
|
||||
decoded_time, decoded_sequence);
|
||||
|
Loading…
Reference in New Issue
Block a user