声音不适用于 Android Things 的树莓派

Posted

技术标签:

【中文标题】声音不适用于 Android Things 的树莓派【英文标题】:Sound not working on raspberry pi with Android Things 【发布时间】:2017-09-15 04:57:03 【问题描述】:

最近我们在树莓派 3 上刷了 android Things,除了声音外,一切都运行良好。 我尝试连接 3.5 毫米插孔耳机和 hdmi 屏幕以及不同的组合,例如:

    只有耳机没有 hdmi 显示。 仅限 hdmi 显示器。 连接到树莓派 3.5 音频插孔的耳机和 HDMI 显示器也已连接。

我使用 adb 命令尝试了所有这些。示例:

adb shell am start -a android.intent.action.VIEW -d file:///sdcard/music/sample.mp3 -t audio/mp3

或者,后来也使用了如下代码:

MediaPlayer mPlayer = MediaPlayer.create(this.getBaseContext(), R.raw.humma);
mPlayer.setOnErrorListener(this);
mPlayer.start();

但在这些条件下,声音都不起作用。

以下是控制台日志:

OMXClient: MuxOMX ctor
04-24 06:08:15.256   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:15.258   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:15.259   157   157 I OMXMaster: makeComponentInstance(OMX.google.mp3.decoder) in mediacodec process
04-24 06:08:15.401   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:15.402   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:15.403   157  1277 I OMXMaster: makeComponentInstance(OMX.google.amrnb.decoder) in mediacodec process
04-24 06:08:15.423   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:15.423   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:15.424   157  1277 I OMXMaster: makeComponentInstance(OMX.google.amrwb.decoder) in mediacodec process
04-24 06:08:15.433   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:15.434   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:15.435   157  1277 I OMXMaster: makeComponentInstance(OMX.google.aac.decoder) in mediacodec process
04-24 06:08:15.462   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:15.463   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:15.463   157   206 I OMXMaster: makeComponentInstance(OMX.google.g711.alaw.decoder) in mediacodec process
04-24 06:08:15.593   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:15.594   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:15.594   157   206 I OMXMaster: makeComponentInstance(OMX.google.g711.mlaw.decoder) in mediacodec process
04-24 06:08:15.723   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:15.724   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:15.724   157   206 I OMXMaster: makeComponentInstance(OMX.google.vorbis.decoder) in mediacodec process
04-24 06:08:15.853   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:15.854   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:15.854   157   206 I OMXMaster: makeComponentInstance(OMX.google.opus.decoder) in mediacodec process
04-24 06:08:15.984   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:15.985   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:15.985   157   206 I OMXMaster: makeComponentInstance(OMX.google.raw.decoder) in mediacodec process
04-24 06:08:15.997   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:15.998   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:15.998   157   206 I OMXMaster: makeComponentInstance(OMX.google.aac.encoder) in mediacodec process
04-24 06:08:16.025   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:16.025   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:16.026   157  1278 I OMXMaster: makeComponentInstance(OMX.google.amrnb.encoder) in mediacodec process
04-24 06:08:16.042   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:16.042   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:16.043   157  1278 I OMXMaster: makeComponentInstance(OMX.google.amrwb.encoder) in mediacodec process
04-24 06:08:16.065   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:16.066   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:16.066   157  1278 I OMXMaster: makeComponentInstance(OMX.google.flac.encoder) in mediacodec process
04-24 06:08:16.167  1246  1257 I art     : Background partial concurrent mark sweep GC freed 13776(3MB) AllocSpace objects, 18(360KB) LOS objects, 39% free, 2MB/3MB, paused 969us total 101.384ms
04-24 06:08:16.213   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:16.214   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:16.215   157  1278 I OMXMaster: makeComponentInstance(OMX.google.gsm.decoder) in mediacodec process
04-24 06:08:16.350   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:16.351   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:16.352   157   206 I OMXMaster: makeComponentInstance(OMX.google.mpeg4.decoder) in mediacodec process
04-24 06:08:16.391  1246  1246 I Choreographer: Skipped 54 frames!  The application may be doing too much work on its main thread.
04-24 06:08:16.464   409   431 I ActivityManager: Displayed schneider_electric.com.mqttclient/.MainActivity: +23s558ms
04-24 06:08:16.485   409   471 I WindowManager: Destroying surface Surface(name=com.android.iotlauncher/com.android.iotlauncher.IoTLauncher) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.destroyOrSaveSurface:2073 com.android.server.wm.AppWindowToken.destroySurfaces:363 com.android.server.wm.AppWindowToken.notifyAppStopped:389 com.android.server.wm.WindowManagerService.notifyAppStopped:4456 com.android.server.am.ActivityStack.activityStoppedLocked:1252 com.android.server.am.ActivityManagerService.activityStopped:6902 
04-24 06:08:16.500   157  1277 E OMXNodeInstance: getExtensionIndex(9d000f:google.mpeg4.decoder, OMX.google.android.index.configureVideoTunnelMode) ERROR: UnsupportedIndex(0x8000101a)
04-24 06:08:16.500   157   157 W OMXNodeInstance: [9d000f:google.mpeg4.decoder] component does not support metadata mode; using fallback
04-24 06:08:16.505   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:16.506   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:16.506   157   157 I OMXMaster: makeComponentInstance(OMX.google.h263.decoder) in mediacodec process
04-24 06:08:16.634   157  1277 E OMXNodeInstance: getExtensionIndex(9d0010:google.h263.decoder, OMX.google.android.index.configureVideoTunnelMode) ERROR: UnsupportedIndex(0x8000101a)
04-24 06:08:16.634   157  1277 W OMXNodeInstance: [9d0010:google.h263.decoder] component does not support metadata mode; using fallback
04-24 06:08:16.641   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:16.641   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:16.643   157  1277 I OMXMaster: makeComponentInstance(OMX.google.h264.decoder) in mediacodec process
04-24 06:08:16.720   409   431 I WindowManager: Destroying surface Surface(name=Starting schneider_electric.com.mqttclient) called by com.android.server.wm.WindowStateAnimator.destroySurface:2014 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:881 com.android.server.wm.WindowState.destroyOrSaveSurface:2073 com.android.server.wm.AppWindowToken.destroySurfaces:363 com.android.server.wm.WindowStateAnimator.finishExit:565 com.android.server.wm.WindowStateAnimator.stepAnimationLocked:491 com.android.server.wm.WindowAnimator.updateWindowsLocked:303 com.android.server.wm.WindowAnimator.animateLocked:704 
04-24 06:08:16.788   160  1273 W ACodec  : [OMX.google.h264.decoder] stopping checking profiles after 32: 2/8000
04-24 06:08:16.789   157   206 E OMXNodeInstance: getExtensionIndex(9d0011:google.h264.decoder, OMX.google.android.index.configureVideoTunnelMode) ERROR: UnsupportedIndex(0x8000101a)
04-24 06:08:16.789   157  1277 W OMXNodeInstance: [9d0011:google.h264.decoder] component does not support metadata mode; using fallback
04-24 06:08:16.796   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:16.797   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:16.797   157  1277 I OMXMaster: makeComponentInstance(OMX.google.hevc.decoder) in mediacodec process
04-24 06:08:16.943   157  1277 E OMXNodeInstance: getExtensionIndex(9d0012:google.hevc.decoder, OMX.google.android.index.configureVideoTunnelMode) ERROR: UnsupportedIndex(0x8000101a)
04-24 06:08:16.943   157   157 W OMXNodeInstance: [9d0012:google.hevc.decoder] component does not support metadata mode; using fallback
04-24 06:08:16.949   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:16.950   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:16.950   157   157 I OMXMaster: makeComponentInstance(OMX.google.vp8.decoder) in mediacodec process
04-24 06:08:17.078   157  1277 E OMXNodeInstance: getExtensionIndex(9d0013:google.vp8.decoder, OMX.google.android.index.configureVideoTunnelMode) ERROR: UnsupportedIndex(0x8000101a)
04-24 06:08:17.079   157  1277 W OMXNodeInstance: [9d0013:google.vp8.decoder] component does not support metadata mode; using fallback
04-24 06:08:17.084   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:17.084   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:17.085   157  1277 I OMXMaster: makeComponentInstance(OMX.google.vp9.decoder) in mediacodec process
04-24 06:08:17.177  1246  1308 D AlarmPingSender: Register alarmreceiver to MqttServiceMqttService.pingSender.02:00:00:00:00:00-pub
04-24 06:08:17.184  1246  1308 D AlarmPingSender: Schedule next alarm at 1493014157183
04-24 06:08:17.186  1246  1308 D AlarmPingSender: Alarm scheule using setExactAndAllowWhileIdle, next: 60000
04-24 06:08:17.219   157  1278 E OMXNodeInstance: getExtensionIndex(9d0014:google.vp9.decoder, OMX.google.android.index.configureVideoTunnelMode) ERROR: UnsupportedIndex(0x8000101a)
04-24 06:08:17.219   157   157 W OMXNodeInstance: [9d0014:google.vp9.decoder] component does not support metadata mode; using fallback
04-24 06:08:17.225   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:17.227   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:17.227   157   157 I OMXMaster: makeComponentInstance(OMX.google.h263.encoder) in mediacodec process
04-24 06:08:17.365   157   157 I SoftMPEG4Encoder: Construct SoftMPEG4Encoder
04-24 06:08:17.369   160  1273 W ACodec  : do not know color format 0x7f000789 = 2130708361
04-24 06:08:17.370   157  1277 E OMXNodeInstance: getConfig(9d0015:google.h263.encoder, ConfigAndroidIntraRefresh(0x6f60000a)) ERROR: Undefined(0x80001001)
04-24 06:08:17.375   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:17.376   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:17.376   157   157 I OMXMaster: makeComponentInstance(OMX.google.h264.encoder) in mediacodec process
04-24 06:08:17.514   160  1273 W ACodec  : do not know color format 0x7f000789 = 2130708361
04-24 06:08:17.519   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:17.520   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:17.520   157  1278 I OMXMaster: makeComponentInstance(OMX.google.mpeg4.encoder) in mediacodec process
04-24 06:08:17.641   157  1278 I SoftMPEG4Encoder: Construct SoftMPEG4Encoder
04-24 06:08:17.645   160  1273 W ACodec  : do not know color format 0x7f000789 = 2130708361
04-24 06:08:17.646   157  1277 E OMXNodeInstance: getConfig(9d0017:google.mpeg4.encoder, ConfigAndroidIntraRefresh(0x6f60000a)) ERROR: Undefined(0x80001001)
04-24 06:08:17.651   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:17.652   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:17.652   157   206 I OMXMaster: makeComponentInstance(OMX.google.vp8.encoder) in mediacodec process
04-24 06:08:17.786   160  1273 W ACodec  : do not know color format 0x7f000789 = 2130708361
04-24 06:08:17.787   157  1277 E OMXNodeInstance: getConfig(9d0018:google.vp8.encoder, ConfigAndroidIntraRefresh(0x6f60000a)) ERROR: Undefined(0x80001001)
04-24 06:08:17.792   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:17.792   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:17.792   160  1273 W MediaCodecList: unable to open media codecs configuration xml file: /etc/media_codecs_performance.xml
04-24 06:08:17.793   160  1273 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:17.794   160  1273 I OMXClient: MuxOMX ctor
04-24 06:08:17.799   160  1273 W MediaCodecList: unable to open media codecs configuration xml file: /data/misc/media/media_codecs_profiling_results.xml
04-24 06:08:17.800   160  1274 I MediaPlayerService: MediaPlayerService::getOMX
04-24 06:08:17.801   160  1274 I OMXClient: MuxOMX ctor
04-24 06:08:17.801   157  1277 I OMXMaster: makeComponentInstance(OMX.google.mp3.decoder) in mediacodec process
04-24 06:08:17.918   157  1278 E OMXNodeInstance: setConfig(9d0019:google.mp3.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
04-24 06:08:17.918   160  1274 I ACodec  : codec does not support config priority (err -2147483648)
04-24 06:08:17.922   160  1274 I MediaCodec: MediaCodec will operate in async mode
04-24 06:08:17.946   160  1272 D AudioTrack: Client defaulted notificationFrames to 7520 for frameCount 22560
04-24 06:08:17.949   160  1267 D NuPlayerDriver: notifyListener_l(0xa810c000), (6, 0, 0), loop setting(0, 0)
04-24 06:08:41.720   170   170 I update_engine: [0424/060841:INFO:update_manager-inl.h(52)] ChromeOSPolicy::UpdateCheckAllowed: START
04-24 06:08:41.721   170   170 I update_engine: [0424/060841:INFO:chromeos_policy.cc(322)] Allowing update check.

请帮帮我。

【问题讨论】:

您期待什么声音?你写了什么代码来产生声音? 我期待 3.5 毫米声音插孔的输出...我尝试编写代码来播放声音以及使用 adb 命令(如 adb shell am start -a android.intent)直接从目录播放。 action.VIEW -d file:///sdcard/music/xxxxx.mp3 -t audio/mp3 Recently we flashed Android Things on raspberry Pi 3??对我来说是新的。怎么刷一个raspi 3? Viren,您应该在问题中显示您希望播放声音的代码。 @greenapps developer.android.com/things/hardware/raspberrypi.html 谢谢。但是您不会像我已经想的那样闪烁 pi。而是微型 SD 卡。 【参考方案1】:

adb shell am start -a android.intent.action.VIEW

告诉 Android 使用动作 VIEW 触发意图以“查看 mp3”。 AndroidThings 不像 Android AOSP - 它没有任何内置应用程序。因此它没有可以VIEW 即播放您的 MP3 的应用程序。

要在您自己的应用程序中播放 mp3,您需要确保文件与系统兼容。 See here for supported media formats

如果没问题,那么您就有了播放媒体文件的正确代码 (more info here)。然后您应该检查日志以查看它是否正在播放。

【讨论】:

谢谢布伦德尔。我同意您回答的第一部分(“查看 mp3”)。然而在第二部分,情况并不好。我有一个有效的 mp3(访问过的共享链接),但它仍然不起作用。我正在向我的问题添加日志,请查看并提出建议【参考方案2】:

我怀疑它与以下带有音频管理的 API 有关:https://developer.android.com/things/sdk/drivers/audio.html

【讨论】:

以上是关于声音不适用于 Android Things 的树莓派的主要内容,如果未能解决你的问题,请参考以下文章

FCM 自定义声音通知不适用于 IOS Xcode

MediaPlayer无法在Android Things Raspberry Pi 3上运行

带有外部 GPS 的自定义定位服务通过 android things 连接到 Raspberry Pi

Android:按钮单击时的随机声音效果

快速播放声音似乎不适用于我的应用程序

播放声音文件不适用于除 IE 以外的所有浏览器