mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
fmod: Fallback to opening file via callbacks if direct doesn't work
Fixes #1002
This commit is contained in:
parent
ab6bf5f4f7
commit
1cc82f47b6
@ -123,8 +123,13 @@ FmodAudioSound(AudioManager *manager, VirtualFile *file, bool positional) {
|
||||
<< "Reading " << _file_name << " into memory (" << sound_info.length
|
||||
<< " bytes)\n";
|
||||
}
|
||||
result =
|
||||
_manager->_system->createSound(name_or_data, flags, &sound_info, &_sound);
|
||||
}
|
||||
else {
|
||||
result = FMOD_ERR_FILE_BAD;
|
||||
|
||||
} else if (file->get_system_info(info)) {
|
||||
if (file->get_system_info(info)) {
|
||||
// The file exists on disk (or it's part of a multifile that exists on
|
||||
// disk), so we can have FMod read the file directly. This is also
|
||||
// safe, because FMod uses its own IO operations that don't involve
|
||||
@ -140,11 +145,18 @@ FmodAudioSound(AudioManager *manager, VirtualFile *file, bool positional) {
|
||||
<< ", " << sound_info.fileoffset << ", " << sound_info.length << ")\n";
|
||||
}
|
||||
|
||||
} else {
|
||||
result =
|
||||
_manager->_system->createSound(name_or_data, flags, &sound_info, &_sound);
|
||||
}
|
||||
|
||||
// If FMOD can't directly read the file (eg. if Panda is locking it for
|
||||
// write, or it's compressed) we have to use the callback interface.
|
||||
if (result == FMOD_ERR_FILE_BAD) {
|
||||
#if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS)
|
||||
// Otherwise, if the Panda threading system is compiled in, we can
|
||||
// assign callbacks to read the file through the VFS.
|
||||
name_or_data = (const char *)file;
|
||||
sound_info.fileoffset = 0;
|
||||
sound_info.length = (unsigned int)info.get_size();
|
||||
sound_info.useropen = open_callback;
|
||||
sound_info.userclose = close_callback;
|
||||
@ -155,6 +167,8 @@ FmodAudioSound(AudioManager *manager, VirtualFile *file, bool positional) {
|
||||
fmodAudio_cat.debug()
|
||||
<< "Streaming " << _file_name << " from disk using callbacks\n";
|
||||
}
|
||||
result =
|
||||
_manager->_system->createSound(name_or_data, flags, &sound_info, &_sound);
|
||||
|
||||
#else // HAVE_THREADS && !SIMPLE_THREADS
|
||||
// Without threads, we can't safely read this file.
|
||||
@ -164,9 +178,7 @@ FmodAudioSound(AudioManager *manager, VirtualFile *file, bool positional) {
|
||||
<< "Cannot stream " << _file_name << "; file is not literally on disk.\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
result =
|
||||
_manager->_system->createSound(name_or_data, flags, &sound_info, &_sound);
|
||||
}
|
||||
}
|
||||
|
||||
if (result != FMOD_OK) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user