문제

확인을 위해.Android 용 OpenSL ES를 통해 생성 된 오디오 플레이어가 버퍼 재생을 완료하면 버퍼가 가비지 수집기에 의해 자동으로 해제됩니까?또는 버퍼를 자유롭게해야합니까?

후자 인 경우 도움을받을 수 있습니다.그러나 지금은 내가 그것을 나 자신을해야한다고 말할 때까지 어떤 코드를 게시하지 않을 것입니다 ...

도움이 되었습니까?

해결책

The buffer queue doesn't actually allocate buffer memory itself (or need to free it), you pass in pointers to memory you have allocated via the 'enqueue' function. You will need to free the memory you allocated when you're finished playing buffers.

As OpenSL ES is a native library in C++, it knows nothing of garbage collection, any memory you allocate for the API must be freed by you, and objects you create must have 'destroy' called on them to clean up internal memory.

다른 팁

As the previous poster said, you call Enqueue with a buffer you have created previously. I'd point out, however, that unless you're playing only one audio event once in your app, you should probably keep re-using your audio buffers to avoid GC altogether - the beauty of C!

Also check out the Android OpenSL ES doc concerning Destroying your interfaces once your done with them, that has to be done manually.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top