diff options
| author | Marco Nelissen <marcone@google.com> | 2012-04-02 12:16:49 -0700 |
|---|---|---|
| committer | Marco Nelissen <marcone@google.com> | 2012-04-04 14:26:45 -0700 |
| commit | 99448608f375a7191c068c3bfd296f204b58a219 (patch) | |
| tree | 2233a958570ce34e7203560677dcea2fe0e726e3 | |
| parent | f15cb4472aaca54c13f8250e4c7872470c4bed83 (diff) | |
| download | frameworks_av-99448608f375a7191c068c3bfd296f204b58a219.zip frameworks_av-99448608f375a7191c068c3bfd296f204b58a219.tar.gz frameworks_av-99448608f375a7191c068c3bfd296f204b58a219.tar.bz2 | |
Allow AudioTrack to start at nonzero position
When creating a new AudioTrack (not inheriting one from a previous play),
the AudioSink should take the AudioTrack's position as the initial starting
point for mBytesWritten, since otherwise NuPlayer's calculations will be off.
Normally this position will be 0, but if the test code for 32 bit wraparound
in AudioFlinger.cpp is enabled, it might be (much) larger.
Change-Id: I1e4f906d529861c3dea996de8afc6dbd491589af
| -rw-r--r-- | media/libmediaplayerservice/MediaPlayerService.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp index 7c3fb0d..8bde8f1 100644 --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -1617,6 +1617,10 @@ status_t MediaPlayerService::AudioOutput::open( mSampleRateHz = sampleRate; mMsecsPerFrame = mPlaybackRatePermille / (float) sampleRate; + uint32_t pos; + if (t->getPosition(&pos) == OK) { + mBytesWritten = uint64_t(pos) * t->frameSize(); + } mTrack = t; status_t res = t->setSampleRate(mPlaybackRatePermille * mSampleRateHz / 1000); |
