// must be done after reading the policy (since conditionned by Speaker Drc Enabling) /** 调节音量曲线 */ mEngine->initializeVolumeCurves(mSpeakerDrcEnabled);
// open all output streams needed to access attached devices audio_devices_t outputDeviceTypes = mAvailableOutputDevices.types(); audio_devices_t inputDeviceTypes = mAvailableInputDevices.types() & ~AUDIO_DEVICE_BIT_IN; for (size_t i = 0; i < mHwModules.size(); i++) { mHwModules[i]->mHandle = mpClientInterface->loadHwModule(mHwModules[i]->mName); if (mHwModules[i]->mHandle == 0) { ALOGW("could not open HW module %s", mHwModules[i]->mName); continue; } // open all output streams needed to access attached devices // except for direct output streams that are only opened when they are actually // required by an app. // This also validates mAvailableOutputDevices list for (size_t j = 0; j < mHwModules[i]->mOutputProfiles.size(); j++) { const sp<IOProfile> outProfile = mHwModules[i]->mOutputProfiles[j];
/** 打开 recordThread */ if (cbf != NULL) { mAudioRecordThread = newAudioRecordThread(*this, threadCanCallJava); mAudioRecordThread->run("AudioRecord", ANDROID_PRIORITY_AUDIO); // thread begins in paused state, and will not reference us until start() }
// create the IAudioRecord status_t status = openRecord_l(0/*epoch*/, mOpPackageName);
/** Microphone audio source with same orientation as camera if available, the main * device microphone otherwise */ publicstaticfinalintCAMCORDER=5;
/** Microphone audio source tuned for voice recognition if available, behaves like * {@link #DEFAULT} otherwise. */ publicstaticfinalintVOICE_RECOGNITION=6;
/** Microphone audio source tuned for voice communications such as VoIP. It * will for instance take advantage of echo cancellation or automatic gain control * if available. It otherwise behaves like {@link #DEFAULT} if no voice processing * is applied. */ publicstaticfinalintVOICE_COMMUNICATION=7;
/** * Audio source for a submix of audio streams to be presented remotely. * <p> * An application can use this audio source to capture a mix of audio streams * that should be transmitted to a remote receiver such as a Wifi display. * While recording is active, these audio streams are redirected to the remote * submix instead of being played on the device speaker or headset. * </p><p> * Certain streams are excluded from the remote submix, including * {@link AudioManager#STREAM_RING}, {@link AudioManager#STREAM_ALARM}, * and {@link AudioManager#STREAM_NOTIFICATION}. These streams will continue * to be presented locally as usual. * </p><p> * Capturing the remote submix audio requires the * {@link android.Manifest.permission#CAPTURE_AUDIO_OUTPUT} permission. * This permission is reserved for use by system components and is not available to * third-party applications. * </p> */ publicstaticfinalintREMOTE_SUBMIX=8;
// MStar Android Patch Begin /** * @hide * BT PCM data send from remote devices which needs to be processed as PCM input */ publicstaticfinalintBT_MIC=9; // MStar Android Patch End
/** * Audio source for capturing broadcast radio tuner output. * @hide */ @SystemApi publicstaticfinalintRADIO_TUNER=1998;
/** * Audio source for preemptible, low-priority software hotword detection * It presents the same gain and pre processing tuning as {@link #VOICE_RECOGNITION}. * <p> * An application should use this audio source when it wishes to do * always-on software hotword detection, while gracefully giving in to any other application * that might want to read from the microphone. * </p> * This is a hidden audio source. * @hide */ @SystemApi publicstaticfinalintHOTWORD=1999; }
typedefenum { AUDIO_SOURCE_DEFAULT = 0, AUDIO_SOURCE_MIC = 1, AUDIO_SOURCE_VOICE_UPLINK = 2, AUDIO_SOURCE_VOICE_DOWNLINK = 3, AUDIO_SOURCE_VOICE_CALL = 4, AUDIO_SOURCE_CAMCORDER = 5, AUDIO_SOURCE_VOICE_RECOGNITION = 6, AUDIO_SOURCE_VOICE_COMMUNICATION = 7, AUDIO_SOURCE_REMOTE_SUBMIX = 8, /* Source for the mix to be presented remotely. */ /* An example of remote presentation is Wifi Display */ /* where a dongle attached to a TV can be used to */ /* play the mix captured by this audio source. */ // MStar Android Patch Begin AUDIO_SOURCE_BLUETOOTH_MIC = 9, AUDIO_SOURCE_CAPTURE_DEVICE0 = 10, AUDIO_SOURCE_CAPTURE_DEVICE1 = 11, AUDIO_SOURCE_A2DP = 12, /* restricted to internal audioflinger routing */ // MStar Android Patch End AUDIO_SOURCE_CNT, AUDIO_SOURCE_MAX = AUDIO_SOURCE_CNT - 1, AUDIO_SOURCE_FM_TUNER = 1998, AUDIO_SOURCE_HOTWORD = 1999, /* A low-priority, preemptible audio source for for background software hotword detection. Same tuning as AUDIO_SOURCE_VOICE_RECOGNITION. Used only internally to the framework. Not exposed at the audio HAL. */ } audio_source_t;
case AUDIO_SOURCE_VOICE_COMMUNICATION: // Allow only use of devices on primary input if in call and HAL does not support routing // to voice call path. if ((getPhoneState() == AUDIO_MODE_IN_CALL) && (availableOutputDevices.types() & AUDIO_DEVICE_OUT_TELEPHONY_TX) == 0) { sp<AudioOutputDescriptor> primaryOutput = outputs.getPrimaryOutput(); availableDeviceTypes = availableInputDevices.getDevicesFromHwModule(primaryOutput->getModuleHandle()) & ~AUDIO_DEVICE_BIT_IN; }
switch (mForceUse[AUDIO_POLICY_FORCE_FOR_COMMUNICATION]) { case AUDIO_POLICY_FORCE_BT_SCO: // if SCO device is requested but no SCO device is available, fall back to default case if (availableDeviceTypes & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) { device = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET; break; } // FALL THROUGH