From 147044796b0632fa04aa1caed7c2183039e164db Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Sun, 24 Mar 2024 11:33:42 +0000 Subject: [PATCH] sfxSndStream Ogg file from libsndfile now working. we can pull more information from the format and specifics of the file from libsndfile should maybe look at updating all the parameters around mFormat so it feeds openal settings better. Next step is to remove the other stream classes. --- Engine/source/sfx/media/sfxSndStream.cpp | 8 ++++---- Engine/source/sfx/sfxProfile.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Engine/source/sfx/media/sfxSndStream.cpp b/Engine/source/sfx/media/sfxSndStream.cpp index f7eedff92..ef1d20dc4 100644 --- a/Engine/source/sfx/media/sfxSndStream.cpp +++ b/Engine/source/sfx/media/sfxSndStream.cpp @@ -128,6 +128,7 @@ void SFXSndStream::setPosition(U32 offset) sf_count_t SFXSndStream::sndSeek(sf_count_t offset, int whence, void* user_data) { VIO_DATA* vf = (VIO_DATA*)user_data; + Stream* stream = reinterpret_cast(vf->data); switch (whence) { @@ -140,13 +141,13 @@ sf_count_t SFXSndStream::sndSeek(sf_count_t offset, int whence, void* user_data) break; case SEEK_END: - vf->offset = vf->length + offset; + vf->offset = vf->length - offset; break; default: break; }; - return vf->offset; + return stream->setPosition(vf->offset) ? 0 : -1; } sf_count_t SFXSndStream::sndRead(void* ptr, sf_count_t count, void* user_data) @@ -157,8 +158,7 @@ sf_count_t SFXSndStream::sndRead(void* ptr, sf_count_t count, void* user_data) if (vf->offset + count > vf->length) count = vf->length - vf->offset; - stream->read((U32)(count), reinterpret_cast(ptr)); - + stream->read((U32)(count), ptr); vf->offset += count; return count; diff --git a/Engine/source/sfx/sfxProfile.cpp b/Engine/source/sfx/sfxProfile.cpp index 37a55053b..2af2cb6e2 100644 --- a/Engine/source/sfx/sfxProfile.cpp +++ b/Engine/source/sfx/sfxProfile.cpp @@ -350,7 +350,7 @@ SFXBuffer* SFXProfile::_createBuffer() Con::printf( "%s SFX: %s (%i channels, %i kHz, %.02f sec, %i kb)", mDescription->mIsStreaming ? "Streaming" : "Loading", resource->getFileName().c_str(), format.getChannels(), - format.getSamplesPerSecond() / 1000, + format.getSamplesPerSecond(), F32( resource->getDuration() ) / 1000.0f, format.getDataLength( resource->getDuration() ) / 1024 ); #endif