3737#include < cutils/properties.h>
3838#include < cutils/compiler.h>
3939
40+ #undef ADD_BATTERY_DATA
41+
42+ #ifdef ADD_BATTERY_DATA
4043#include < media/IMediaPlayerService.h>
4144#include < media/IMediaDeathNotifier.h>
45+ #endif
4246
4347#include < private/media/AudioTrackShared.h>
4448#include < private/media/AudioEffectShared.h>
@@ -105,6 +109,7 @@ nsecs_t AudioFlinger::mStandbyTimeInNsecs = kDefaultStandbyTimeInNsecs;
105109
106110// ----------------------------------------------------------------------------
107111
112+ #ifdef ADD_BATTERY_DATA
108113// To collect the amplifier usage
109114static void addBatteryData (uint32_t params) {
110115 sp<IMediaPlayerService> service = IMediaDeathNotifier::getMediaPlayerService ();
@@ -115,6 +120,7 @@ static void addBatteryData(uint32_t params) {
115120
116121 service->addBatteryData (params);
117122}
123+ #endif
118124
119125static int load_audio_interface (const char *if_name, const hw_module_t **mod,
120126 audio_hw_device_t **dev)
@@ -2612,6 +2618,7 @@ bool AudioFlinger::MixerThread::checkForNewParameters_l()
26122618 }
26132619 }
26142620 if (param.getInt (String8 (AudioParameter::keyRouting), value) == NO_ERROR) {
2621+ #ifdef ADD_BATTERY_DATA
26152622 // when changing the audio output device, call addBatteryData to notify
26162623 // the change
26172624 if ((int )mDevice != value) {
@@ -2632,6 +2639,7 @@ bool AudioFlinger::MixerThread::checkForNewParameters_l()
26322639 addBatteryData (params);
26332640 }
26342641 }
2642+ #endif
26352643
26362644 // forward device change to effects that have requested to be
26372645 // aware of attached audio device.
@@ -3454,8 +3462,10 @@ void AudioFlinger::PlaybackThread::Track::destroy()
34543462 if (mState == ACTIVE || mState == RESUMING) {
34553463 AudioSystem::stopOutput (thread->id (), mStreamType , mSessionId );
34563464
3465+ #ifdef ADD_BATTERY_DATA
34573466 // to track the speaker usage
34583467 addBatteryData (IMediaPlayerService::kBatteryDataAudioFlingerStop );
3468+ #endif
34593469 }
34603470 AudioSystem::releaseOutput (thread->id ());
34613471 }
@@ -3572,10 +3582,12 @@ status_t AudioFlinger::PlaybackThread::Track::start(pid_t tid)
35723582 status = AudioSystem::startOutput (thread->id (), mStreamType , mSessionId );
35733583 thread->mLock .lock ();
35743584
3585+ #ifdef ADD_BATTERY_DATA
35753586 // to track the speaker usage
35763587 if (status == NO_ERROR) {
35773588 addBatteryData (IMediaPlayerService::kBatteryDataAudioFlingerStart );
35783589 }
3590+ #endif
35793591 }
35803592 if (status == NO_ERROR) {
35813593 PlaybackThread *playbackThread = (PlaybackThread *)thread.get ();
@@ -3610,8 +3622,10 @@ void AudioFlinger::PlaybackThread::Track::stop()
36103622 AudioSystem::stopOutput (thread->id (), mStreamType , mSessionId );
36113623 thread->mLock .lock ();
36123624
3625+ #ifdef ADD_BATTERY_DATA
36133626 // to track the speaker usage
36143627 addBatteryData (IMediaPlayerService::kBatteryDataAudioFlingerStop );
3628+ #endif
36153629 }
36163630 }
36173631}
@@ -3630,8 +3644,10 @@ void AudioFlinger::PlaybackThread::Track::pause()
36303644 AudioSystem::stopOutput (thread->id (), mStreamType , mSessionId );
36313645 thread->mLock .lock ();
36323646
3647+ #ifdef ADD_BATTERY_DATA
36333648 // to track the speaker usage
36343649 addBatteryData (IMediaPlayerService::kBatteryDataAudioFlingerStop );
3650+ #endif
36353651 }
36363652 }
36373653 }
0 commit comments