Loading include/media/AudioTrack.h +1 −0 Original line number Diff line number Diff line Loading @@ -599,6 +599,7 @@ protected: int mPreviousPriority; // before start() SchedPolicy mPreviousSchedulingGroup; AudioTrackClientProxy* mProxy; bool mAwaitBoost; // thread should wait for priority boost before running }; class TimedAudioTrack : public AudioTrack Loading media/libmedia/AudioTrack.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -893,9 +893,11 @@ status_t AudioTrack::createTrack_l( ALOGW("Requested frameCount %u but received frameCount %u", frameCount, temp); } frameCount = temp; mAwaitBoost = false; if (flags & AUDIO_OUTPUT_FLAG_FAST) { if (trackFlags & IAudioFlinger::TRACK_FAST) { ALOGV("AUDIO_OUTPUT_FLAG_FAST successful; frameCount %u", frameCount); mAwaitBoost = true; } else { ALOGV("AUDIO_OUTPUT_FLAG_FAST denied by server; frameCount %u", frameCount); // once denied, do not request again if IAudioTrack is re-created Loading Loading @@ -1219,6 +1221,25 @@ bool AudioTrack::processAudioBuffer(const sp<AudioTrackThread>& thread) size_t writtenSize; mLock.lock(); if (mAwaitBoost) { mAwaitBoost = false; mLock.unlock(); static const int32_t kMaxTries = 5; int32_t tryCounter = kMaxTries; uint32_t pollUs = 10000; do { int policy = sched_getscheduler(0); if (policy == SCHED_FIFO || policy == SCHED_RR) { break; } usleep(pollUs); pollUs <<= 1; } while (tryCounter-- > 0); if (tryCounter < 0) { ALOGE("did not receive expected priority boost on time"); } return true; } // acquire a strong reference on the IMemory and IAudioTrack so that they cannot be destroyed // while we are accessing the cblk sp<IAudioTrack> audioTrack = mAudioTrack; Loading services/audioflinger/FastMixer.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,10 @@ bool FastMixer::threadLoop() if (old <= 0) { __futex_syscall4(coldFutexAddr, FUTEX_WAIT_PRIVATE, old - 1, NULL); } int policy = sched_getscheduler(0); if (!(policy == SCHED_FIFO || policy == SCHED_RR)) { ALOGE("did not receive expected priority boost"); } // This may be overly conservative; there could be times that the normal mixer // requests such a brief cold idle that it doesn't require resetting this flag. isWarm = false; Loading services/audioflinger/ISchedulingPolicyService.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -37,14 +37,15 @@ public: { } virtual int requestPriority(int32_t pid, int32_t tid, int32_t prio) virtual int requestPriority(int32_t pid, int32_t tid, int32_t prio, bool asynchronous) { Parcel data, reply; data.writeInterfaceToken(ISchedulingPolicyService::getInterfaceDescriptor()); data.writeInt32(pid); data.writeInt32(tid); data.writeInt32(prio); remote()->transact(REQUEST_PRIORITY_TRANSACTION, data, &reply, IBinder::FLAG_ONEWAY); uint32_t flags = asynchronous ? IBinder::FLAG_ONEWAY : 0; remote()->transact(REQUEST_PRIORITY_TRANSACTION, data, &reply, flags); // fail on exception if (reply.readExceptionCode() != 0) return -1; return reply.readInt32(); Loading services/audioflinger/ISchedulingPolicyService.h +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ public: DECLARE_META_INTERFACE(SchedulingPolicyService); virtual int requestPriority(/*pid_t*/int32_t pid, /*pid_t*/int32_t tid, int32_t prio) = 0; int32_t prio, bool asynchronous) = 0; }; Loading Loading
include/media/AudioTrack.h +1 −0 Original line number Diff line number Diff line Loading @@ -599,6 +599,7 @@ protected: int mPreviousPriority; // before start() SchedPolicy mPreviousSchedulingGroup; AudioTrackClientProxy* mProxy; bool mAwaitBoost; // thread should wait for priority boost before running }; class TimedAudioTrack : public AudioTrack Loading
media/libmedia/AudioTrack.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -893,9 +893,11 @@ status_t AudioTrack::createTrack_l( ALOGW("Requested frameCount %u but received frameCount %u", frameCount, temp); } frameCount = temp; mAwaitBoost = false; if (flags & AUDIO_OUTPUT_FLAG_FAST) { if (trackFlags & IAudioFlinger::TRACK_FAST) { ALOGV("AUDIO_OUTPUT_FLAG_FAST successful; frameCount %u", frameCount); mAwaitBoost = true; } else { ALOGV("AUDIO_OUTPUT_FLAG_FAST denied by server; frameCount %u", frameCount); // once denied, do not request again if IAudioTrack is re-created Loading Loading @@ -1219,6 +1221,25 @@ bool AudioTrack::processAudioBuffer(const sp<AudioTrackThread>& thread) size_t writtenSize; mLock.lock(); if (mAwaitBoost) { mAwaitBoost = false; mLock.unlock(); static const int32_t kMaxTries = 5; int32_t tryCounter = kMaxTries; uint32_t pollUs = 10000; do { int policy = sched_getscheduler(0); if (policy == SCHED_FIFO || policy == SCHED_RR) { break; } usleep(pollUs); pollUs <<= 1; } while (tryCounter-- > 0); if (tryCounter < 0) { ALOGE("did not receive expected priority boost on time"); } return true; } // acquire a strong reference on the IMemory and IAudioTrack so that they cannot be destroyed // while we are accessing the cblk sp<IAudioTrack> audioTrack = mAudioTrack; Loading
services/audioflinger/FastMixer.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,10 @@ bool FastMixer::threadLoop() if (old <= 0) { __futex_syscall4(coldFutexAddr, FUTEX_WAIT_PRIVATE, old - 1, NULL); } int policy = sched_getscheduler(0); if (!(policy == SCHED_FIFO || policy == SCHED_RR)) { ALOGE("did not receive expected priority boost"); } // This may be overly conservative; there could be times that the normal mixer // requests such a brief cold idle that it doesn't require resetting this flag. isWarm = false; Loading
services/audioflinger/ISchedulingPolicyService.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -37,14 +37,15 @@ public: { } virtual int requestPriority(int32_t pid, int32_t tid, int32_t prio) virtual int requestPriority(int32_t pid, int32_t tid, int32_t prio, bool asynchronous) { Parcel data, reply; data.writeInterfaceToken(ISchedulingPolicyService::getInterfaceDescriptor()); data.writeInt32(pid); data.writeInt32(tid); data.writeInt32(prio); remote()->transact(REQUEST_PRIORITY_TRANSACTION, data, &reply, IBinder::FLAG_ONEWAY); uint32_t flags = asynchronous ? IBinder::FLAG_ONEWAY : 0; remote()->transact(REQUEST_PRIORITY_TRANSACTION, data, &reply, flags); // fail on exception if (reply.readExceptionCode() != 0) return -1; return reply.readInt32(); Loading
services/audioflinger/ISchedulingPolicyService.h +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ public: DECLARE_META_INTERFACE(SchedulingPolicyService); virtual int requestPriority(/*pid_t*/int32_t pid, /*pid_t*/int32_t tid, int32_t prio) = 0; int32_t prio, bool asynchronous) = 0; }; Loading