首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >安卓双簧管c++ E/AudioALSAPlaybackHandlerBase: openPcmDriver(),pcm_start(0xeff82fc0)由于无法启动通道而失败

安卓双簧管c++ E/AudioALSAPlaybackHandlerBase: openPcmDriver(),pcm_start(0xeff82fc0)由于无法启动通道而失败
EN

Stack Overflow用户
提问于 2018-12-12 15:14:15
回答 1查看 685关注 0票数 0

在某些设备上,用于高性能音频的android双簧管库运行良好。然而,在其他设备上,它在加载声音文件后崩溃。

这个jni方法执行得很好:

代码语言:javascript
运行
复制
void SoundFunctions::loadSounds() {

    LOGD("SoundFunctions loadSounds called");

    // Load the RAW PCM data files for both the clap sound and backing track into memory.
    stdB = SoundRecording::loadFromAssets(mAssetManager, "std_kit_b.wav");
    stdSN= SoundRecording::loadFromAssets(mAssetManager, "std_kit_sn.wav");

    // Add all to mixer
    mMixer.addTrack(stdB);
    mMixer.addTrack(stdSN);


    // Create a builder
    AudioStreamBuilder builder;
    builder.setFormat(AudioFormat::I16);
    builder.setChannelCount(1);
    builder.setSampleRate(kSampleRateHz);
    builder.setCallback(this);
    builder.setPerformanceMode(PerformanceMode::LowLatency);
    builder.setSharingMode(SharingMode::Exclusive);
    LOGD("After creating a builder");

    // Open stream
    Result result = builder.openStream(&mAudioStream);
    if (result != Result::OK){
        LOGE("Failed to open stream. Error: %s", convertToText(result));
    }
    LOGD("After openstream");

    // Reduce stream latency by setting the buffer size to a multiple of the burst size
    mAudioStream->setBufferSizeInFrames(mAudioStream->getFramesPerBurst() * 2);

    // Start the stream
    result = mAudioStream->requestStart();
    if (result != Result::OK){
        LOGE("Failed to start stream. Error: %s", convertToText(result));
    }
    LOGD("After starting stream");


}

然而,不久之后,出现了本机崩溃E/AudioALSAPlaybackHandlerBase: openPcmDriver(),pcm_start(0xeff82fc0)由于无法启动通道:中断管道而失败。

,这意味着什么,我如何解决?

这是错误日志:

