From f2f072e87718ecf6df40ba51b95e2a93bc68f720 Mon Sep 17 00:00:00 2001 From: Wei Jia Date: Fri, 31 Oct 2014 17:57:05 -0700 Subject: AnotherPacketSource.cpp: Do not queue discontinity signal buffer resulted from seek. This will remove the unnecessary flush for seek. Bug: 17511837 Change-Id: I4b7acfc71a410372f5c630afb94b6a95d09d8974 --- .../nuplayer/GenericSource.cpp | 8 +-- media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 77 ++++++++++------------ media/libmediaplayerservice/nuplayer/NuPlayer.h | 11 +++- .../libmediaplayerservice/nuplayer/RTSPSource.cpp | 2 +- .../nuplayer/StreamingSource.cpp | 4 +- media/libstagefright/httplive/LiveSession.cpp | 2 +- media/libstagefright/httplive/PlaylistFetcher.cpp | 2 +- media/libstagefright/mpeg2ts/ATSParser.h | 2 - .../libstagefright/mpeg2ts/AnotherPacketSource.cpp | 4 ++ 9 files changed, 55 insertions(+), 57 deletions(-) diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.cpp b/media/libmediaplayerservice/nuplayer/GenericSource.cpp index 6859a1a..0e520a8 100644 --- a/media/libmediaplayerservice/nuplayer/GenericSource.cpp +++ b/media/libmediaplayerservice/nuplayer/GenericSource.cpp @@ -1311,11 +1311,9 @@ void NuPlayer::GenericSource::readBuffer( if ((seeking || formatChange) && (trackType == MEDIA_TRACK_TYPE_AUDIO || trackType == MEDIA_TRACK_TYPE_VIDEO)) { - ATSParser::DiscontinuityType type = formatChange - ? (seeking - ? ATSParser::DISCONTINUITY_FORMATCHANGE - : ATSParser::DISCONTINUITY_NONE) - : ATSParser::DISCONTINUITY_SEEK; + ATSParser::DiscontinuityType type = (formatChange && seeking) + ? ATSParser::DISCONTINUITY_FORMATCHANGE + : ATSParser::DISCONTINUITY_NONE; track->mPackets->queueDiscontinuity( type, NULL, true /* discard */); } diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index 931451f..47bd989 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -95,21 +95,21 @@ private: DISALLOW_EVIL_CONSTRUCTORS(SetSurfaceAction); }; -struct NuPlayer::ShutdownDecoderAction : public Action { - ShutdownDecoderAction(bool audio, bool video) +struct NuPlayer::FlushDecoderAction : public Action { + FlushDecoderAction(FlushCommand audio, FlushCommand video) : mAudio(audio), mVideo(video) { } virtual void execute(NuPlayer *player) { - player->performDecoderShutdown(mAudio, mVideo); + player->performDecoderFlush(mAudio, mVideo); } private: - bool mAudio; - bool mVideo; + FlushCommand mAudio; + FlushCommand mVideo; - DISALLOW_EVIL_CONSTRUCTORS(ShutdownDecoderAction); + DISALLOW_EVIL_CONSTRUCTORS(FlushDecoderAction); }; struct NuPlayer::PostMessageAction : public Action { @@ -522,19 +522,24 @@ void NuPlayer::onMessageReceived(const sp &msg) { { ALOGV("kWhatSetVideoNativeWindow"); - mDeferredActions.push_back( - new ShutdownDecoderAction( - false /* audio */, true /* video */)); - sp obj; CHECK(msg->findObject("native-window", &obj)); + if (mSource->getFormat(false /* audio */) == NULL) { + performSetSurface(static_cast(obj.get())); + break; + } + + mDeferredActions.push_back( + new FlushDecoderAction(FLUSH_CMD_FLUSH /* audio */, + FLUSH_CMD_SHUTDOWN /* video */)); + mDeferredActions.push_back( new SetSurfaceAction( static_cast(obj.get()))); if (obj != NULL) { - if (mStarted && mSource->getFormat(false /* audio */) != NULL) { + if (mStarted) { // Issue a seek to refresh the video screen only if started otherwise // the extractor may not yet be started and will assert. // If the video decoder is not set (perhaps audio only in this case) @@ -749,7 +754,9 @@ void NuPlayer::onMessageReceived(const sp &msg) { switch (*flushing) { case NONE: mDeferredActions.push_back( - new ShutdownDecoderAction(audio, !audio /* video */)); + new FlushDecoderAction( + audio ? FLUSH_CMD_SHUTDOWN : FLUSH_CMD_NONE, + audio ? FLUSH_CMD_NONE : FLUSH_CMD_SHUTDOWN)); processDeferredActions(); break; case FLUSHING_DECODER: @@ -872,8 +879,9 @@ void NuPlayer::onMessageReceived(const sp &msg) { ALOGV("kWhatReset"); mDeferredActions.push_back( - new ShutdownDecoderAction( - true /* audio */, true /* video */)); + new FlushDecoderAction( + FLUSH_CMD_SHUTDOWN /* audio */, + FLUSH_CMD_SHUTDOWN /* video */)); mDeferredActions.push_back( new SimpleAction(&NuPlayer::performReset)); @@ -893,7 +901,8 @@ void NuPlayer::onMessageReceived(const sp &msg) { seekTimeUs, needNotify); mDeferredActions.push_back( - new SimpleAction(&NuPlayer::performDecoderFlush)); + new FlushDecoderAction(FLUSH_CMD_FLUSH /* audio */, + FLUSH_CMD_FLUSH /* video */)); mDeferredActions.push_back( new SeekAction(seekTimeUs, needNotify)); @@ -1625,7 +1634,9 @@ void NuPlayer::queueDecoderShutdown( ALOGI("queueDecoderShutdown audio=%d, video=%d", audio, video); mDeferredActions.push_back( - new ShutdownDecoderAction(audio, video)); + new FlushDecoderAction( + audio ? FLUSH_CMD_SHUTDOWN : FLUSH_CMD_NONE, + video ? FLUSH_CMD_SHUTDOWN : FLUSH_CMD_NONE)); mDeferredActions.push_back( new SimpleAction(&NuPlayer::performScanSources)); @@ -1770,40 +1781,22 @@ void NuPlayer::performSeek(int64_t seekTimeUs, bool needNotify) { // everything's flushed, continue playback. } -void NuPlayer::performDecoderFlush() { - ALOGV("performDecoderFlush"); - - if (mAudioDecoder == NULL && mVideoDecoder == NULL) { - return; - } - - mTimeDiscontinuityPending = true; - - if (mAudioDecoder != NULL) { - flushDecoder(true /* audio */, false /* needShutdown */); - } - - if (mVideoDecoder != NULL) { - flushDecoder(false /* audio */, false /* needShutdown */); - } -} - -void NuPlayer::performDecoderShutdown(bool audio, bool video) { - ALOGV("performDecoderShutdown audio=%d, video=%d", audio, video); +void NuPlayer::performDecoderFlush(FlushCommand audio, FlushCommand video) { + ALOGV("performDecoderFlush audio=%d, video=%d", audio, video); - if ((!audio || mAudioDecoder == NULL) - && (!video || mVideoDecoder == NULL)) { + if ((audio == FLUSH_CMD_NONE || mAudioDecoder == NULL) + && (video == FLUSH_CMD_NONE || mVideoDecoder == NULL)) { return; } mTimeDiscontinuityPending = true; - if (audio && mAudioDecoder != NULL) { - flushDecoder(true /* audio */, true /* needShutdown */); + if (audio != FLUSH_CMD_NONE && mAudioDecoder != NULL) { + flushDecoder(true /* audio */, (audio == FLUSH_CMD_SHUTDOWN)); } - if (video && mVideoDecoder != NULL) { - flushDecoder(false /* audio */, true /* needShutdown */); + if (video != FLUSH_CMD_NONE && mVideoDecoder != NULL) { + flushDecoder(false /* audio */, (video == FLUSH_CMD_SHUTDOWN)); } } diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h index 14056ca..121f7dd 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h @@ -94,7 +94,7 @@ private: struct Action; struct SeekAction; struct SetSurfaceAction; - struct ShutdownDecoderAction; + struct FlushDecoderAction; struct PostMessageAction; struct SimpleAction; @@ -159,6 +159,12 @@ private: SHUT_DOWN, }; + enum FlushCommand { + FLUSH_CMD_NONE, + FLUSH_CMD_FLUSH, + FLUSH_CMD_SHUTDOWN, + }; + // Once the current flush is complete this indicates whether the // notion of time has changed. bool mTimeDiscontinuityPending; @@ -229,8 +235,7 @@ private: void processDeferredActions(); void performSeek(int64_t seekTimeUs, bool needNotify); - void performDecoderFlush(); - void performDecoderShutdown(bool audio, bool video); + void performDecoderFlush(FlushCommand audio, FlushCommand video); void performReset(); void performScanSources(); void performSetSurface(const sp &wrapper); diff --git a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp index ffacb8f..52ae9ee 100644 --- a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp +++ b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp @@ -506,7 +506,7 @@ void NuPlayer::RTSPSource::onMessageReceived(const sp &msg) { sp source = info->mSource; if (source != NULL) { source->queueDiscontinuity( - ATSParser::DISCONTINUITY_SEEK, + ATSParser::DISCONTINUITY_TIME, NULL, true /* discard */); } diff --git a/media/libmediaplayerservice/nuplayer/StreamingSource.cpp b/media/libmediaplayerservice/nuplayer/StreamingSource.cpp index 2e9a29a..27f5159 100644 --- a/media/libmediaplayerservice/nuplayer/StreamingSource.cpp +++ b/media/libmediaplayerservice/nuplayer/StreamingSource.cpp @@ -80,7 +80,7 @@ status_t NuPlayer::StreamingSource::feedMoreTSData() { mFinalResult = ERROR_END_OF_STREAM; break; } else if (n == INFO_DISCONTINUITY) { - int32_t type = ATSParser::DISCONTINUITY_SEEK; + int32_t type = ATSParser::DISCONTINUITY_TIME; int32_t mask; if (extra != NULL @@ -118,7 +118,7 @@ status_t NuPlayer::StreamingSource::feedMoreTSData() { mTSParser->signalDiscontinuity( ((type & 1) == 0) - ? ATSParser::DISCONTINUITY_SEEK + ? ATSParser::DISCONTINUITY_TIME : ATSParser::DISCONTINUITY_FORMATCHANGE, extra); } else { diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp index fba6b09..874c118 100644 --- a/media/libstagefright/httplive/LiveSession.cpp +++ b/media/libstagefright/httplive/LiveSession.cpp @@ -1458,7 +1458,7 @@ void LiveSession::onChangeConfiguration3(const sp &msg) { extra->setInt64("timeUs", timeUs); discontinuityQueue = mDiscontinuities.valueFor(indexToType(j)); discontinuityQueue->queueDiscontinuity( - ATSParser::DISCONTINUITY_SEEK, extra, true); + ATSParser::DISCONTINUITY_TIME, extra, true); } else { int32_t type; int64_t srcSegmentStartTimeUs; diff --git a/media/libstagefright/httplive/PlaylistFetcher.cpp b/media/libstagefright/httplive/PlaylistFetcher.cpp index 30fa868..89181b5 100644 --- a/media/libstagefright/httplive/PlaylistFetcher.cpp +++ b/media/libstagefright/httplive/PlaylistFetcher.cpp @@ -1155,7 +1155,7 @@ status_t PlaylistFetcher::extractAndQueueAccessUnitsFromTs(const sp &bu extra->setInt64(IStreamListener::kKeyMediaTimeUs, 0); mTSParser->signalDiscontinuity( - ATSParser::DISCONTINUITY_SEEK, extra); + ATSParser::DISCONTINUITY_TIME, extra); mAbsoluteTimeAnchorUs = mNextPTSTimeUs; mNextPTSTimeUs = -1ll; diff --git a/media/libstagefright/mpeg2ts/ATSParser.h b/media/libstagefright/mpeg2ts/ATSParser.h index 8986a22..204934d 100644 --- a/media/libstagefright/mpeg2ts/ATSParser.h +++ b/media/libstagefright/mpeg2ts/ATSParser.h @@ -41,8 +41,6 @@ struct ATSParser : public RefBase { DISCONTINUITY_ABSOLUTE_TIME = 8, DISCONTINUITY_TIME_OFFSET = 16, - DISCONTINUITY_SEEK = DISCONTINUITY_TIME, - // For legacy reasons this also implies a time discontinuity. DISCONTINUITY_FORMATCHANGE = DISCONTINUITY_AUDIO_FORMAT diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp index a03f6f9..ed40bdd 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp @@ -262,6 +262,10 @@ void AnotherPacketSource::queueDiscontinuity( } } + if (type == ATSParser::DISCONTINUITY_NONE) { + return; + } + mEOSResult = OK; mLastQueuedTimeUs = 0; mLatestEnqueuedMeta = NULL; -- cgit v1.1 From ba37077dc8507a32109128a4fcfbc5f43fb47217 Mon Sep 17 00:00:00 2001 From: Marco Nelissen Date: Tue, 11 Nov 2014 13:56:44 -0800 Subject: Fix looping sound playback The renderer stops the audio sink at the end in order to play out the last little bit of audio. When the sound is looping, the sink needs to be restarted. Bug: 18326137 Change-Id: I3bc3629597fc43cce33bdf5691d29cc4c2285926 --- media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp index b9a1a6c..b42b480 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp @@ -628,6 +628,11 @@ void NuPlayerDriver::notifyListener_l( if (mLooping || (mAutoLoop && (mAudioSink == NULL || mAudioSink->realtime()))) { mPlayer->seekToAsync(0); + if (mAudioSink != NULL) { + // The renderer has stopped the sink at the end in order to play out + // the last little bit of audio. If we're looping, we need to restart it. + mAudioSink->start(); + } break; } -- cgit v1.1 From d7535106412d2245f1995051355529615ed93868 Mon Sep 17 00:00:00 2001 From: Wei Jia Date: Wed, 12 Nov 2014 15:37:07 -0800 Subject: AnotherPacketSource: need reset some members before returning from queueDiscontinuity(). Bug: 18355014 Bug: 17511837 Change-Id: I4b623d3bc4fbeaf0e8bf4ddd96661469d17afe7a --- media/libstagefright/mpeg2ts/AnotherPacketSource.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp index ed40bdd..c579d4c 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp @@ -262,15 +262,15 @@ void AnotherPacketSource::queueDiscontinuity( } } + mEOSResult = OK; + mLastQueuedTimeUs = 0; + mLatestEnqueuedMeta = NULL; + if (type == ATSParser::DISCONTINUITY_NONE) { return; } - mEOSResult = OK; - mLastQueuedTimeUs = 0; - mLatestEnqueuedMeta = NULL; ++mQueuedDiscontinuityCount; - sp buffer = new ABuffer(0); buffer->meta()->setInt32("discontinuity", static_cast(type)); buffer->meta()->setMessage("extra", extra); -- cgit v1.1 From fd85870ee9f7ded70adce065b524e0c63bab2b50 Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Mon, 17 Nov 2014 13:42:01 -0800 Subject: Fix race condition in signaling completion for decode. Bug: 18048775 Change-Id: I2207eb2cf30cf205d9bf414edbb1d3e709185f67 --- media/libmediaplayerservice/MediaPlayerService.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp index c120898..d461af3 100644 --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -2125,6 +2125,7 @@ ssize_t MediaPlayerService::AudioCache::write(const void* buffer, size_t size) // immutable with respect to future writes. // // It is thus safe for another thread to read the AudioCache. + Mutex::Autolock lock(mLock); mCommandComplete = true; mSignal.signal(); } -- cgit v1.1 From 2e4800145a173732b832bd168dfed7100ed2fadc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= Date: Thu, 20 Nov 2014 13:18:24 +0100 Subject: Fix overload of SoftVideoDecoderOMXComponent::updatePortDefinitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An overloaded function should take the same parameters as the function it is overloading. Bug: 18639027 Change-Id: I8327fe1b363917515cf76c8f76bdbc05b2c0fbf0 Signed-off-by: Bernhard Rosenkränzer --- media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp | 4 ++-- media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp b/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp index e399984..246069b 100644 --- a/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp +++ b/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.cpp @@ -353,8 +353,8 @@ void SoftMPEG4::onReset() { } } -void SoftMPEG4::updatePortDefinitions() { - SoftVideoDecoderOMXComponent::updatePortDefinitions(); +void SoftMPEG4::updatePortDefinitions(bool updateCrop) { + SoftVideoDecoderOMXComponent::updatePortDefinitions(updateCrop); /* We have to align our width and height - this should affect stride! */ OMX_PARAM_PORTDEFINITIONTYPE *def = &editPortInfo(kOutputPortIndex)->mDef; diff --git a/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.h b/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.h index 8a06a00..31577e2 100644 --- a/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.h +++ b/media/libstagefright/codecs/m4v_h263/dec/SoftMPEG4.h @@ -66,7 +66,7 @@ private: status_t initDecoder(); - virtual void updatePortDefinitions(); + virtual void updatePortDefinitions(bool updateCrop = true); bool handlePortSettingsChange(); DISALLOW_EVIL_CONSTRUCTORS(SoftMPEG4); -- cgit v1.1 From 9210450a8b62805c8e961aa66e025c1a84a4b382 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Wed, 10 Dec 2014 11:21:49 -0800 Subject: audio policy: suppport for dynamic source Completed support for dynamic sources: - remote submix input device is dynamically connected/disconnected when corresponding AudioTrack starts/stops. Also do not create a duplicated output for mixes used by dynamic policies. Bug: 16006090. Change-Id: Ib5b5a2159fcac9d9f410a5a2f1c64d7ebad79f72 --- services/audiopolicy/AudioPolicyManager.cpp | 140 +++++++++++++++++++--------- services/audiopolicy/AudioPolicyManager.h | 9 +- 2 files changed, 101 insertions(+), 48 deletions(-) diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp index 9918b6f..3cd5fb2 100644 --- a/services/audiopolicy/AudioPolicyManager.cpp +++ b/services/audiopolicy/AudioPolicyManager.cpp @@ -899,14 +899,13 @@ status_t AudioPolicyManager::getOutputForAttr(const audio_attributes_t *attr, mPolicyMixes[i]->mMix.mRegistrationId.string(), AUDIO_ATTRIBUTES_TAGS_MAX_SIZE - strlen("addr=") - 1) == 0) { desc = mPolicyMixes[i]->mOutput; - break; } } if (desc != 0) { if (!audio_is_linear_pcm(format)) { return BAD_VALUE; } - desc->mPolicyMixAddress = mPolicyMixes[i]->mMix.mRegistrationId; + desc->mPolicyMix = &mPolicyMixes[i]->mMix; *stream = streamTypefromAttributesInt(&attributes); *output = desc->mIoHandle; ALOGV("getOutputForAttr() returns output %d", *output); @@ -1227,8 +1226,7 @@ status_t AudioPolicyManager::startOutput(audio_io_handle_t output, if (outputDesc->mRefCount[stream] == 1) { // starting an output being rerouted? audio_devices_t newDevice; - if (outputDesc->mPolicyMixAddress != String8("") - && outputDesc->mPolicyMixAddress != String8("0")) { + if (outputDesc->mPolicyMix != NULL) { newDevice = AUDIO_DEVICE_OUT_REMOTE_SUBMIX; } else { newDevice = getNewOutputDevice(output, false /*fromCache*/); @@ -1275,6 +1273,16 @@ status_t AudioPolicyManager::startOutput(audio_io_handle_t output, // update the outputs if starting an output with a stream that can affect notification // routing handleNotificationRoutingForStream(stream); + + // Automatically enable the remote submix input when output is started on a re routing mix + // of type MIX_TYPE_RECORDERS + if (audio_is_remote_submix_device(newDevice) && outputDesc->mPolicyMix != NULL && + outputDesc->mPolicyMix->mMixType == MIX_TYPE_RECORDERS) { + setDeviceConnectionState(AUDIO_DEVICE_IN_REMOTE_SUBMIX, + AUDIO_POLICY_DEVICE_STATE_AVAILABLE, + outputDesc->mPolicyMix->mRegistrationId); + } + if (waitMs > muteWaitMs) { usleep((waitMs - muteWaitMs) * 2 * 1000); } @@ -1309,6 +1317,16 @@ status_t AudioPolicyManager::stopOutput(audio_io_handle_t output, outputDesc->changeRefCount(stream, -1); // store time at which the stream was stopped - see isStreamActive() if (outputDesc->mRefCount[stream] == 0) { + // Automatically disable the remote submix input when output is stopped on a + // re routing mix of type MIX_TYPE_RECORDERS + if (audio_is_remote_submix_device(outputDesc->mDevice) && + outputDesc->mPolicyMix != NULL && + outputDesc->mPolicyMix->mMixType == MIX_TYPE_RECORDERS) { + setDeviceConnectionState(AUDIO_DEVICE_IN_REMOTE_SUBMIX, + AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, + outputDesc->mPolicyMix->mRegistrationId); + } + outputDesc->mStopTime[stream] = systemTime(); audio_devices_t newDevice = getNewOutputDevice(output, false /*fromCache*/); // delay the device switch by twice the latency because stopOutput() is executed when @@ -1406,6 +1424,7 @@ status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr, String8 address = String8(""); bool isSoundTrigger = false; audio_source_t halInputSource = attr->source; + AudioMix *policyMix = NULL; if (attr->source == AUDIO_SOURCE_REMOTE_SUBMIX && strncmp(attr->tags, "addr=", strlen("addr=")) == 0) { @@ -1416,13 +1435,22 @@ status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr, ALOGW("getInputForAttr() no policy for address %s", address.string()); return BAD_VALUE; } + if (mPolicyMixes[index]->mMix.mMixType != MIX_TYPE_PLAYERS) { + ALOGW("getInputForAttr() bad policy mix type for address %s", address.string()); + return BAD_VALUE; + } + policyMix = &mPolicyMixes[index]->mMix; } else { - device = getDeviceForInputSource(attr->source, &address); - + device = getDeviceForInputSource(attr->source, &policyMix); if (device == AUDIO_DEVICE_NONE) { ALOGW("getInputForAttr() could not find device for source %d", attr->source); return BAD_VALUE; } + if (policyMix != NULL) { + address = policyMix->mRegistrationId; + } else if (audio_is_remote_submix_device(device)) { + address = String8("0"); + } // adapt channel selection to input source switch (attr->source) { case AUDIO_SOURCE_VOICE_UPLINK: @@ -1507,8 +1535,9 @@ status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr, inputDesc->mFormat = format; inputDesc->mChannelMask = channelMask; inputDesc->mDevice = device; - inputDesc->mSessions.add(session, address); + inputDesc->mSessions.add(session); inputDesc->mIsSoundTrigger = isSoundTrigger; + inputDesc->mPolicyMix = policyMix; addInput(*input, inputDesc); mpClientInterface->onAudioPortListUpdate(); @@ -1526,7 +1555,7 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input, } sp inputDesc = mInputs.valueAt(index); - index = inputDesc->mSessions.indexOfKey(session); + index = inputDesc->mSessions.indexOf(session); if (index < 0) { ALOGW("startInput() unknown session %d on input %d", session, input); return BAD_VALUE; @@ -1544,8 +1573,8 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input, sp activeDesc = mInputs.valueFor(activeInput); if (activeDesc->mInputSource == AUDIO_SOURCE_HOTWORD) { ALOGW("startInput(%d) preempting low-priority input %d", input, activeInput); - stopInput(activeInput, activeDesc->mSessions.keyAt(0)); - releaseInput(activeInput, activeDesc->mSessions.keyAt(0)); + stopInput(activeInput, activeDesc->mSessions.itemAt(0)); + releaseInput(activeInput, activeDesc->mSessions.itemAt(0)); } else { ALOGE("startInput(%d) failed: other input %d already started", input, activeInput); return INVALID_OPERATION; @@ -1559,12 +1588,21 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input, } setInputDevice(input, getNewInputDevice(input), true /* force */); - // Automatically enable the remote submix output when input is started. + // automatically enable the remote submix output when input is started if not + // used by a policy mix of type MIX_TYPE_RECORDERS // For remote submix (a virtual device), we open only one input per capture request. if (audio_is_remote_submix_device(inputDesc->mDevice)) { - setDeviceConnectionState(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, - AUDIO_POLICY_DEVICE_STATE_AVAILABLE, - inputDesc->mSessions.valueAt(index)); + String8 address = String8(""); + if (inputDesc->mPolicyMix == NULL) { + address = String8("0"); + } else if (inputDesc->mPolicyMix->mMixType == MIX_TYPE_PLAYERS) { + address = inputDesc->mPolicyMix->mRegistrationId; + } + if (address != "") { + setDeviceConnectionState(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, + AUDIO_POLICY_DEVICE_STATE_AVAILABLE, + address); + } } } @@ -1585,7 +1623,7 @@ status_t AudioPolicyManager::stopInput(audio_io_handle_t input, } sp inputDesc = mInputs.valueAt(index); - index = inputDesc->mSessions.indexOfKey(session); + index = inputDesc->mSessions.indexOf(session); if (index < 0) { ALOGW("stopInput() unknown session %d on input %d", session, input); return BAD_VALUE; @@ -1599,11 +1637,20 @@ status_t AudioPolicyManager::stopInput(audio_io_handle_t input, inputDesc->mRefCount--; if (inputDesc->mRefCount == 0) { - // automatically disable the remote submix output when input is stopped + // automatically disable the remote submix output when input is stopped if not + // used by a policy mix of type MIX_TYPE_RECORDERS if (audio_is_remote_submix_device(inputDesc->mDevice)) { - setDeviceConnectionState(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, - AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, - inputDesc->mSessions.valueAt(index)); + String8 address = String8(""); + if (inputDesc->mPolicyMix == NULL) { + address = String8("0"); + } else if (inputDesc->mPolicyMix->mMixType == MIX_TYPE_PLAYERS) { + address = inputDesc->mPolicyMix->mRegistrationId; + } + if (address != "") { + setDeviceConnectionState(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, + AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, + address); + } } resetInputDevice(input); @@ -1627,12 +1674,12 @@ void AudioPolicyManager::releaseInput(audio_io_handle_t input, sp inputDesc = mInputs.valueAt(index); ALOG_ASSERT(inputDesc != 0); - index = inputDesc->mSessions.indexOfKey(session); + index = inputDesc->mSessions.indexOf(session); if (index < 0) { ALOGW("releaseInput() unknown session %d on input %d", session, input); return; } - inputDesc->mSessions.removeItem(session); + inputDesc->mSessions.remove(session); if (inputDesc->mOpenRefCount == 0) { ALOGW("releaseInput() invalid open ref count %d", inputDesc->mOpenRefCount); return; @@ -1961,10 +2008,9 @@ bool AudioPolicyManager::isStreamActiveRemotely(audio_stream_type_t stream, const sp outputDesc = mOutputs.valueAt(i); if (((outputDesc->device() & APM_AUDIO_OUT_DEVICE_REMOTE_ALL) != 0) && outputDesc->isStreamActive(stream, inPastMs, sysTime)) { - // only consider empty or "0" address to only qualify the screen mirroring case - // as "remote playback" (vs rerouting when the output is going to a dynamic policy) - if (outputDesc->mPolicyMixAddress == String8("") - || outputDesc->mPolicyMixAddress == String8("0")) { + // do not consider re routing (when the output is going to a dynamic policy) + // as "remote playback" + if (outputDesc->mPolicyMix == NULL) { return true; } } @@ -2046,9 +2092,15 @@ status_t AudioPolicyManager::registerPolicyMixes(Vector mixes) sp policyMix = new AudioPolicyMix(); policyMix->mMix = mixes[i]; mPolicyMixes.add(address, policyMix); - setDeviceConnectionState(AUDIO_DEVICE_IN_REMOTE_SUBMIX, - AUDIO_POLICY_DEVICE_STATE_AVAILABLE, - address.string()); + if (mixes[i].mMixType == MIX_TYPE_PLAYERS) { + setDeviceConnectionState(AUDIO_DEVICE_IN_REMOTE_SUBMIX, + AUDIO_POLICY_DEVICE_STATE_AVAILABLE, + address.string()); + } else { + setDeviceConnectionState(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, + AUDIO_POLICY_DEVICE_STATE_AVAILABLE, + address.string()); + } } return NO_ERROR; } @@ -2080,9 +2132,13 @@ status_t AudioPolicyManager::unregisterPolicyMixes(Vector mixes) mPolicyMixes.removeItemsAt(index); - setDeviceConnectionState(AUDIO_DEVICE_IN_REMOTE_SUBMIX, - AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, - address.string()); + if (getDeviceConnectionState(AUDIO_DEVICE_IN_REMOTE_SUBMIX, address.string()) == + AUDIO_POLICY_DEVICE_STATE_AVAILABLE) + { + setDeviceConnectionState(AUDIO_DEVICE_IN_REMOTE_SUBMIX, + AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, + address.string()); + } if (getDeviceConnectionState(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, address.string()) == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) @@ -3543,12 +3599,14 @@ status_t AudioPolicyManager::checkOutputsForDevice(const sp de ssize_t index = mPolicyMixes.indexOfKey(address); if (index >= 0) { mPolicyMixes[index]->mOutput = desc; + desc->mPolicyMix = &mPolicyMixes[index]->mMix; } else { ALOGE("checkOutputsForDevice() cannot find policy for address %s", address.string()); } - } - if ((desc->mFlags & AUDIO_OUTPUT_FLAG_DIRECT) == 0) { + } else if ((desc->mFlags & AUDIO_OUTPUT_FLAG_DIRECT) == 0) { + // no duplicated output for direct outputs and + // outputs used by dynamic policy mixes audio_io_handle_t duplicatedOutput = AUDIO_IO_HANDLE_NONE; // set initial stream volume for device @@ -5014,7 +5072,7 @@ sp AudioPolicyManager::getInputProfile(audio_devi } audio_devices_t AudioPolicyManager::getDeviceForInputSource(audio_source_t inputSource, - String8 *address) + AudioMix **policyMix) { uint32_t device = AUDIO_DEVICE_NONE; audio_devices_t availableDeviceTypes = mAvailableInputDevices.types() & @@ -5030,8 +5088,8 @@ audio_devices_t AudioPolicyManager::getDeviceForInputSource(audio_source_t input (RULE_EXCLUDE_ATTRIBUTE_CAPTURE_PRESET == mPolicyMixes[i]->mMix.mCriteria[j].mRule && mPolicyMixes[i]->mMix.mCriteria[j].mAttr.mSource != inputSource)) { if (availableDeviceTypes & AUDIO_DEVICE_IN_REMOTE_SUBMIX) { - if (address != NULL) { - *address = mPolicyMixes[i]->mMix.mRegistrationId; + if (policyMix != NULL) { + *policyMix = &mPolicyMixes[i]->mMix; } return AUDIO_DEVICE_IN_REMOTE_SUBMIX; } @@ -5127,9 +5185,6 @@ audio_devices_t AudioPolicyManager::getDeviceForInputSource(audio_source_t input case AUDIO_SOURCE_REMOTE_SUBMIX: if (availableDeviceTypes & AUDIO_DEVICE_IN_REMOTE_SUBMIX) { device = AUDIO_DEVICE_IN_REMOTE_SUBMIX; - if (address != NULL) { - *address = "0"; - } } break; case AUDIO_SOURCE_FM_TUNER: @@ -5571,8 +5626,7 @@ status_t AudioPolicyManager::checkAndSetVolume(audio_stream_type_t stream, ssize_t index = mOutputs.indexOfKey(output); if (index >= 0) { sp outputDesc = mOutputs.valueAt(index); - if (outputDesc->mPolicyMixAddress != String8("") - && outputDesc->mPolicyMixAddress != String8("0")) { + if (outputDesc->mPolicyMix != NULL) { ALOGV("max gain when rerouting for output=%d", output); volume = 1.0f; } @@ -5761,7 +5815,7 @@ uint32_t AudioPolicyManager::getMaxEffectsMemory() AudioPolicyManager::AudioOutputDescriptor::AudioOutputDescriptor( const sp& profile) : mId(0), mIoHandle(0), mLatency(0), - mFlags((audio_output_flags_t)0), mDevice(AUDIO_DEVICE_NONE), mPolicyMixAddress(String8("")), + mFlags((audio_output_flags_t)0), mDevice(AUDIO_DEVICE_NONE), mPolicyMix(NULL), mPatchHandle(0), mOutput1(0), mOutput2(0), mProfile(profile), mDirectOpenCount(0) { @@ -5957,7 +6011,7 @@ status_t AudioPolicyManager::AudioOutputDescriptor::dump(int fd) AudioPolicyManager::AudioInputDescriptor::AudioInputDescriptor(const sp& profile) : mId(0), mIoHandle(0), - mDevice(AUDIO_DEVICE_NONE), mPatchHandle(0), mRefCount(0), + mDevice(AUDIO_DEVICE_NONE), mPolicyMix(NULL), mPatchHandle(0), mRefCount(0), mInputSource(AUDIO_SOURCE_DEFAULT), mProfile(profile), mIsSoundTrigger(false) { if (profile != NULL) { diff --git a/services/audiopolicy/AudioPolicyManager.h b/services/audiopolicy/AudioPolicyManager.h index 3eef8fe..9ec3557 100644 --- a/services/audiopolicy/AudioPolicyManager.h +++ b/services/audiopolicy/AudioPolicyManager.h @@ -497,7 +497,7 @@ protected: uint32_t mLatency; // audio_output_flags_t mFlags; // audio_devices_t mDevice; // current device this output is routed to - String8 mPolicyMixAddress; // non empty or "0" when used by a dynamic policy + AudioMix *mPolicyMix; // non NULL when used by a dynamic policy audio_patch_handle_t mPatchHandle; uint32_t mRefCount[AUDIO_STREAM_CNT]; // number of streams of each type using this output nsecs_t mStopTime[AUDIO_STREAM_CNT]; @@ -523,6 +523,7 @@ protected: audio_port_handle_t mId; audio_io_handle_t mIoHandle; // input handle audio_devices_t mDevice; // current device this input is routed to + AudioMix *mPolicyMix; // non NULL when used by a dynamic policy audio_patch_handle_t mPatchHandle; uint32_t mRefCount; // number of AudioRecord clients using // this input @@ -530,9 +531,7 @@ protected: audio_source_t mInputSource; // input source selected by application //(mediarecorder.h) const sp mProfile; // I/O profile this output derives from - // audio sessions attached to this input and the - // corresponding device address - DefaultKeyedVector mSessions; + SortedVector mSessions; // audio sessions attached to this input bool mIsSoundTrigger; // used by a soundtrigger capture virtual void toAudioPortConfig(struct audio_port_config *dstConfig, @@ -612,7 +611,7 @@ protected: // select input device corresponding to requested audio source virtual audio_devices_t getDeviceForInputSource(audio_source_t inputSource, - String8 *address = NULL); + AudioMix **policyMix = NULL); // return io handle of active input or 0 if no input is active // Only considers inputs from physical devices (e.g. main mic, headset mic) when -- cgit v1.1 From fa736496b3a7c1de2a4dbe2ced5bb62df4db6a6e Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Fri, 12 Dec 2014 14:34:22 -0800 Subject: audio policy: fix remote mic capture commit 275e8e9de introduced a regression for platforms overriding AudioPolicyManager::getDeviceForInputSource() method. Fixed by defining specific non virtual methods when overiding would break remote submix implementation. Bug: 18736417. Change-Id: Id4d0a6c48da987e6fb24422f2d61c7ab0fbfc921 --- services/audiopolicy/AudioPolicyManager.cpp | 47 ++++++++++++++++++++--------- services/audiopolicy/AudioPolicyManager.h | 13 ++++++-- 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp index 3cd5fb2..744556d 100644 --- a/services/audiopolicy/AudioPolicyManager.cpp +++ b/services/audiopolicy/AudioPolicyManager.cpp @@ -215,6 +215,13 @@ status_t AudioPolicyManager::setDeviceConnectionState(audio_devices_t device, audio_policy_dev_state_t state, const char *device_address) { + return setDeviceConnectionStateInt(device, state, device_address); +} + +status_t AudioPolicyManager::setDeviceConnectionStateInt(audio_devices_t device, + audio_policy_dev_state_t state, + const char *device_address) +{ String8 address = (device_address == NULL) ? String8("") : String8(device_address); // handle legacy remote submix case where the address was not always specified if (deviceDistinguishesOnAddress(device) && (address.length() == 0)) { @@ -457,7 +464,7 @@ void AudioPolicyManager::updateCallRouting(audio_devices_t rxDevice, int delayMs audio_patch_handle_t afPatchHandle; DeviceVector deviceList; - audio_devices_t txDevice = getDeviceForInputSource(AUDIO_SOURCE_VOICE_COMMUNICATION); + audio_devices_t txDevice = getDeviceAndMixForInputSource(AUDIO_SOURCE_VOICE_COMMUNICATION); ALOGV("updateCallRouting device rxDevice %08x txDevice %08x", rxDevice, txDevice); // release existing RX patch if any @@ -1278,7 +1285,7 @@ status_t AudioPolicyManager::startOutput(audio_io_handle_t output, // of type MIX_TYPE_RECORDERS if (audio_is_remote_submix_device(newDevice) && outputDesc->mPolicyMix != NULL && outputDesc->mPolicyMix->mMixType == MIX_TYPE_RECORDERS) { - setDeviceConnectionState(AUDIO_DEVICE_IN_REMOTE_SUBMIX, + setDeviceConnectionStateInt(AUDIO_DEVICE_IN_REMOTE_SUBMIX, AUDIO_POLICY_DEVICE_STATE_AVAILABLE, outputDesc->mPolicyMix->mRegistrationId); } @@ -1322,7 +1329,7 @@ status_t AudioPolicyManager::stopOutput(audio_io_handle_t output, if (audio_is_remote_submix_device(outputDesc->mDevice) && outputDesc->mPolicyMix != NULL && outputDesc->mPolicyMix->mMixType == MIX_TYPE_RECORDERS) { - setDeviceConnectionState(AUDIO_DEVICE_IN_REMOTE_SUBMIX, + setDeviceConnectionStateInt(AUDIO_DEVICE_IN_REMOTE_SUBMIX, AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, outputDesc->mPolicyMix->mRegistrationId); } @@ -1441,7 +1448,7 @@ status_t AudioPolicyManager::getInputForAttr(const audio_attributes_t *attr, } policyMix = &mPolicyMixes[index]->mMix; } else { - device = getDeviceForInputSource(attr->source, &policyMix); + device = getDeviceAndMixForInputSource(attr->source, &policyMix); if (device == AUDIO_DEVICE_NONE) { ALOGW("getInputForAttr() could not find device for source %d", attr->source); return BAD_VALUE; @@ -1599,7 +1606,7 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input, address = inputDesc->mPolicyMix->mRegistrationId; } if (address != "") { - setDeviceConnectionState(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, + setDeviceConnectionStateInt(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, AUDIO_POLICY_DEVICE_STATE_AVAILABLE, address); } @@ -1647,7 +1654,7 @@ status_t AudioPolicyManager::stopInput(audio_io_handle_t input, address = inputDesc->mPolicyMix->mRegistrationId; } if (address != "") { - setDeviceConnectionState(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, + setDeviceConnectionStateInt(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, address); } @@ -2093,11 +2100,11 @@ status_t AudioPolicyManager::registerPolicyMixes(Vector mixes) policyMix->mMix = mixes[i]; mPolicyMixes.add(address, policyMix); if (mixes[i].mMixType == MIX_TYPE_PLAYERS) { - setDeviceConnectionState(AUDIO_DEVICE_IN_REMOTE_SUBMIX, + setDeviceConnectionStateInt(AUDIO_DEVICE_IN_REMOTE_SUBMIX, AUDIO_POLICY_DEVICE_STATE_AVAILABLE, address.string()); } else { - setDeviceConnectionState(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, + setDeviceConnectionStateInt(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, AUDIO_POLICY_DEVICE_STATE_AVAILABLE, address.string()); } @@ -2135,7 +2142,7 @@ status_t AudioPolicyManager::unregisterPolicyMixes(Vector mixes) if (getDeviceConnectionState(AUDIO_DEVICE_IN_REMOTE_SUBMIX, address.string()) == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) { - setDeviceConnectionState(AUDIO_DEVICE_IN_REMOTE_SUBMIX, + setDeviceConnectionStateInt(AUDIO_DEVICE_IN_REMOTE_SUBMIX, AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, address.string()); } @@ -2143,7 +2150,7 @@ status_t AudioPolicyManager::unregisterPolicyMixes(Vector mixes) if (getDeviceConnectionState(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, address.string()) == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) { - setDeviceConnectionState(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, + setDeviceConnectionStateInt(AUDIO_DEVICE_OUT_REMOTE_SUBMIX, AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, address.string()); } @@ -2896,7 +2903,7 @@ status_t AudioPolicyManager::acquireSoundTriggerSession(audio_session_t *session { *session = (audio_session_t)mpClientInterface->newAudioUniqueId(); *ioHandle = (audio_io_handle_t)mpClientInterface->newAudioUniqueId(); - *device = getDeviceForInputSource(AUDIO_SOURCE_HOTWORD); + *device = getDeviceAndMixForInputSource(AUDIO_SOURCE_HOTWORD); mSoundTriggerSessions.add(*session, *ioHandle); @@ -4224,7 +4231,7 @@ audio_devices_t AudioPolicyManager::getNewInputDevice(audio_io_handle_t input) } } - audio_devices_t device = getDeviceForInputSource(inputDesc->mInputSource); + audio_devices_t device = getDeviceAndMixForInputSource(inputDesc->mInputSource); ALOGV("getNewInputDevice() selected device %x", device); return device; @@ -4490,7 +4497,8 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate // - cannot route from voice call RX OR // - audio HAL version is < 3.0 and TX device is on the primary HW module if (mPhoneState == AUDIO_MODE_IN_CALL) { - audio_devices_t txDevice = getDeviceForInputSource(AUDIO_SOURCE_VOICE_COMMUNICATION); + audio_devices_t txDevice = + getDeviceAndMixForInputSource(AUDIO_SOURCE_VOICE_COMMUNICATION); sp hwOutputDesc = mOutputs.valueFor(mPrimaryOutput); if (((mAvailableInputDevices.types() & AUDIO_DEVICE_IN_TELEPHONY_RX & ~AUDIO_DEVICE_BIT_IN) == 0) || @@ -5071,10 +5079,10 @@ sp AudioPolicyManager::getInputProfile(audio_devi return NULL; } -audio_devices_t AudioPolicyManager::getDeviceForInputSource(audio_source_t inputSource, + +audio_devices_t AudioPolicyManager::getDeviceAndMixForInputSource(audio_source_t inputSource, AudioMix **policyMix) { - uint32_t device = AUDIO_DEVICE_NONE; audio_devices_t availableDeviceTypes = mAvailableInputDevices.types() & ~AUDIO_DEVICE_BIT_IN; @@ -5098,6 +5106,15 @@ audio_devices_t AudioPolicyManager::getDeviceForInputSource(audio_source_t input } } + return getDeviceForInputSource(inputSource); +} + +audio_devices_t AudioPolicyManager::getDeviceForInputSource(audio_source_t inputSource) +{ + uint32_t device = AUDIO_DEVICE_NONE; + audio_devices_t availableDeviceTypes = mAvailableInputDevices.types() & + ~AUDIO_DEVICE_BIT_IN; + switch (inputSource) { case AUDIO_SOURCE_VOICE_UPLINK: if (availableDeviceTypes & AUDIO_DEVICE_IN_VOICE_CALL) { diff --git a/services/audiopolicy/AudioPolicyManager.h b/services/audiopolicy/AudioPolicyManager.h index 9ec3557..ff3afab 100644 --- a/services/audiopolicy/AudioPolicyManager.h +++ b/services/audiopolicy/AudioPolicyManager.h @@ -610,8 +610,7 @@ protected: audio_patch_handle_t *patchHandle = NULL); // select input device corresponding to requested audio source - virtual audio_devices_t getDeviceForInputSource(audio_source_t inputSource, - AudioMix **policyMix = NULL); + virtual audio_devices_t getDeviceForInputSource(audio_source_t inputSource); // return io handle of active input or 0 if no input is active // Only considers inputs from physical devices (e.g. main mic, headset mic) when @@ -914,6 +913,16 @@ private: uint32_t handleEventForBeacon(int event); uint32_t setBeaconMute(bool mute); bool isValidAttributes(const audio_attributes_t *paa); + + // select input device corresponding to requested audio source and return associated policy + // mix if any. Calls getDeviceForInputSource(). + audio_devices_t getDeviceAndMixForInputSource(audio_source_t inputSource, + AudioMix **policyMix = NULL); + + // Called by setDeviceConnectionState(). + status_t setDeviceConnectionStateInt(audio_devices_t device, + audio_policy_dev_state_t state, + const char *device_address); }; }; -- cgit v1.1 From 5db7897ddd32e3ec3ab45ecdb6f21b6265e7e14a Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Wed, 7 Jan 2015 10:42:33 -0800 Subject: make libserviceutility a shared lib so that we have only one getpid_cached in mediaserver process bug: 18919657 Change-Id: Iff3cd932c9110e874b3885f79705f49bf3e3f1fc --- services/audioflinger/Android.mk | 14 ++++++++++---- services/audiopolicy/Android.mk | 6 +++--- services/soundtrigger/Android.mk | 4 +--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk index 697fb37..f0196c6 100644 --- a/services/audioflinger/Android.mk +++ b/services/audioflinger/Android.mk @@ -19,7 +19,13 @@ LOCAL_SRC_FILES := \ # FIXME Move this library to frameworks/native LOCAL_MODULE := libserviceutility -include $(BUILD_STATIC_LIBRARY) +LOCAL_SHARED_LIBRARIES := \ + libcutils \ + libutils \ + liblog \ + libbinder + +include $(BUILD_SHARED_LIBRARY) include $(CLEAR_VARS) @@ -51,13 +57,13 @@ LOCAL_SHARED_LIBRARIES := \ libhardware \ libhardware_legacy \ libeffects \ - libpowermanager + libpowermanager \ + libserviceutility LOCAL_STATIC_LIBRARIES := \ libscheduling_policy \ libcpustats \ - libmedia_helper \ - libserviceutility + libmedia_helper LOCAL_MODULE:= libaudioflinger LOCAL_32_BIT_ONLY := true diff --git a/services/audiopolicy/Android.mk b/services/audiopolicy/Android.mk index 6512c38..188fc89 100644 --- a/services/audiopolicy/Android.mk +++ b/services/audiopolicy/Android.mk @@ -30,7 +30,8 @@ LOCAL_SHARED_LIBRARIES := \ libbinder \ libmedia \ libhardware \ - libhardware_legacy + libhardware_legacy \ + libserviceutility ifneq ($(USE_LEGACY_AUDIO_POLICY), 1) LOCAL_SHARED_LIBRARIES += \ @@ -38,8 +39,7 @@ LOCAL_SHARED_LIBRARIES += \ endif LOCAL_STATIC_LIBRARIES := \ - libmedia_helper \ - libserviceutility + libmedia_helper LOCAL_MODULE:= libaudiopolicyservice diff --git a/services/soundtrigger/Android.mk b/services/soundtrigger/Android.mk index 572ae56..ecc49ae 100644 --- a/services/soundtrigger/Android.mk +++ b/services/soundtrigger/Android.mk @@ -32,9 +32,7 @@ LOCAL_SHARED_LIBRARIES:= \ libcutils \ libhardware \ libsoundtrigger \ - libmedia - -LOCAL_STATIC_LIBRARIES := \ + libmedia \ libserviceutility LOCAL_C_INCLUDES += \ -- cgit v1.1