4d6c4a46610704ce9f0f393f6c318c3bbcad9a59
[blender.git] / extern / verse / dist / v_gen_pack_a_node.c
1 /*
2 ** This is automatically generated source code -- do not edit.
3 ** Changes are affected either by editing the corresponding protocol
4 ** definition file (v_cmd_def_X.c where X=node type), or by editing
5 ** the code generator itself, in v_cmd_gen.c.
6 */
7
8 #include <stdlib.h>
9 #include <stdio.h>
10
11 #include "v_cmd_gen.h"
12 #if !defined(V_GENERATE_FUNC_MODE)
13 #include "verse.h"
14 #include "v_cmd_buf.h"
15 #include "v_network_out_que.h"
16 #include "v_network.h"
17 #include "v_connection.h"
18 #include "v_util.h"
19
20 void verse_send_a_buffer_create(VNodeID node_id, VBufferID buffer_id, const char *name, VNABlockType type, real64 frequency)
21 {
22         uint8 *buf;
23         unsigned int buffer_pos = 0;
24         VCMDBufHead *head;
25         head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */
26         buf = ((VCMDBuffer10 *)head)->buf;
27
28         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 160);        /* Pack the command. */
29 #if defined V_PRINT_SEND_COMMANDS
30         printf("send: verse_send_a_buffer_create(node_id = %u buffer_id = %u name = %s type = %u frequency = %f );\n", node_id, buffer_id, name, type, frequency);
31 #endif
32         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
33         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id);
34         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16);
35         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
36         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], frequency);
37         if(node_id == (uint32)(-1) || buffer_id == (uint16)(-1))
38                 v_cmd_buf_set_unique_address_size(head, 7);
39         else
40                 v_cmd_buf_set_address_size(head, 7);
41         v_cmd_buf_set_size(head, buffer_pos);
42         v_noq_send_buf(v_con_get_network_queue(), head);
43 }
44
45 void verse_send_a_buffer_destroy(VNodeID node_id, VBufferID buffer_id)
46 {
47         uint8 *buf;
48         unsigned int buffer_pos = 0;
49         VCMDBufHead *head;
50         head = v_cmd_buf_allocate(VCMDBS_80);/* Allocating the buffer */
51         buf = ((VCMDBuffer10 *)head)->buf;
52
53         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 160);        /* Pack the command. */
54 #if defined V_PRINT_SEND_COMMANDS
55         printf("send: verse_send_a_buffer_destroy(node_id = %u buffer_id = %u );\n", node_id, buffer_id);
56 #endif
57         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
58         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id);
59         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16);
60         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1);
61         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], V_REAL64_MAX);
62         if(node_id == (uint32)(-1) || buffer_id == (uint16)(-1))
63                 v_cmd_buf_set_unique_address_size(head, 7);
64         else
65                 v_cmd_buf_set_address_size(head, 7);
66         v_cmd_buf_set_size(head, buffer_pos);
67         v_noq_send_buf(v_con_get_network_queue(), head);
68 }
69
70 unsigned int v_unpack_a_buffer_create(const char *buf, size_t buffer_length)
71 {
72         uint8 enum_temp;
73         unsigned int buffer_pos = 0;
74         void (* func_a_buffer_create)(void *user_data, VNodeID node_id, VBufferID buffer_id, const char *name, VNABlockType type, real64 frequency);
75         VNodeID node_id;
76         VBufferID buffer_id;
77         char name[16];
78         VNABlockType type;
79         real64 frequency;
80         
81         func_a_buffer_create = v_fs_get_user_func(160);
82         if(buffer_length < 6)
83                 return -1;
84         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
85         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &buffer_id);
86         buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos);
87         if(buffer_length < 9 + buffer_pos)
88                 return -1;
89         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
90         type = (VNABlockType)enum_temp;
91         buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frequency);
92 #if defined V_PRINT_RECEIVE_COMMANDS
93         if(name[0] == 0)
94                 printf("receive: verse_send_a_buffer_destroy(node_id = %u buffer_id = %u ); callback = %p\n", node_id, buffer_id, v_fs_get_alias_user_func(160));
95         else
96                 printf("receive: verse_send_a_buffer_create(node_id = %u buffer_id = %u name = %s type = %u frequency = %f ); callback = %p\n", node_id, buffer_id, name, type, frequency, v_fs_get_user_func(160));
97 #endif
98         if(name[0] == 0)
99         {
100                 void (* alias_a_buffer_destroy)(void *user_data, VNodeID node_id, VBufferID buffer_id);
101                 alias_a_buffer_destroy = v_fs_get_alias_user_func(160);
102                 if(alias_a_buffer_destroy != NULL)
103                         alias_a_buffer_destroy(v_fs_get_alias_user_data(160), node_id, buffer_id);
104                 return buffer_pos;
105         }
106         if(func_a_buffer_create != NULL)
107                 func_a_buffer_create(v_fs_get_user_data(160), node_id, buffer_id, name, (VNABlockType) type, frequency);
108
109         return buffer_pos;
110 }
111
112 void verse_send_a_buffer_subscribe(VNodeID node_id, VBufferID layer_id)
113 {
114         uint8 *buf;
115         unsigned int buffer_pos = 0;
116         VCMDBufHead *head;
117         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
118         buf = ((VCMDBuffer10 *)head)->buf;
119
120         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 161);        /* Pack the command. */
121 #if defined V_PRINT_SEND_COMMANDS
122         printf("send: verse_send_a_buffer_subscribe(node_id = %u layer_id = %u );\n", node_id, layer_id);
123 #endif
124         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
125         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id);
126         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE);
127         if(node_id == (uint32)(-1) || layer_id == (uint16)(-1))
128                 v_cmd_buf_set_unique_address_size(head, 7);
129         else
130                 v_cmd_buf_set_address_size(head, 7);
131         v_cmd_buf_set_size(head, buffer_pos);
132         v_noq_send_buf(v_con_get_network_queue(), head);
133 }
134
135 void verse_send_a_buffer_unsubscribe(VNodeID node_id, VBufferID layer_id)
136 {
137         uint8 *buf;
138         unsigned int buffer_pos = 0;
139         VCMDBufHead *head;
140         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
141         buf = ((VCMDBuffer10 *)head)->buf;
142
143         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 161);        /* Pack the command. */
144 #if defined V_PRINT_SEND_COMMANDS
145         printf("send: verse_send_a_buffer_unsubscribe(node_id = %u layer_id = %u );\n", node_id, layer_id);
146 #endif
147         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
148         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id);
149         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);
150         if(node_id == (uint32)(-1) || layer_id == (uint16)(-1))
151                 v_cmd_buf_set_unique_address_size(head, 7);
152         else
153                 v_cmd_buf_set_address_size(head, 7);
154         v_cmd_buf_set_size(head, buffer_pos);
155         v_noq_send_buf(v_con_get_network_queue(), head);
156 }
157
158 unsigned int v_unpack_a_buffer_subscribe(const char *buf, size_t buffer_length)
159 {
160         unsigned int buffer_pos = 0;
161         void (* func_a_buffer_subscribe)(void *user_data, VNodeID node_id, VBufferID layer_id);
162         VNodeID node_id;
163         VBufferID layer_id;
164         uint8   alias_bool;
165
166         func_a_buffer_subscribe = v_fs_get_user_func(161);
167         if(buffer_length < 6)
168                 return -1;
169         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
170         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &layer_id);
171         if(buffer_length < buffer_pos + 1)
172                 return -1;
173         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool);
174 #if defined V_PRINT_RECEIVE_COMMANDS
175         if(!alias_bool)
176                 printf("receive: verse_send_a_buffer_unsubscribe(node_id = %u layer_id = %u ); callback = %p\n", node_id, layer_id, v_fs_get_alias_user_func(161));
177         else
178                 printf("receive: verse_send_a_buffer_subscribe(node_id = %u layer_id = %u ); callback = %p\n", node_id, layer_id, v_fs_get_user_func(161));
179 #endif
180         if(!alias_bool)
181         {
182                 void (* alias_a_buffer_unsubscribe)(void *user_data, VNodeID node_id, VBufferID layer_id);
183                 alias_a_buffer_unsubscribe = v_fs_get_alias_user_func(161);
184                 if(alias_a_buffer_unsubscribe != NULL)
185                         alias_a_buffer_unsubscribe(v_fs_get_alias_user_data(161), node_id, layer_id);
186                 return buffer_pos;
187         }
188         if(func_a_buffer_subscribe != NULL)
189                 func_a_buffer_subscribe(v_fs_get_user_data(161), node_id, layer_id);
190
191         return buffer_pos;
192 }
193
194 void verse_send_a_block_set(VNodeID node_id, VLayerID buffer_id, uint32 block_index, VNABlockType type, const VNABlock *samples)
195 {
196         uint8 *buf;
197         unsigned int buffer_pos = 0;
198         VCMDBufHead *head;
199         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
200         buf = ((VCMDBuffer10 *)head)->buf;
201
202         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 162);        /* Pack the command. */
203 #if defined V_PRINT_SEND_COMMANDS
204         printf("send: verse_send_a_block_set(node_id = %u buffer_id = %u block_index = %u type = %u samples = %p );\n", node_id, buffer_id, block_index, type, samples);
205 #endif
206         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
207         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id);
208         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], block_index);
209         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
210         buffer_pos += vnp_pack_audio_block(&buf[buffer_pos], type, samples);
211         if(node_id == (uint32)(-1) || buffer_id == (uint16)(-1) || block_index == (uint32)(-1))
212                 v_cmd_buf_set_unique_address_size(head, 11);
213         else
214                 v_cmd_buf_set_address_size(head, 11);
215         v_cmd_buf_set_size(head, buffer_pos);
216         v_noq_send_buf(v_con_get_network_queue(), head);
217 }
218
219 void verse_send_a_block_clear(VNodeID node_id, VLayerID buffer_id, uint32 block_index)
220 {
221         uint8 *buf;
222         unsigned int buffer_pos = 0;
223         VCMDBufHead *head;
224         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
225         buf = ((VCMDBuffer10 *)head)->buf;
226
227         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 162);        /* Pack the command. */
228 #if defined V_PRINT_SEND_COMMANDS
229         printf("send: verse_send_a_block_clear(node_id = %u buffer_id = %u block_index = %u );\n", node_id, buffer_id, block_index);
230 #endif
231         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
232         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id);
233         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], block_index);
234         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1);
235         if(node_id == (uint32)(-1) || buffer_id == (uint16)(-1) || block_index == (uint32)(-1))
236                 v_cmd_buf_set_unique_address_size(head, 11);
237         else
238                 v_cmd_buf_set_address_size(head, 11);
239         v_cmd_buf_set_size(head, buffer_pos);
240         v_noq_send_buf(v_con_get_network_queue(), head);
241 }
242
243 unsigned int v_unpack_a_block_set(const char *buf, size_t buffer_length)
244 {
245         uint8 enum_temp;
246         unsigned int buffer_pos = 0;
247         void (* func_a_block_set)(void *user_data, VNodeID node_id, VLayerID buffer_id, uint32 block_index, VNABlockType type, const VNABlock *samples);
248         VNodeID node_id;
249         VLayerID buffer_id;
250         uint32 block_index;
251         VNABlockType type;
252         const VNABlock *samples;
253         
254         func_a_block_set = v_fs_get_user_func(162);
255         if(buffer_length < 10)
256                 return -1;
257         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
258         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &buffer_id);
259         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &block_index);
260         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
261         type = (VNABlockType)enum_temp;
262 #if defined V_PRINT_RECEIVE_COMMANDS
263         if(type > VN_A_BLOCK_REAL64)
264                 printf("receive: verse_send_a_block_clear(node_id = %u buffer_id = %u block_index = %u ); callback = %p\n", node_id, buffer_id, block_index, v_fs_get_alias_user_func(162));
265         else
266                 printf("receive: verse_send_a_block_set(node_id = %u buffer_id = %u block_index = %u type = %u ); callback = %p\n", node_id, buffer_id, block_index, type, v_fs_get_user_func(162));
267 #endif
268         if(type <= VN_A_BLOCK_REAL64)
269         {
270                 VNABlock        block;
271                 buffer_pos += vnp_unpack_audio_block(&buf[buffer_pos], type, &block);
272                 if(func_a_block_set != NULL)
273                         func_a_block_set(v_fs_get_user_data(162), node_id, buffer_id, block_index, (VNABlockType) type, &block);
274                 return buffer_pos;
275         }
276
277         if(type > VN_A_BLOCK_REAL64)
278         {
279                 void (* alias_a_block_clear)(void *user_data, VNodeID node_id, VLayerID buffer_id, uint32 block_index);
280                 alias_a_block_clear = v_fs_get_alias_user_func(162);
281                 if(alias_a_block_clear != NULL)
282                         alias_a_block_clear(v_fs_get_alias_user_data(162), node_id, buffer_id, block_index);
283                 return buffer_pos;
284         }
285         if(func_a_block_set != NULL)
286                 func_a_block_set(v_fs_get_user_data(162), node_id, buffer_id, block_index, (VNABlockType) type, samples);
287
288         return buffer_pos;
289 }
290
291 void verse_send_a_stream_create(VNodeID node_id, VLayerID stream_id, const char *name)
292 {
293         uint8 *buf;
294         unsigned int buffer_pos = 0;
295         VCMDBufHead *head;
296         head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
297         buf = ((VCMDBuffer10 *)head)->buf;
298
299         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 163);        /* Pack the command. */
300 #if defined V_PRINT_SEND_COMMANDS
301         printf("send: verse_send_a_stream_create(node_id = %u stream_id = %u name = %s );\n", node_id, stream_id, name);
302 #endif
303         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
304         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], stream_id);
305         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], name, 16);
306         if(node_id == (uint32)(-1) || stream_id == (uint16)(-1))
307                 v_cmd_buf_set_unique_address_size(head, 7);
308         else
309                 v_cmd_buf_set_address_size(head, 7);
310         v_cmd_buf_set_size(head, buffer_pos);
311         v_noq_send_buf(v_con_get_network_queue(), head);
312 }
313
314 void verse_send_a_stream_destroy(VNodeID node_id, VLayerID stream_id)
315 {
316         uint8 *buf;
317         unsigned int buffer_pos = 0;
318         VCMDBufHead *head;
319         head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
320         buf = ((VCMDBuffer10 *)head)->buf;
321
322         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 163);        /* Pack the command. */
323 #if defined V_PRINT_SEND_COMMANDS
324         printf("send: verse_send_a_stream_destroy(node_id = %u stream_id = %u );\n", node_id, stream_id);
325 #endif
326         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
327         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], stream_id);
328         buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16);
329         if(node_id == (uint32)(-1) || stream_id == (uint16)(-1))
330                 v_cmd_buf_set_unique_address_size(head, 7);
331         else
332                 v_cmd_buf_set_address_size(head, 7);
333         v_cmd_buf_set_size(head, buffer_pos);
334         v_noq_send_buf(v_con_get_network_queue(), head);
335 }
336
337 unsigned int v_unpack_a_stream_create(const char *buf, size_t buffer_length)
338 {
339         unsigned int buffer_pos = 0;
340         void (* func_a_stream_create)(void *user_data, VNodeID node_id, VLayerID stream_id, const char *name);
341         VNodeID node_id;
342         VLayerID stream_id;
343         char name[16];
344         
345         func_a_stream_create = v_fs_get_user_func(163);
346         if(buffer_length < 6)
347                 return -1;
348         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
349         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &stream_id);
350         buffer_pos += vnp_raw_unpack_string(&buf[buffer_pos], name, 16, buffer_length - buffer_pos);
351 #if defined V_PRINT_RECEIVE_COMMANDS
352         if(name[0] == 0)
353                 printf("receive: verse_send_a_stream_destroy(node_id = %u stream_id = %u ); callback = %p\n", node_id, stream_id, v_fs_get_alias_user_func(163));
354         else
355                 printf("receive: verse_send_a_stream_create(node_id = %u stream_id = %u name = %s ); callback = %p\n", node_id, stream_id, name, v_fs_get_user_func(163));
356 #endif
357         if(name[0] == 0)
358         {
359                 void (* alias_a_stream_destroy)(void *user_data, VNodeID node_id, VLayerID stream_id);
360                 alias_a_stream_destroy = v_fs_get_alias_user_func(163);
361                 if(alias_a_stream_destroy != NULL)
362                         alias_a_stream_destroy(v_fs_get_alias_user_data(163), node_id, stream_id);
363                 return buffer_pos;
364         }
365         if(func_a_stream_create != NULL)
366                 func_a_stream_create(v_fs_get_user_data(163), node_id, stream_id, name);
367
368         return buffer_pos;
369 }
370
371 void verse_send_a_stream_subscribe(VNodeID node_id, VLayerID stream_id)
372 {
373         uint8 *buf;
374         unsigned int buffer_pos = 0;
375         VCMDBufHead *head;
376         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
377         buf = ((VCMDBuffer10 *)head)->buf;
378
379         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 164);        /* Pack the command. */
380 #if defined V_PRINT_SEND_COMMANDS
381         printf("send: verse_send_a_stream_subscribe(node_id = %u stream_id = %u );\n", node_id, stream_id);
382 #endif
383         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
384         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], stream_id);
385         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], TRUE);
386         if(node_id == (uint32)(-1) || stream_id == (uint16)(-1))
387                 v_cmd_buf_set_unique_address_size(head, 7);
388         else
389                 v_cmd_buf_set_address_size(head, 7);
390         v_cmd_buf_set_size(head, buffer_pos);
391         v_noq_send_buf(v_con_get_network_queue(), head);
392 }
393
394 void verse_send_a_stream_unsubscribe(VNodeID node_id, VLayerID stream_id)
395 {
396         uint8 *buf;
397         unsigned int buffer_pos = 0;
398         VCMDBufHead *head;
399         head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
400         buf = ((VCMDBuffer10 *)head)->buf;
401
402         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 164);        /* Pack the command. */
403 #if defined V_PRINT_SEND_COMMANDS
404         printf("send: verse_send_a_stream_unsubscribe(node_id = %u stream_id = %u );\n", node_id, stream_id);
405 #endif
406         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
407         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], stream_id);
408         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);
409         if(node_id == (uint32)(-1) || stream_id == (uint16)(-1))
410                 v_cmd_buf_set_unique_address_size(head, 7);
411         else
412                 v_cmd_buf_set_address_size(head, 7);
413         v_cmd_buf_set_size(head, buffer_pos);
414         v_noq_send_buf(v_con_get_network_queue(), head);
415 }
416
417 unsigned int v_unpack_a_stream_subscribe(const char *buf, size_t buffer_length)
418 {
419         unsigned int buffer_pos = 0;
420         void (* func_a_stream_subscribe)(void *user_data, VNodeID node_id, VLayerID stream_id);
421         VNodeID node_id;
422         VLayerID stream_id;
423         uint8   alias_bool;
424
425         func_a_stream_subscribe = v_fs_get_user_func(164);
426         if(buffer_length < 6)
427                 return -1;
428         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
429         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &stream_id);
430         if(buffer_length < buffer_pos + 1)
431                 return -1;
432         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &alias_bool);
433 #if defined V_PRINT_RECEIVE_COMMANDS
434         if(!alias_bool)
435                 printf("receive: verse_send_a_stream_unsubscribe(node_id = %u stream_id = %u ); callback = %p\n", node_id, stream_id, v_fs_get_alias_user_func(164));
436         else
437                 printf("receive: verse_send_a_stream_subscribe(node_id = %u stream_id = %u ); callback = %p\n", node_id, stream_id, v_fs_get_user_func(164));
438 #endif
439         if(!alias_bool)
440         {
441                 void (* alias_a_stream_unsubscribe)(void *user_data, VNodeID node_id, VLayerID stream_id);
442                 alias_a_stream_unsubscribe = v_fs_get_alias_user_func(164);
443                 if(alias_a_stream_unsubscribe != NULL)
444                         alias_a_stream_unsubscribe(v_fs_get_alias_user_data(164), node_id, stream_id);
445                 return buffer_pos;
446         }
447         if(func_a_stream_subscribe != NULL)
448                 func_a_stream_subscribe(v_fs_get_user_data(164), node_id, stream_id);
449
450         return buffer_pos;
451 }
452
453 void verse_send_a_stream(VNodeID node_id, VLayerID stream_id, uint32 time_s, uint32 time_f, VNABlockType type, real64 frequency, const VNABlock *samples)
454 {
455         uint8 *buf;
456         unsigned int buffer_pos = 0;
457         VCMDBufHead *head;
458         head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
459         buf = ((VCMDBuffer10 *)head)->buf;
460
461         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 165);        /* Pack the command. */
462 #if defined V_PRINT_SEND_COMMANDS
463         printf("send: verse_send_a_stream(node_id = %u stream_id = %u time_s = %u time_f = %u type = %u frequency = %f samples = %p );\n", node_id, stream_id, time_s, time_f, type, frequency, samples);
464 #endif
465         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
466         buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], stream_id);
467         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_s);
468         buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], time_f);
469         buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
470         buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], frequency);
471         buffer_pos += vnp_pack_audio_block(&buf[buffer_pos], type, samples);
472         if(node_id == (uint32)(-1) || stream_id == (uint16)(-1))
473                 v_cmd_buf_set_unique_address_size(head, 7);
474         else
475                 v_cmd_buf_set_address_size(head, 7);
476         v_cmd_buf_set_size(head, buffer_pos);
477         v_noq_send_buf(v_con_get_network_queue(), head);
478 }
479
480 unsigned int v_unpack_a_stream(const char *buf, size_t buffer_length)
481 {
482         uint8 enum_temp;
483         unsigned int buffer_pos = 0;
484         void (* func_a_stream)(void *user_data, VNodeID node_id, VLayerID stream_id, uint32 time_s, uint32 time_f, VNABlockType type, real64 frequency, const VNABlock *samples);
485         VNodeID node_id;
486         VLayerID stream_id;
487         uint32 time_s;
488         uint32 time_f;
489         VNABlockType type;
490         real64 frequency;
491         const VNABlock *samples;
492         
493         func_a_stream = v_fs_get_user_func(165);
494         if(buffer_length < 6)
495                 return -1;
496         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &node_id);
497         buffer_pos += vnp_raw_unpack_uint16(&buf[buffer_pos], &stream_id);
498         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_s);
499         buffer_pos += vnp_raw_unpack_uint32(&buf[buffer_pos], &time_f);
500         buffer_pos += vnp_raw_unpack_uint8(&buf[buffer_pos], &enum_temp);
501         type = (VNABlockType)enum_temp;
502         buffer_pos += vnp_raw_unpack_real64(&buf[buffer_pos], &frequency);
503 #if defined V_PRINT_RECEIVE_COMMANDS
504         printf("receive: verse_send_a_stream(node_id = %u stream_id = %u time_s = %u time_f = %u type = %u frequency = %f ); callback = %p\n", node_id, stream_id, time_s, time_f, type, frequency, v_fs_get_user_func(165));
505 #endif
506         {
507                 VNABlock        block;
508         buffer_pos += vnp_unpack_audio_block(&buf[buffer_pos], type, &block);
509                 if(func_a_stream != NULL)
510                         func_a_stream(v_fs_get_user_data(165), node_id, stream_id, time_s, time_f, (VNABlockType) type, frequency, &block);
511                 return buffer_pos;
512         }
513
514         if(func_a_stream != NULL)
515                 func_a_stream(v_fs_get_user_data(165), node_id, stream_id, time_s, time_f, (VNABlockType) type, frequency, samples);
516
517         return buffer_pos;
518 }
519
520 #endif
521