Consolidate libaudioclient buffers p1
Prepare for libaudioclient buffer refactor by updating
clients of libaudioclient to use new buffer interface.
libaudioclient
- Wrap existing buffers with new interface
- Modify internal calls to be compatible with wrap
AAudio
- Update to use new buffer interface
- Update record to use callback
TrackPlayerBase
- Used for SLES (in different repo). Update to use sp<>
ToneGenerator/MediaPlayerService/AudioPlayer
- Update to use new buffer interface
StageFright
- Update to new callback interface
- Update to use new buffer interface
Bug: 216175830 - shared buffer
Bug: 199156212 - callback interface
Test: atest AudioTrackTest AudioRecordTest
atest AudioTrackOffloadTest
OboeTester non-exclusive, non-MMAP, power-saving for both
AAudio and SLES, input and output
No-Typo-Check: Existing class members
Change-Id: Ib1241f2e530bc509b2d4dde956ec5188f2287994
diff --git a/media/libaudioclient/ToneGenerator.cpp b/media/libaudioclient/ToneGenerator.cpp
index cd3eacb..9b43f3c 100644
--- a/media/libaudioclient/ToneGenerator.cpp
+++ b/media/libaudioclient/ToneGenerator.cpp
@@ -1329,7 +1329,7 @@
//
// Input:
// buffer An buffer object containing a pointer which we will fill with
-// buffer.size bytes.
+// buffer.size() bytes.
//
// Output:
// The number of bytes we successfully wrote.
@@ -1337,16 +1337,16 @@
////////////////////////////////////////////////////////////////////////////////
size_t ToneGenerator::onMoreData(const AudioTrack::Buffer& buffer) {
- int16_t *lpOut = buffer.i16;
- uint32_t lNumSmp = (buffer.size / sizeof(int16_t) < UINT32_MAX) ?
- buffer.size / sizeof(int16_t) : UINT32_MAX;
- if (buffer.size == 0) return 0;
+ int16_t *lpOut = reinterpret_cast<int16_t*>(buffer.data());
+ uint32_t lNumSmp = (buffer.size() / sizeof(int16_t) < UINT32_MAX) ?
+ buffer.size() / sizeof(int16_t) : UINT32_MAX;
+ if (buffer.size() == 0) return 0;
// We will write to the entire buffer unless we are stopped, then we return
// 0 at loop end
size_t bytesWritten = lNumSmp * sizeof(int16_t);
// Clear output buffer: WaveGenerator accumulates into lpOut buffer
- memset(lpOut, 0, buffer.size);
+ memset(lpOut, 0, buffer.size());
while (lNumSmp) {
unsigned int lReqSmp = lNumSmp < mProcessSize*2 ? lNumSmp : mProcessSize;