예제 #1
0
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;
}
예제 #2
0
void BKE_sound_load(struct Main *bmain, bSound *sound)
{
	if (sound) {
		if (sound->cache) {
			AUD_Sound_free(sound->cache);
			sound->cache = NULL;
		}

		if (sound->handle) {
			AUD_Sound_free(sound->handle);
			sound->handle = NULL;
			sound->playback_handle = NULL;
		}

		BKE_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_Sound_bufferFile((unsigned char *) pf->data, pf->size);
			/* or else load it from disk */
			else
				sound->handle = AUD_Sound_file(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_Sound_rechannel(sound->handle, AUD_CHANNELS_MONO);
			AUD_Sound_free(sound->handle);
			sound->handle = handle;
		}

		if (sound->flags & SOUND_FLAGS_CACHING) {
			sound->cache = AUD_Sound_cache(sound->handle);
		}

		if (sound->cache)
			sound->playback_handle = sound->cache;
		else
			sound->playback_handle = sound->handle;

		BKE_sound_update_sequencer(bmain, sound);
	}