summaryrefslogtreecommitdiffstats
path: root/media/libmedia
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-11-30 15:00:36 -0800
committerGlenn Kasten <gkasten@google.com>2012-12-03 11:38:57 -0800
commit8f7453f6770070f4789cb769bd2b6a3eabad7d68 (patch)
tree787fcacb821498bd7493739157bcdb83873ae386 /media/libmedia
parentec7dcac79c121ef015ee237891a5c90e67a977ab (diff)
downloadframeworks_av-8f7453f6770070f4789cb769bd2b6a3eabad7d68.zip
frameworks_av-8f7453f6770070f4789cb769bd2b6a3eabad7d68.tar.gz
frameworks_av-8f7453f6770070f4789cb769bd2b6a3eabad7d68.tar.bz2
Emphasize distinction between streaming and static
Update comments and improve error checks to match Change-Id: I7370d6e59a7ef26dfb284a8b058d5ab2e0a42ccf
Diffstat (limited to 'media/libmedia')
-rw-r--r--media/libmedia/AudioTrack.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 597d057..ac672a7 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -138,6 +138,11 @@ AudioTrack::AudioTrack(
mPreviousPriority(ANDROID_PRIORITY_NORMAL),
mPreviousSchedulingGroup(SP_DEFAULT)
{
+ if (sharedBuffer == 0) {
+ ALOGE("sharedBuffer must be non-0");
+ mStatus = BAD_VALUE;
+ return;
+ }
mStatus = set(streamType, sampleRate, format, channelMask,
0 /*frameCount*/, flags, cbf, user, notificationFrames,
sharedBuffer, false /*threadCanCallJava*/, sessionId);
@@ -535,6 +540,10 @@ status_t AudioTrack::setLoop(uint32_t loopStart, uint32_t loopEnd, int loopCount
// must be called with mLock held
status_t AudioTrack::setLoop_l(uint32_t loopStart, uint32_t loopEnd, int loopCount)
{
+ if (mSharedBuffer == 0 || mIsTimed) {
+ return INVALID_OPERATION;
+ }
+
audio_track_cblk_t* cblk = mCblk;
Mutex::Autolock _l(cblk->lock);
@@ -547,10 +556,6 @@ status_t AudioTrack::setLoop_l(uint32_t loopStart, uint32_t loopEnd, int loopCou
return NO_ERROR;
}
- if (mIsTimed) {
- return INVALID_OPERATION;
- }
-
if (loopStart >= loopEnd ||
loopEnd - loopStart > mFrameCount ||
cblk->server > loopStart) {
@@ -624,7 +629,7 @@ status_t AudioTrack::getPositionUpdatePeriod(uint32_t *updatePeriod) const
status_t AudioTrack::setPosition(uint32_t position)
{
- if (mIsTimed) {
+ if (mSharedBuffer == 0 || mIsTimed) {
return INVALID_OPERATION;
}
@@ -660,6 +665,10 @@ status_t AudioTrack::getPosition(uint32_t *position)
status_t AudioTrack::reload()
{
+ if (mSharedBuffer == 0 || mIsTimed) {
+ return INVALID_OPERATION;
+ }
+
AutoMutex lock(mLock);
if (!stopped_l()) {
@@ -1036,10 +1045,7 @@ void AudioTrack::releaseBuffer(Buffer* audioBuffer)
ssize_t AudioTrack::write(const void* buffer, size_t userSize)
{
- if (mSharedBuffer != 0) {
- return INVALID_OPERATION;
- }
- if (mIsTimed) {
+ if (mSharedBuffer != 0 || mIsTimed) {
return INVALID_OPERATION;
}