Advertisement
Hemirt

Untitled

Sep 10th, 2017
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. void ts3plugin_onEditPlaybackVoiceDataEvent(uint64 serverConnectionHandlerID, anyID clientID, short* samples, int sampleCount, int channels) {
  2.     // todo:
  3.     // - handle endianess
  4.     // - add packet sequence number
  5.     // - handle overflow (maybe)
  6.  
  7.     int sampleLen = sampleCount * sizeof(short) * channels;
  8.     int bufLen = 1 + sampleLen;
  9.  
  10.     char *buf = (char *)malloc(bufLen);
  11.  
  12.     if (buf != NULL) {
  13.         buf[0] = channels;
  14.         memcpy(buf + 1, (char *)samples, sampleLen);
  15.  
  16.         sendto(sock, (char *)buf, bufLen, 0, (struct sockaddr *)&serverAddr, sizeof(serverAddr));
  17.  
  18.         free(buf);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement