Send data buffer of sound data to stream.
- int StreamSendData(void* SoundData, int SoundDataLength)
Pointer to the memory buffer containing the sound data.
Size of the sound data, in bytes.
No errors; data accepted.
The data was not accepted, likely because the port was not ready to receive data. Ensure that StreamStart was called first.
The port is not valid (either CreateClient has not been called or DestroyClient has been called prior to this call).
The operation failed because the port was shutting down.
An exception occurred while processing the request.
This function is used to do the actual streaming. Call it with each filled sound data buffer, in a function similar to the one below. This call copies sound data to an internal buffer and returns immediately. The processing of sound data takes place on a background thread.
void StreamAudio(LVSpeechPort port)
int single_chunk = 160;
int audio_processed = 0;
current pos = audio_buffer;
while(current_pos < audio_buffer + audio_size)
- // If the next iteration would bring the audio stream past
- // the end of the buffer, set the amount to be streamed
- // equal to the remaining space in the buffer.
- if((audio_processed + single_chunk) > audio_size)
single_chunk = audio_size - audio_processed;
- // Send data to the voicechannel and increment the current position.
- port.StreamSendData(current_pos, single_chunk);
- current_pos += single_chunk;
- audio_processed += single_chunk;
- Sleep((DWORD)(single_chunk / 8))