Prevent TunerHAL passthrough from going into standby
Test: compiles, see bug
Bug: 226349461
Merged-In: Ic5175bc79cf699cbacf9799940bdf5abfd87a3a3
Change-Id: Ic5175bc79cf699cbacf9799940bdf5abfd87a3a3
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 0249283..bb096fe 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -2840,13 +2840,15 @@
ALOGV("openOutput_l() created spatializer output: ID %d thread %p",
*output, thread.get());
} else if (flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
- thread = new OffloadThread(this, outputStream, *output, mSystemReady);
+ thread = new OffloadThread(this, outputStream, *output,
+ mSystemReady, halConfig->offload_info);
ALOGV("openOutput_l() created offload output: ID %d thread %p",
*output, thread.get());
} else if ((flags & AUDIO_OUTPUT_FLAG_DIRECT)
|| !isValidPcmSinkFormat(halConfig->format)
|| !isValidPcmSinkChannelMask(halConfig->channel_mask)) {
- thread = new DirectOutputThread(this, outputStream, *output, mSystemReady);
+ thread = new DirectOutputThread(this, outputStream, *output,
+ mSystemReady, halConfig->offload_info);
ALOGV("openOutput_l() created direct output: ID %d thread %p",
*output, thread.get());
} else {
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index c1fadb2..6acfab9 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -6105,8 +6105,10 @@
// ----------------------------------------------------------------------------
AudioFlinger::DirectOutputThread::DirectOutputThread(const sp<AudioFlinger>& audioFlinger,
- AudioStreamOut* output, audio_io_handle_t id, ThreadBase::type_t type, bool systemReady)
+ AudioStreamOut* output, audio_io_handle_t id, ThreadBase::type_t type, bool systemReady,
+ const audio_offload_info_t& offloadInfo)
: PlaybackThread(audioFlinger, output, id, type, systemReady)
+ , mOffloadInfo(offloadInfo)
{
setMasterBalance(audioFlinger->getMasterBalance_l());
}
@@ -6372,7 +6374,8 @@
// fill a buffer, then remove it from active list.
// Only consider last track started for mixer state control
bool isTimestampAdvancing = mIsTimestampAdvancing.check(mOutput);
- if (--(track->mRetryCount) <= 0) {
+ if (!isTunerStream() // tuner streams remain active in underrun
+ && --(track->mRetryCount) <= 0) {
if (isTimestampAdvancing) { // HAL is still playing audio, give us more time.
track->mRetryCount = kMaxTrackRetriesOffload;
} else {
@@ -6735,8 +6738,9 @@
// ----------------------------------------------------------------------------
AudioFlinger::OffloadThread::OffloadThread(const sp<AudioFlinger>& audioFlinger,
- AudioStreamOut* output, audio_io_handle_t id, bool systemReady)
- : DirectOutputThread(audioFlinger, output, id, OFFLOAD, systemReady),
+ AudioStreamOut* output, audio_io_handle_t id, bool systemReady,
+ const audio_offload_info_t& offloadInfo)
+ : DirectOutputThread(audioFlinger, output, id, OFFLOAD, systemReady, offloadInfo),
mPausedWriteLength(0), mPausedBytesRemaining(0), mKeepWakeLock(true)
{
//FIXME: mStandby should be set to true by ThreadBase constructo
@@ -6955,7 +6959,8 @@
// No buffers for this track. Give it a few chances to
// fill a buffer, then remove it from active list.
bool isTimestampAdvancing = mIsTimestampAdvancing.check(mOutput);
- if (--(track->mRetryCount) <= 0) {
+ if (!isTunerStream() // tuner streams remain active in underrun
+ && --(track->mRetryCount) <= 0) {
if (isTimestampAdvancing) { // HAL is still playing audio, give us more time.
track->mRetryCount = kMaxTrackRetriesOffload;
} else {
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index da5adea..044aba3 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -1540,8 +1540,9 @@
public:
DirectOutputThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
- audio_io_handle_t id, bool systemReady)
- : DirectOutputThread(audioFlinger, output, id, DIRECT, systemReady) { }
+ audio_io_handle_t id, bool systemReady,
+ const audio_offload_info_t& offloadInfo)
+ : DirectOutputThread(audioFlinger, output, id, DIRECT, systemReady, offloadInfo) { }
virtual ~DirectOutputThread();
@@ -1573,11 +1574,14 @@
virtual void onAddNewTrack_l();
+ const audio_offload_info_t mOffloadInfo;
bool mVolumeShaperActive = false;
DirectOutputThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
- audio_io_handle_t id, ThreadBase::type_t type, bool systemReady);
+ audio_io_handle_t id, ThreadBase::type_t type, bool systemReady,
+ const audio_offload_info_t& offloadInfo);
void processVolume_l(Track *track, bool lastTrack);
+ bool isTunerStream() const { return (mOffloadInfo.content_id > 0); }
// prepareTracks_l() tells threadLoop_mix() the name of the single active track
sp<Track> mActiveTrack;
@@ -1615,7 +1619,8 @@
public:
OffloadThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
- audio_io_handle_t id, bool systemReady);
+ audio_io_handle_t id, bool systemReady,
+ const audio_offload_info_t& offloadInfo);
virtual ~OffloadThread() {};
void flushHw_l() override;