Skip to content

Commit

Permalink
Added support for larger varint's (Potential fix for #19)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkacjios committed May 24, 2021
1 parent 855048c commit ff421ab
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ int util_set_varint(uint8_t buffer[], const uint64_t value)
buffer[0] = (value >> 8) | 0x80;
buffer[1] = value & 0xFF;
return 2;
} else if (value < 0x200000) {
buffer[0] = (value >> 16) | 0xC0;
buffer[1] = (value >> 8) & 0xFF;
buffer[2] = value & 0xFF;
return 3;
} else if (value < 0x10000000) {
buffer[0] = (value >> 24) | 0xE0;
buffer[1] = (value >> 16) & 0xFF;
buffer[2] = (value >> 8) & 0xFF;
buffer[3] = value & 0xFF;
return 4;
} else if (value < 0x100000000) {
buffer[0] = 0xF0;
buffer[1] = (value >> 24) | 0xFF;
buffer[2] = (value >> 16) & 0xFF;
buffer[3] = (value >> 8) & 0xFF;
buffer[4] = value & 0xFF;
return 5;
}
return -1;
}
Expand Down

3 comments on commit ff421ab

@hbeni
Copy link

@hbeni hbeni commented on ff421ab May 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you miss the line 251 client->audio_sequence = (client->audio_sequence + 1) % 1000; on purpose here?

@bkacjios
Copy link
Owner Author

@bkacjios bkacjios commented on ff421ab May 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I did, this is just a more complex fix for the issue. This bit of code allows it to write a number above the value 0x4000, which audio_sequence is doing. Setting it to 1000 is just a more simple fix. :P

@bkacjios
Copy link
Owner Author

@bkacjios bkacjios commented on ff421ab May 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use a similar value in my LuaJit/FFI implementation of this module which fully implements mumble varint's as well, and I've had audio playing for hours on end without issue.

https://github.com/bkacjios/Lumble/blob/a56ac08e81ee9634cbcab2d89a240f108f7c910b/modules/lumble/client/init.lua#L750
https://github.com/bkacjios/Lumble/blob/a56ac08e81ee9634cbcab2d89a240f108f7c910b/modules/buffer.lua#L231

This is basically just a backport.

Please sign in to comment.