summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/media/stagefright/MediaCodecList.h6
-rw-r--r--media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp233
-rw-r--r--media/libeffects/lvm/wrapper/Bundle/EffectBundle.h15
-rw-r--r--media/libmediaplayerservice/nuplayer/GenericSource.cpp8
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.cpp4
-rw-r--r--media/libstagefright/ACodec.cpp16
-rw-r--r--media/libstagefright/MediaCodecList.cpp13
-rw-r--r--media/libstagefright/data/media_codecs_google_audio.xml3
-rw-r--r--media/libstagefright/httplive/LiveSession.cpp4
-rw-r--r--services/audiopolicy/AudioPolicyManager.cpp52
-rw-r--r--services/audiopolicy/AudioPolicyManager.h13
-rw-r--r--services/camera/libcameraservice/api1/Camera2Client.cpp9
12 files changed, 249 insertions, 127 deletions
diff --git a/include/media/stagefright/MediaCodecList.h b/include/media/stagefright/MediaCodecList.h
index 8605d99..c2bbe4d 100644
--- a/include/media/stagefright/MediaCodecList.h
+++ b/include/media/stagefright/MediaCodecList.h
@@ -52,6 +52,12 @@ struct MediaCodecList : public BnMediaCodecList {
static sp<IMediaCodecList> getLocalInstance();
private:
+ class BinderDeathObserver : public IBinder::DeathRecipient {
+ void binderDied(const wp<IBinder> &the_late_who __unused);
+ };
+
+ static sp<BinderDeathObserver> sBinderDeathObserver;
+
enum Section {
SECTION_TOPLEVEL,
SECTION_DECODERS,
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index 3ddeb4e..6aeb919 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -766,6 +766,122 @@ int LvmBundle_process(LVM_INT16 *pIn,
return 0;
} /* end LvmBundle_process */
+
+//----------------------------------------------------------------------------
+// EqualizerUpdateActiveParams()
+//----------------------------------------------------------------------------
+// Purpose: Update ActiveParams for Equalizer
+//
+// Inputs:
+// pContext: effect engine context
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+void EqualizerUpdateActiveParams(EffectContext *pContext) {
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
+
+ /* Get the current settings */
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerUpdateActiveParams")
+ //ALOGV("\tEqualizerUpdateActiveParams Succesfully returned from LVM_GetControlParameters\n");
+ //ALOGV("\tEqualizerUpdateActiveParams just Got -> %d\n",
+ // ActiveParams.pEQNB_BandDefinition[band].Gain);
+
+
+ for (int i = 0; i < FIVEBAND_NUMBANDS; i++) {
+ ActiveParams.pEQNB_BandDefinition[i].Frequency = EQNB_5BandPresetsFrequencies[i];
+ ActiveParams.pEQNB_BandDefinition[i].QFactor = EQNB_5BandPresetsQFactors[i];
+ ActiveParams.pEQNB_BandDefinition[i].Gain = pContext->pBundledContext->bandGaindB[i];
+ }
+
+ /* Activate the initial settings */
+ LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerUpdateActiveParams")
+ //ALOGV("\tEqualizerUpdateActiveParams just Set -> %d\n",
+ // ActiveParams.pEQNB_BandDefinition[band].Gain);
+
+}
+
+//----------------------------------------------------------------------------
+// LvmEffect_limitLevel()
+//----------------------------------------------------------------------------
+// Purpose: limit the overall level to a value less than 0 dB preserving
+// the overall EQ band gain and BassBoost relative levels.
+//
+// Inputs:
+// pContext: effect engine context
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+void LvmEffect_limitLevel(EffectContext *pContext) {
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
+
+ /* Get the current settings */
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "LvmEffect_limitLevel")
+ //ALOGV("\tLvmEffect_limitLevel Succesfully returned from LVM_GetControlParameters\n");
+ //ALOGV("\tLvmEffect_limitLevel just Got -> %d\n",
+ // ActiveParams.pEQNB_BandDefinition[band].Gain);
+
+ int gainCorrection = 0;
+ //Count the energy contribution per band for EQ and BassBoost only if they are active.
+ float energyContribution = 0;
+
+ //EQ contribution
+ if (pContext->pBundledContext->bEqualizerEnabled == LVM_TRUE) {
+ for (int i = 0; i < FIVEBAND_NUMBANDS; i++) {
+ float bandEnergy = (pContext->pBundledContext->bandGaindB[i] *
+ LimitLevel_bandEnergyContribution[i])/15.0;
+ if (bandEnergy > 0)
+ energyContribution += bandEnergy;
+ }
+ }
+
+ //BassBoost contribution
+ if (pContext->pBundledContext->bBassEnabled == LVM_TRUE) {
+ float bandEnergy = (pContext->pBundledContext->BassStrengthSaved *
+ LimitLevel_bassBoostEnergyContribution)/1000.0;
+ if (bandEnergy > 0)
+ energyContribution += bandEnergy;
+ }
+
+ //Virtualizer contribution
+ if (pContext->pBundledContext->bVirtualizerEnabled == LVM_TRUE) {
+ energyContribution += LimitLevel_virtualizerContribution;
+ }
+
+ //roundoff
+ int maxLevelRound = (int)(energyContribution + 0.99);
+ if (maxLevelRound + pContext->pBundledContext->volume > 0) {
+ gainCorrection = maxLevelRound + pContext->pBundledContext->volume;
+ }
+
+ ActiveParams.VC_EffectLevel = pContext->pBundledContext->volume - gainCorrection;
+ if (ActiveParams.VC_EffectLevel < -96) {
+ ActiveParams.VC_EffectLevel = -96;
+ }
+ ALOGV("\tVol:%d, GainCorrection: %d, Actual vol: %d", pContext->pBundledContext->volume,
+ gainCorrection, ActiveParams.VC_EffectLevel);
+
+ /* Activate the initial settings */
+ LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "LvmEffect_limitLevel")
+ //ALOGV("\tLvmEffect_limitLevel just Set -> %d\n",
+ // ActiveParams.pEQNB_BandDefinition[band].Gain);
+
+ //ALOGV("\tLvmEffect_limitLevel just set (-96dB -> 0dB) -> %d\n",ActiveParams.VC_EffectLevel );
+ if (pContext->pBundledContext->firstVolume == LVM_TRUE){
+ LvmStatus = LVM_SetVolumeNoSmoothing(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_SetVolumeNoSmoothing", "LvmBundle_process")
+ ALOGV("\tLVM_VOLUME: Disabling Smoothing for first volume change to remove spikes/clicks");
+ pContext->pBundledContext->firstVolume = LVM_FALSE;
+ }
+}
+
//----------------------------------------------------------------------------
// LvmEffect_enable()
//----------------------------------------------------------------------------
@@ -814,6 +930,7 @@ int LvmEffect_enable(EffectContext *pContext){
//ALOGV("\tLvmEffect_enable Succesfully called LVM_SetControlParameters\n");
//ALOGV("\tLvmEffect_enable end");
+ LvmEffect_limitLevel(pContext);
return 0;
}
@@ -864,6 +981,7 @@ int LvmEffect_disable(EffectContext *pContext){
//ALOGV("\tLvmEffect_disable Succesfully called LVM_SetControlParameters\n");
//ALOGV("\tLvmEffect_disable end");
+ LvmEffect_limitLevel(pContext);
return 0;
}
@@ -1099,6 +1217,8 @@ void BassSetStrength(EffectContext *pContext, uint32_t strength){
LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "BassSetStrength")
//ALOGV("\tBassSetStrength Succesfully called LVM_SetControlParameters\n");
+
+ LvmEffect_limitLevel(pContext);
} /* end BassSetStrength */
//----------------------------------------------------------------------------
@@ -1159,13 +1279,14 @@ void VirtualizerSetStrength(EffectContext *pContext, uint32_t strength){
/* Virtualizer parameters */
ActiveParams.CS_EffectLevel = (int)((strength*32767)/1000);
- //ALOGV("\tVirtualizerSetStrength() (0-1000) -> %d\n", strength );
- //ALOGV("\tVirtualizerSetStrength() (0- 100) -> %d\n", ActiveParams.CS_EffectLevel );
+ ALOGV("\tVirtualizerSetStrength() (0-1000) -> %d\n", strength );
+ ALOGV("\tVirtualizerSetStrength() (0- 100) -> %d\n", ActiveParams.CS_EffectLevel );
/* Activate the initial settings */
LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VirtualizerSetStrength")
//ALOGV("\tVirtualizerSetStrength Succesfully called LVM_SetControlParameters\n\n");
+ LvmEffect_limitLevel(pContext);
} /* end setStrength */
//----------------------------------------------------------------------------
@@ -1343,104 +1464,6 @@ audio_devices_t VirtualizerGetVirtualizationMode(EffectContext *pContext) {
}
//----------------------------------------------------------------------------
-// EqualizerLimitBandLevels()
-//----------------------------------------------------------------------------
-// Purpose: limit all EQ band gains to a value less than 0 dB while
-// preserving the relative band levels.
-//
-// Inputs:
-// pContext: effect engine context
-//
-// Outputs:
-//
-//----------------------------------------------------------------------------
-void EqualizerLimitBandLevels(EffectContext *pContext) {
- LVM_ControlParams_t ActiveParams; /* Current control Parameters */
- LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
-
- /* Get the current settings */
- LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
- LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerLimitBandLevels")
- //ALOGV("\tEqualizerLimitBandLevels Succesfully returned from LVM_GetControlParameters\n");
- //ALOGV("\tEqualizerLimitBandLevels just Got -> %d\n",
- // ActiveParams.pEQNB_BandDefinition[band].Gain);
-
- // Apply a volume correction to avoid clipping in the EQ based on 2 factors:
- // - the maximum EQ band gain: the volume correction is such that the total of volume + max
- // band gain is <= 0 dB
- // - the average gain in all bands weighted by their proximity to max gain band.
- int maxGain = 0;
- int avgGain = 0;
- int avgCount = 0;
- for (int i = 0; i < FIVEBAND_NUMBANDS; i++) {
- if (pContext->pBundledContext->bandGaindB[i] >= maxGain) {
- int tmpMaxGain = pContext->pBundledContext->bandGaindB[i];
- int tmpAvgGain = 0;
- int tmpAvgCount = 0;
- for (int j = 0; j < FIVEBAND_NUMBANDS; j++) {
- int gain = pContext->pBundledContext->bandGaindB[j];
- // skip current band and gains < 0 dB
- if (j == i || gain < 0)
- continue;
- // no need to continue if one band not processed yet has a higher gain than current
- // max
- if (gain > tmpMaxGain) {
- // force skipping "if (tmpAvgGain >= avgGain)" below as tmpAvgGain is not
- // meaningful in this case
- tmpAvgGain = -1;
- break;
- }
-
- int weight = 1;
- if (j < (i + 2) && j > (i - 2))
- weight = 4;
- tmpAvgGain += weight * gain;
- tmpAvgCount += weight;
- }
- if (tmpAvgGain >= avgGain) {
- maxGain = tmpMaxGain;
- avgGain = tmpAvgGain;
- avgCount = tmpAvgCount;
- }
- }
- ActiveParams.pEQNB_BandDefinition[i].Frequency = EQNB_5BandPresetsFrequencies[i];
- ActiveParams.pEQNB_BandDefinition[i].QFactor = EQNB_5BandPresetsQFactors[i];
- ActiveParams.pEQNB_BandDefinition[i].Gain = pContext->pBundledContext->bandGaindB[i];
- }
-
- int gainCorrection = 0;
- if (maxGain + pContext->pBundledContext->volume > 0) {
- gainCorrection = maxGain + pContext->pBundledContext->volume;
- }
- if (avgCount) {
- gainCorrection += avgGain/avgCount;
- }
-
- ALOGV("EqualizerLimitBandLevels() gainCorrection %d maxGain %d avgGain %d avgCount %d",
- gainCorrection, maxGain, avgGain, avgCount);
-
- ActiveParams.VC_EffectLevel = pContext->pBundledContext->volume - gainCorrection;
- if (ActiveParams.VC_EffectLevel < -96) {
- ActiveParams.VC_EffectLevel = -96;
- }
-
- /* Activate the initial settings */
- LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
- LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerLimitBandLevels")
- //ALOGV("\tEqualizerLimitBandLevels just Set -> %d\n",
- // ActiveParams.pEQNB_BandDefinition[band].Gain);
-
- //ALOGV("\tEqualizerLimitBandLevels just set (-96dB -> 0dB) -> %d\n",ActiveParams.VC_EffectLevel );
- if(pContext->pBundledContext->firstVolume == LVM_TRUE){
- LvmStatus = LVM_SetVolumeNoSmoothing(pContext->pBundledContext->hInstance, &ActiveParams);
- LVM_ERROR_CHECK(LvmStatus, "LVM_SetVolumeNoSmoothing", "LvmBundle_process")
- ALOGV("\tLVM_VOLUME: Disabling Smoothing for first volume change to remove spikes/clicks");
- pContext->pBundledContext->firstVolume = LVM_FALSE;
- }
-}
-
-
-//----------------------------------------------------------------------------
// EqualizerGetBandLevel()
//----------------------------------------------------------------------------
// Purpose: Retrieve the gain currently being used for the band passed in
@@ -1482,7 +1505,8 @@ void EqualizerSetBandLevel(EffectContext *pContext, int band, short Gain){
pContext->pBundledContext->bandGaindB[band] = gainRounded;
pContext->pBundledContext->CurPreset = PRESET_CUSTOM;
- EqualizerLimitBandLevels(pContext);
+ EqualizerUpdateActiveParams(pContext);
+ LvmEffect_limitLevel(pContext);
}
//----------------------------------------------------------------------------
@@ -1617,7 +1641,8 @@ void EqualizerSetPreset(EffectContext *pContext, int preset){
EQNB_5BandSoftPresets[i + preset * FIVEBAND_NUMBANDS];
}
- EqualizerLimitBandLevels(pContext);
+ EqualizerUpdateActiveParams(pContext);
+ LvmEffect_limitLevel(pContext);
//ALOGV("\tEqualizerSetPreset Succesfully called LVM_SetControlParameters\n");
return;
@@ -1672,7 +1697,7 @@ int VolumeSetVolumeLevel(EffectContext *pContext, int16_t level){
pContext->pBundledContext->volume = level / 100;
}
- EqualizerLimitBandLevels(pContext);
+ LvmEffect_limitLevel(pContext);
return 0;
} /* end VolumeSetVolumeLevel */
@@ -1721,7 +1746,7 @@ int32_t VolumeSetMute(EffectContext *pContext, uint32_t mute){
pContext->pBundledContext->volume = pContext->pBundledContext->levelSaved;
}
- EqualizerLimitBandLevels(pContext);
+ LvmEffect_limitLevel(pContext);
return 0;
} /* end setMute */
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
index 420f973..b3071f4 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
@@ -142,6 +142,7 @@ static const uint32_t bandFreqRange[FIVEBAND_NUMBANDS][2] = {
{1800001, 7000000},
{7000001, 1}};
+//Note: If these frequencies change, please update LimitLevel values accordingly.
static const LVM_UINT16 EQNB_5BandPresetsFrequencies[] = {
60, /* Frequencies in Hz */
230,
@@ -192,6 +193,20 @@ static const PresetConfig gEqualizerPresets[] = {
{"Pop"},
{"Rock"}};
+/* The following tables have been computed using the actual levels measured by the output of
+ * white noise or pink noise (IEC268-1) for the EQ and BassBoost Effects. These are estimates of
+ * the actual energy that 'could' be present in the given band.
+ * If the frequency values in EQNB_5BandPresetsFrequencies change, these values might need to be
+ * updated.
+ */
+
+static const float LimitLevel_bandEnergyContribution[FIVEBAND_NUMBANDS] = {
+ 5.0, 6.5, 6.45, 4.8, 1.7 };
+
+static const float LimitLevel_bassBoostEnergyContribution = 6.7;
+
+static const float LimitLevel_virtualizerContribution = 1.9;
+
#if __cplusplus
} // extern "C"
#endif
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.cpp b/media/libmediaplayerservice/nuplayer/GenericSource.cpp
index 1af2713..dd79b50 100644
--- a/media/libmediaplayerservice/nuplayer/GenericSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/GenericSource.cpp
@@ -173,6 +173,14 @@ status_t NuPlayer::GenericSource::initFromDataSource() {
if (mFileMeta->findCString(kKeyMIMEType, &fileMime)
&& !strncasecmp(fileMime, "video/wvm", 9)) {
mIsWidevine = true;
+ if (!mUri.empty()) {
+ // streaming, but the app forgot to specify widevine:// url
+ mWVMExtractor = static_cast<WVMExtractor *>(extractor.get());
+ mWVMExtractor->setAdaptiveStreamingMode(true);
+ if (mUIDValid) {
+ mWVMExtractor->setUID(mUID);
+ }
+ }
}
}
}
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 080cd52..a28591e 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -1667,6 +1667,10 @@ void NuPlayer::onSourceNotify(const sp<AMessage> &msg) {
sp<NuPlayerDriver> driver = mDriver.promote();
if (driver != NULL) {
+ if ((flags & NuPlayer::Source::FLAG_CAN_SEEK) == 0) {
+ driver->notifyListener(
+ MEDIA_INFO, MEDIA_INFO_NOT_SEEKABLE, 0);
+ }
driver->notifyFlagsChanged(flags);
}
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 653d16c..dfb0101 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -1302,7 +1302,21 @@ status_t ACodec::configureCodec(
return err;
}
- inputFormat->setInt32("adaptive-playback", true);
+ int32_t maxWidth = 0, maxHeight = 0;
+ if (msg->findInt32("max-width", &maxWidth) &&
+ msg->findInt32("max-height", &maxHeight)) {
+
+ err = mOMX->prepareForAdaptivePlayback(
+ mNode, kPortIndexOutput, OMX_TRUE, maxWidth, maxHeight);
+ if (err != OK) {
+ ALOGW("[%s] prepareForAdaptivePlayback failed w/ err %d",
+ mComponentName.c_str(), err);
+ } else {
+ inputFormat->setInt32("max-width", maxWidth);
+ inputFormat->setInt32("max-height", maxHeight);
+ inputFormat->setInt32("adaptive-playback", true);
+ }
+ }
} else {
ALOGV("Configuring CPU controlled video playback.");
mTunneled = false;
diff --git a/media/libstagefright/MediaCodecList.cpp b/media/libstagefright/MediaCodecList.cpp
index 5b8be46..cf6e937 100644
--- a/media/libstagefright/MediaCodecList.cpp
+++ b/media/libstagefright/MediaCodecList.cpp
@@ -62,6 +62,14 @@ static Mutex sRemoteInitMutex;
sp<IMediaCodecList> MediaCodecList::sRemoteList;
+sp<MediaCodecList::BinderDeathObserver> MediaCodecList::sBinderDeathObserver;
+
+void MediaCodecList::BinderDeathObserver::binderDied(const wp<IBinder> &who __unused) {
+ Mutex::Autolock _l(sRemoteInitMutex);
+ sRemoteList.clear();
+ sBinderDeathObserver.clear();
+}
+
// static
sp<IMediaCodecList> MediaCodecList::getInstance() {
Mutex::Autolock _l(sRemoteInitMutex);
@@ -72,8 +80,11 @@ sp<IMediaCodecList> MediaCodecList::getInstance() {
interface_cast<IMediaPlayerService>(binder);
if (service.get() != NULL) {
sRemoteList = service->getCodecList();
+ if (sRemoteList != NULL) {
+ sBinderDeathObserver = new BinderDeathObserver();
+ binder->linkToDeath(sBinderDeathObserver.get());
+ }
}
-
if (sRemoteList == NULL) {
// if failed to get remote list, create local list
sRemoteList = getLocalInstance();
diff --git a/media/libstagefright/data/media_codecs_google_audio.xml b/media/libstagefright/data/media_codecs_google_audio.xml
index 85f6615..a06684b 100644
--- a/media/libstagefright/data/media_codecs_google_audio.xml
+++ b/media/libstagefright/data/media_codecs_google_audio.xml
@@ -65,7 +65,8 @@
<Encoders>
<MediaCodec name="OMX.google.aac.encoder" type="audio/mp4a-latm">
<Limit name="channel-count" max="6" />
- <Limit name="sample-rate" ranges="11025,12000,16000,22050,24000,32000,44100,48000" />
+ <Limit name="sample-rate" ranges="8000,11025,12000,16000,22050,24000,32000,44100,48000" />
+ <!-- also may support 64000, 88200 and 96000 Hz -->
<Limit name="bitrate" range="8000-960000" />
</MediaCodec>
<MediaCodec name="OMX.google.amrnb.encoder" type="audio/3gpp">
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp
index 6522ad7..04005bd 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -1110,11 +1110,11 @@ status_t LiveSession::onSeek(const sp<AMessage> &msg) {
}
status_t LiveSession::getDuration(int64_t *durationUs) const {
- int64_t maxDurationUs = 0ll;
+ int64_t maxDurationUs = -1ll;
for (size_t i = 0; i < mFetcherInfos.size(); ++i) {
int64_t fetcherDurationUs = mFetcherInfos.valueAt(i).mDurationUs;
- if (fetcherDurationUs >= 0ll && fetcherDurationUs > maxDurationUs) {
+ if (fetcherDurationUs > maxDurationUs) {
maxDurationUs = fetcherDurationUs;
}
}
diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp
index 3cd5fb2..488d1f3 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<AudioMix> 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<AudioMix> 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<AudioMix> 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<AudioOutputDescriptor> hwOutputDesc = mOutputs.valueFor(mPrimaryOutput);
if (((mAvailableInputDevices.types() &
AUDIO_DEVICE_IN_TELEPHONY_RX & ~AUDIO_DEVICE_BIT_IN) == 0) ||
@@ -4558,7 +4566,7 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate
device = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER;
if (device) break;
}
- if (mPhoneState != AUDIO_MODE_IN_CALL) {
+ if (!isInCall()) {
device = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_USB_ACCESSORY;
if (device) break;
device = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_USB_DEVICE;
@@ -5071,10 +5079,10 @@ sp<AudioPolicyManager::IOProfile> 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) {
@@ -5110,6 +5127,9 @@ audio_devices_t AudioPolicyManager::getDeviceForInputSource(audio_source_t input
case AUDIO_SOURCE_MIC:
if (availableDeviceTypes & AUDIO_DEVICE_IN_BLUETOOTH_A2DP) {
device = AUDIO_DEVICE_IN_BLUETOOTH_A2DP;
+ } else if ((mForceUse[AUDIO_POLICY_FORCE_FOR_RECORD] == AUDIO_POLICY_FORCE_BT_SCO) &&
+ (availableDeviceTypes & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET)) {
+ device = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET;
} else if (availableDeviceTypes & AUDIO_DEVICE_IN_WIRED_HEADSET) {
device = AUDIO_DEVICE_IN_WIRED_HEADSET;
} else if (availableDeviceTypes & AUDIO_DEVICE_IN_USB_DEVICE) {
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);
};
};
diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp
index 60939f9..0ed5586 100644
--- a/services/camera/libcameraservice/api1/Camera2Client.cpp
+++ b/services/camera/libcameraservice/api1/Camera2Client.cpp
@@ -918,6 +918,15 @@ void Camera2Client::stopPreviewL() {
ALOGE("%s: Camera %d: Can't stop streaming: %s (%d)",
__FUNCTION__, mCameraId, strerror(-res), res);
}
+
+ // Flush all in-process captures and buffer in order to stop
+ // preview faster.
+ res = mDevice->flush();
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to flush pending requests: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ }
+
res = mDevice->waitUntilDrained();
if (res != OK) {
ALOGE("%s: Camera %d: Waiting to stop streaming failed: %s (%d)",