From e0b07179a48ee50fda931d2aa1b3c751d167e4d7 Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Tue, 6 Nov 2012 15:03:34 -0800 Subject: [PATCH] Remove CBLK_FAST from control block flags This is part of a series to clean up the control block. Change-Id: Ic881a3560d9547cb63fcc0cefec87aa3da480e0d --- include/media/IAudioFlinger.h | 2 +- include/private/media/AudioTrackShared.h | 1 - media/libmedia/AudioTrack.cpp | 7 +++---- media/libmedia/IAudioFlinger.cpp | 12 +++++++++--- services/audioflinger/AudioFlinger.cpp | 15 +++++++-------- services/audioflinger/AudioFlinger.h | 4 ++-- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h index 359780e301..0aa48c694c 100644 --- a/include/media/IAudioFlinger.h +++ b/include/media/IAudioFlinger.h @@ -62,7 +62,7 @@ public: audio_format_t format, audio_channel_mask_t channelMask, int frameCount, - track_flags_t flags, + track_flags_t *flags, const sp& sharedBuffer, audio_io_handle_t output, pid_t tid, // -1 means unused, otherwise must be valid non-0 diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h index 6a86a00806..141078fb82 100644 --- a/include/private/media/AudioTrackShared.h +++ b/include/private/media/AudioTrackShared.h @@ -41,7 +41,6 @@ namespace android { #define CBLK_DISABLED 0x10 // track disabled by AudioFlinger due to underrun, need to re-start #define CBLK_RESTORING 0x20 // track is being restored after invalidation by AudioFlinger #define CBLK_RESTORED 0x40 // track has been restored after invalidation by AudioFlinger -#define CBLK_FAST 0x80 // AudioFlinger successfully created a fast track // Important: do not add any virtual methods, including ~ struct audio_track_cblk_t diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index 523d844920..38eaa65d2f 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -867,7 +867,7 @@ status_t AudioTrack::createTrack_l( format, channelMask, frameCount, - trackFlags, + &trackFlags, sharedBuffer, output, tid, @@ -887,10 +887,9 @@ status_t AudioTrack::createTrack_l( mCblkMemory = iMem; audio_track_cblk_t* cblk = static_cast(iMem->pointer()); mCblk = cblk; - // old has the previous value of cblk->flags before the "or" operation - int32_t old = android_atomic_or(CBLK_DIRECTION, &cblk->flags); + android_atomic_or(CBLK_DIRECTION, &cblk->flags); if (flags & AUDIO_OUTPUT_FLAG_FAST) { - if (old & CBLK_FAST) { + if (trackFlags & IAudioFlinger::TRACK_FAST) { ALOGV("AUDIO_OUTPUT_FLAG_FAST successful; frameCount %u", cblk->frameCount); } else { ALOGV("AUDIO_OUTPUT_FLAG_FAST denied by server; frameCount %u", cblk->frameCount); diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp index f412591e77..bb936ec79f 100644 --- a/media/libmedia/IAudioFlinger.cpp +++ b/media/libmedia/IAudioFlinger.cpp @@ -90,7 +90,7 @@ public: audio_format_t format, audio_channel_mask_t channelMask, int frameCount, - track_flags_t flags, + track_flags_t *flags, const sp& sharedBuffer, audio_io_handle_t output, pid_t tid, @@ -106,7 +106,8 @@ public: data.writeInt32(format); data.writeInt32(channelMask); data.writeInt32(frameCount); - data.writeInt32((int32_t) flags); + track_flags_t lFlags = flags != NULL ? *flags : TRACK_DEFAULT; + data.writeInt32(lFlags); data.writeStrongBinder(sharedBuffer->asBinder()); data.writeInt32((int32_t) output); data.writeInt32((int32_t) tid); @@ -119,6 +120,10 @@ public: if (lStatus != NO_ERROR) { ALOGE("createTrack error: %s", strerror(-lStatus)); } else { + lFlags = reply.readInt32(); + if (flags != NULL) { + *flags = lFlags; + } lSessionId = reply.readInt32(); if (sessionId != NULL) { *sessionId = lSessionId; @@ -732,7 +737,8 @@ status_t BnAudioFlinger::onTransact( status_t status; sp track = createTrack(pid, (audio_stream_type_t) streamType, sampleRate, format, - channelMask, bufferCount, flags, buffer, output, tid, &sessionId, &status); + channelMask, bufferCount, &flags, buffer, output, tid, &sessionId, &status); + reply->writeInt32(flags); reply->writeInt32(sessionId); reply->writeInt32(status); reply->writeStrongBinder(track->asBinder()); diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index cb44114053..379e936a3e 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -451,7 +451,7 @@ sp AudioFlinger::createTrack( audio_format_t format, audio_channel_mask_t channelMask, int frameCount, - IAudioFlinger::track_flags_t flags, + IAudioFlinger::track_flags_t *flags, const sp& sharedBuffer, audio_io_handle_t output, pid_t tid, @@ -1725,17 +1725,17 @@ sp AudioFlinger::PlaybackThread::createTrac int frameCount, const sp& sharedBuffer, int sessionId, - IAudioFlinger::track_flags_t flags, + IAudioFlinger::track_flags_t *flags, pid_t tid, status_t *status) { sp track; status_t lStatus; - bool isTimed = (flags & IAudioFlinger::TRACK_TIMED) != 0; + bool isTimed = (*flags & IAudioFlinger::TRACK_TIMED) != 0; // client expresses a preference for FAST, but we get the final say - if (flags & IAudioFlinger::TRACK_FAST) { + if (*flags & IAudioFlinger::TRACK_FAST) { if ( // not timed (!isTimed) && @@ -1781,7 +1781,7 @@ sp AudioFlinger::PlaybackThread::createTrac isTimed, sharedBuffer.get(), frameCount, mFrameCount, format, audio_is_linear_pcm(format), channelMask, sampleRate, mSampleRate, hasFastMixer(), tid, mFastTrackAvailMask); - flags &= ~IAudioFlinger::TRACK_FAST; + *flags &= ~IAudioFlinger::TRACK_FAST; // For compatibility with AudioTrack calculation, buffer depth is forced // to be at least 2 x the normal mixer frame count and cover audio hardware latency. // This is probably too conservative, but legacy application code may depend on it. @@ -1845,7 +1845,7 @@ sp AudioFlinger::PlaybackThread::createTrac if (!isTimed) { track = new Track(this, client, streamType, sampleRate, format, - channelMask, frameCount, sharedBuffer, sessionId, flags); + channelMask, frameCount, sharedBuffer, sessionId, *flags); } else { track = TimedTrack::create(this, client, streamType, sampleRate, format, channelMask, frameCount, sharedBuffer, sessionId); @@ -1864,7 +1864,7 @@ sp AudioFlinger::PlaybackThread::createTrac chain->incTrackCnt(); } - if ((flags & IAudioFlinger::TRACK_FAST) && (tid != -1)) { + if ((*flags & IAudioFlinger::TRACK_FAST) && (tid != -1)) { pid_t callingPid = IPCThreadState::self()->getCallingPid(); // we don't have CAP_SYS_NICE, nor do we want to have it as it's too powerful, // so ask activity manager to do this on our behalf @@ -4377,7 +4377,6 @@ AudioFlinger::PlaybackThread::Track::Track( } // only allocate a fast track index if we were able to allocate a normal track name if (flags & IAudioFlinger::TRACK_FAST) { - mCblk->flags |= CBLK_FAST; // atomic op not needed yet ALOG_ASSERT(thread->mFastTrackAvailMask != 0); int i = __builtin_ctz(thread->mFastTrackAvailMask); ALOG_ASSERT(0 < i && i < (int)FastMixerState::kMaxFastTracks); diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h index 2251b45f78..de2fbfaeb4 100644 --- a/services/audioflinger/AudioFlinger.h +++ b/services/audioflinger/AudioFlinger.h @@ -93,7 +93,7 @@ public: audio_format_t format, audio_channel_mask_t channelMask, int frameCount, - IAudioFlinger::track_flags_t flags, + IAudioFlinger::track_flags_t *flags, const sp& sharedBuffer, audio_io_handle_t output, pid_t tid, @@ -1089,7 +1089,7 @@ public: int frameCount, const sp& sharedBuffer, int sessionId, - IAudioFlinger::track_flags_t flags, + IAudioFlinger::track_flags_t *flags, pid_t tid, status_t *status); -- 2.11.0