-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
altrace_playback.c
2068 lines (1750 loc) · 55.9 KB
/
altrace_playback.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* alTrace; a debugging tool for OpenAL.
*
* Please see the file LICENSE.txt in the source's root directory.
*
* This file written by Ryan C. Gordon.
*/
#include "altrace_playback.h"
static int logfd = -1;
static uint32 trace_scope = 0;
static void *guserdata = NULL;
static void quit_altrace_playback(void);
// don't bother doing a full hash map for devices and contexts, since you'll
// usually never have more than one or two and they live basically the entire
// lifetime of your app.
static void free_hash_item_device(ALCdevice *from, ALCdevice *to) { /* no-op */ }
SIMPLE_MAP(device, ALCdevice *, ALCdevice *)
static void free_hash_item_context(ALCcontext *from, ALCcontext *to) { /* no-op */ }
SIMPLE_MAP(context, ALCcontext *, ALCcontext *)
static void free_hash_item_devicelabel(ALCdevice *from, char *to) { free(to); }
SIMPLE_MAP(devicelabel, ALCdevice *, char *)
static void free_hash_item_contextlabel(ALCcontext *from, char *to) { free(to); }
SIMPLE_MAP(contextlabel, ALCcontext *, char *)
static void free_hash_item_alname(ALuint from, ALuint to) { /* no-op */ }
static uint8 hash_alname(const ALuint name) {
/* since these are usually small numbers that increment from 0, they distribute pretty well on their own. */
return (uint8) (name & 0xFF);
}
#define free_hash_item_source free_hash_item_alname
#define hash_source hash_alname
HASH_MAP(source, ALuint, ALuint)
#define free_hash_item_buffer free_hash_item_alname
#define hash_buffer hash_alname
HASH_MAP(buffer, ALuint, ALuint)
static void free_hash_item_alname_label(ALuint from, char *to) { free(to); }
#define free_hash_item_sourcelabel free_hash_item_alname_label
#define hash_sourcelabel hash_alname
HASH_MAP(sourcelabel, ALuint, char *)
#define free_hash_item_bufferlabel free_hash_item_alname_label
#define hash_bufferlabel hash_alname
HASH_MAP(bufferlabel, ALuint, char *)
static void free_hash_item_stackframe(void *from, char *to) { free(to); }
static uint8 hash_stackframe(void *from) {
// everything is going to end in a multiple of pointer size, so flatten down.
const size_t val = ((size_t) from) / (sizeof (void *));
return (uint8) (val & 0xFF); // good enough, I guess.
}
HASH_MAP(stackframe, void *, char *)
static void free_hash_item_threadid(uint64 from, uint32 to) { /* no-op */ }
static uint32 next_mapped_threadid = 0;
SIMPLE_MAP(threadid, uint64, uint32);
static int io_failure = 0;
static void IO_READ_FAIL(const int eof)
{
if (!io_failure) {
fprintf(stderr, "%s: Failed to read from log: %s\n", GAppName, eof ? "end of file" : strerror(errno));
io_failure = 1;
}
}
static uint32 readle32(void)
{
uint32 retval = 0;
if (!io_failure) {
const ssize_t br = read(logfd, &retval, sizeof (retval));
if (br != ((ssize_t) sizeof (retval))) {
IO_READ_FAIL(br >= 0);
}
}
return swap32(retval);
}
static uint64 readle64(void)
{
uint64 retval = 0;
if (!io_failure) {
const ssize_t br = read(logfd, &retval, sizeof (retval));
if (br != ((ssize_t) sizeof (retval))) {
IO_READ_FAIL(br >= 0);
}
}
return swap64(retval);
}
static int32 IO_INT32(void)
{
union { int32 si32; uint32 ui32; } cvt;
cvt.ui32 = readle32();
return cvt.si32;
}
static uint32 IO_UINT32(void)
{
return readle32();
}
static uint64 IO_UINT64(void)
{
return readle64();
}
static ALCsizei IO_ALCSIZEI(void)
{
return (ALCsizei) IO_UINT64();
}
static ALsizei IO_ALSIZEI(void)
{
return (ALsizei) IO_UINT64();
}
static float IO_FLOAT(void)
{
union { float f; uint32 ui32; } cvt;
cvt.ui32 = readle32();
return cvt.f;
}
static double IO_DOUBLE(void)
{
union { double d; uint64 ui64; } cvt;
cvt.ui64 = readle64();
return cvt.d;
}
static uint8 *IO_BLOB(uint64 *_len)
{
const uint64 len = IO_UINT64();
const size_t slen = (size_t) len;
uint8 *ptr;
ssize_t br;
if (io_failure) {
return NULL;
}
if (len == 0xFFFFFFFFFFFFFFFFull) {
*_len = 0;
return NULL;
}
*_len = len;
ptr = (uint8 *) get_ioblob(slen + 1);
br = read(logfd, ptr, slen);
if (br != ((ssize_t) slen)) {
IO_READ_FAIL(br >= 0);
}
ptr[slen] = '\0';
return ptr;
}
static const char *IO_STRING(void)
{
uint64 len;
return (const char *) IO_BLOB(&len);
}
static EventEnum IO_EVENTENUM(void)
{
return (EventEnum) IO_UINT32();
}
static void *IO_PTR(void)
{
return (void *) (size_t) IO_UINT64(); // !!! FIXME: probably need to map this on 32-bit systems.
}
static ALCenum IO_ALCENUM(void)
{
return (ALCenum) IO_UINT32();
}
static ALenum IO_ENUM(void)
{
return (ALenum) IO_UINT32();
}
static ALCboolean IO_ALCBOOLEAN(void)
{
return (ALCboolean) IO_UINT32();
}
static ALboolean IO_BOOLEAN(void)
{
return (ALboolean) IO_UINT32();
}
static void IO_ENTRYINFO(CallerInfo *callerinfo)
{
const uint32 wait_until = IO_UINT32();
const uint64 logthreadid = IO_UINT64();
const uint32 frames = IO_UINT32();
uint32 threadid;
uint32 i;
if (io_failure) {
return;
}
threadid = get_mapped_threadid(logthreadid);
if (!threadid) {
threadid = ++next_mapped_threadid;
add_threadid_to_map(logthreadid, threadid);
}
callerinfo->num_callstack_frames = (frames < MAX_CALLSTACKS) ? frames : MAX_CALLSTACKS;
callerinfo->threadid = threadid;
callerinfo->trace_scope = trace_scope;
callerinfo->wait_until = wait_until;
callerinfo->userdata = guserdata;
for (i = 0; i < frames; i++) {
void *ptr = IO_PTR();
if ((!io_failure) && (i < MAX_CALLSTACKS)) {
callerinfo->callstack[i].frame = ptr;
callerinfo->callstack[i].sym = get_mapped_stackframe(ptr);
}
}
callerinfo->fdoffset = lseek(logfd, 0, SEEK_CUR);
}
#define IO_START(e) { CallerInfo callerinfo; IO_ENTRYINFO(&callerinfo); if (!io_failure) {
#define IO_END() } }
static int init_altrace_playback(const char *filename, void *userdata)
{
int okay = 1;
io_failure = 0;
next_mapped_threadid = 0;
trace_scope = 0;
guserdata = userdata;
logfd = open(filename, O_RDONLY);
if (logfd == -1) {
fprintf(stderr, "%s: Failed to open OpenAL log file '%s': %s\n", GAppName, filename, strerror(errno));
okay = 0;
}
fflush(stderr);
if (okay) {
if (IO_UINT32() != ALTRACE_LOG_FILE_MAGIC) {
fprintf(stderr, "%s: File '%s' does not appear to be an OpenAL log file.\n", GAppName, filename);
okay = 0;
} else if (IO_UINT32() != ALTRACE_LOG_FILE_FORMAT) {
fprintf(stderr, "%s: File '%s' is an unsupported log file format version.\n", GAppName, filename);
okay = 0;
}
}
if (!okay) {
quit_altrace_playback();
}
return okay;
}
static void quit_altrace_playback(void)
{
const int io = logfd;
logfd = -1;
io_failure = 0;
next_mapped_threadid = 0;
trace_scope = 0;
guserdata = NULL;
fflush(stdout);
if ((io != -1) && (close(io) < 0)) {
fprintf(stderr, "%s: Failed to close OpenAL log file: %s\n", GAppName, strerror(errno));
}
free_device_map();
free_context_map();
free_source_map();
free_buffer_map();
free_stackframe_map();
free_threadid_map();
free_devicelabel_map();
free_contextlabel_map();
free_sourcelabel_map();
free_bufferlabel_map();
free_ioblobs();
fflush(stderr);
}
const char *alcboolString(const ALCboolean x)
{
switch (x) {
case ALC_TRUE: return "ALC_TRUE";
case ALC_FALSE: return "ALC_FALSE";
default: break;
}
return sprintf_alloc("0x%X", (uint) x);
}
const char *alboolString(const ALCboolean x)
{
switch (x) {
case AL_TRUE: return "AL_TRUE";
case AL_FALSE: return "AL_FALSE";
default: break;
}
return sprintf_alloc("0x%X", (uint) x);
}
const char *alcenumString(const ALCenum x)
{
switch (x) {
#define ENUM_TEST(e) case e: return #e
ENUM_TEST(ALC_FREQUENCY);
ENUM_TEST(ALC_REFRESH);
ENUM_TEST(ALC_SYNC);
ENUM_TEST(ALC_MONO_SOURCES);
ENUM_TEST(ALC_STEREO_SOURCES);
ENUM_TEST(ALC_NO_ERROR);
ENUM_TEST(ALC_INVALID_DEVICE);
ENUM_TEST(ALC_INVALID_CONTEXT);
ENUM_TEST(ALC_INVALID_ENUM);
ENUM_TEST(ALC_INVALID_VALUE);
ENUM_TEST(ALC_OUT_OF_MEMORY);
ENUM_TEST(ALC_MAJOR_VERSION);
ENUM_TEST(ALC_MINOR_VERSION);
ENUM_TEST(ALC_ATTRIBUTES_SIZE);
ENUM_TEST(ALC_ALL_ATTRIBUTES);
ENUM_TEST(ALC_DEFAULT_DEVICE_SPECIFIER);
ENUM_TEST(ALC_DEVICE_SPECIFIER);
ENUM_TEST(ALC_EXTENSIONS);
ENUM_TEST(ALC_CAPTURE_DEVICE_SPECIFIER);
ENUM_TEST(ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER);
ENUM_TEST(ALC_CAPTURE_SAMPLES);
ENUM_TEST(ALC_DEFAULT_ALL_DEVICES_SPECIFIER);
ENUM_TEST(ALC_ALL_DEVICES_SPECIFIER);
ENUM_TEST(ALC_CONNECTED);
#undef ENUM_TEST
default: break;
}
return sprintf_alloc("0x%X", (uint) x);
}
const char *alenumString(const ALCenum x)
{
switch (x) {
#define ENUM_TEST(e) case e: return #e
ENUM_TEST(AL_NONE);
ENUM_TEST(AL_SOURCE_RELATIVE);
ENUM_TEST(AL_CONE_INNER_ANGLE);
ENUM_TEST(AL_CONE_OUTER_ANGLE);
ENUM_TEST(AL_PITCH);
ENUM_TEST(AL_POSITION);
ENUM_TEST(AL_DIRECTION);
ENUM_TEST(AL_VELOCITY);
ENUM_TEST(AL_LOOPING);
ENUM_TEST(AL_BUFFER);
ENUM_TEST(AL_GAIN);
ENUM_TEST(AL_MIN_GAIN);
ENUM_TEST(AL_MAX_GAIN);
ENUM_TEST(AL_ORIENTATION);
ENUM_TEST(AL_SOURCE_STATE);
ENUM_TEST(AL_INITIAL);
ENUM_TEST(AL_PLAYING);
ENUM_TEST(AL_PAUSED);
ENUM_TEST(AL_STOPPED);
ENUM_TEST(AL_BUFFERS_QUEUED);
ENUM_TEST(AL_BUFFERS_PROCESSED);
ENUM_TEST(AL_REFERENCE_DISTANCE);
ENUM_TEST(AL_ROLLOFF_FACTOR);
ENUM_TEST(AL_CONE_OUTER_GAIN);
ENUM_TEST(AL_MAX_DISTANCE);
ENUM_TEST(AL_SEC_OFFSET);
ENUM_TEST(AL_SAMPLE_OFFSET);
ENUM_TEST(AL_BYTE_OFFSET);
ENUM_TEST(AL_SOURCE_TYPE);
ENUM_TEST(AL_STATIC);
ENUM_TEST(AL_STREAMING);
ENUM_TEST(AL_UNDETERMINED);
ENUM_TEST(AL_FORMAT_MONO8);
ENUM_TEST(AL_FORMAT_MONO16);
ENUM_TEST(AL_FORMAT_STEREO8);
ENUM_TEST(AL_FORMAT_STEREO16);
ENUM_TEST(AL_FREQUENCY);
ENUM_TEST(AL_BITS);
ENUM_TEST(AL_CHANNELS);
ENUM_TEST(AL_SIZE);
ENUM_TEST(AL_UNUSED);
ENUM_TEST(AL_PENDING);
ENUM_TEST(AL_PROCESSED);
ENUM_TEST(AL_INVALID_NAME);
ENUM_TEST(AL_INVALID_ENUM);
ENUM_TEST(AL_INVALID_VALUE);
ENUM_TEST(AL_INVALID_OPERATION);
ENUM_TEST(AL_OUT_OF_MEMORY);
ENUM_TEST(AL_VENDOR);
ENUM_TEST(AL_VERSION);
ENUM_TEST(AL_RENDERER);
ENUM_TEST(AL_EXTENSIONS);
ENUM_TEST(AL_DOPPLER_FACTOR);
ENUM_TEST(AL_DOPPLER_VELOCITY);
ENUM_TEST(AL_SPEED_OF_SOUND);
ENUM_TEST(AL_DISTANCE_MODEL);
ENUM_TEST(AL_INVERSE_DISTANCE);
ENUM_TEST(AL_INVERSE_DISTANCE_CLAMPED);
ENUM_TEST(AL_LINEAR_DISTANCE);
ENUM_TEST(AL_LINEAR_DISTANCE_CLAMPED);
ENUM_TEST(AL_EXPONENT_DISTANCE);
ENUM_TEST(AL_EXPONENT_DISTANCE_CLAMPED);
ENUM_TEST(AL_FORMAT_MONO_FLOAT32);
ENUM_TEST(AL_FORMAT_STEREO_FLOAT32);
#undef ENUM_TEST
default: break;
}
return sprintf_alloc("0x%X", (uint) x);
}
const char *litString(const char *str)
{
if (str) {
const size_t slen = (strlen(str) + 1) * 2;
char *retval = (char *) get_ioblob(slen);
char *ptr = retval;
*(ptr++) = '"';
while (1) {
const char ch = *(str++);
if (ch == '\0') {
*(ptr++) = '"';
*(ptr++) = '\0';
break;
} else if (ch == '"') {
*(ptr++) = '\\';
*(ptr++) = '"';
} else {
*(ptr++) = ch;
}
}
return retval;
}
return "NULL";
}
const char *ptrString(const void *ptr)
{
return ptr ? sprintf_alloc("%p", ptr) : "NULL";
}
const char *ctxString(ALCcontext *ctx)
{
char *label = ctx ? get_mapped_contextlabel(ctx) : NULL;
return label ? sprintf_alloc("%s<%s>", ptrString(ctx), label) : ptrString(ctx);
}
const char *deviceString(ALCdevice *device)
{
char *label = device ? get_mapped_devicelabel(device) : NULL;
return label ? sprintf_alloc("%s<%s>", ptrString(device), label) : ptrString(device);
}
const char *sourceString(const ALuint name)
{
char *label = name ? get_mapped_sourcelabel(name) : NULL;
return label ? sprintf_alloc("%u<%s>", (uint) name, label) : sprintf_alloc("%u", (uint) name);
}
const char *bufferString(const ALuint name)
{
char *label = name ? get_mapped_bufferlabel(name) : NULL;
return label ? sprintf_alloc("%u<%s>", (uint) name, label) : sprintf_alloc("%u", (uint) name);
}
static void decode_alcGetCurrentContext(void)
{
IO_START(alcGetCurrentContext);
ALCcontext *retval = (ALCcontext *) IO_PTR();
if (!io_failure) visit_alcGetCurrentContext(&callerinfo, retval);
IO_END();
}
static void decode_alcGetContextsDevice(void)
{
IO_START(alcGetContextsDevice);
ALCcontext *context = (ALCcontext *) IO_PTR();
ALCdevice *retval = (ALCdevice *) IO_PTR();
if (!io_failure) visit_alcGetContextsDevice(&callerinfo, retval, context);
IO_END();
}
static void decode_alcIsExtensionPresent(void)
{
IO_START(alcIsExtensionPresent);
ALCdevice *device = (ALCdevice *) IO_PTR();
const ALCchar *extname = (const ALCchar *) IO_STRING();
const ALCboolean retval = IO_ALCBOOLEAN();
if (!io_failure) visit_alcIsExtensionPresent(&callerinfo, retval, device, extname);
IO_END();
}
static void decode_alcGetProcAddress(void)
{
IO_START(alcGetProcAddress);
ALCdevice *device = (ALCdevice *) IO_PTR();
const ALCchar *funcname = (const ALCchar *) IO_STRING();
void *retval = IO_PTR();
if (!io_failure) visit_alcGetProcAddress(&callerinfo, retval, device, funcname);
IO_END();
}
static void decode_alcGetEnumValue(void)
{
IO_START(alcGetEnumValue);
ALCdevice *device = (ALCdevice *) IO_PTR();
const ALCchar *enumname = (const ALCchar *) IO_STRING();
const ALCenum retval = IO_ALCENUM();
if (!io_failure) visit_alcGetEnumValue(&callerinfo, retval, device, enumname);
IO_END();
}
static void decode_alcGetString(void)
{
IO_START(alcGetEnumValue);
ALCdevice *device = (ALCdevice *) IO_PTR();
const ALCenum param = IO_ALCENUM();
const ALCchar *retval = (const ALCchar *) IO_STRING();
if (!io_failure) visit_alcGetString(&callerinfo, retval, device, param);
IO_END();
}
static void decode_alcCaptureOpenDevice(void)
{
IO_START(alcCaptureOpenDevice);
const ALCchar *devicename = (const ALCchar *) IO_STRING();
const ALCuint frequency = IO_UINT32();
const ALCenum format = IO_ALCENUM();
const ALCsizei buffersize = IO_ALSIZEI();
ALCdevice *retval = (ALCdevice *) IO_PTR();
const ALint major_version = retval ? IO_INT32() : 0;
const ALint minor_version = retval ? IO_INT32() : 0;
const ALCchar *devspec = (const ALCchar *) (retval ? IO_STRING() : NULL);
const ALCchar *extensions = (const ALCchar *) (retval ? IO_STRING() : NULL);
if (!io_failure) visit_alcCaptureOpenDevice(&callerinfo, retval, devicename, frequency, format, buffersize, major_version, minor_version, devspec, extensions);
IO_END();
}
static void decode_alcCaptureCloseDevice(void)
{
IO_START(alcCaptureCloseDevice);
ALCdevice *device = (ALCdevice *) IO_PTR();
const ALCboolean retval = IO_ALCBOOLEAN();
if (!io_failure) visit_alcCaptureCloseDevice(&callerinfo, retval, device);
add_devicelabel_to_map(device, NULL);
IO_END();
}
static void decode_alcOpenDevice(void)
{
IO_START(alcOpenDevice);
const ALCchar *devicename = IO_STRING();
ALCdevice *retval = (ALCdevice *) IO_PTR();
const ALint major_version = retval ? IO_INT32() : 0;
const ALint minor_version = retval ? IO_INT32() : 0;
const ALCchar *devspec = (const ALCchar *) (retval ? IO_STRING() : NULL);
const ALCchar *extensions = (const ALCchar *) (retval ? IO_STRING() : NULL);
if (!io_failure) visit_alcOpenDevice(&callerinfo, retval, devicename, major_version, minor_version, devspec, extensions);
IO_END();
}
static void decode_alcCloseDevice(void)
{
IO_START(alcCloseDevice);
ALCdevice *device = (ALCdevice *) IO_PTR();
const ALCboolean retval = IO_ALCBOOLEAN();
if (!io_failure) visit_alcCloseDevice(&callerinfo, retval, device);
add_devicelabel_to_map(device, NULL);
IO_END();
}
static void decode_alcCreateContext(void)
{
IO_START(alcCreateContext);
ALCcontext *retval;
ALCdevice *device = (ALCdevice *) IO_PTR();
ALCint *origattrlist = (ALCint *) IO_PTR();
const uint32 attrcount = IO_UINT32();
ALCint *attrlist = NULL;
if (attrcount) {
ALCint i;
attrlist = (ALCint *) get_ioblob(sizeof (ALCint) * attrcount);
for (i = 0; i < attrcount; i++) {
attrlist[i] = (ALCint) IO_INT32();
}
}
retval = (ALCcontext *) IO_PTR();
if (!io_failure) visit_alcCreateContext(&callerinfo, retval, device, origattrlist, attrcount, attrlist);
IO_END();
}
static void decode_alcMakeContextCurrent(void)
{
IO_START(alcMakeContextCurrent);
ALCcontext *ctx = (ALCcontext *) IO_PTR();
const ALCboolean retval = IO_ALCBOOLEAN();
if (!io_failure) visit_alcMakeContextCurrent(&callerinfo, retval, ctx);
IO_END();
}
static void decode_alcProcessContext(void)
{
IO_START(alcProcessContext);
ALCcontext *ctx = (ALCcontext *) IO_PTR();
if (!io_failure) visit_alcProcessContext(&callerinfo, ctx);
IO_END();
}
static void decode_alcSuspendContext(void)
{
IO_START(alcSuspendContext);
ALCcontext *ctx = (ALCcontext *) IO_PTR();
if (!io_failure) visit_alcSuspendContext(&callerinfo, ctx);
IO_END();
}
static void decode_alcDestroyContext(void)
{
IO_START(alcDestroyContext);
ALCcontext *ctx = (ALCcontext *) IO_PTR();
if (!io_failure) visit_alcDestroyContext(&callerinfo, ctx);
add_contextlabel_to_map(ctx, NULL);
IO_END();
}
static void decode_alcGetError(void)
{
IO_START(alcGetError);
ALCdevice *device = (ALCdevice *) IO_PTR();
const ALCenum retval = IO_ALCENUM();
if (!io_failure) visit_alcGetError(&callerinfo, retval, device);
IO_END();
}
static void decode_alcGetIntegerv(void)
{
IO_START(alcGetIntegerv);
ALCdevice *device = (ALCdevice *) IO_PTR();
const ALCenum param = IO_ALCENUM();
const ALCsizei size = IO_ALCSIZEI();
ALCint *origvalues = (ALint *) IO_PTR();
ALCint *values = (ALCint *) (origvalues ? get_ioblob(size * sizeof (ALCint)) : NULL);
ALCsizei i;
ALCboolean isbool = ALC_FALSE;
if (origvalues) {
for (i = 0; i < size; i++) {
values[i] = IO_INT32();
}
}
switch (param) {
case ALC_CONNECTED: isbool = ALC_TRUE; break;
default: break;
}
if (!io_failure) visit_alcGetIntegerv(&callerinfo, device, param, size, origvalues, isbool, values);
IO_END();
}
static void decode_alcCaptureStart(void)
{
IO_START(alcCaptureStart);
ALCdevice *device = (ALCdevice *) IO_PTR();
if (!io_failure) visit_alcCaptureStart(&callerinfo, device);
IO_END();
}
static void decode_alcCaptureStop(void)
{
IO_START(alcCaptureStop);
ALCdevice *device = (ALCdevice *) IO_PTR();
if (!io_failure) visit_alcCaptureStop(&callerinfo, device);
IO_END();
}
static void decode_alcCaptureSamples(void)
{
IO_START(alcCaptureSamples);
ALCdevice *device = (ALCdevice *) IO_PTR();
void *origbuffer = IO_PTR();
const ALCsizei samples = IO_ALCSIZEI();
uint64 bloblen;
uint8 *blob = IO_BLOB(&bloblen);
if (!io_failure) visit_alcCaptureSamples(&callerinfo, device, origbuffer, blob, bloblen, samples);
IO_END();
}
static void decode_alDopplerFactor(void)
{
IO_START(alDopplerFactor);
const ALfloat value = IO_FLOAT();
if (!io_failure) visit_alDopplerFactor(&callerinfo, value);
IO_END();
}
static void decode_alDopplerVelocity(void)
{
IO_START(alDopplerVelocity);
const ALfloat value = IO_FLOAT();
if (!io_failure) visit_alDopplerVelocity(&callerinfo, value);
IO_END();
}
static void decode_alSpeedOfSound(void)
{
IO_START(alSpeedOfSound);
const ALfloat value = IO_FLOAT();
if (!io_failure) visit_alSpeedOfSound(&callerinfo, value);
IO_END();
}
static void decode_alDistanceModel(void)
{
IO_START(alDistanceModel);
const ALenum model = IO_ENUM();
if (!io_failure) visit_alDistanceModel(&callerinfo, model);
IO_END();
}
static void decode_alEnable(void)
{
IO_START(alEnable);
const ALenum capability = IO_ENUM();
if (!io_failure) visit_alEnable(&callerinfo, capability);
IO_END();
}
static void decode_alDisable(void)
{
IO_START(alDisable);
const ALenum capability = IO_ENUM();
if (!io_failure) visit_alDisable(&callerinfo, capability);
IO_END();
}
static void decode_alIsEnabled(void)
{
IO_START(alIsEnabled);
const ALenum capability = IO_ENUM();
const ALboolean retval = IO_BOOLEAN();
if (!io_failure) visit_alIsEnabled(&callerinfo, retval, capability);
IO_END();
}
static void decode_alGetString(void)
{
IO_START(alGetString);
const ALenum param = IO_ENUM();
const ALchar *retval = (const ALchar *) IO_STRING();
if (!io_failure) visit_alGetString(&callerinfo, retval, param);
IO_END();
}
static void decode_alGetBooleanv(void)
{
IO_START(alGetBooleanv);
const ALenum param = IO_ENUM();
ALboolean *origvalues = (ALboolean *) IO_PTR();
const uint32 numvals = IO_UINT32();
ALboolean *values = (ALboolean *) (numvals ? get_ioblob(numvals * sizeof (ALboolean)) : NULL);
ALsizei i;
for (i = 0; i < numvals; i++) {
values[i] = IO_BOOLEAN();
}
if (!io_failure) visit_alGetBooleanv(&callerinfo, param, origvalues, numvals, values);
IO_END();
}
static void decode_alGetIntegerv(void)
{
IO_START(alGetIntegerv);
const ALenum param = IO_ENUM();
ALint *origvalues = (ALint *) IO_PTR();
const uint32 numvals = IO_UINT32();
ALint *values = (ALint *) (numvals ? get_ioblob(numvals * sizeof (ALint)) : NULL);
ALsizei i;
ALboolean isenum = AL_FALSE;
for (i = 0; i < numvals; i++) {
values[i] = IO_INT32();
}
switch (param) {
case AL_DISTANCE_MODEL: isenum = AL_TRUE; break;
default: break;
}
if (!io_failure) visit_alGetIntegerv(&callerinfo, param, origvalues, numvals, isenum, values);
IO_END();
}
static void decode_alGetFloatv(void)
{
IO_START(alGetFloatv);
const ALenum param = IO_ENUM();
ALfloat *origvalues = (ALfloat *) IO_PTR();
const uint32 numvals = IO_UINT32();
ALfloat *values = (ALfloat *) (numvals ? get_ioblob(numvals * sizeof (ALfloat)) : NULL);
ALsizei i;
for (i = 0; i < numvals; i++) {
values[i] = IO_FLOAT();
}
if (!io_failure) visit_alGetFloatv(&callerinfo, param, origvalues, numvals, values);
IO_END();
}
static void decode_alGetDoublev(void)
{
IO_START(alGetDoublev);
const ALenum param = IO_ENUM();
ALdouble *origvalues = (ALdouble *) IO_PTR();
const uint32 numvals = IO_UINT32();
ALdouble *values = (ALdouble *) (numvals ? get_ioblob(numvals * sizeof (ALdouble)) : NULL);
ALsizei i;
for (i = 0; i < numvals; i++) {
values[i] = IO_DOUBLE();
}
if (!io_failure) visit_alGetDoublev(&callerinfo, param, origvalues, numvals, values);
IO_END();
}
static void decode_alGetBoolean(void)
{
IO_START(alGetBoolean);
const ALenum param = IO_ENUM();
const ALboolean retval = IO_BOOLEAN();
if (!io_failure) visit_alGetBoolean(&callerinfo, retval, param);
IO_END();
}
static void decode_alGetInteger(void)
{
IO_START(alGetInteger);
const ALenum param = IO_ENUM();
const ALint retval = IO_INT32();
#warning fixme isenum?
if (!io_failure) visit_alGetInteger(&callerinfo, retval, param);
IO_END();
}
static void decode_alGetFloat(void)
{
IO_START(alGetFloat);
const ALenum param = IO_ENUM();
const ALfloat retval = IO_FLOAT();
if (!io_failure) visit_alGetFloat(&callerinfo, retval, param);
IO_END();
}
static void decode_alGetDouble(void)
{
IO_START(alGetDouble);
const ALenum param = IO_ENUM();
const ALdouble retval = IO_DOUBLE();
if (!io_failure) visit_alGetDouble(&callerinfo, retval, param);
IO_END();
}
static void decode_alIsExtensionPresent(void)
{
IO_START(alIsExtensionPresent);
const ALchar *extname = (const ALchar *) IO_STRING();
const ALboolean retval = IO_BOOLEAN();
if (!io_failure) visit_alIsExtensionPresent(&callerinfo, retval, extname);
IO_END();
}
static void decode_alGetError(void)
{
IO_START(alGetError);
const ALenum retval = IO_ENUM();
if (!io_failure) visit_alGetError(&callerinfo, retval);
IO_END();
}
static void decode_alGetProcAddress(void)
{
IO_START(alGetProcAddress);
const ALchar *funcname = (const ALchar *) IO_STRING();
void *retval = IO_PTR();
if (!io_failure) visit_alGetProcAddress(&callerinfo, retval, funcname);
IO_END();
}
static void decode_alGetEnumValue(void)
{
IO_START(alGetProcAddress);
const ALchar *enumname = (const ALchar *) IO_STRING();
const ALenum retval = IO_ENUM();
if (!io_failure) visit_alGetEnumValue(&callerinfo, retval, enumname);
IO_END();
}
static void decode_alListenerfv(void)
{
IO_START(alListenerfv);
const ALenum param = IO_ENUM();
ALfloat *origvalues = (ALfloat *) IO_PTR();
const uint32 numvals = IO_UINT32();
ALfloat *values = (ALfloat *) (numvals ? get_ioblob(sizeof (ALfloat) * numvals) : NULL);
uint32 i;
for (i = 0; i < numvals; i++) {
values[i] = IO_FLOAT();
}
if (!io_failure) visit_alListenerfv(&callerinfo, param, origvalues, numvals, values);
IO_END();
}
static void decode_alListenerf(void)
{
IO_START(alListenerf);
const ALenum param = IO_ENUM();
const ALfloat value = IO_FLOAT();
if (!io_failure) visit_alListenerf(&callerinfo, param, value);
IO_END();
}
static void decode_alListener3f(void)
{
IO_START(alListener3f);
const ALenum param = IO_ENUM();
const ALfloat value1 = IO_FLOAT();
const ALfloat value2 = IO_FLOAT();
const ALfloat value3 = IO_FLOAT();
if (!io_failure) visit_alListener3f(&callerinfo, param, value1, value2, value3);
IO_END();
}
static void decode_alListeneriv(void)
{
IO_START(alListeneriv);
const ALenum param = IO_ENUM();
ALint *origvalues = (ALint *) IO_PTR();
const uint32 numvals = IO_UINT32();
ALint *values = (ALint *) (numvals ? get_ioblob(sizeof (ALint) * numvals) : NULL);
uint32 i;
for (i = 0; i < numvals; i++) {
values[i] = IO_INT32();
}
if (!io_failure) visit_alListeneriv(&callerinfo, param, origvalues, numvals, values);
IO_END();
}
static void decode_alListeneri(void)
{
IO_START(alListeneri);
const ALenum param = IO_ENUM();