Rss Categories


Reference Number: AA-00730 Views: 1632 0 Rating/ Voters

Send data buffer of sound data to stream.


  • int LV_SRE_StreamSendData(HPORT hport, void* SoundData, int SoundDataLength)



The port's handle.


Pointer to the memory buffer containing the sound data.


Size of the sound data, in bytes.

Return Values


No errors; data accepted.


The input hport is not a valid one.


The operation failed because the port was shutting down.


The data was not accepted, likely because the port was not ready to receive data. Ensure that LV_SRE_StreamStart was called first.


An exception occurred while processing the request.


This function is used to do the actual streaming. Call it with each filled sound data buffer. This call copies sound data to an internal buffer and returns immediately. The processing of sound data takes place on a background thread.

C Code

  1. // Here, audio_length is the length of the audio file being streamed.
  2. // pStreamingUserData contains information about the given audio stream.
  3. unsigned char* audio_buffer = (unsigned char*)malloc(audio_length);
  4. unsigned char* CurrentPos = audio_buffer;
  5. int StreamedBytes = 0;
  6. int ChunkBytes = 2400;

  7. while (CurrentPos != (audio_buffer + audio_length))
  8. {
  9. if (pStreamingUserData->StopStreaming == true)
  10. pStreamingUserData->Streaming = -1;

  11. // Check to see if streaming has stopped; if so, break. Next, make sure
  12. // that you are not trying to send in more than the entire length of the
  13. // audio. Once these conditions are accounted for, then you can pass the
  14. // audio chunk to the ASR.
  15. SpeechPortReturnValue = LV_SRE_StreamSendData(
  16. pStreamingUserData->PortHandle, CurrentPos, ChunkBytes);

  17. // Sleep to allow streaming to finish.
  18. SLEEP_MS(ChunkBytes/8)

  19. // Make another check to see if streaming has stopped
  20. // Finally, append the amount we just passed to our total so far, and
  21. // move the current position accordingly
  22. StreamedBytes += ChunkBytes;
  23. CurrentPos += ChunkBytes;
  24. }

See Also