Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2020-03-08 22:45:00 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2020-03-08 22:45:00 +0300
commit668b64380a7ef5c5079f436dc145a625af56b402 (patch)
tree3eb6f01c959f4c4eb25aeec1b6df4d748803c031
parent014f78b5b5a49c133ff95b3c9d973744de6eec2d (diff)
Cleanup: Sound: Move to IDTypeInfo and remove unused BKE API.
-rw-r--r--source/blender/blenkernel/BKE_idtype.h2
-rw-r--r--source/blender/blenkernel/BKE_sound.h9
-rw-r--r--source/blender/blenkernel/intern/idtype.c2
-rw-r--r--source/blender/blenkernel/intern/lib_id.c8
-rw-r--r--source/blender/blenkernel/intern/lib_id_delete.c2
-rw-r--r--source/blender/blenkernel/intern/sound.c127
6 files changed, 75 insertions, 75 deletions
diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h
index 6795d91ba96..ba6daa03436 100644
--- a/source/blender/blenkernel/BKE_idtype.h
+++ b/source/blender/blenkernel/BKE_idtype.h
@@ -143,7 +143,7 @@ extern IDTypeInfo IDType_ID_SCR;
extern IDTypeInfo IDType_ID_VF;
extern IDTypeInfo IDType_ID_TXT;
extern IDTypeInfo IDType_ID_SPK;
-// extern IDTypeInfo IDType_ID_SO;
+extern IDTypeInfo IDType_ID_SO;
extern IDTypeInfo IDType_ID_GR;
extern IDTypeInfo IDType_ID_AR;
extern IDTypeInfo IDType_ID_AC;
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index e2866728bba..e6d931276bf 100644
--- a/source/blender/blenkernel/BKE_sound.h
+++ b/source/blender/blenkernel/BKE_sound.h
@@ -80,8 +80,6 @@ void BKE_sound_reset_runtime(struct bSound *sound);
void BKE_sound_load(struct Main *main, struct bSound *sound);
void BKE_sound_ensure_loaded(struct Main *bmain, struct bSound *sound);
-void BKE_sound_free(struct bSound *sound);
-
/* Matches AUD_Channels. */
typedef enum eSoundChannels {
SOUND_CHANNELS_INVALID = 0,
@@ -106,13 +104,6 @@ typedef struct SoundInfo {
* or if the codes is not supported. */
bool BKE_sound_info_get(struct Main *main, struct bSound *sound, SoundInfo *sound_info);
-void BKE_sound_copy_data(struct Main *bmain,
- struct bSound *sound_dst,
- const struct bSound *sound_src,
- const int flag);
-
-void BKE_sound_make_local(struct Main *bmain, struct bSound *sound, const int flags);
-
#if defined(WITH_AUDASPACE)
AUD_Device *BKE_sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume);
#endif
diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c
index 94adf5e3456..e2c52520e47 100644
--- a/source/blender/blenkernel/intern/idtype.c
+++ b/source/blender/blenkernel/intern/idtype.c
@@ -70,7 +70,7 @@ static void id_type_init(void)
INIT_TYPE(ID_VF);
INIT_TYPE(ID_TXT);
INIT_TYPE(ID_SPK);
- // INIT_TYPE(ID_SO);
+ INIT_TYPE(ID_SO);
INIT_TYPE(ID_GR);
INIT_TYPE(ID_AR);
INIT_TYPE(ID_AC);
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index 6db83434cc6..22496f47345 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -515,9 +515,7 @@ bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const int flags
BLI_assert(0);
return true;
case ID_SO:
- if (!test) {
- BKE_sound_make_local(bmain, (bSound *)id, flags);
- }
+ BLI_assert(0);
return true;
case ID_GR:
BLI_assert(0);
@@ -777,7 +775,7 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
BKE_cachefile_copy_data(bmain, (CacheFile *)*r_newid, (CacheFile *)id, flag);
break;
case ID_SO:
- BKE_sound_copy_data(bmain, (bSound *)*r_newid, (bSound *)id, flag);
+ BLI_assert(0);
break;
case ID_VF:
BLI_assert(0);
@@ -1360,7 +1358,7 @@ void BKE_libblock_init_empty(ID *id)
BLI_assert(0);
break;
case ID_SO:
- /* Another fuzzy case, think NULLified content is OK here... */
+ BLI_assert(0);
break;
case ID_GR:
/* Nothing to do. */
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index 8ca660639c0..c36c5afa1cf 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -196,7 +196,7 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
BLI_assert(0);
break;
case ID_SO:
- BKE_sound_free((bSound *)id);
+ BLI_assert(0);
break;
case ID_GR:
BLI_assert(0);
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index cd38030faf4..df7597b7f01 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -31,6 +31,8 @@
#include "BLI_math.h"
#include "BLI_threads.h"
+#include "BLT_translation.h"
+
#include "DNA_anim_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -50,6 +52,7 @@
#endif
#include "BKE_global.h"
+#include "BKE_idtype.h"
#include "BKE_main.h"
#include "BKE_sound.h"
#include "BKE_lib_id.h"
@@ -60,6 +63,72 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
+static void sound_free_audio(bSound *sound);
+
+static void sound_copy_data(Main *UNUSED(bmain),
+ ID *id_dst,
+ const ID *id_src,
+ const int UNUSED(flag))
+{
+ bSound *sound_dst = (bSound *)id_dst;
+ const bSound *sound_src = (const bSound *)id_src;
+
+ sound_dst->handle = NULL;
+ sound_dst->cache = NULL;
+ sound_dst->waveform = NULL;
+ sound_dst->playback_handle = NULL;
+ sound_dst->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
+ BLI_spin_init(sound_dst->spinlock);
+
+ /* Just to be sure, should not have any value actually after reading time. */
+ sound_dst->ipo = NULL;
+ sound_dst->newpackedfile = NULL;
+
+ if (sound_src->packedfile != NULL) {
+ sound_dst->packedfile = BKE_packedfile_duplicate(sound_src->packedfile);
+ }
+
+ BKE_sound_reset_runtime(sound_dst);
+}
+
+static void sound_free_data(ID *id)
+{
+ bSound *sound = (bSound *)id;
+
+ /* No animdata here. */
+
+ if (sound->packedfile) {
+ BKE_packedfile_free(sound->packedfile);
+ sound->packedfile = NULL;
+ }
+
+ sound_free_audio(sound);
+ BKE_sound_free_waveform(sound);
+
+ if (sound->spinlock) {
+ BLI_spin_end(sound->spinlock);
+ MEM_freeN(sound->spinlock);
+ sound->spinlock = NULL;
+ }
+}
+
+IDTypeInfo IDType_ID_SO = {
+ .id_code = ID_SO,
+ .id_filter = FILTER_ID_SO,
+ .main_listbase_index = INDEX_ID_SO,
+ .struct_size = sizeof(bSound),
+ .name = "Sound",
+ .name_plural = "sounds",
+ .translation_context = BLT_I18NCONTEXT_ID_SOUND,
+ .flags = 0,
+
+ /* A fuzzy case, think NULLified content is OK here... */
+ .init_data = NULL,
+ .copy_data = sound_copy_data,
+ .free_data = sound_free_data,
+ .make_local = NULL,
+};
+
#ifdef WITH_AUDASPACE
/* evil globals ;-) */
static int sound_cfra;
@@ -164,64 +233,6 @@ static void sound_free_audio(bSound *sound)
#endif /* WITH_AUDASPACE */
}
-/** Free (or release) any data used by this sound (does not free the sound itself). */
-void BKE_sound_free(bSound *sound)
-{
- /* No animdata here. */
-
- if (sound->packedfile) {
- BKE_packedfile_free(sound->packedfile);
- sound->packedfile = NULL;
- }
-
- sound_free_audio(sound);
- BKE_sound_free_waveform(sound);
-
- if (sound->spinlock) {
- BLI_spin_end(sound->spinlock);
- MEM_freeN(sound->spinlock);
- sound->spinlock = NULL;
- }
-}
-
-/**
- * Only copy internal data of Sound ID from source
- * to already allocated/initialized destination.
- * You probably never want to use that directly,
- * use #BKE_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_lib_id.h's LIB_ID_COPY_... flags for more).
- */
-void BKE_sound_copy_data(Main *UNUSED(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 = MEM_mallocN(sizeof(SpinLock), "sound_spinlock");
- BLI_spin_init(sound_dst->spinlock);
-
- /* 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 = BKE_packedfile_duplicate(sound_dst->packedfile);
- }
-
- BKE_sound_reset_runtime(sound_dst);
-}
-
-void BKE_sound_make_local(Main *bmain, bSound *sound, const int flags)
-{
- BKE_lib_id_make_local_generic(bmain, &sound->id, flags);
-}
-
#ifdef WITH_AUDASPACE
static const char *force_device = NULL;