Guest User

Untitled

a guest
Apr 24th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. int AudioSink::CopyData(const BYTE* Data, const int NumFramesAvailable)
  2. {
  3. // Data is the ppData returned pointer from IAudioCaptureClient::GetBuffer
  4.  
  5. std::lock_guard<std::mutex> lock(m_mutex);
  6.  
  7. AudioChunk chunk;
  8. if (Data == NULL)
  9. {
  10. chunk.size = 0;
  11. m_queue.push(chunk);
  12. return 0;
  13. }
  14.  
  15. // ***** WHAT'S GOING ON HERE *******
  16. chunk.size = NumFramesAvailable * 2;
  17. chunk.chunk = new int16[chunk.size];
  18. int multiplier = sizeof(int16) / sizeof(unsigned char);
  19. std::memcpy(chunk.chunk, Data, chunk.size * multiplier);
  20. bool nonZero = false;
  21.  
  22. for (int i = 0; i < chunk.size; i++)
  23. {
  24. if (chunk.chunk[i] == -1 || chunk.chunk[i] == 1)
  25. {
  26. chunk.chunk[i] = 0;
  27. }
  28. if (chunk.chunk[i] != 0)
  29. {
  30. nonZero = true;
  31. UE_LOG(LogTemp, Log, TEXT("NumFramesAvailable: %d, Sample number %d, Sample value %hi"), NumFramesAvailable, i, chunk.chunk[i]);
  32. }
  33. }
  34.  
  35. if (nonZero)
  36. {
  37. m_queue.push(chunk);
  38. }
  39.  
  40. return 0;
  41. }
Add Comment
Please, Sign In to add comment