RockChip hdmirx 声音预览 FAQ

文章讲述了用户在使用Android12设备时遇到HDMIIN应用启动时音频记录功能崩溃的问题,错误代码指向AudioRecord初始化失败。文中提供了针对该问题的补丁,涉及AudioPolicyEngine和硬件驱动的修改。后续提到了Android13和14可能需要类似解决,但具体内容尚未给出。
摘要由CSDN通过智能技术生成

Android 12

1.打开Hdmiin应用,android界面重启1

报错如下:

01-26 12:08:48.841  2140  2175 E APM::AudioPolicyEngine: getDeviceForInputSource() no default device defined
01-26 12:08:48.841  2140  2175 W APM_AudioPolicyManager: getInputForAttr() could not find device for source 11
01-26 12:08:48.841  2140  2175 E AudioFlinger: createRecord() getInputForAttr return error -22
01-26 12:08:48.841  2210  3898 E AudioRecord: createRecord_l(6553646): AudioFlinger could not create record track, status: -22
01-26 12:08:48.841  2210  3898 E AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -22.
01-26 12:08:48.841  2210  3898 E android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.
--------- beginning of crash
01-26 12:08:48.841  2210  3898 E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: Thread-21
01-26 12:08:48.841  2210  3898 E AndroidRuntime: java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord.
01-26 12:08:48.841  2210  3898 E AndroidRuntime:        at android.media.AudioRecord.startRecording(AudioRecord.java:1284)
01-26 12:08:48.841  2210  3898 E AndroidRuntime:        at com.android.server.tv.AudioStream$recordSound.run(AudioStream.java:202)
01-26 12:08:48.841  2210  3898 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:920)

需加上如下补丁
frameworks/av

diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp
index 3b75ccbabe..da146cbae2 100644
--- a/services/audiopolicy/enginedefault/src/Engine.cpp
+++ b/services/audiopolicy/enginedefault/src/Engine.cpp
@@ -611,13 +611,18 @@ sp<DeviceDescriptor> Engine::getDeviceForInputSource(audio_source_t inputSource)
     }
     if (device == nullptr) {
         ALOGV("getDeviceForInputSource() no device found for source %d", inputSource);
-        device = availableDevices.getDevice(
-                AUDIO_DEVICE_IN_STUB, String8(""), AUDIO_FORMAT_DEFAULT);
+        if (inputSource == AUDIO_SOURCE_HDMIIN || inputSource == AUDIO_SOURCE_HDMIIN_1) {
+            device = availableDevices.getDevice(
+                    AUDIO_DEVICE_IN_BUILTIN_MIC, String8(""), AUDIO_FORMAT_DEFAULT);
+        } else {
+            device = availableDevices.getDevice(
+                    AUDIO_DEVICE_IN_STUB, String8(""), AUDIO_FORMAT_DEFAULT);
+        }
         ALOGE_IF(device == nullptr,
                  "getDeviceForInputSource() no default device defined");
     }

