StreamDescriptor.cpp revision 5a2b62984c7cecd1761fe272c078dd814c167942
1dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie/* 2dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie * Copyright (C) 2015 The Android Open Source Project 3dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie * 4dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie * Licensed under the Apache License, Version 2.0 (the "License"); 5dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie * you may not use this file except in compliance with the License. 6dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie * You may obtain a copy of the License at 7dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie * 8dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie * http://www.apache.org/licenses/LICENSE-2.0 9dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie * 10dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie * Unless required by applicable law or agreed to in writing, software 11dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie * distributed under the License is distributed on an "AS IS" BASIS, 12dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie * See the License for the specific language governing permissions and 14dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie * limitations under the License. 15dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie */ 16dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 17dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie#define LOG_TAG "APM::Volumes" 18dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie//#define LOG_NDEBUG 0 19dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 20dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie//#define VERY_VERBOSE_LOGGING 21dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie#ifdef VERY_VERBOSE_LOGGING 22dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie#define ALOGVV ALOGV 23dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie#else 24dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie#define ALOGVV(a...) do { } while(0) 25dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie#endif 26dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 27dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie#include "StreamDescriptor.h" 28d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie#include "Gains.h" 29dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie#include <utils/Log.h> 30dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie#include <utils/String8.h> 31dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 32dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffienamespace android { 33dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 34dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie// --- StreamDescriptor class implementation 35dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 36dfd7409c1b708f6c429aa43722ca8493a91d8df0François GaffieStreamDescriptor::StreamDescriptor() 37dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie : mIndexMin(0), mIndexMax(1), mCanBeMuted(true) 38dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 395664139e0ae16bb180a8eaae917f35f7c99d2a0aRalph Nathan // Initialize the current stream's index to mIndexMax so volume isn't 0 in 405664139e0ae16bb180a8eaae917f35f7c99d2a0aRalph Nathan // cases where the Java layer doesn't call into the audio policy service to 415664139e0ae16bb180a8eaae917f35f7c99d2a0aRalph Nathan // set the default volume. 425a2b62984c7cecd1761fe272c078dd814c167942Eric Laurent mIndexCur.add(AUDIO_DEVICE_OUT_DEFAULT_FOR_VOLUME, mIndexMax); 43dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 44dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 45dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffieint StreamDescriptor::getVolumeIndex(audio_devices_t device) const 46dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 47dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie device = Volume::getDeviceForVolume(device); 485a2b62984c7cecd1761fe272c078dd814c167942Eric Laurent // there is always a valid entry for AUDIO_DEVICE_OUT_DEFAULT_FOR_VOLUME 49dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie if (mIndexCur.indexOfKey(device) < 0) { 505a2b62984c7cecd1761fe272c078dd814c167942Eric Laurent device = AUDIO_DEVICE_OUT_DEFAULT_FOR_VOLUME; 51dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie } 52dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie return mIndexCur.valueFor(device); 53dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 54dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 55dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffievoid StreamDescriptor::clearCurrentVolumeIndex() 56dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 57dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie mIndexCur.clear(); 58dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 59dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 60dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffievoid StreamDescriptor::addCurrentVolumeIndex(audio_devices_t device, int index) 61dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 62dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie mIndexCur.add(device, index); 63dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 64dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 65dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffievoid StreamDescriptor::setVolumeIndexMin(int volIndexMin) 66dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 67dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie mIndexMin = volIndexMin; 68dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 69dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 70dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffievoid StreamDescriptor::setVolumeIndexMax(int volIndexMax) 71dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 72dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie mIndexMax = volIndexMax; 73dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 74dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 75d0609ad390ff8bb1cafebdf363bf1d15e63b949fFrançois Gaffievoid StreamDescriptor::setVolumeCurvePoint(device_category deviceCategory, 76dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie const VolumeCurvePoint *point) 77dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 78dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie mVolumeCurve[deviceCategory] = point; 79dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 80dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 81dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffievoid StreamDescriptor::dump(int fd) const 82dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 83dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie const size_t SIZE = 256; 84dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie char buffer[SIZE]; 85dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie String8 result; 86dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 87dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie snprintf(buffer, SIZE, "%s %02d %02d ", 88dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie mCanBeMuted ? "true " : "false", mIndexMin, mIndexMax); 89dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie result.append(buffer); 90dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie for (size_t i = 0; i < mIndexCur.size(); i++) { 91dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie snprintf(buffer, SIZE, "%04x : %02d, ", 92dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie mIndexCur.keyAt(i), 93dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie mIndexCur.valueAt(i)); 94dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie result.append(buffer); 95dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie } 96dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie result.append("\n"); 97dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 98dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie write(fd, result.string(), result.size()); 99dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 100dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 101dfd7409c1b708f6c429aa43722ca8493a91d8df0François GaffieStreamDescriptorCollection::StreamDescriptorCollection() 102dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 103dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie for (size_t stream = 0 ; stream < AUDIO_STREAM_CNT; stream++) { 104dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie add(static_cast<audio_stream_type_t>(stream), StreamDescriptor()); 105dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie } 106dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 107dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 108dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffiebool StreamDescriptorCollection::canBeMuted(audio_stream_type_t stream) 109dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 110dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie return valueAt(stream).canBeMuted(); 111dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 112dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 113dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffievoid StreamDescriptorCollection::clearCurrentVolumeIndex(audio_stream_type_t stream) 114dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 115dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie editValueAt(stream).clearCurrentVolumeIndex(); 116dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 117dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 118dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffievoid StreamDescriptorCollection::addCurrentVolumeIndex(audio_stream_type_t stream, 119dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie audio_devices_t device, int index) 120dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 121dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie editValueAt(stream).addCurrentVolumeIndex(device, index); 122dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 123dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 124dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffievoid StreamDescriptorCollection::setVolumeCurvePoint(audio_stream_type_t stream, 125d0609ad390ff8bb1cafebdf363bf1d15e63b949fFrançois Gaffie device_category deviceCategory, 126dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie const VolumeCurvePoint *point) 127dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 128dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie editValueAt(stream).setVolumeCurvePoint(deviceCategory, point); 129dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 130dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 131dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffieconst VolumeCurvePoint *StreamDescriptorCollection::getVolumeCurvePoint(audio_stream_type_t stream, 132d0609ad390ff8bb1cafebdf363bf1d15e63b949fFrançois Gaffie device_category deviceCategory) const 133dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 134dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie return valueAt(stream).getVolumeCurvePoint(deviceCategory); 135dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 136dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 137dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffievoid StreamDescriptorCollection::setVolumeIndexMin(audio_stream_type_t stream,int volIndexMin) 138dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 139dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie return editValueAt(stream).setVolumeIndexMin(volIndexMin); 140dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 141dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 142dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffievoid StreamDescriptorCollection::setVolumeIndexMax(audio_stream_type_t stream,int volIndexMax) 143dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 144dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie return editValueAt(stream).setVolumeIndexMax(volIndexMax); 145dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 146dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 147d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffiefloat StreamDescriptorCollection::volIndexToDb(audio_stream_type_t stream, device_category category, 148d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie int indexInUi) const 149d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie{ 150d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie const StreamDescriptor &streamDesc = valueAt(stream); 151d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie return Gains::volIndexToDb(streamDesc.getVolumeCurvePoint(category), 152d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie streamDesc.getVolumeIndexMin(), streamDesc.getVolumeIndexMax(), 153d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie indexInUi); 154d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie} 155d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie 156d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffiestatus_t StreamDescriptorCollection::initStreamVolume(audio_stream_type_t stream, 157d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie int indexMin, int indexMax) 158d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie{ 159d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie ALOGV("initStreamVolume() stream %d, min %d, max %d", stream , indexMin, indexMax); 160d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie if (indexMin < 0 || indexMin >= indexMax) { 161d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie ALOGW("initStreamVolume() invalid index limits for stream %d, min %d, max %d", 162d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie stream , indexMin, indexMax); 163d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie return BAD_VALUE; 164d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie } 165d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie setVolumeIndexMin(stream, indexMin); 166d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie setVolumeIndexMax(stream, indexMax); 167d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie return NO_ERROR; 168d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie} 169d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie 170d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffievoid StreamDescriptorCollection::initializeVolumeCurves(bool isSpeakerDrcEnabled) 171d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie{ 172d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie for (int i = 0; i < AUDIO_STREAM_CNT; i++) { 173d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie for (int j = 0; j < DEVICE_CATEGORY_CNT; j++) { 174d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie setVolumeCurvePoint(static_cast<audio_stream_type_t>(i), 175d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie static_cast<device_category>(j), 176d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie Gains::sVolumeProfiles[i][j]); 177d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie } 178d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie } 179d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie 180d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie // Check availability of DRC on speaker path: if available, override some of the speaker curves 181d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie if (isSpeakerDrcEnabled) { 182d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie setVolumeCurvePoint(AUDIO_STREAM_SYSTEM, DEVICE_CATEGORY_SPEAKER, 183d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie Gains::sDefaultSystemVolumeCurveDrc); 184d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie setVolumeCurvePoint(AUDIO_STREAM_RING, DEVICE_CATEGORY_SPEAKER, 185d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie Gains::sSpeakerSonificationVolumeCurveDrc); 186d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie setVolumeCurvePoint(AUDIO_STREAM_ALARM, DEVICE_CATEGORY_SPEAKER, 187d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie Gains::sSpeakerSonificationVolumeCurveDrc); 188d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie setVolumeCurvePoint(AUDIO_STREAM_NOTIFICATION, DEVICE_CATEGORY_SPEAKER, 189d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie Gains::sSpeakerSonificationVolumeCurveDrc); 190d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie setVolumeCurvePoint(AUDIO_STREAM_MUSIC, DEVICE_CATEGORY_SPEAKER, 191d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie Gains::sSpeakerMediaVolumeCurveDrc); 192d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie setVolumeCurvePoint(AUDIO_STREAM_ACCESSIBILITY, DEVICE_CATEGORY_SPEAKER, 193d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie Gains::sSpeakerMediaVolumeCurveDrc); 194d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie } 195d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie} 196d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie 197d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffievoid StreamDescriptorCollection::switchVolumeCurve(audio_stream_type_t streamSrc, 198d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie audio_stream_type_t streamDst) 199d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie{ 200d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie for (int j = 0; j < DEVICE_CATEGORY_CNT; j++) { 201d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie setVolumeCurvePoint(streamDst, static_cast<device_category>(j), 202d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie Gains::sVolumeProfiles[streamSrc][j]); 203d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie } 204d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie} 205d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie 206dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffiestatus_t StreamDescriptorCollection::dump(int fd) const 207dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie{ 208dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie const size_t SIZE = 256; 209dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie char buffer[SIZE]; 210dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 211dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie snprintf(buffer, SIZE, "\nStreams dump:\n"); 212dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie write(fd, buffer, strlen(buffer)); 213dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie snprintf(buffer, SIZE, 214dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie " Stream Can be muted Index Min Index Max Index Cur [device : index]...\n"); 215dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie write(fd, buffer, strlen(buffer)); 216dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie for (size_t i = 0; i < size(); i++) { 217dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie snprintf(buffer, SIZE, " %02zu ", i); 218dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie write(fd, buffer, strlen(buffer)); 219dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie valueAt(i).dump(fd); 220dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie } 221dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 222dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie return NO_ERROR; 223dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie} 224dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie 225dfd7409c1b708f6c429aa43722ca8493a91d8df0François Gaffie}; // namespace android 226