gpt4 book ai didi

Android OpenSLES 缓冲区饥饿问题

转载 作者:太空狗 更新时间:2023-10-29 15:07:03 28 4
gpt4 key购买 nike

我正在尝试解决 Android OpenSLES 中的以下问题。

OpenSLES 规范说明如下:

http://www.khronos.org/registry/sles/specs/OpenSL_ES_Specification_1.0.1.pdf - 8.12

When the player is in the SL_PLAYSTATE_PLAYING state, which is controlled by the SLPlayItf interface [see section 8.32], adding buffers will implicitly start playback. In the case of starvation due to insufficient buffers in the queue, the playing of audio data stops. The player remains in the SL_PLAYSTATE_PLAYING state. Upon queuing of additional buffers, the playing of audio data resumes. Note that starvation of queued buffers causes audible gaps in the audio data stream. In the case where the player is not in the playing state, addition of buffers does not start audio playback.

唉,一旦我们到了安卓:

http://mobilepearls.com/labs/native-android-api/ndk/docs/opensles/index.html - Decode audio to PCM

Depending on the platform implementation, decoding may require resources that cannot be left idle. Therefore it is not recommended to starve the decoder by failing to provide a sufficient number of empty PCM buffers, e.g. by returning from the Android simple buffer queue callback without enqueueing another empty buffer. The result of decoder starvation is unspecified; the implementation may choose to either drop the decoded PCM data, pause the decoding process, or in severe cases terminate the decoder.

这种非规范行为已经完全停止了我的项目的进展,我不知道如何最好地解决它。将整个文件解码为内存或磁盘上的 pcm 不是一个选项,我真的需要这是一个流媒体解决方案。对此的任何帮助将不胜感激

最佳答案

似乎没有办法解决这个问题。其他项目似乎使用较低级别的 api(例如 libstagefright)来进行解码。该方法确实可以让您获取数据

[编辑]没有办法解决饥饿问题。 Android 只是不遵守规范。基本上,您需要缓冲到内存中,并确保在需要控制数据流时使用暂停和恢复解码。

This is a discussion on the subject in the ndk google group

关于Android OpenSLES 缓冲区饥饿问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21022660/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com