Cause Analysis and Solution for switching between stereo and single channel during video playback by android

Source: Internet
Author: User

Some customers use third-party video players and switch between stereo and single channels. After the switch, it is found that it does not work.
The reason is that by default, the HAL layer does not handle the commands sent from stereo to mono, so it will be ineffective,

You can add related processing as follows:
1. Modify AudioMTKHardware. cpp.
Add: static String8 keySetStereo2MonoMode = String8 ("EnableStereoOutput ");

2. Modify status_t AudioMTKHardware: setParameters (const String8 & keyValuePairs)
In EXIT_SETPARAMETERS:
Previously added:Copy codeThe Code is as follows: if (param. getInt (keySetStereo2MonoMode, value) = NO_ERROR ){
ALOGD ("setParameters (): % s value = % d", keyValuePairs. string (), value );
(AudioMTKStreamManager *) mAudioMTKStreamManager)-> ForceSterer2Mono (value );
}

3. Modify AudioMTKStreamManager. h
Add public method definition:Copy codeThe Code is as follows: status_t ForceSterer2Mono (bool flag );
Status_t AudioMTKStreamManager: ForceSterer2Mono (bool flag)
{
// Force all stream to standby
ALOGD ("ForceSterer2Mono = % d", flag );
If (mStreamOutVector. size ()){
For (size_t I = 0; I <mStreamOutVector. size (); I ++ ){
AudioMTKStreamOut * pTempOut = (AudioMTKStreamOut *) mStreamOutVector. valueAt (I );
PTempOut-> SetStereoToMonoFlagForce (flag );
}
}
Return NO_ERROR;
}

4. Modify AudioMTKStreamOut. h
T add definition:Copy codeThe Code is as follows: status_t SetStereoToMonoFlagForce (bool flag );
Status_t AudioMTKStreamOut: SetStereoToMonoFlagForce (bool flag)
{
ALOGD ("SetStereoToMonoFlagForce = % d", flag );
MSteroToMono = flag;
Return NO_ERROR;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.