SHARE
TWEET

TS3 plugin processCustomCaptureData

a guest Mar 10th, 2016 295 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. void ts3plugin_onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int newStatus, unsigned int errorNumber) {
  3.     /* Some example code following to show how to use the information query functions. */
  4.  
  5.     connection = serverConnectionHandlerID;
  6.     ... // irrelevant code omitted
  7. }
  8. int ts3plugin_init() {
  9.  
  10.     ... // irrelevant code omitted
  11.     // copied from the clientSDK example
  12. if (!readWave("c:\\Program Files\\TeamSpeak 3 Client\\plugins\\welcome_to_teamspeak.wav", &captureFrequency, &captureChannels, &captureBuffer, &buffer_size, &captureBufferSamples)) {
  13.         cout << "readWave failed";
  14.         return 1;
  15.     }
  16.  
  17.     unsigned int error;
  18.     if ((error = ts3Functions.registerCustomDevice(myDeviceId, "Nice displayable wave device name", captureFrequency, captureChannels, PLAYBACK_FREQUENCY, PLAYBACK_CHANNELS)) != ERROR_ok) {
  19.         char* errormsg;
  20.         if (ts3Functions.getErrorMessage(error, &errormsg) == ERROR_ok) {
  21.             printf("Error registering custom sound device: %s\n", errormsg);
  22.             ts3Functions.freeMemory(errormsg);
  23.             MessageBoxA(0, "Error registering custom sound device", 0, 0);
  24.         }
  25.     }
  26.     return 0;
  27. }
  28.  
  29. void SomeCallbackFunction() {
  30.     if ((error = ts3Functions.openPlaybackDevice(connection, "custom", myDeviceId)) != ERROR_ok) {
  31.         printf("Error opening playback device: 0x%x\n", error);
  32.     }
  33.     ts3Functions.activateCaptureDevice(connection);
  34.  
  35.     capturePeriodSize = (captureFrequency * 20) / 1000;
  36.     //playbackPeriodSize = (PLAYBACK_FREQUENCY * 20) / 1000;
  37.  
  38.     int captureAudioOffset = 0;
  39.     //playbackAudioOffset = 0;
  40.     for (audioPeriodCounter = 0; audioPeriodCounter < 50 * AUDIO_PROCESS_SECONDS; ++audioPeriodCounter) { /*50*20=1000*/
  41.  
  42.  
  43.         /* make sure we dont stream past the end of our wave sample */
  44.         if (captureAudioOffset + capturePeriodSize > captureBufferSamples) {
  45.             captureAudioOffset = 0;
  46.             break;
  47.         }
  48.  
  49.         SLEEP(20);
  50.  
  51.         /* stream capture data to the client lib */
  52.         if ((error = ts3Functions.processCustomCaptureData(myDeviceId, captureBuffer + captureAudioOffset*captureChannels, capturePeriodSize)) != ERROR_ok) {
  53.             printf("Failed to get stream capture data: %d\n", error);
  54.             return 1;
  55.         }
  56.  
  57.  
  58.         /*update buffer offsets */
  59.         captureAudioOffset += capturePeriodSize;
  60.        
  61.     }
  62.  
  63.  
  64.     if ((error = ts3Functions.closePlaybackDevice(connection) != ERROR_ok)) {
  65.         printf("Error closePlaybackDevice: 0x%x\n", error);
  66.         return 1;
  67.     }
  68.  
  69. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top