Example #1
0
bSound *BKE_sound_new_file(struct Main *bmain, const char *filename)
{
	bSound *sound;

	char str[FILE_MAX];
	const char *path;

	size_t len;

	BLI_strncpy(str, filename, sizeof(str));

	path = /*bmain ? bmain->name :*/ G.main->name;

	BLI_path_abs(str, path);

	len = strlen(filename);
	while (len > 0 && filename[len - 1] != '/' && filename[len - 1] != '\\')
		len--;

	sound = BKE_libblock_alloc(bmain, ID_SO, filename + len);
	BLI_strncpy(sound->name, filename, FILE_MAX);
	/* sound->type = SOUND_TYPE_FILE; */ /* XXX unused currently */

	BKE_sound_load(bmain, sound);

	return sound;
}
Example #2
0
/**
 * Only copy internal data of Sound ID from source to already allocated/initialized destination.
 * You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
 *
 * WARNING! This function will not handle ID user count!
 *
 * \param flag  Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
 */
void BKE_sound_copy_data(Main *bmain, bSound *sound_dst, const bSound *UNUSED(sound_src), const int UNUSED(flag))
{
	sound_dst->handle = NULL;
	sound_dst->cache = NULL;
	sound_dst->waveform = NULL;
	sound_dst->playback_handle = NULL;
	sound_dst->spinlock = NULL;  /* Think this is OK? Otherwise, easy to create new spinlock here... */

	/* Just to be sure, should not have any value actually after reading time. */
	sound_dst->ipo = NULL;
	sound_dst->newpackedfile = NULL;

	if (sound_dst->packedfile) {
		sound_dst->packedfile = dupPackedFile(sound_dst->packedfile);
	}

	/* Initialize whole runtime (audaspace) stuff. */
	BKE_sound_load(bmain, sound_dst);
}
Example #3
0
bSound *BKE_sound_new_file(struct Main *bmain, const char *filepath)
{
	bSound *sound;
	const char *path;
	char str[FILE_MAX];

	BLI_strncpy(str, filepath, sizeof(str));

	path = /*bmain ? bmain->name :*/ G.main->name;

	BLI_path_abs(str, path);

	sound = BKE_libblock_alloc(bmain, ID_SO, BLI_path_basename(filepath));
	BLI_strncpy(sound->name, filepath, FILE_MAX);
	/* sound->type = SOUND_TYPE_FILE; */ /* XXX unused currently */

	BKE_sound_load(bmain, sound);

	return sound;
}
Example #4
0
int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how)
{
	char localname[FILE_MAX], absname[FILE_MAX];
	char *newname;
	int ret_value = RET_ERROR;

	if (sound != NULL) {
		unpack_generate_paths(sound->name, (ID *)sound, absname, localname, sizeof(absname), sizeof(localname));
		newname = unpackFile(reports, absname, localname, sound->packedfile, how);
		if (newname != NULL) {
			BLI_strncpy(sound->name, newname, sizeof(sound->name));
			MEM_freeN(newname);

			freePackedFile(sound->packedfile);
			sound->packedfile = NULL;

			BKE_sound_load(bmain, sound);

			ret_value = RET_OK;
		}
	}
	
	return(ret_value);
}
Example #5
0
static void rna_Sound_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
  BKE_sound_load(bmain, (bSound *)ptr->data);
}