12-12 14:55:14.995 11622-11622/com.learntomaster.dlmp D/节奏游戏:开始流12-12 14:55:15.006 1462-1987/?E/AudioALSAPlaybackHandlerBase: openPcmDriver(),pcm_start(0xeff82fc0)由于无法启动通道而失败:管道破裂 代码1,故障地址0x90在tid 11622 (rntomaster.dlmp) 12-1214:55:15.137 10957-11660/?结冰:中止语料库播放列表的索引12-12 14:55:15.151 11895-11895/?I/AEE/AED:* * 12-12 14:55:15.152 11895-11895/?I/AEE/AED:建立指纹:'Lenovo/LenovoTB3-850F/TB3-850F:6.0/MRA58K/TB3-850F_S100031_171010_ROW:user/release-keys‘12-12 14:55:15.152 11895-11895/?I/AEE/AED:修订:'0‘12-12 14:55:15.152 11895-11895/?I/AEE/AED: ABI:'arm64‘12-1214:55:15.152 11895-11895/?I/AEE/AED: pid: 11622,tid: 11622,名称: rntomaster.dlmp com.learntomaster.dlmp <<< 12-12 14:55:15.152 11895-11895/?I/AEE/AED: 11号信号(SIGSEGV),代码1 (SEGV_MAPERR),故障地址0x90 12-12 14:55:15.174 11895-11895/?I/AEE/AED: x0 0000000000000090 x1 0000007fdedc 7540 x2 0000000000000000 x3 0000000000000000 12-12 14:55:15.174 11895-11895/?I/AEE/AED: x4 0000000000000000 x5 0000000000000000 x6 00000000000000 x7 00000000000000 12-12 14:55:15.174 11895-11895/?I/AEE/AED: x8 0000000000000001 x9 0000007f956290a0 x10 0000000000000001 x11 0000007f937c20e0 12-12 14:55:15.174 11895-11895/?I/AEE/AED: x12 0000007f96ecea40 x13 0000000000000004 x14 0000000000000005 x15 000000000000c0 12-12 14:55:15.174 11895-11895/?I/AEE/AED: x16 0000007f9562e760 x17 00007f96e9048c x18 0000007f937c20e0 x19 0000000000000000 12-12 14:55:15.174 11895-11895/?I/AEE/AED: x20 0000000000000090 x21 0000007f7ea3b488 x22 00007f7ea3b380 x23 0000007f7f7ea3b012-12 14:55:15.174 11895-11895/?I/AEE/AED: x24 0000007fdedc 7540 x25 0000000000000000 x26 0000007fdedc7a78 x27 0000279200002d66 12-12 14:55:15.174 11895-11895/?I/AEE/AED: x28 0000279200002d66 x29 0000007fdedc 7490 x30 0000007f955948a4 12-12 14:55:15.174 11895-11895/?I/AEE/AED: sp 0000007fdedc 7490 pc 000000007f96e90494 pstate 0000000060000000 12-12 14:55:15.195 1462-1988/?E/AudioFlinger: getNextBuffer,获得零缓冲区12-12 14:55:15.203 11895-11895/?I/AEE/AED:回溯: 12-12 14:55:15.203 11895-11895/?I/AEE/AED:#00 pc 0000000000068494 /system/lib64 64/libc.so (pthread_mutex_lock+8) 12-1214:55:15.203 11895-11895/?I/AEE/AED:#01 pc 000000000002f8a0 /system/lib64 64/libhwui.so (_ZN7android10uirenderer12renderthread12RenderThread5queueEPNS1_10RenderTaskE+28) 12-12 14:55:15.203 -11895/?I/AEE/AED:#02 pc 000000000002e324 /system/lib64 64/libhwui.so (_ZN7android10uirenderer12renderthread11RenderProxy11postAndWaitEPNS1_22MethodInvokeRenderTaskE+132) 12-1214:55:15.203 11895-11895/?I/AEE/AED:#03 pc 000000000002e600 /system/lib64 64/libhwui.so (_ZN7android10uirenderer12renderthread11RenderProxy20loadSystemPropertiesEv+92) 12-1214:55:15.203 11895-11895/?I/AEE/AED:#04 pc 0000000002a1b990 /system/framework/arm64/boot.oat (偏移号0x2439000) 12-1214:55:15.795 1858-1858/?TRAFFIC_STATS_POLL真令牌14 num客户端9 12-12 14:55:15.796 1858-1858/?Tx=11477 Rx=15018 12-12 14:55:15.823 11895-11895/?I/AEE/AED:墓碑:/数据/墓碑/墓碑_04 12-12 14:55:15.824 11895-11895/?E/AEE/AED: AM写失败:断管12-12 14:55:15.824 11895-11895/?E/AEE/AED: request.action: 0

EN

回答 1

Stack Overflow用户

发布于 2018-12-27 17:17:03

我的猜测是,您的应用程序试图使用比可用内存更多的内存。每次调用SoundRecording::loadFromAssets时,都会将声音文件的全部内容加载到内存中,并且有40个声音文件。

如果这些声音文件中的一个无法加载,则生成的SoundRecording *对象将为空指针。这将添加到Mixer中。调用mAudioStream->requestStart()之后,将发生第一个回调,在此期间调用Mixer::renderAudio,然后调用SoundRecording::renderAudio来取消空指针MAPERR

我不是100%肯定,但我认为至少需要一个回调才能启动流(在使用OpenSL ES时肯定需要这样做),这将解释为什么pcm_start方法失败。

验证这一点的一种简单方法是在调用nullptr后检查loadFromAssets

代码语言:javascript
运行
复制
if (stdB == nullptr){ LOGE("Failed to load sound file"); }

您还应该检查更新样本代码,它修复了RhythmGame示例中的内存泄漏,并使用了智能指针。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53746049

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档