هل يجب إطلاق سراح المخزن المؤقت الانتهاء من مشغل صوت Opensl ES؟

StackOverflow https://stackoverflow.com/questions/6031213

  •  14-11-2019
  •  | 
  •  

سؤال

فقط للتأكيد.عند مشغل صوتي، تم إنشاؤه عبر Opensl Es for Android، ينتهي تشغيل المخزن المؤقت، هو أن المخزن المؤقت تحرير تلقائيا بواسطة جامع القمامة؟أو هل أحتاج إلى تحرير العازلة بنفسي؟

إذا كان هذا هو الأخير، يمكنني استخدام بعض المساعدة.ولكن كما الآن، لن أشر أي رمز حتى أخبرني أنني بحاجة إلى القيام بذلك بنفسي ...

هل كانت مفيدة؟

المحلول

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