Android强制HDMI音频 [英] Android force HDMI audio
问题描述
我的ADT-1连接到电视后,无法通过HDMI播放声音.
My ADT-1 does not play sound over HDMI when connected to the TV.
在那台特定的电视上,我不得不在Raspberry PI上强制使用HDMI音频,因此我也试图在ADT-1上强制使用它.
On that specific TV I had to force HDMI audio on the Raspberry PI, so I'm trying to force it on the ADT-1 as well.
我尝试在获得许可的情况下制作应用
I tried making an app with the permission
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
并使用AudioManager实例更改设置
And using an AudioManager instance to change the settings
AudioManager manager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
Log.d(TAG, "ATTACHED: " + manager.getParameters("attached_output_devices"));
Log.d(TAG, "DEFAULT: " + manager.getParameters("default_output_device"));
Log.d(TAG, "PRE: " + manager.getParameters("audio_devices_out_active"));
manager.setParameters("audio_devices_out_active=AUDIO_DEVICE_OUT_AUX_DIGITAL");
Log.d(TAG, "POST: " + manager.getParameters("audio_devices_out_active"));
但是所有日志都返回为空,并且音频没有变化.
but all the logs are returning empty, and there's no change in the audio.
ATTACHED: attached_output_devices=
DEFAULT: default_output_device=
PRE: audio_devices_out_active=
POST: audio_devices_out_active=
我从TIF(电视输入框架)中了解了电视音频以及设置音频补丁的可能性,但我认为情况并非如此,这似乎更多是由于电视仅被视为HDMI监视器而没有音频功能.
I read about TV Audio from the TIF (TV Input Framework) and the possibility to set audio patches, but I don't think that's the case, this seems more due to the TV being seen only as an HDMI monitor with no audio capabilities.
文件/etc/audio_policy.conf显示:
the file /etc/audio_policy.conf shows:
global_configuration{
attached_output_devices AUDIO_DEVICE_OUT_SPEAKER
default_output_device AUDIO_DEVICE_OUT_SPEAKER
...
}
audio_hw_modules {
outputs{
primary{
...
devices AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_AUX_DIGITAL
flags AUDIO_OUTPUT_FLAG_PRIMARY
}
}
}
其中AUDIO_DEVICE_OUT_AUX_DIGITAL是HDMI.
Where AUDIO_DEVICE_OUT_AUX_DIGITAL is the HDMI.
关于如何强制ADT-1在HDMI上输出音频的任何想法吗?
Any idea on how to force ADT-1 to output audio on HDMI?
推荐答案
使用
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
在您的清单中
audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
audioManager.setParameters("audio_devices_out_active=AUDIO_CODEC");
// or
audioManager.setParameters("audio_devices_out_active=AUDIO_HDMI");
// or
audioManager.setParameters("audio_devices_out_active=AUDIO_HDMI,AUDIO_CODEC");
在您的代码中
设置有效音频输出
in your code for setting the active audio output
这篇关于Android强制HDMI音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!