Blender  V2.93
speaker.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include "DNA_defaults.h"
22 #include "DNA_object_types.h"
23 #include "DNA_sound_types.h"
24 #include "DNA_speaker_types.h"
25 
26 #include "BLI_math.h"
27 #include "BLI_utildefines.h"
28 
29 #include "BLT_translation.h"
30 
31 #include "BKE_anim_data.h"
32 #include "BKE_idtype.h"
33 #include "BKE_lib_id.h"
34 #include "BKE_lib_query.h"
35 #include "BKE_main.h"
36 #include "BKE_speaker.h"
37 
38 #include "BLO_read_write.h"
39 
40 static void speaker_init_data(ID *id)
41 {
42  Speaker *speaker = (Speaker *)id;
43 
45 
47 }
48 
50 {
51  Speaker *speaker = (Speaker *)id;
52 
54 }
55 
56 static void speaker_blend_write(BlendWriter *writer, ID *id, const void *id_address)
57 {
58  Speaker *spk = (Speaker *)id;
59  if (spk->id.us > 0 || BLO_write_is_undo(writer)) {
60  /* write LibData */
61  BLO_write_id_struct(writer, Speaker, id_address, &spk->id);
62  BKE_id_blend_write(writer, &spk->id);
63 
64  if (spk->adt) {
65  BKE_animdata_blend_write(writer, spk->adt);
66  }
67  }
68 }
69 
70 static void speaker_blend_read_data(BlendDataReader *reader, ID *id)
71 {
72  Speaker *spk = (Speaker *)id;
73  BLO_read_data_address(reader, &spk->adt);
74  BKE_animdata_blend_read_data(reader, spk->adt);
75 
76 #if 0
77  spk->sound = newdataadr(fd, spk->sound);
78  direct_link_sound(fd, spk->sound);
79 #endif
80 }
81 
82 static void speaker_blend_read_lib(BlendLibReader *reader, ID *id)
83 {
84  Speaker *spk = (Speaker *)id;
85  BLO_read_id_address(reader, spk->id.lib, &spk->sound);
86 }
87 
88 static void speaker_blend_read_expand(BlendExpander *expander, ID *id)
89 {
90  Speaker *spk = (Speaker *)id;
91  BLO_expand(expander, spk->sound);
92 }
93 
95  .id_code = ID_SPK,
96  .id_filter = FILTER_ID_SPK,
97  .main_listbase_index = INDEX_ID_SPK,
98  .struct_size = sizeof(Speaker),
99  .name = "Speaker",
100  .name_plural = "speakers",
101  .translation_context = BLT_I18NCONTEXT_ID_SPEAKER,
102  .flags = 0,
103 
105  .copy_data = NULL,
106  .free_data = NULL,
107  .make_local = NULL,
108  .foreach_id = speaker_foreach_id,
109  .foreach_cache = NULL,
110  .owner_get = NULL,
111 
112  .blend_write = speaker_blend_write,
113  .blend_read_data = speaker_blend_read_data,
114  .blend_read_lib = speaker_blend_read_lib,
115  .blend_read_expand = speaker_blend_read_expand,
116 
117  .blend_read_undo_preserve = NULL,
118 
119  .lib_override_apply_post = NULL,
120 };
121 
122 void *BKE_speaker_add(Main *bmain, const char *name)
123 {
124  Speaker *spk;
125 
126  spk = BKE_id_new(bmain, ID_SPK, name);
127 
128  return spk;
129 }
void BKE_animdata_blend_read_data(struct BlendDataReader *reader, struct AnimData *adt)
Definition: anim_data.c:1574
void BKE_animdata_blend_write(struct BlendWriter *writer, struct AnimData *adt)
Definition: anim_data.c:1552
void BKE_id_blend_write(struct BlendWriter *writer, struct ID *id)
Definition: lib_id.c:2395
void * BKE_id_new(struct Main *bmain, const short type, const char *name)
Definition: lib_id.c:1177
#define BKE_LIB_FOREACHID_PROCESS(_data, _id_super, _cb_flag)
@ IDWALK_CB_USER
Definition: BKE_lib_query.h:87
General operations for speakers.
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define BLO_read_data_address(reader, ptr_p)
#define BLO_write_id_struct(writer, struct_name, id_address, id)
#define BLO_read_id_address(reader, lib, id_ptr_p)
#define BLO_expand(expander, id)
bool BLO_write_is_undo(BlendWriter *writer)
Definition: writefile.c:1412
#define BLT_I18NCONTEXT_ID_SPEAKER
#define FILTER_ID_SPK
Definition: DNA_ID.h:726
@ INDEX_ID_SPK
Definition: DNA_ID.h:836
@ ID_SPK
Definition: DNA_ID_enums.h:75
#define DNA_struct_default_get(struct_name)
Definition: DNA_defaults.h:44
Object is a sort of wrapper for general info.
struct Speaker Speaker
static void init_data(ModifierData *md)
static void * newdataadr(FileData *fd, const void *adr)
Definition: readfile.c:1806
static void speaker_blend_read_lib(BlendLibReader *reader, ID *id)
Definition: speaker.c:82
static void speaker_blend_read_expand(BlendExpander *expander, ID *id)
Definition: speaker.c:88
void * BKE_speaker_add(Main *bmain, const char *name)
Definition: speaker.c:122
static void speaker_init_data(ID *id)
Definition: speaker.c:40
IDTypeInfo IDType_ID_SPK
Definition: speaker.c:94
static void speaker_blend_read_data(BlendDataReader *reader, ID *id)
Definition: speaker.c:70
static void speaker_blend_write(BlendWriter *writer, ID *id, const void *id_address)
Definition: speaker.c:56
static void speaker_foreach_id(ID *id, LibraryForeachIDData *data)
Definition: speaker.c:49
short id_code
Definition: BKE_idtype.h:120
Definition: DNA_ID.h:273
struct Library * lib
Definition: DNA_ID.h:277
int us
Definition: DNA_ID.h:293
Definition: BKE_main.h:116
struct AnimData * adt
struct bSound * sound