-    ALOGV_IF(device != nullptr,
+    ALOGD_IF(device != nullptr,
              "getDeviceForInputSource()input source %d, device %08x",
              inputSource, device->type());
     return device;

2.打开Hdmiin应用,android界面重启2

报错如下:

TimeCheck: requesting tombstone for pid: 415
01-31 09:22:40.354  2185  2185 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-31 09:22:40.354  2185  2185 F DEBUG   : Build fingerprint: 'rockchip/rk3588_s/rk3588_s:12/SQ3A.220705.003.A1/eng.yutong.20240131.090607:userdebug/release-keys'
01-31 09:22:40.354  2185  2185 F DEBUG   : Revision: '0'
01-31 09:22:40.354  2185  2185 F DEBUG   : ABI: 'arm'
01-31 09:22:40.354  2185  2185 F DEBUG   : Timestamp: 2024-01-31 09:22:40.160503171+0000
01-31 09:22:40.354  2185  2185 F DEBUG   : Process uptime: 0s
01-31 09:22:40.354  2185  2185 F DEBUG   : Cmdline: /vendor/bin/hw/android.hardware.audio.service
01-31 09:22:40.354  2185  2185 F DEBUG   : pid: 415, tid: 415, name: audio.service  >>> /vendor/bin/hw/android.hardware.audio.service <<<
01-31 09:22:40.354  2185  2185 F DEBUG   : uid: 1041
01-31 09:22:40.354  2185  2185 F DEBUG   : signal 35 (<debuggerd signal>), code -1 (SI_QUEUE from pid 439, uid 1041), fault addr --------
01-31 09:22:40.354  2185  2185 F DEBUG   :     r0  f56408fc  r1  00000089  r2  00000002  r3  00000000
01-31 09:22:40.355  2185  2185 F DEBUG   :     r4  00000000  r5  ffffffff  r6  84b3d7d6  r7  000000f0
01-31 09:22:40.355  2185  2185 F DEBUG   :     r8  00000002  r9  f56408fc  r10 00000000  r11 00000000
01-31 09:22:40.355  2185  2185 F DEBUG   :     ip  ffd56b68  sp  ffd56b58  lr  f5ac5203  pc  f5abfa24
01-31 09:22:40.355  2185  2185 F DEBUG   : backtrace:
01-31 09:22:40.355  2185  2185 F DEBUG   :       #00 pc 00033a24  /apex/com.android.runtime/lib/bionic/libc.so (syscall+28) (BuildId: a0f86e06c7ea70b36f3cae2d93197708)
01-31 09:22:40.355  2185  2185 F DEBUG   :       #01 pc 000391ff  /apex/com.android.runtime/lib/bionic/libc.so (__futex_wait_ex(void volatile*, bool, int, bool, timespec const*)+94) (BuildId: a0f86e06c7ea70b36f3cae2d93197708)
01-31 09:22:40.355  2185  2185 F DEBUG   :       #02 pc 000813d1  /apex/com.android.runtime/lib/bionic/libc.so (NonPI::MutexLockWithTimeout(pthread_mutex_internal_t*, bool, timespec const*)+144) (BuildId: a0f86e06c7ea70b36f3cae2d93197708)
01-31 09:22:40.355  2185  2185 F DEBUG   :       #03 pc 0001238d  /vendor/lib/hw/audio.hdmi.rk30board.so (in_set_parameters+108) (BuildId: 137740932946f485800e435d2042caca)
01-31 09:22:40.355  2185  2185 F DEBUG   :       #04 pc 000188bd  /vendor/lib/hw/android.hardware.audio@7.0-impl.so (android::hardware::audio::V7_0::implementation::ParametersUtil::setParametersImpl(android::hardware::hidl_vec<android::hardware::audio::V7_0::ParameterValue> const&, android::hardware::hidl_vec<android::hardware::audio::V7_0::ParameterValue> const&)+268) (BuildId: 20f3c60e9b22b96f7c73f3f9f1e14be8)
01-31 09:22:40.355  2185  2185 F DEBUG   :       #05 pc 0001b007  /vendor/lib/hw/android.hardware.audio@7.0-impl.so (android::hardware::audio::V7_0::implementation::Stream::setParameters(android::hardware::hidl_vec<android::hardware::audio::V7_0::ParameterValue> const&, android::hardware::hidl_vec<android::hardware::audio::V7_0::ParameterValue> const&)+10) (BuildId: 20f3c60e9b22b96f7c73f3f9f1e14be8)
01-31 09:22:40.355  2185  2185 F DEBUG   :       #06 pc 0001c37d  /vendor/lib/hw/android.hardware.audio@7.0-impl.so (android::hardware::audio::V7_0::implementation::StreamIn::setParameters(android::hardware::hidl_vec<android::hardware::audio::V7_0::ParameterValue> const&, android::hardware::hidl_vec<android::hardware::audio::V7_0::ParameterValue> const&)+12) (BuildId: 20f3c60e9b22b96f7c73f3f9f1e14be8)
01-31 09:22:40.355  2185  2185 F DEBUG   :       #07 pc 0005fad3  /vendor/lib/android.hardware.audio@7.0.so (android::hardware::audio::V7_0::BnHwStream::_hidl_setParameters(android::hidl::base::V1_0::BnHwBase*, android::hardware::Parcel const&, android::hardware::Parcel*, std::__1::function<void (android::hardware::Parcel&)>)+330) (BuildId: 46d122b0b02dd4e17eec6a1d7990b3c1)
01-31 09:22:40.355  2185  2185 F DEBUG   :       #08 pc 0006b8db  /vendor/lib/android.hardware.audio@7.0.so (android::hardware::audio::V7_0::BnHwStreamIn::onTransact(unsigned int, android::hardware::Parcel const&, android::hardware::Parcel*, unsigned int, std::__1::function<void (android::hardware::Parcel&)>)+1454) (BuildId: 46d122b0b02dd4e17eec6a1d7990b3c1)
01-31 09:22:40.355  2185  2185 F DEBUG   :       #09 pc 00054761  /apex/com.android.vndk.v32/lib/libhidlbase.so (android::hardware::BHwBinder::transact(unsigned int, android::hardware::Parcel const&, android::hardware::Parcel*, unsigned int, std::__1::function<void (android::hardware::Parcel&)>)+92) (BuildId: 46b9878f25ee1e256cc89ea6b856011b)
01-31 09:22:40.355  2185  2185 F DEBUG   :       #10 pc 00053751  /apex/com.android.vndk.v32/lib/libhidlbase.so (android::hardware::IPCThreadState::getAndExecuteCommand()+976) (BuildId: 46b9878f25ee1e256cc89ea6b856011b)
01-31 09:22:40.355  2185  2185 F DEBUG   :       #11 pc 000532e1  /apex/com.android.vndk.v32/lib/libhidlbase.so (android::hardware::IPCThreadState::joinThreadPool(bool)+56) (BuildId: 46b9878f25ee1e256cc89ea6b856011b)
01-31 09:22:40.355  2185  2185 F DEBUG   :       #12 pc 0000267f  /vendor/bin/hw/android.hardware.audio.service (main+2526) (BuildId: 5ec58a6fae980d06a4053eeca01ddc34)
01-31 09:22:40.355  2185  2185 F DEBUG   :       #13 pc 00031f7b  /apex/com.android.runtime/lib/bionic/libc.so (__libc_init+54) (BuildId: a0f86e06c7ea70b36f3cae2d93197708)

kernel需要加上如下补丁

diff --git a/sound/soc/rockchip/rockchip_i2s_tdm.c b/sound/soc/rockchip/rockchip_i2s_tdm.c
index b7ffaaa7153e..e7a58d9c8c43 100644
--- a/sound/soc/rockchip/rockchip_i2s_tdm.c
+++ b/sound/soc/rockchip/rockchip_i2s_tdm.c
@@ -1173,6 +1173,10 @@ static int rockchip_i2s_tdm_trigger(struct snd_pcm_substream *substream,
         break;
     }

+    if(substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+        substream->wait_time = msecs_to_jiffies(500);
+    }
+
     return ret;
 }
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
index d29ab5c33468..10a8c83f4e8c 100644
--- a/sound/soc/rockchip/rockchip_i2s.c
+++ b/sound/soc/rockchip/rockchip_i2s.c
@@ -435,6 +435,9 @@ static int rockchip_i2s_trigger(struct snd_pcm_substream *substream,
                break;
        }

+       if(substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+               substream->wait_time = msecs_to_jiffies(500);
+       }
        return ret;
 }

Android 13

待补充

Android 14

待补充

  • 9
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值