.../Android/AndroidAudio/Private/AndroidAudioBuffer.cpp | 14 ++++++++++++++ .../Android/AndroidAudio/Private/AndroidAudioSource.cpp | 5 +++++ .../Android/AndroidAudio/Public/AndroidAudioDevice.h | 8 ++++++++ 3 files changed, 27 insertions(+) diff --git a/Engine/Source/Runtime/Android/AndroidAudio/Private/AndroidAudioBuffer.cpp b/Engine/Source/Runtime/Android/AndroidAudio/Private/AndroidAudioBuffer.cpp index 7bf6f4b..7e98a4f 100644 --- a/Engine/Source/Runtime/Android/AndroidAudio/Private/AndroidAudioBuffer.cpp +++ b/Engine/Source/Runtime/Android/AndroidAudio/Private/AndroidAudioBuffer.cpp @@ -125,6 +125,8 @@ FSLESSoundBuffer* FSLESSoundBuffer::CreateNativeBuffer( FSLESAudioDevice* AudioD // Create new buffer. Buffer = new FSLESSoundBuffer( AudioDevice ); + Buffer->DecompressionState = new FADPCMAudioInfo(); + FAudioDeviceManager* AudioDeviceManager = GEngine->GetAudioDeviceManager(); check(AudioDeviceManager != nullptr); @@ -199,6 +201,8 @@ FSLESSoundBuffer* FSLESSoundBuffer::Init( FSLESAudioDevice* AudioDevice ,USound EDecompressionType DecompressionType = InWave->DecompressionType; + UE_LOG(LogAndroidAudio, Warning, TEXT("Init: Using %d decompression type"), EDecompressionType); + switch( DecompressionType ) { case DTYPE_Setup: @@ -259,6 +263,16 @@ bool FSLESSoundBuffer::ReadCompressedData( uint8* Destination, bool bLooping ) return(DecompressionState->ReadCompressedData(Destination, bLooping, DecompressionState->GetStreamBufferSize() * NumChannels)); } +// NOTE: copied and pasted from CoreAudioBuffer.cpp +// IMHO This and the duplicate code in FXAudio2SoundBuffer::Seek() and FCoreAudioSoundBuffer::Seek() should be refactored into FAudioBuffer +void FSLESSoundBuffer::Seek(const float SeekTime) +{ + if (ensure(DecompressionState)) + { + DecompressionState->SeekToTime(SeekTime); + } +} + /** * Returns the size for a real time/streaming buffer based on decompressor * diff --git a/Engine/Source/Runtime/Android/AndroidAudio/Private/AndroidAudioSource.cpp b/Engine/Source/Runtime/Android/AndroidAudio/Private/AndroidAudioSource.cpp index 8e51d5a..b5d5787 100644 --- a/Engine/Source/Runtime/Android/AndroidAudio/Private/AndroidAudioSource.cpp +++ b/Engine/Source/Runtime/Android/AndroidAudio/Private/AndroidAudioSource.cpp @@ -287,6 +287,11 @@ bool FSLESSoundSource::Init( FWaveInstance* InWaveInstance ) { WaveInstance = InWaveInstance; + if (WaveInstance->StartTime > 0.f) + { + Buffer->Seek(WaveInstance->StartTime); + } + switch( Buffer->Format) { case SoundFormat_PCM: diff --git a/Engine/Source/Runtime/Android/AndroidAudio/Public/AndroidAudioDevice.h b/Engine/Source/Runtime/Android/AndroidAudio/Public/AndroidAudioDevice.h index f58d12b..9d4de5d 100644 --- a/Engine/Source/Runtime/Android/AndroidAudio/Public/AndroidAudioDevice.h +++ b/Engine/Source/Runtime/Android/AndroidAudio/Public/AndroidAudioDevice.h @@ -99,6 +99,14 @@ public: bool ReadCompressedData( uint8* Destination, bool bLooping ); /** + * Sets the point in time within the buffer to the specified time + * If the time specified is beyond the end of the sound, it will be set to the end + * + * @param SeekTime Time in seconds from the beginning of sound to seek to + */ + void Seek(const float SeekTime); + + /** * Returns the size of this buffer in bytes. * * @return Size in bytes