Parcourir la source

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.
marauder2k7 il y a 1 an
Parent
commit
147044796b
2 fichiers modifiés avec 5 ajouts et 5 suppressions
  1. 4 4
      Engine/source/sfx/media/sfxSndStream.cpp
  2. 1 1
      Engine/source/sfx/sfxProfile.cpp

+ 4 - 4
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)
 sf_count_t SFXSndStream::sndSeek(sf_count_t offset, int whence, void* user_data)
 {
 {
    VIO_DATA* vf = (VIO_DATA*)user_data;
    VIO_DATA* vf = (VIO_DATA*)user_data;
+   Stream* stream = reinterpret_cast<Stream*>(vf->data);
 
 
    switch (whence)
    switch (whence)
    {
    {
@@ -140,13 +141,13 @@ sf_count_t SFXSndStream::sndSeek(sf_count_t offset, int whence, void* user_data)
       break;
       break;
 
 
    case SEEK_END:
    case SEEK_END:
-      vf->offset = vf->length + offset;
+      vf->offset = vf->length - offset;
       break;
       break;
    default:
    default:
       break;
       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)
 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)
    if (vf->offset + count > vf->length)
       count = vf->length - vf->offset;
       count = vf->length - vf->offset;
 
 
-   stream->read((U32)(count), reinterpret_cast<U8*>(ptr));
-
+   stream->read((U32)(count), ptr);
    vf->offset += count;
    vf->offset += count;
 
 
    return count;
    return count;

+ 1 - 1
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)",
          Con::printf( "%s SFX: %s (%i channels, %i kHz, %.02f sec, %i kb)",
             mDescription->mIsStreaming ? "Streaming" : "Loading", resource->getFileName().c_str(),
             mDescription->mIsStreaming ? "Streaming" : "Loading", resource->getFileName().c_str(),
             format.getChannels(),
             format.getChannels(),
-            format.getSamplesPerSecond() / 1000,
+            format.getSamplesPerSecond(),
             F32( resource->getDuration() ) / 1000.0f,
             F32( resource->getDuration() ) / 1000.0f,
             format.getDataLength( resource->getDuration() ) / 1024 );
             format.getDataLength( resource->getDuration() ) / 1024 );
          #endif
          #endif