Loading media/libaudioclient/AudioRecord.cpp +65 −4 Original line number Diff line number Diff line Loading @@ -105,6 +105,10 @@ void AudioRecord::MediaMetrics::gather(const AudioRecord *record) } } static const char *stateToString(bool active) { return active ? "ACTIVE" : "STOPPED"; } // hand the user a snapshot of the metrics. status_t AudioRecord::getMetrics(mediametrics::Item * &item) { Loading Loading @@ -164,6 +168,11 @@ AudioRecord::~AudioRecord() { mMediaMetrics.gather(this); mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_DTOR) .set(AMEDIAMETRICS_PROP_STATUS, (int32_t)mStatus) .record(); if (mStatus == NO_ERROR) { // Make sure that callback function exits in the case where // it is looping on buffer empty condition in obtainBuffer(). Loading Loading @@ -380,11 +389,21 @@ exit: status_t AudioRecord::start(AudioSystem::sync_event_t event, audio_session_t triggerSession) { const int64_t beginNs = systemTime(); ALOGV("%s(%d): sync event %d trigger session %d", __func__, mPortId, event, triggerSession); AutoMutex lock(mLock); status_t status = NO_ERROR; mediametrics::Defer([&] { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_START) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mActive)) .set(AMEDIAMETRICS_PROP_STATUS, (int32_t)status) .record(); }); if (mActive) { return NO_ERROR; return status; } // discard data in buffer Loading @@ -409,7 +428,6 @@ status_t AudioRecord::start(AudioSystem::sync_event_t event, audio_session_t tri // mActive is checked by restoreRecord_l mActive = true; status_t status = NO_ERROR; if (!(flags & CBLK_INVALID)) { status = mAudioRecord->start(event, triggerSession).transactionError(); if (status == DEAD_OBJECT) { Loading Loading @@ -447,7 +465,15 @@ status_t AudioRecord::start(AudioSystem::sync_event_t event, audio_session_t tri void AudioRecord::stop() { const int64_t beginNs = systemTime(); AutoMutex lock(mLock); mediametrics::Defer([&] { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_STOP) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mActive)) .record(); }); ALOGV("%s(%d): mActive:%d\n", __func__, mPortId, mActive); if (!mActive) { return; Loading Loading @@ -663,6 +689,7 @@ const char * AudioRecord::convertTransferToText(transfer_type transferType) { // must be called with mLock held status_t AudioRecord::createRecord_l(const Modulo<uint32_t> &epoch, const String16& opPackageName) { const int64_t beginNs = systemTime(); const sp<IAudioFlinger>& audioFlinger = AudioSystem::get_audio_flinger(); IAudioFlinger::CreateRecordInput input; IAudioFlinger::CreateRecordOutput output; Loading Loading @@ -849,6 +876,29 @@ status_t AudioRecord::createRecord_l(const Modulo<uint32_t> &epoch, const String mDeathNotifier = new DeathNotifier(this); IInterface::asBinder(mAudioRecord)->linkToDeath(mDeathNotifier, this); mMetricsId = std::string(AMEDIAMETRICS_KEY_PREFIX_AUDIO_RECORD) + std::to_string(mPortId); mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_CREATE) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) // the following are immutable (at least until restore) .set(AMEDIAMETRICS_PROP_FLAGS, (int32_t)mFlags) .set(AMEDIAMETRICS_PROP_ORIGINALFLAGS, (int32_t)mOrigFlags) .set(AMEDIAMETRICS_PROP_SESSIONID, (int32_t)mSessionId) .set(AMEDIAMETRICS_PROP_TRACKID, mPortId) .set(AMEDIAMETRICS_PROP_SOURCE, toString(mAttributes.source).c_str()) .set(AMEDIAMETRICS_PROP_THREADID, (int32_t)output.inputId) .set(AMEDIAMETRICS_PROP_SELECTEDDEVICEID, (int32_t)mSelectedDeviceId) .set(AMEDIAMETRICS_PROP_ROUTEDDEVICEID, (int32_t)mRoutedDeviceId) .set(AMEDIAMETRICS_PROP_ENCODING, toString(mFormat).c_str()) .set(AMEDIAMETRICS_PROP_CHANNELMASK, (int32_t)mChannelMask) .set(AMEDIAMETRICS_PROP_FRAMECOUNT, (int32_t)mFrameCount) .set(AMEDIAMETRICS_PROP_SAMPLERATE, (int32_t)mSampleRate) // the following are NOT immutable .set(AMEDIAMETRICS_PROP_STATE, stateToString(mActive)) .set(AMEDIAMETRICS_PROP_SELECTEDMICDIRECTION, (int32_t)mSelectedMicDirection) .set(AMEDIAMETRICS_PROP_SELECTEDMICFIELDDIRECTION, (double)mSelectedMicFieldDimension) .record(); exit: mStatus = status; // sp<IAudioTrack> track destructor will cause releaseOutput() to be called by AudioFlinger Loading Loading @@ -1288,6 +1338,17 @@ nsecs_t AudioRecord::processAudioBuffer() status_t AudioRecord::restoreRecord_l(const char *from) { status_t result = NO_ERROR; // logged: make sure to set this before returning. const int64_t beginNs = systemTime(); mediametrics::Defer([&] { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_RESTORE) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mActive)) .set(AMEDIAMETRICS_PROP_STATUS, (int32_t)result) .set(AMEDIAMETRICS_PROP_WHERE, from) .record(); }); ALOGW("%s(%d): dead IAudioRecord, creating a new one from %s()", __func__, mPortId, from); ++mSequence; Loading @@ -1306,7 +1367,7 @@ retry: // It will also delete the strong references on previous IAudioRecord and IMemory Modulo<uint32_t> position(mProxy->getPosition()); mNewPosition = position + mUpdatePeriod; status_t result = createRecord_l(position, mOpPackageName); result = createRecord_l(position, mOpPackageName); if (result == NO_ERROR) { if (mActive) { Loading media/libaudioclient/AudioTrack.cpp +120 −4 Original line number Diff line number Diff line Loading @@ -296,6 +296,12 @@ AudioTrack::~AudioTrack() // pull together the numbers, before we clean up our structures mMediaMetrics.gather(this); mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_DTOR) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mState)) .set(AMEDIAMETRICS_PROP_STATUS, (int32_t)mStatus) .record(); if (mStatus == NO_ERROR) { // Make sure that callback function exits in the case where // it is looping on buffer full condition in obtainBuffer(). Loading Loading @@ -626,11 +632,23 @@ exit: status_t AudioTrack::start() { const int64_t beginNs = systemTime(); AutoMutex lock(mLock); status_t status = NO_ERROR; // logged: make sure to set this before returning. mediametrics::Defer([&] { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_START) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mState)) .set(AMEDIAMETRICS_PROP_STATUS, (int32_t)status) .record(); }); ALOGV("%s(%d): prior state:%s", __func__, mPortId, stateToString(mState)); if (mState == STATE_ACTIVE) { return INVALID_OPERATION; status = INVALID_OPERATION; return status; } mInUnderrun = true; Loading Loading @@ -703,7 +721,6 @@ status_t AudioTrack::start() mNewPosition = mPosition + mUpdatePeriod; int32_t flags = android_atomic_and(~(CBLK_STREAM_END_DONE | CBLK_DISABLED), &mCblk->mFlags); status_t status = NO_ERROR; if (!(flags & CBLK_INVALID)) { status = mAudioTrack->start(); if (status == DEAD_OBJECT) { Loading Loading @@ -749,7 +766,16 @@ status_t AudioTrack::start() void AudioTrack::stop() { const int64_t beginNs = systemTime(); AutoMutex lock(mLock); mediametrics::Defer([&]() { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_STOP) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mState)) .record(); }); ALOGV("%s(%d): prior state:%s", __func__, mPortId, stateToString(mState)); if (mState != STATE_ACTIVE && mState != STATE_PAUSED) { Loading Loading @@ -801,7 +827,15 @@ bool AudioTrack::stopped() const void AudioTrack::flush() { const int64_t beginNs = systemTime(); AutoMutex lock(mLock); mediametrics::Defer([&]() { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_FLUSH) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mState)) .record(); }); ALOGV("%s(%d): prior state:%s", __func__, mPortId, stateToString(mState)); if (mSharedBuffer != 0) { Loading Loading @@ -834,7 +868,15 @@ void AudioTrack::flush_l() void AudioTrack::pause() { const int64_t beginNs = systemTime(); AutoMutex lock(mLock); mediametrics::Defer([&]() { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_PAUSE) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mState)) .record(); }); ALOGV("%s(%d): prior state:%s", __func__, mPortId, stateToString(mState)); if (mState == STATE_ACTIVE) { Loading Loading @@ -876,6 +918,12 @@ status_t AudioTrack::setVolume(float left, float right) return BAD_VALUE; } mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_SETVOLUME) .set(AMEDIAMETRICS_PROP_VOLUME_LEFT, (double)left) .set(AMEDIAMETRICS_PROP_VOLUME_RIGHT, (double)right) .record(); AutoMutex lock(mLock); mVolume[AUDIO_INTERLEAVE_LEFT] = left; mVolume[AUDIO_INTERLEAVE_RIGHT] = right; Loading Loading @@ -1027,6 +1075,20 @@ status_t AudioTrack::setPlaybackRate(const AudioPlaybackRate &playbackRate) //set effective rates mProxy->setPlaybackRate(playbackRateTemp); mProxy->setSampleRate(effectiveRate); // FIXME: not quite "atomic" with setPlaybackRate mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_SETPLAYBACKPARAM) .set(AMEDIAMETRICS_PROP_SAMPLERATE, (int32_t)mSampleRate) .set(AMEDIAMETRICS_PROP_PLAYBACK_SPEED, (double)mPlaybackRate.mSpeed) .set(AMEDIAMETRICS_PROP_PLAYBACK_PITCH, (double)mPlaybackRate.mPitch) .set(AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE AMEDIAMETRICS_PROP_SAMPLERATE, (int32_t)effectiveRate) .set(AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE AMEDIAMETRICS_PROP_PLAYBACK_SPEED, (double)playbackRateTemp.mSpeed) .set(AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE AMEDIAMETRICS_PROP_PLAYBACK_PITCH, (double)playbackRateTemp.mPitch) .record(); return NO_ERROR; } Loading Loading @@ -1618,6 +1680,48 @@ status_t AudioTrack::createTrack_l() mDeathNotifier = new DeathNotifier(this); IInterface::asBinder(mAudioTrack)->linkToDeath(mDeathNotifier, this); // This is the first log sent from the AudioTrack client. // The creation of the audio track by AudioFlinger (in the code above) // is the first log of the AudioTrack and must be present before // any AudioTrack client logs will be accepted. mMetricsId = std::string(AMEDIAMETRICS_KEY_PREFIX_AUDIO_TRACK) + std::to_string(mPortId); mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_CREATE) // the following are immutable .set(AMEDIAMETRICS_PROP_FLAGS, (int32_t)mFlags) .set(AMEDIAMETRICS_PROP_ORIGINALFLAGS, (int32_t)mOrigFlags) .set(AMEDIAMETRICS_PROP_SESSIONID, (int32_t)mSessionId) .set(AMEDIAMETRICS_PROP_TRACKID, mPortId) // dup from key .set(AMEDIAMETRICS_PROP_STREAMTYPE, toString(mStreamType).c_str()) .set(AMEDIAMETRICS_PROP_CONTENTTYPE, toString(mAttributes.content_type).c_str()) .set(AMEDIAMETRICS_PROP_USAGE, toString(mAttributes.usage).c_str()) .set(AMEDIAMETRICS_PROP_THREADID, (int32_t)output.outputId) .set(AMEDIAMETRICS_PROP_SELECTEDDEVICEID, (int32_t)mSelectedDeviceId) .set(AMEDIAMETRICS_PROP_ROUTEDDEVICEID, (int32_t)mRoutedDeviceId) .set(AMEDIAMETRICS_PROP_ENCODING, toString(mFormat).c_str()) .set(AMEDIAMETRICS_PROP_CHANNELMASK, (int32_t)mChannelMask) .set(AMEDIAMETRICS_PROP_FRAMECOUNT, (int32_t)mFrameCount) // the following are NOT immutable .set(AMEDIAMETRICS_PROP_VOLUME_LEFT, (double)mVolume[AUDIO_INTERLEAVE_LEFT]) .set(AMEDIAMETRICS_PROP_VOLUME_RIGHT, (double)mVolume[AUDIO_INTERLEAVE_RIGHT]) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mState)) .set(AMEDIAMETRICS_PROP_AUXEFFECTID, (int32_t)mAuxEffectId) .set(AMEDIAMETRICS_PROP_SAMPLERATE, (int32_t)mSampleRate) .set(AMEDIAMETRICS_PROP_PLAYBACK_SPEED, (double)mPlaybackRate.mSpeed) .set(AMEDIAMETRICS_PROP_PLAYBACK_PITCH, (double)mPlaybackRate.mPitch) .set(AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE AMEDIAMETRICS_PROP_SAMPLERATE, (int32_t)effectiveSampleRate) .set(AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE AMEDIAMETRICS_PROP_PLAYBACK_SPEED, (double)effectiveSpeed) .set(AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE AMEDIAMETRICS_PROP_PLAYBACK_PITCH, (double)effectivePitch) .record(); // mSendLevel // mReqFrameCount? // mNotificationFramesAct, mNotificationFramesReq, mNotificationsPerBufferReq // mLatency, mAfLatency, mAfFrameCount, mAfSampleRate } exit: Loading Loading @@ -2294,6 +2398,17 @@ nsecs_t AudioTrack::processAudioBuffer() status_t AudioTrack::restoreTrack_l(const char *from) { status_t result = NO_ERROR; // logged: make sure to set this before returning. const int64_t beginNs = systemTime(); mediametrics::Defer([&] { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_RESTORE) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mState)) .set(AMEDIAMETRICS_PROP_STATUS, (int32_t)result) .set(AMEDIAMETRICS_PROP_WHERE, from) .record(); }); ALOGW("%s(%d): dead IAudioTrack, %s, creating a new one from %s()", __func__, mPortId, isOffloadedOrDirect_l() ? "Offloaded or Direct" : "PCM", from); ++mSequence; Loading @@ -2305,7 +2420,8 @@ status_t AudioTrack::restoreTrack_l(const char *from) if (isOffloadedOrDirect_l() || mDoNotReconnect) { // FIXME re-creation of offloaded and direct tracks is not yet implemented; // reconsider enabling for linear PCM encodings when position can be preserved. return DEAD_OBJECT; result = DEAD_OBJECT; return result; } // Save so we can return count since creation. Loading Loading @@ -2336,7 +2452,7 @@ retry: // following member variables: mAudioTrack, mCblkMemory and mCblk. // It will also delete the strong references on previous IAudioTrack and IMemory. // If a new IAudioTrack cannot be created, the previous (dead) instance will be left intact. status_t result = createTrack_l(); result = createTrack_l(); if (result == NO_ERROR) { // take the frames that will be lost by track recreation into account in saved position Loading media/libaudioclient/include/media/AudioRecord.h +1 −0 Original line number Diff line number Diff line Loading @@ -771,6 +771,7 @@ private: std::string mLastErrorFunc; }; MediaMetrics mMediaMetrics; std::string mMetricsId; // GUARDED_BY(mLock), could change in createRecord_l(). }; }; // namespace android Loading media/libaudioclient/include/media/AudioTrack.h +1 −0 Original line number Diff line number Diff line Loading @@ -1245,6 +1245,7 @@ private: std::unique_ptr<mediametrics::Item> mMetricsItem; }; MediaMetrics mMediaMetrics; std::string mMetricsId; // GUARDED_BY(mLock), could change in createTrack_l(). }; }; // namespace android Loading media/libmediametrics/include/MediaMetricsConstants.h 0 → 100644 +135 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_MEDIA_MEDIAMETRICSCONSTANTS_H #define ANDROID_MEDIA_MEDIAMETRICSCONSTANTS_H /* * MediaMetrics Keys and Properties. * * C/C++ friendly constants that ensure * 1) Compilation error on misspelling * 2) Consistent behavior and documentation. */ /* * Taxonomy of audio keys * * To build longer keys, we use compiler string concatenation of * adjacent string literals. This is done in the translation phase * of compilation to make a single string token. */ // Key Prefixes are used for MediaMetrics Item Keys and ends with a ".". // They must be appended with another value to make a key. #define AMEDIAMETRICS_KEY_PREFIX_AUDIO "audio." // The AudioRecord key appends the "trackId" to the prefix. #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_RECORD AMEDIAMETRICS_KEY_PREFIX_AUDIO "record." // The AudioThread key appends the "threadId" to the prefix. #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_THREAD AMEDIAMETRICS_KEY_PREFIX_AUDIO "thread." // The AudioTrack key appends the "trackId" to the prefix. #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_TRACK AMEDIAMETRICS_KEY_PREFIX_AUDIO "track." // Keys are strings used for MediaMetrics Item Keys #define AMEDIAMETRICS_KEY_AUDIO_FLINGER AMEDIAMETRICS_KEY_PREFIX_AUDIO "flinger" #define AMEDIAMETRICS_KEY_AUDIO_POLICY AMEDIAMETRICS_KEY_PREFIX_AUDIO "policy" /* * MediaMetrics Properties are unified space for consistency and readability. */ // Property prefixes may be applied before a property name to indicate a specific // category to which it is associated. #define AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE "effective." #define AMEDIAMETRICS_PROP_PREFIX_HAL "hal." #define AMEDIAMETRICS_PROP_PREFIX_HAPTIC "haptic." #define AMEDIAMETRICS_PROP_PREFIX_SERVER "server." // Properties within mediametrics are string constants denoted by // a macro name beginning with AMEDIAMETRICS_PROP_* // // For a property name like "auxEffectId" we write this as a single upper case word // at the end of the macro name, such as AMEDIAMETRICS_PROP_AUXEFFECTID. // // Underscores after the AMEDIAMETRICS_PROP_* prefix indicate // a "dot" in the property name. For example AMEDIAMETRICS_PROP_VOLUME_LEFT // corresponds to "volume.left". #define AMEDIAMETRICS_PROP_AUXEFFECTID "auxEffectId" // int32 (AudioTrack) #define AMEDIAMETRICS_PROP_CHANNELCOUNT "channelCount" // int32 #define AMEDIAMETRICS_PROP_CHANNELMASK "channelMask" // int32 #define AMEDIAMETRICS_PROP_CONTENTTYPE "contentType" // string attributes (AudioTrack) #define AMEDIAMETRICS_PROP_DURATIONNS "durationNs" // int64 duration time span #define AMEDIAMETRICS_PROP_ENCODING "encoding" // string value of format #define AMEDIAMETRICS_PROP_EVENT "event" // string value (often func name) // TODO: fix inconsistency in flags: AudioRecord / AudioTrack int32, AudioThread string #define AMEDIAMETRICS_PROP_FLAGS "flags" #define AMEDIAMETRICS_PROP_FRAMECOUNT "frameCount" // int32 #define AMEDIAMETRICS_PROP_INPUTDEVICES "inputDevices" // string value #define AMEDIAMETRICS_PROP_LATENCYMS "latencyMs" // double value #define AMEDIAMETRICS_PROP_ORIGINALFLAGS "originalFlags" // int32 #define AMEDIAMETRICS_PROP_OUTPUTDEVICES "outputDevices" // string value #define AMEDIAMETRICS_PROP_PLAYBACK_PITCH "playback.pitch" // double value (AudioTrack) #define AMEDIAMETRICS_PROP_PLAYBACK_SPEED "playback.speed" // double value (AudioTrack) #define AMEDIAMETRICS_PROP_ROUTEDDEVICEID "routedDeviceId" // int32 #define AMEDIAMETRICS_PROP_SAMPLERATE "sampleRate" // int32 #define AMEDIAMETRICS_PROP_SELECTEDDEVICEID "selectedDeviceId" // int32 #define AMEDIAMETRICS_PROP_SELECTEDMICDIRECTION "selectedMicDirection" // int32 #define AMEDIAMETRICS_PROP_SELECTEDMICFIELDDIRECTION "selectedMicFieldDimension" // double #define AMEDIAMETRICS_PROP_SESSIONID "sessionId" // int32 #define AMEDIAMETRICS_PROP_SOURCE "source" // string (AudioAttributes) #define AMEDIAMETRICS_PROP_STARTUPMS "startupMs" // double value // State is "ACTIVE" or "STOPPED" for AudioRecord #define AMEDIAMETRICS_PROP_STATE "state" // string #define AMEDIAMETRICS_PROP_STATUS "status" // int32 status_t #define AMEDIAMETRICS_PROP_STREAMTYPE "streamType" // string (AudioTrack) #define AMEDIAMETRICS_PROP_THREADID "threadId" // int32 value io handle #define AMEDIAMETRICS_PROP_THROTTLEMS "throttleMs" // double #define AMEDIAMETRICS_PROP_TRACKID "trackId" // int32 port id of track/record #define AMEDIAMETRICS_PROP_TYPE "type" // string (thread type) #define AMEDIAMETRICS_PROP_UNDERRUN "underrun" // int32 #define AMEDIAMETRICS_PROP_USAGE "usage" // string attributes (ATrack) #define AMEDIAMETRICS_PROP_VOLUME_LEFT "volume.left" // double (AudioTrack) #define AMEDIAMETRICS_PROP_VOLUME_RIGHT "volume.right" // double (AudioTrack) #define AMEDIAMETRICS_PROP_WHERE "where" // string value // Timing values: millisecond values are suffixed with MS and the type is double // nanosecond values are suffixed with NS and the type is int64. // Values are strings accepted for a given property. // An event is a general description, which often is a function name. #define AMEDIAMETRICS_PROP_EVENT_VALUE_CREATE "create" #define AMEDIAMETRICS_PROP_EVENT_VALUE_CREATEAUDIOPATCH "createAudioPatch" #define AMEDIAMETRICS_PROP_EVENT_VALUE_CTOR "ctor" #define AMEDIAMETRICS_PROP_EVENT_VALUE_DTOR "dtor" #define AMEDIAMETRICS_PROP_EVENT_VALUE_FLUSH "flush" // AudioTrack #define AMEDIAMETRICS_PROP_EVENT_VALUE_INVALIDATE "invalidate" // server track, record #define AMEDIAMETRICS_PROP_EVENT_VALUE_PAUSE "pause" // AudioTrack #define AMEDIAMETRICS_PROP_EVENT_VALUE_READPARAMETERS "readParameters" // Thread #define AMEDIAMETRICS_PROP_EVENT_VALUE_RESTORE "restore" #define AMEDIAMETRICS_PROP_EVENT_VALUE_SETPLAYBACKPARAM "setPlaybackParam" // AudioTrack #define AMEDIAMETRICS_PROP_EVENT_VALUE_SETVOLUME "setVolume" // AudioTrack #define AMEDIAMETRICS_PROP_EVENT_VALUE_START "start" // AudioTrack, AudioRecord #define AMEDIAMETRICS_PROP_EVENT_VALUE_STOP "stop" // AudioTrack, AudioRecord #define AMEDIAMETRICS_PROP_EVENT_VALUE_UNDERRUN "underrun" // from Thread #endif // ANDROID_MEDIA_MEDIAMETRICSCONSTANTS_H Loading
media/libaudioclient/AudioRecord.cpp +65 −4 Original line number Diff line number Diff line Loading @@ -105,6 +105,10 @@ void AudioRecord::MediaMetrics::gather(const AudioRecord *record) } } static const char *stateToString(bool active) { return active ? "ACTIVE" : "STOPPED"; } // hand the user a snapshot of the metrics. status_t AudioRecord::getMetrics(mediametrics::Item * &item) { Loading Loading @@ -164,6 +168,11 @@ AudioRecord::~AudioRecord() { mMediaMetrics.gather(this); mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_DTOR) .set(AMEDIAMETRICS_PROP_STATUS, (int32_t)mStatus) .record(); if (mStatus == NO_ERROR) { // Make sure that callback function exits in the case where // it is looping on buffer empty condition in obtainBuffer(). Loading Loading @@ -380,11 +389,21 @@ exit: status_t AudioRecord::start(AudioSystem::sync_event_t event, audio_session_t triggerSession) { const int64_t beginNs = systemTime(); ALOGV("%s(%d): sync event %d trigger session %d", __func__, mPortId, event, triggerSession); AutoMutex lock(mLock); status_t status = NO_ERROR; mediametrics::Defer([&] { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_START) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mActive)) .set(AMEDIAMETRICS_PROP_STATUS, (int32_t)status) .record(); }); if (mActive) { return NO_ERROR; return status; } // discard data in buffer Loading @@ -409,7 +428,6 @@ status_t AudioRecord::start(AudioSystem::sync_event_t event, audio_session_t tri // mActive is checked by restoreRecord_l mActive = true; status_t status = NO_ERROR; if (!(flags & CBLK_INVALID)) { status = mAudioRecord->start(event, triggerSession).transactionError(); if (status == DEAD_OBJECT) { Loading Loading @@ -447,7 +465,15 @@ status_t AudioRecord::start(AudioSystem::sync_event_t event, audio_session_t tri void AudioRecord::stop() { const int64_t beginNs = systemTime(); AutoMutex lock(mLock); mediametrics::Defer([&] { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_STOP) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mActive)) .record(); }); ALOGV("%s(%d): mActive:%d\n", __func__, mPortId, mActive); if (!mActive) { return; Loading Loading @@ -663,6 +689,7 @@ const char * AudioRecord::convertTransferToText(transfer_type transferType) { // must be called with mLock held status_t AudioRecord::createRecord_l(const Modulo<uint32_t> &epoch, const String16& opPackageName) { const int64_t beginNs = systemTime(); const sp<IAudioFlinger>& audioFlinger = AudioSystem::get_audio_flinger(); IAudioFlinger::CreateRecordInput input; IAudioFlinger::CreateRecordOutput output; Loading Loading @@ -849,6 +876,29 @@ status_t AudioRecord::createRecord_l(const Modulo<uint32_t> &epoch, const String mDeathNotifier = new DeathNotifier(this); IInterface::asBinder(mAudioRecord)->linkToDeath(mDeathNotifier, this); mMetricsId = std::string(AMEDIAMETRICS_KEY_PREFIX_AUDIO_RECORD) + std::to_string(mPortId); mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_CREATE) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) // the following are immutable (at least until restore) .set(AMEDIAMETRICS_PROP_FLAGS, (int32_t)mFlags) .set(AMEDIAMETRICS_PROP_ORIGINALFLAGS, (int32_t)mOrigFlags) .set(AMEDIAMETRICS_PROP_SESSIONID, (int32_t)mSessionId) .set(AMEDIAMETRICS_PROP_TRACKID, mPortId) .set(AMEDIAMETRICS_PROP_SOURCE, toString(mAttributes.source).c_str()) .set(AMEDIAMETRICS_PROP_THREADID, (int32_t)output.inputId) .set(AMEDIAMETRICS_PROP_SELECTEDDEVICEID, (int32_t)mSelectedDeviceId) .set(AMEDIAMETRICS_PROP_ROUTEDDEVICEID, (int32_t)mRoutedDeviceId) .set(AMEDIAMETRICS_PROP_ENCODING, toString(mFormat).c_str()) .set(AMEDIAMETRICS_PROP_CHANNELMASK, (int32_t)mChannelMask) .set(AMEDIAMETRICS_PROP_FRAMECOUNT, (int32_t)mFrameCount) .set(AMEDIAMETRICS_PROP_SAMPLERATE, (int32_t)mSampleRate) // the following are NOT immutable .set(AMEDIAMETRICS_PROP_STATE, stateToString(mActive)) .set(AMEDIAMETRICS_PROP_SELECTEDMICDIRECTION, (int32_t)mSelectedMicDirection) .set(AMEDIAMETRICS_PROP_SELECTEDMICFIELDDIRECTION, (double)mSelectedMicFieldDimension) .record(); exit: mStatus = status; // sp<IAudioTrack> track destructor will cause releaseOutput() to be called by AudioFlinger Loading Loading @@ -1288,6 +1338,17 @@ nsecs_t AudioRecord::processAudioBuffer() status_t AudioRecord::restoreRecord_l(const char *from) { status_t result = NO_ERROR; // logged: make sure to set this before returning. const int64_t beginNs = systemTime(); mediametrics::Defer([&] { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_RESTORE) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mActive)) .set(AMEDIAMETRICS_PROP_STATUS, (int32_t)result) .set(AMEDIAMETRICS_PROP_WHERE, from) .record(); }); ALOGW("%s(%d): dead IAudioRecord, creating a new one from %s()", __func__, mPortId, from); ++mSequence; Loading @@ -1306,7 +1367,7 @@ retry: // It will also delete the strong references on previous IAudioRecord and IMemory Modulo<uint32_t> position(mProxy->getPosition()); mNewPosition = position + mUpdatePeriod; status_t result = createRecord_l(position, mOpPackageName); result = createRecord_l(position, mOpPackageName); if (result == NO_ERROR) { if (mActive) { Loading
media/libaudioclient/AudioTrack.cpp +120 −4 Original line number Diff line number Diff line Loading @@ -296,6 +296,12 @@ AudioTrack::~AudioTrack() // pull together the numbers, before we clean up our structures mMediaMetrics.gather(this); mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_DTOR) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mState)) .set(AMEDIAMETRICS_PROP_STATUS, (int32_t)mStatus) .record(); if (mStatus == NO_ERROR) { // Make sure that callback function exits in the case where // it is looping on buffer full condition in obtainBuffer(). Loading Loading @@ -626,11 +632,23 @@ exit: status_t AudioTrack::start() { const int64_t beginNs = systemTime(); AutoMutex lock(mLock); status_t status = NO_ERROR; // logged: make sure to set this before returning. mediametrics::Defer([&] { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_START) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mState)) .set(AMEDIAMETRICS_PROP_STATUS, (int32_t)status) .record(); }); ALOGV("%s(%d): prior state:%s", __func__, mPortId, stateToString(mState)); if (mState == STATE_ACTIVE) { return INVALID_OPERATION; status = INVALID_OPERATION; return status; } mInUnderrun = true; Loading Loading @@ -703,7 +721,6 @@ status_t AudioTrack::start() mNewPosition = mPosition + mUpdatePeriod; int32_t flags = android_atomic_and(~(CBLK_STREAM_END_DONE | CBLK_DISABLED), &mCblk->mFlags); status_t status = NO_ERROR; if (!(flags & CBLK_INVALID)) { status = mAudioTrack->start(); if (status == DEAD_OBJECT) { Loading Loading @@ -749,7 +766,16 @@ status_t AudioTrack::start() void AudioTrack::stop() { const int64_t beginNs = systemTime(); AutoMutex lock(mLock); mediametrics::Defer([&]() { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_STOP) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mState)) .record(); }); ALOGV("%s(%d): prior state:%s", __func__, mPortId, stateToString(mState)); if (mState != STATE_ACTIVE && mState != STATE_PAUSED) { Loading Loading @@ -801,7 +827,15 @@ bool AudioTrack::stopped() const void AudioTrack::flush() { const int64_t beginNs = systemTime(); AutoMutex lock(mLock); mediametrics::Defer([&]() { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_FLUSH) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mState)) .record(); }); ALOGV("%s(%d): prior state:%s", __func__, mPortId, stateToString(mState)); if (mSharedBuffer != 0) { Loading Loading @@ -834,7 +868,15 @@ void AudioTrack::flush_l() void AudioTrack::pause() { const int64_t beginNs = systemTime(); AutoMutex lock(mLock); mediametrics::Defer([&]() { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_PAUSE) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mState)) .record(); }); ALOGV("%s(%d): prior state:%s", __func__, mPortId, stateToString(mState)); if (mState == STATE_ACTIVE) { Loading Loading @@ -876,6 +918,12 @@ status_t AudioTrack::setVolume(float left, float right) return BAD_VALUE; } mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_SETVOLUME) .set(AMEDIAMETRICS_PROP_VOLUME_LEFT, (double)left) .set(AMEDIAMETRICS_PROP_VOLUME_RIGHT, (double)right) .record(); AutoMutex lock(mLock); mVolume[AUDIO_INTERLEAVE_LEFT] = left; mVolume[AUDIO_INTERLEAVE_RIGHT] = right; Loading Loading @@ -1027,6 +1075,20 @@ status_t AudioTrack::setPlaybackRate(const AudioPlaybackRate &playbackRate) //set effective rates mProxy->setPlaybackRate(playbackRateTemp); mProxy->setSampleRate(effectiveRate); // FIXME: not quite "atomic" with setPlaybackRate mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_SETPLAYBACKPARAM) .set(AMEDIAMETRICS_PROP_SAMPLERATE, (int32_t)mSampleRate) .set(AMEDIAMETRICS_PROP_PLAYBACK_SPEED, (double)mPlaybackRate.mSpeed) .set(AMEDIAMETRICS_PROP_PLAYBACK_PITCH, (double)mPlaybackRate.mPitch) .set(AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE AMEDIAMETRICS_PROP_SAMPLERATE, (int32_t)effectiveRate) .set(AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE AMEDIAMETRICS_PROP_PLAYBACK_SPEED, (double)playbackRateTemp.mSpeed) .set(AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE AMEDIAMETRICS_PROP_PLAYBACK_PITCH, (double)playbackRateTemp.mPitch) .record(); return NO_ERROR; } Loading Loading @@ -1618,6 +1680,48 @@ status_t AudioTrack::createTrack_l() mDeathNotifier = new DeathNotifier(this); IInterface::asBinder(mAudioTrack)->linkToDeath(mDeathNotifier, this); // This is the first log sent from the AudioTrack client. // The creation of the audio track by AudioFlinger (in the code above) // is the first log of the AudioTrack and must be present before // any AudioTrack client logs will be accepted. mMetricsId = std::string(AMEDIAMETRICS_KEY_PREFIX_AUDIO_TRACK) + std::to_string(mPortId); mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_CREATE) // the following are immutable .set(AMEDIAMETRICS_PROP_FLAGS, (int32_t)mFlags) .set(AMEDIAMETRICS_PROP_ORIGINALFLAGS, (int32_t)mOrigFlags) .set(AMEDIAMETRICS_PROP_SESSIONID, (int32_t)mSessionId) .set(AMEDIAMETRICS_PROP_TRACKID, mPortId) // dup from key .set(AMEDIAMETRICS_PROP_STREAMTYPE, toString(mStreamType).c_str()) .set(AMEDIAMETRICS_PROP_CONTENTTYPE, toString(mAttributes.content_type).c_str()) .set(AMEDIAMETRICS_PROP_USAGE, toString(mAttributes.usage).c_str()) .set(AMEDIAMETRICS_PROP_THREADID, (int32_t)output.outputId) .set(AMEDIAMETRICS_PROP_SELECTEDDEVICEID, (int32_t)mSelectedDeviceId) .set(AMEDIAMETRICS_PROP_ROUTEDDEVICEID, (int32_t)mRoutedDeviceId) .set(AMEDIAMETRICS_PROP_ENCODING, toString(mFormat).c_str()) .set(AMEDIAMETRICS_PROP_CHANNELMASK, (int32_t)mChannelMask) .set(AMEDIAMETRICS_PROP_FRAMECOUNT, (int32_t)mFrameCount) // the following are NOT immutable .set(AMEDIAMETRICS_PROP_VOLUME_LEFT, (double)mVolume[AUDIO_INTERLEAVE_LEFT]) .set(AMEDIAMETRICS_PROP_VOLUME_RIGHT, (double)mVolume[AUDIO_INTERLEAVE_RIGHT]) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mState)) .set(AMEDIAMETRICS_PROP_AUXEFFECTID, (int32_t)mAuxEffectId) .set(AMEDIAMETRICS_PROP_SAMPLERATE, (int32_t)mSampleRate) .set(AMEDIAMETRICS_PROP_PLAYBACK_SPEED, (double)mPlaybackRate.mSpeed) .set(AMEDIAMETRICS_PROP_PLAYBACK_PITCH, (double)mPlaybackRate.mPitch) .set(AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE AMEDIAMETRICS_PROP_SAMPLERATE, (int32_t)effectiveSampleRate) .set(AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE AMEDIAMETRICS_PROP_PLAYBACK_SPEED, (double)effectiveSpeed) .set(AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE AMEDIAMETRICS_PROP_PLAYBACK_PITCH, (double)effectivePitch) .record(); // mSendLevel // mReqFrameCount? // mNotificationFramesAct, mNotificationFramesReq, mNotificationsPerBufferReq // mLatency, mAfLatency, mAfFrameCount, mAfSampleRate } exit: Loading Loading @@ -2294,6 +2398,17 @@ nsecs_t AudioTrack::processAudioBuffer() status_t AudioTrack::restoreTrack_l(const char *from) { status_t result = NO_ERROR; // logged: make sure to set this before returning. const int64_t beginNs = systemTime(); mediametrics::Defer([&] { mediametrics::LogItem(mMetricsId) .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_RESTORE) .set(AMEDIAMETRICS_PROP_DURATIONNS, (int64_t)(systemTime() - beginNs)) .set(AMEDIAMETRICS_PROP_STATE, stateToString(mState)) .set(AMEDIAMETRICS_PROP_STATUS, (int32_t)result) .set(AMEDIAMETRICS_PROP_WHERE, from) .record(); }); ALOGW("%s(%d): dead IAudioTrack, %s, creating a new one from %s()", __func__, mPortId, isOffloadedOrDirect_l() ? "Offloaded or Direct" : "PCM", from); ++mSequence; Loading @@ -2305,7 +2420,8 @@ status_t AudioTrack::restoreTrack_l(const char *from) if (isOffloadedOrDirect_l() || mDoNotReconnect) { // FIXME re-creation of offloaded and direct tracks is not yet implemented; // reconsider enabling for linear PCM encodings when position can be preserved. return DEAD_OBJECT; result = DEAD_OBJECT; return result; } // Save so we can return count since creation. Loading Loading @@ -2336,7 +2452,7 @@ retry: // following member variables: mAudioTrack, mCblkMemory and mCblk. // It will also delete the strong references on previous IAudioTrack and IMemory. // If a new IAudioTrack cannot be created, the previous (dead) instance will be left intact. status_t result = createTrack_l(); result = createTrack_l(); if (result == NO_ERROR) { // take the frames that will be lost by track recreation into account in saved position Loading
media/libaudioclient/include/media/AudioRecord.h +1 −0 Original line number Diff line number Diff line Loading @@ -771,6 +771,7 @@ private: std::string mLastErrorFunc; }; MediaMetrics mMediaMetrics; std::string mMetricsId; // GUARDED_BY(mLock), could change in createRecord_l(). }; }; // namespace android Loading
media/libaudioclient/include/media/AudioTrack.h +1 −0 Original line number Diff line number Diff line Loading @@ -1245,6 +1245,7 @@ private: std::unique_ptr<mediametrics::Item> mMetricsItem; }; MediaMetrics mMediaMetrics; std::string mMetricsId; // GUARDED_BY(mLock), could change in createTrack_l(). }; }; // namespace android Loading
media/libmediametrics/include/MediaMetricsConstants.h 0 → 100644 +135 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_MEDIA_MEDIAMETRICSCONSTANTS_H #define ANDROID_MEDIA_MEDIAMETRICSCONSTANTS_H /* * MediaMetrics Keys and Properties. * * C/C++ friendly constants that ensure * 1) Compilation error on misspelling * 2) Consistent behavior and documentation. */ /* * Taxonomy of audio keys * * To build longer keys, we use compiler string concatenation of * adjacent string literals. This is done in the translation phase * of compilation to make a single string token. */ // Key Prefixes are used for MediaMetrics Item Keys and ends with a ".". // They must be appended with another value to make a key. #define AMEDIAMETRICS_KEY_PREFIX_AUDIO "audio." // The AudioRecord key appends the "trackId" to the prefix. #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_RECORD AMEDIAMETRICS_KEY_PREFIX_AUDIO "record." // The AudioThread key appends the "threadId" to the prefix. #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_THREAD AMEDIAMETRICS_KEY_PREFIX_AUDIO "thread." // The AudioTrack key appends the "trackId" to the prefix. #define AMEDIAMETRICS_KEY_PREFIX_AUDIO_TRACK AMEDIAMETRICS_KEY_PREFIX_AUDIO "track." // Keys are strings used for MediaMetrics Item Keys #define AMEDIAMETRICS_KEY_AUDIO_FLINGER AMEDIAMETRICS_KEY_PREFIX_AUDIO "flinger" #define AMEDIAMETRICS_KEY_AUDIO_POLICY AMEDIAMETRICS_KEY_PREFIX_AUDIO "policy" /* * MediaMetrics Properties are unified space for consistency and readability. */ // Property prefixes may be applied before a property name to indicate a specific // category to which it is associated. #define AMEDIAMETRICS_PROP_PREFIX_EFFECTIVE "effective." #define AMEDIAMETRICS_PROP_PREFIX_HAL "hal." #define AMEDIAMETRICS_PROP_PREFIX_HAPTIC "haptic." #define AMEDIAMETRICS_PROP_PREFIX_SERVER "server." // Properties within mediametrics are string constants denoted by // a macro name beginning with AMEDIAMETRICS_PROP_* // // For a property name like "auxEffectId" we write this as a single upper case word // at the end of the macro name, such as AMEDIAMETRICS_PROP_AUXEFFECTID. // // Underscores after the AMEDIAMETRICS_PROP_* prefix indicate // a "dot" in the property name. For example AMEDIAMETRICS_PROP_VOLUME_LEFT // corresponds to "volume.left". #define AMEDIAMETRICS_PROP_AUXEFFECTID "auxEffectId" // int32 (AudioTrack) #define AMEDIAMETRICS_PROP_CHANNELCOUNT "channelCount" // int32 #define AMEDIAMETRICS_PROP_CHANNELMASK "channelMask" // int32 #define AMEDIAMETRICS_PROP_CONTENTTYPE "contentType" // string attributes (AudioTrack) #define AMEDIAMETRICS_PROP_DURATIONNS "durationNs" // int64 duration time span #define AMEDIAMETRICS_PROP_ENCODING "encoding" // string value of format #define AMEDIAMETRICS_PROP_EVENT "event" // string value (often func name) // TODO: fix inconsistency in flags: AudioRecord / AudioTrack int32, AudioThread string #define AMEDIAMETRICS_PROP_FLAGS "flags" #define AMEDIAMETRICS_PROP_FRAMECOUNT "frameCount" // int32 #define AMEDIAMETRICS_PROP_INPUTDEVICES "inputDevices" // string value #define AMEDIAMETRICS_PROP_LATENCYMS "latencyMs" // double value #define AMEDIAMETRICS_PROP_ORIGINALFLAGS "originalFlags" // int32 #define AMEDIAMETRICS_PROP_OUTPUTDEVICES "outputDevices" // string value #define AMEDIAMETRICS_PROP_PLAYBACK_PITCH "playback.pitch" // double value (AudioTrack) #define AMEDIAMETRICS_PROP_PLAYBACK_SPEED "playback.speed" // double value (AudioTrack) #define AMEDIAMETRICS_PROP_ROUTEDDEVICEID "routedDeviceId" // int32 #define AMEDIAMETRICS_PROP_SAMPLERATE "sampleRate" // int32 #define AMEDIAMETRICS_PROP_SELECTEDDEVICEID "selectedDeviceId" // int32 #define AMEDIAMETRICS_PROP_SELECTEDMICDIRECTION "selectedMicDirection" // int32 #define AMEDIAMETRICS_PROP_SELECTEDMICFIELDDIRECTION "selectedMicFieldDimension" // double #define AMEDIAMETRICS_PROP_SESSIONID "sessionId" // int32 #define AMEDIAMETRICS_PROP_SOURCE "source" // string (AudioAttributes) #define AMEDIAMETRICS_PROP_STARTUPMS "startupMs" // double value // State is "ACTIVE" or "STOPPED" for AudioRecord #define AMEDIAMETRICS_PROP_STATE "state" // string #define AMEDIAMETRICS_PROP_STATUS "status" // int32 status_t #define AMEDIAMETRICS_PROP_STREAMTYPE "streamType" // string (AudioTrack) #define AMEDIAMETRICS_PROP_THREADID "threadId" // int32 value io handle #define AMEDIAMETRICS_PROP_THROTTLEMS "throttleMs" // double #define AMEDIAMETRICS_PROP_TRACKID "trackId" // int32 port id of track/record #define AMEDIAMETRICS_PROP_TYPE "type" // string (thread type) #define AMEDIAMETRICS_PROP_UNDERRUN "underrun" // int32 #define AMEDIAMETRICS_PROP_USAGE "usage" // string attributes (ATrack) #define AMEDIAMETRICS_PROP_VOLUME_LEFT "volume.left" // double (AudioTrack) #define AMEDIAMETRICS_PROP_VOLUME_RIGHT "volume.right" // double (AudioTrack) #define AMEDIAMETRICS_PROP_WHERE "where" // string value // Timing values: millisecond values are suffixed with MS and the type is double // nanosecond values are suffixed with NS and the type is int64. // Values are strings accepted for a given property. // An event is a general description, which often is a function name. #define AMEDIAMETRICS_PROP_EVENT_VALUE_CREATE "create" #define AMEDIAMETRICS_PROP_EVENT_VALUE_CREATEAUDIOPATCH "createAudioPatch" #define AMEDIAMETRICS_PROP_EVENT_VALUE_CTOR "ctor" #define AMEDIAMETRICS_PROP_EVENT_VALUE_DTOR "dtor" #define AMEDIAMETRICS_PROP_EVENT_VALUE_FLUSH "flush" // AudioTrack #define AMEDIAMETRICS_PROP_EVENT_VALUE_INVALIDATE "invalidate" // server track, record #define AMEDIAMETRICS_PROP_EVENT_VALUE_PAUSE "pause" // AudioTrack #define AMEDIAMETRICS_PROP_EVENT_VALUE_READPARAMETERS "readParameters" // Thread #define AMEDIAMETRICS_PROP_EVENT_VALUE_RESTORE "restore" #define AMEDIAMETRICS_PROP_EVENT_VALUE_SETPLAYBACKPARAM "setPlaybackParam" // AudioTrack #define AMEDIAMETRICS_PROP_EVENT_VALUE_SETVOLUME "setVolume" // AudioTrack #define AMEDIAMETRICS_PROP_EVENT_VALUE_START "start" // AudioTrack, AudioRecord #define AMEDIAMETRICS_PROP_EVENT_VALUE_STOP "stop" // AudioTrack, AudioRecord #define AMEDIAMETRICS_PROP_EVENT_VALUE_UNDERRUN "underrun" // from Thread #endif // ANDROID_MEDIA_MEDIAMETRICSCONSTANTS_H