getBufferSize method

int getBufferSize(
  1. AudioSource sound
)

Get the current buffer size in bytes of this sound with hash hash. hash the hash of the stream sound.

NOTE: the returned value is in bytes and since by default uses floats, the returned value should be divided by 4 and by the number of channels to have the number of samples.

Throws SoLoudNotInitializedException if the engine is not initialized. Throws SoLoudSoundHashNotFoundDartException if the sound is not found.

Implementation

int getBufferSize(AudioSource sound) {
  if (!isInitialized) {
    throw const SoLoudNotInitializedException();
  }
  final e = SoLoudController().soLoudFFI.getBufferSize(sound.soundHash);

  if (e.error != PlayerErrors.noError) {
    _logPlayerError(e.error, from: 'getBufferSize() result');
    throw SoLoudCppException.fromPlayerError(e.error);
  }
  return e.sizeInBytes;
}