void BKE_sound_free(bSound *sound) { if (sound->packedfile) { freePackedFile(sound->packedfile); sound->packedfile = NULL; } #ifdef WITH_AUDASPACE if (sound->handle) { AUD_unload(sound->handle); sound->handle = NULL; sound->playback_handle = NULL; } if (sound->cache) { AUD_unload(sound->cache); sound->cache = NULL; } BKE_sound_free_waveform(sound); if (sound->spinlock) { BLI_spin_end(sound->spinlock); MEM_freeN(sound->spinlock); sound->spinlock = NULL; } #endif /* WITH_AUDASPACE */ }
void sound_delete_cache(bSound *sound) { sound->flags &= ~SOUND_FLAGS_CACHING; if (sound->cache) { AUD_unload(sound->cache); sound->cache = NULL; sound->playback_handle = sound->handle; } }
void sound_cache(bSound *sound) { sound->flags |= SOUND_FLAGS_CACHING; if (sound->cache) AUD_unload(sound->cache); sound->cache = AUD_bufferSound(sound->handle); if (sound->cache) sound->playback_handle = sound->cache; else sound->playback_handle = sound->handle; }
void BKE_sound_free(bSound *sound) { if (sound->packedfile) { freePackedFile(sound->packedfile); sound->packedfile = NULL; } #ifdef WITH_AUDASPACE if (sound->handle) { AUD_unload(sound->handle); sound->handle = NULL; sound->playback_handle = NULL; } if (sound->cache) { AUD_unload(sound->cache); sound->cache = NULL; } sound_free_waveform(sound); #endif /* WITH_AUDASPACE */ }
void sound_load(struct Main *bmain, bSound *sound) { if (sound) { if (sound->cache) { AUD_unload(sound->cache); sound->cache = NULL; } if (sound->handle) { AUD_unload(sound->handle); sound->handle = NULL; sound->playback_handle = NULL; } sound_free_waveform(sound); /* XXX unused currently */ #if 0 switch (sound->type) { case SOUND_TYPE_FILE: #endif { char fullpath[FILE_MAX]; /* load sound */ PackedFile *pf = sound->packedfile; /* don't modify soundact->sound->name, only change a copy */ BLI_strncpy(fullpath, sound->name, sizeof(fullpath)); BLI_path_abs(fullpath, ID_BLEND_PATH(bmain, &sound->id)); /* but we need a packed file then */ if (pf) sound->handle = AUD_loadBuffer((unsigned char *) pf->data, pf->size); /* or else load it from disk */ else sound->handle = AUD_load(fullpath); } /* XXX unused currently */ #if 0 break; } case SOUND_TYPE_BUFFER: if (sound->child_sound && sound->child_sound->handle) sound->handle = AUD_bufferSound(sound->child_sound->handle); break; case SOUND_TYPE_LIMITER: if (sound->child_sound && sound->child_sound->handle) sound->handle = AUD_limitSound(sound->child_sound, sound->start, sound->end); break; } #endif if (sound->flags & SOUND_FLAGS_MONO) { void *handle = AUD_monoSound(sound->handle); AUD_unload(sound->handle); sound->handle = handle; } if (sound->flags & SOUND_FLAGS_CACHING) { sound->cache = AUD_bufferSound(sound->handle); } if (sound->cache) sound->playback_handle = sound->cache; else sound->playback_handle = sound->handle; sound_update_sequencer(bmain, sound); }