Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ts3plugin_onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int newStatus, unsigned int errorNumber) {
- /* Some example code following to show how to use the information query functions. */
- connection = serverConnectionHandlerID;
- ... // irrelevant code omitted
- }
- int ts3plugin_init() {
- ... // irrelevant code omitted
- // copied from the clientSDK example
- if (!readWave("c:\\Program Files\\TeamSpeak 3 Client\\plugins\\welcome_to_teamspeak.wav", &captureFrequency, &captureChannels, &captureBuffer, &buffer_size, &captureBufferSamples)) {
- cout << "readWave failed";
- return 1;
- }
- unsigned int error;
- if ((error = ts3Functions.registerCustomDevice(myDeviceId, "Nice displayable wave device name", captureFrequency, captureChannels, PLAYBACK_FREQUENCY, PLAYBACK_CHANNELS)) != ERROR_ok) {
- char* errormsg;
- if (ts3Functions.getErrorMessage(error, &errormsg) == ERROR_ok) {
- printf("Error registering custom sound device: %s\n", errormsg);
- ts3Functions.freeMemory(errormsg);
- MessageBoxA(0, "Error registering custom sound device", 0, 0);
- }
- }
- return 0;
- }
- void SomeCallbackFunction() {
- if ((error = ts3Functions.openPlaybackDevice(connection, "custom", myDeviceId)) != ERROR_ok) {
- printf("Error opening playback device: 0x%x\n", error);
- }
- ts3Functions.activateCaptureDevice(connection);
- capturePeriodSize = (captureFrequency * 20) / 1000;
- //playbackPeriodSize = (PLAYBACK_FREQUENCY * 20) / 1000;
- int captureAudioOffset = 0;
- //playbackAudioOffset = 0;
- for (audioPeriodCounter = 0; audioPeriodCounter < 50 * AUDIO_PROCESS_SECONDS; ++audioPeriodCounter) { /*50*20=1000*/
- /* make sure we dont stream past the end of our wave sample */
- if (captureAudioOffset + capturePeriodSize > captureBufferSamples) {
- captureAudioOffset = 0;
- break;
- }
- SLEEP(20);
- /* stream capture data to the client lib */
- if ((error = ts3Functions.processCustomCaptureData(myDeviceId, captureBuffer + captureAudioOffset*captureChannels, capturePeriodSize)) != ERROR_ok) {
- printf("Failed to get stream capture data: %d\n", error);
- return 1;
- }
- /*update buffer offsets */
- captureAudioOffset += capturePeriodSize;
- }
- if ((error = ts3Functions.closePlaybackDevice(connection) != ERROR_ok)) {
- printf("Error closePlaybackDevice: 0x%x\n", error);
- return 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement