-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild-cubeb-pulse-arm.patch
More file actions
4946 lines (4785 loc) · 190 KB
/
build-cubeb-pulse-arm.patch
File metadata and controls
4946 lines (4785 loc) · 190 KB
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
diff -up firefox-55.0/media/libcubeb/cubeb-pulse-rs/Cargo.toml.cubeb-pulse-arm firefox-55.0/media/libcubeb/cubeb-pulse-rs/Cargo.toml
--- firefox-55.0/media/libcubeb/cubeb-pulse-rs/Cargo.toml.cubeb-pulse-arm 2017-07-31 18:20:49.000000000 +0200
+++ firefox-55.0/media/libcubeb/cubeb-pulse-rs/Cargo.toml 2017-08-04 13:37:46.383821740 +0200
@@ -7,7 +7,11 @@ description = "Cubeb backed for PulseAud
[features]
pulse-dlopen = ["pulse-ffi/dlopen"]
+[lib]
+crate-type = ["staticlib", "rlib"]
+
[dependencies]
cubeb-ffi = { path = "cubeb-ffi" }
pulse-ffi = { path = "pulse-ffi" }
+pulse = { path = "pulse-rs" }
semver = "^0.6"
diff -up firefox-55.0/media/libcubeb/cubeb-pulse-rs/cubeb-ffi/src/ffi.rs.cubeb-pulse-arm firefox-55.0/media/libcubeb/cubeb-pulse-rs/cubeb-ffi/src/ffi.rs
--- firefox-55.0/media/libcubeb/cubeb-pulse-rs/cubeb-ffi/src/ffi.rs.cubeb-pulse-arm 2017-07-31 18:20:49.000000000 +0200
+++ firefox-55.0/media/libcubeb/cubeb-pulse-rs/cubeb-ffi/src/ffi.rs 2017-08-04 13:37:46.384821737 +0200
@@ -11,45 +11,45 @@ pub enum Context {}
pub enum Stream {}
// These need to match cubeb_sample_format
-pub const SAMPLE_S16LE: c_int = 0;
-pub const SAMPLE_S16BE: c_int = 1;
-pub const SAMPLE_FLOAT32LE: c_int = 2;
-pub const SAMPLE_FLOAT32BE: c_int = 3;
pub type SampleFormat = c_int;
+pub const SAMPLE_S16LE: SampleFormat = 0;
+pub const SAMPLE_S16BE: SampleFormat = 1;
+pub const SAMPLE_FLOAT32LE: SampleFormat = 2;
+pub const SAMPLE_FLOAT32BE: SampleFormat = 3;
#[cfg(target_endian = "little")]
-pub const SAMPLE_S16NE: c_int = SAMPLE_S16LE;
+pub const SAMPLE_S16NE: SampleFormat = SAMPLE_S16LE;
#[cfg(target_endian = "little")]
-pub const SAMPLE_FLOAT32NE: c_int = SAMPLE_FLOAT32LE;
+pub const SAMPLE_FLOAT32NE: SampleFormat = SAMPLE_FLOAT32LE;
#[cfg(target_endian = "big")]
-pub const SAMPLE_S16NE: c_int = SAMPLE_S16BE;
+pub const SAMPLE_S16NE: SampleFormat = SAMPLE_S16BE;
#[cfg(target_endian = "big")]
-pub const SAMPLE_FLOAT32NE: c_int = SAMPLE_FLOAT32BE;
+pub const SAMPLE_FLOAT32NE: SampleFormat = SAMPLE_FLOAT32BE;
pub type DeviceId = *const c_void;
// These need to match cubeb_channel_layout
-pub const LAYOUT_UNDEFINED: c_int = 0;
-pub const LAYOUT_DUAL_MONO: c_int = 1;
-pub const LAYOUT_DUAL_MONO_LFE: c_int = 2;
-pub const LAYOUT_MONO: c_int = 3;
-pub const LAYOUT_MONO_LFE: c_int = 4;
-pub const LAYOUT_STEREO: c_int = 5;
-pub const LAYOUT_STEREO_LFE: c_int = 6;
-pub const LAYOUT_3F: c_int = 7;
-pub const LAYOUT_3F_LFE: c_int = 8;
-pub const LAYOUT_2F1: c_int = 9;
-pub const LAYOUT_2F1_LFE: c_int = 10;
-pub const LAYOUT_3F1: c_int = 11;
-pub const LAYOUT_3F1_LFE: c_int = 12;
-pub const LAYOUT_2F2: c_int = 13;
-pub const LAYOUT_2F2_LFE: c_int = 14;
-pub const LAYOUT_3F2: c_int = 15;
-pub const LAYOUT_3F2_LFE: c_int = 16;
-pub const LAYOUT_3F3R_LFE: c_int = 17;
-pub const LAYOUT_3F4_LFE: c_int = 18;
-pub const LAYOUT_MAX: c_int = 19;
pub type ChannelLayout = c_int;
+pub const LAYOUT_UNDEFINED: ChannelLayout = 0;
+pub const LAYOUT_DUAL_MONO: ChannelLayout = 1;
+pub const LAYOUT_DUAL_MONO_LFE: ChannelLayout = 2;
+pub const LAYOUT_MONO: ChannelLayout = 3;
+pub const LAYOUT_MONO_LFE: ChannelLayout = 4;
+pub const LAYOUT_STEREO: ChannelLayout = 5;
+pub const LAYOUT_STEREO_LFE: ChannelLayout = 6;
+pub const LAYOUT_3F: ChannelLayout = 7;
+pub const LAYOUT_3F_LFE: ChannelLayout = 8;
+pub const LAYOUT_2F1: ChannelLayout = 9;
+pub const LAYOUT_2F1_LFE: ChannelLayout = 10;
+pub const LAYOUT_3F1: ChannelLayout = 11;
+pub const LAYOUT_3F1_LFE: ChannelLayout = 12;
+pub const LAYOUT_2F2: ChannelLayout = 13;
+pub const LAYOUT_2F2_LFE: ChannelLayout = 14;
+pub const LAYOUT_3F2: ChannelLayout = 15;
+pub const LAYOUT_3F2_LFE: ChannelLayout = 16;
+pub const LAYOUT_3F3R_LFE: ChannelLayout = 17;
+pub const LAYOUT_3F4_LFE: ChannelLayout = 18;
+pub const LAYOUT_MAX: ChannelLayout = 256;
#[repr(C)]
#[derive(Clone, Copy, Debug)]
@@ -77,11 +77,11 @@ impl Default for Device {
}
// These need to match cubeb_state
-pub const STATE_STARTED: c_int = 0;
-pub const STATE_STOPPED: c_int = 1;
-pub const STATE_DRAINED: c_int = 2;
-pub const STATE_ERROR: c_int = 3;
pub type State = c_int;
+pub const STATE_STARTED: State = 0;
+pub const STATE_STOPPED: State = 1;
+pub const STATE_DRAINED: State = 2;
+pub const STATE_ERROR: State = 3;
pub const OK: i32 = 0;
pub const ERROR: i32 = -1;
@@ -249,32 +249,42 @@ pub struct LayoutMap {
}
// cubeb_mixer.h
+pub type Channel = c_int;
// These need to match cubeb_channel
-pub const CHANNEL_INVALID: c_int = -1;
-pub const CHANNEL_MONO: c_int = 0;
-pub const CHANNEL_LEFT: c_int = 1;
-pub const CHANNEL_RIGHT: c_int = 2;
-pub const CHANNEL_CENTER: c_int = 3;
-pub const CHANNEL_LS: c_int = 4;
-pub const CHANNEL_RS: c_int = 5;
-pub const CHANNEL_RLS: c_int = 6;
-pub const CHANNEL_RCENTER: c_int = 7;
-pub const CHANNEL_RRS: c_int = 8;
-pub const CHANNEL_LFE: c_int = 9;
-pub const CHANNEL_MAX: c_int = 256;
-pub type Channel = c_int;
+pub const CHANNEL_INVALID: Channel = -1;
+pub const CHANNEL_MONO: Channel = 0;
+pub const CHANNEL_LEFT: Channel = 1;
+pub const CHANNEL_RIGHT: Channel = 2;
+pub const CHANNEL_CENTER: Channel = 3;
+pub const CHANNEL_LS: Channel = 4;
+pub const CHANNEL_RS: Channel = 5;
+pub const CHANNEL_RLS: Channel = 6;
+pub const CHANNEL_RCENTER: Channel = 7;
+pub const CHANNEL_RRS: Channel = 8;
+pub const CHANNEL_LFE: Channel = 9;
+pub const CHANNEL_MAX: Channel = 10;
#[repr(C)]
+#[derive(Clone, Copy, Debug)]
pub struct ChannelMap {
pub channels: c_uint,
- pub map: [Channel; 256],
+ pub map: [Channel; CHANNEL_MAX as usize],
}
impl ::std::default::Default for ChannelMap {
fn default() -> Self {
ChannelMap {
channels: 0,
- map: unsafe { ::std::mem::zeroed() },
+ map: [CHANNEL_INVALID,
+ CHANNEL_INVALID,
+ CHANNEL_INVALID,
+ CHANNEL_INVALID,
+ CHANNEL_INVALID,
+ CHANNEL_INVALID,
+ CHANNEL_INVALID,
+ CHANNEL_INVALID,
+ CHANNEL_INVALID,
+ CHANNEL_INVALID],
}
}
}
diff -up firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-ffi/src/ffi_funcs.rs.cubeb-pulse-arm firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-ffi/src/ffi_funcs.rs
--- firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-ffi/src/ffi_funcs.rs.cubeb-pulse-arm 2017-07-31 18:20:49.000000000 +0200
+++ firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-ffi/src/ffi_funcs.rs 2017-08-04 13:37:46.384821737 +0200
@@ -8,8 +8,8 @@ macro_rules! cstr {
#[cfg(not(feature = "dlopen"))]
mod static_fns {
- use std::os::raw::{c_char, c_double, c_int, c_float, c_uint, c_void};
use super::*;
+ use std::os::raw::{c_char, c_double, c_float, c_int, c_uint, c_void};
#[link(name = "pulse")]
extern "C" {
@@ -62,6 +62,7 @@ mod static_fns {
userdata: *mut c_void)
-> *mut pa_operation;
pub fn pa_context_set_state_callback(c: *mut pa_context, cb: pa_context_notify_cb_t, userdata: *mut c_void);
+ pub fn pa_context_errno(c: *mut pa_context) -> c_int;
pub fn pa_context_set_subscribe_callback(c: *mut pa_context,
cb: pa_context_subscribe_cb_t,
userdata: *mut c_void);
@@ -70,6 +71,7 @@ mod static_fns {
cb: pa_context_success_cb_t,
userdata: *mut c_void)
-> *mut pa_operation;
+ pub fn pa_context_ref(c: *mut pa_context) -> *mut pa_context;
pub fn pa_context_unref(c: *mut pa_context);
pub fn pa_cvolume_set(a: *mut pa_cvolume, channels: c_uint, v: pa_volume_t) -> *mut pa_cvolume;
pub fn pa_cvolume_set_balance(v: *mut pa_cvolume,
@@ -80,12 +82,20 @@ mod static_fns {
pub fn pa_mainloop_api_once(m: *mut pa_mainloop_api,
callback: pa_mainloop_api_once_cb_t,
userdata: *mut c_void);
- pub fn pa_operation_get_state(o: *const pa_operation) -> pa_operation_state_t;
+ pub fn pa_strerror(error: pa_error_code_t) -> *const c_char;
+ pub fn pa_operation_ref(o: *mut pa_operation) -> *mut pa_operation;
pub fn pa_operation_unref(o: *mut pa_operation);
+ pub fn pa_operation_cancel(o: *mut pa_operation);
+ pub fn pa_operation_get_state(o: *const pa_operation) -> pa_operation_state_t;
+ pub fn pa_operation_set_state_callback(o: *mut pa_operation,
+ cb: pa_operation_notify_cb_t,
+ userdata: *mut c_void);
pub fn pa_proplist_gets(p: *mut pa_proplist, key: *const c_char) -> *const c_char;
pub fn pa_rtclock_now() -> pa_usec_t;
pub fn pa_stream_begin_write(p: *mut pa_stream, data: *mut *mut c_void, nbytes: *mut usize) -> c_int;
pub fn pa_stream_cancel_write(p: *mut pa_stream) -> c_int;
+ pub fn pa_stream_is_suspended(s: *const pa_stream) -> c_int;
+ pub fn pa_stream_is_corked(s: *const pa_stream) -> c_int;
pub fn pa_stream_connect_playback(s: *mut pa_stream,
dev: *const c_char,
attr: *const pa_buffer_attr,
@@ -112,6 +122,7 @@ mod static_fns {
pub fn pa_stream_get_latency(s: *const pa_stream, r_usec: *mut pa_usec_t, negative: *mut c_int) -> c_int;
pub fn pa_stream_get_sample_spec(s: *const pa_stream) -> *const pa_sample_spec;
pub fn pa_stream_get_state(p: *const pa_stream) -> pa_stream_state_t;
+ pub fn pa_stream_get_context(s: *const pa_stream) -> *mut pa_context;
pub fn pa_stream_get_time(s: *const pa_stream, r_usec: *mut pa_usec_t) -> c_int;
pub fn pa_stream_new(c: *mut pa_context,
name: *const c_char,
@@ -123,6 +134,7 @@ mod static_fns {
pub fn pa_stream_set_state_callback(s: *mut pa_stream, cb: pa_stream_notify_cb_t, userdata: *mut c_void);
pub fn pa_stream_set_write_callback(p: *mut pa_stream, cb: pa_stream_request_cb_t, userdata: *mut c_void);
pub fn pa_stream_set_read_callback(p: *mut pa_stream, cb: pa_stream_request_cb_t, userdata: *mut c_void);
+ pub fn pa_stream_ref(s: *mut pa_stream) -> *mut pa_stream;
pub fn pa_stream_unref(s: *mut pa_stream);
pub fn pa_stream_update_timing_info(p: *mut pa_stream,
cb: pa_stream_success_cb_t,
@@ -148,8 +160,6 @@ mod static_fns {
pub fn pa_threaded_mainloop_unlock(m: *mut pa_threaded_mainloop);
pub fn pa_threaded_mainloop_wait(m: *mut pa_threaded_mainloop);
pub fn pa_usec_to_bytes(t: pa_usec_t, spec: *const pa_sample_spec) -> usize;
- pub fn pa_xfree(ptr: *mut c_void);
- pub fn pa_xstrdup(str: *const c_char) -> *mut c_char;
pub fn pa_xrealloc(ptr: *mut c_void, size: usize) -> *mut c_void;
}
}
@@ -159,9 +169,9 @@ pub use self::static_fns::*;
#[cfg(feature = "dlopen")]
mod dynamic_fns {
- use std::os::raw::{c_char, c_double, c_int, c_float, c_uint, c_void};
- use libc::{dlclose, dlopen, dlsym, RTLD_LAZY};
use super::*;
+ use libc::{RTLD_LAZY, dlclose, dlopen, dlsym};
+ use std::os::raw::{c_char, c_double, c_float, c_int, c_uint, c_void};
#[derive(Debug)]
pub struct LibLoader {
@@ -287,6 +297,13 @@ mod dynamic_fns {
}
fp
};
+ PA_CONTEXT_ERRNO = {
+ let fp = dlsym(h, cstr!("pa_context_errno"));
+ if fp.is_null() {
+ return None;
+ }
+ fp
+ };
PA_CONTEXT_SET_SUBSCRIBE_CALLBACK = {
let fp = dlsym(h, cstr!("pa_context_set_subscribe_callback"));
if fp.is_null() {
@@ -301,6 +318,13 @@ mod dynamic_fns {
}
fp
};
+ PA_CONTEXT_REF = {
+ let fp = dlsym(h, cstr!("pa_context_ref"));
+ if fp.is_null() {
+ return None;
+ }
+ fp
+ };
PA_CONTEXT_UNREF = {
let fp = dlsym(h, cstr!("pa_context_unref"));
if fp.is_null() {
@@ -336,8 +360,15 @@ mod dynamic_fns {
}
fp
};
- PA_OPERATION_GET_STATE = {
- let fp = dlsym(h, cstr!("pa_operation_get_state"));
+ PA_STRERROR = {
+ let fp = dlsym(h, cstr!("pa_strerror"));
+ if fp.is_null() {
+ return None;
+ }
+ fp
+ };
+ PA_OPERATION_REF = {
+ let fp = dlsym(h, cstr!("pa_operation_ref"));
if fp.is_null() {
return None;
}
@@ -350,6 +381,27 @@ mod dynamic_fns {
}
fp
};
+ PA_OPERATION_CANCEL = {
+ let fp = dlsym(h, cstr!("pa_operation_cancel"));
+ if fp.is_null() {
+ return None;
+ }
+ fp
+ };
+ PA_OPERATION_GET_STATE = {
+ let fp = dlsym(h, cstr!("pa_operation_get_state"));
+ if fp.is_null() {
+ return None;
+ }
+ fp
+ };
+ PA_OPERATION_SET_STATE_CALLBACK = {
+ let fp = dlsym(h, cstr!("pa_operation_set_state_callback"));
+ if fp.is_null() {
+ return None;
+ }
+ fp
+ };
PA_PROPLIST_GETS = {
let fp = dlsym(h, cstr!("pa_proplist_gets"));
if fp.is_null() {
@@ -378,6 +430,20 @@ mod dynamic_fns {
}
fp
};
+ PA_STREAM_IS_SUSPENDED = {
+ let fp = dlsym(h, cstr!("pa_stream_is_suspended"));
+ if fp.is_null() {
+ return None;
+ }
+ fp
+ };
+ PA_STREAM_IS_CORKED = {
+ let fp = dlsym(h, cstr!("pa_stream_is_corked"));
+ if fp.is_null() {
+ return None;
+ }
+ fp
+ };
PA_STREAM_CONNECT_PLAYBACK = {
let fp = dlsym(h, cstr!("pa_stream_connect_playback"));
if fp.is_null() {
@@ -462,6 +528,13 @@ mod dynamic_fns {
}
fp
};
+ PA_STREAM_GET_CONTEXT = {
+ let fp = dlsym(h, cstr!("pa_stream_get_context"));
+ if fp.is_null() {
+ return None;
+ }
+ fp
+ };
PA_STREAM_GET_TIME = {
let fp = dlsym(h, cstr!("pa_stream_get_time"));
if fp.is_null() {
@@ -511,6 +584,13 @@ mod dynamic_fns {
}
fp
};
+ PA_STREAM_REF = {
+ let fp = dlsym(h, cstr!("pa_stream_ref"));
+ if fp.is_null() {
+ return None;
+ }
+ fp
+ };
PA_STREAM_UNREF = {
let fp = dlsym(h, cstr!("pa_stream_unref"));
if fp.is_null() {
@@ -623,20 +703,6 @@ mod dynamic_fns {
}
fp
};
- PA_XFREE = {
- let fp = dlsym(h, cstr!("pa_xfree"));
- if fp.is_null() {
- return None;
- }
- fp
- };
- PA_XSTRDUP = {
- let fp = dlsym(h, cstr!("pa_xstrdup"));
- if fp.is_null() {
- return None;
- }
- fp
- };
PA_XREALLOC = {
let fp = dlsym(h, cstr!("pa_xrealloc"));
if fp.is_null() {
@@ -837,6 +903,12 @@ mod dynamic_fns {
*mut c_void)>(PA_CONTEXT_SET_STATE_CALLBACK))(c, cb, userdata)
}
+ static mut PA_CONTEXT_ERRNO: *mut ::libc::c_void = 0 as *mut _;
+ #[inline]
+ pub unsafe fn pa_context_errno(c: *mut pa_context) -> c_int {
+ (::std::mem::transmute::<_, extern "C" fn(*mut pa_context) -> c_int>(PA_CONTEXT_ERRNO))(c)
+ }
+
static mut PA_CONTEXT_SET_SUBSCRIBE_CALLBACK: *mut ::libc::c_void = 0 as *mut _;
#[inline]
pub unsafe fn pa_context_set_subscribe_callback(c: *mut pa_context,
@@ -863,6 +935,12 @@ mod dynamic_fns {
-> *mut pa_operation>(PA_CONTEXT_SUBSCRIBE))(c, m, cb, userdata)
}
+ static mut PA_CONTEXT_REF: *mut ::libc::c_void = 0 as *mut _;
+ #[inline]
+ pub unsafe fn pa_context_ref(c: *mut pa_context) -> *mut pa_context {
+ (::std::mem::transmute::<_, extern "C" fn(*mut pa_context) -> *mut pa_context>(PA_CONTEXT_REF))(c)
+ }
+
static mut PA_CONTEXT_UNREF: *mut ::libc::c_void = 0 as *mut _;
#[inline]
pub unsafe fn pa_context_unref(c: *mut pa_context) {
@@ -907,6 +985,30 @@ mod dynamic_fns {
*mut c_void)>(PA_MAINLOOP_API_ONCE))(m, callback, userdata)
}
+ static mut PA_STRERROR: *mut ::libc::c_void = 0 as *mut _;
+ #[inline]
+ pub unsafe fn pa_strerror(error: pa_error_code_t) -> *const c_char {
+ (::std::mem::transmute::<_, extern "C" fn(pa_error_code_t) -> *const c_char>(PA_STRERROR))(error)
+ }
+
+ static mut PA_OPERATION_REF: *mut ::libc::c_void = 0 as *mut _;
+ #[inline]
+ pub unsafe fn pa_operation_ref(o: *mut pa_operation) -> *mut pa_operation {
+ (::std::mem::transmute::<_, extern "C" fn(*mut pa_operation) -> *mut pa_operation>(PA_OPERATION_REF))(o)
+ }
+
+ static mut PA_OPERATION_UNREF: *mut ::libc::c_void = 0 as *mut _;
+ #[inline]
+ pub unsafe fn pa_operation_unref(o: *mut pa_operation) {
+ (::std::mem::transmute::<_, extern "C" fn(*mut pa_operation)>(PA_OPERATION_UNREF))(o)
+ }
+
+ static mut PA_OPERATION_CANCEL: *mut ::libc::c_void = 0 as *mut _;
+ #[inline]
+ pub unsafe fn pa_operation_cancel(o: *mut pa_operation) {
+ (::std::mem::transmute::<_, extern "C" fn(*mut pa_operation)>(PA_OPERATION_CANCEL))(o)
+ }
+
static mut PA_OPERATION_GET_STATE: *mut ::libc::c_void = 0 as *mut _;
#[inline]
pub unsafe fn pa_operation_get_state(o: *const pa_operation) -> pa_operation_state_t {
@@ -915,10 +1017,15 @@ mod dynamic_fns {
-> pa_operation_state_t>(PA_OPERATION_GET_STATE))(o)
}
- static mut PA_OPERATION_UNREF: *mut ::libc::c_void = 0 as *mut _;
+ static mut PA_OPERATION_SET_STATE_CALLBACK: *mut ::libc::c_void = 0 as *mut _;
#[inline]
- pub unsafe fn pa_operation_unref(o: *mut pa_operation) {
- (::std::mem::transmute::<_, extern "C" fn(*mut pa_operation)>(PA_OPERATION_UNREF))(o)
+ pub unsafe fn pa_operation_set_state_callback(o: *mut pa_operation,
+ cb: pa_operation_notify_cb_t,
+ userdata: *mut c_void) {
+ (::std::mem::transmute::<_,
+ extern "C" fn(*mut pa_operation,
+ pa_operation_notify_cb_t,
+ *mut c_void)>(PA_OPERATION_SET_STATE_CALLBACK))(o, cb, userdata)
}
static mut PA_PROPLIST_GETS: *mut ::libc::c_void = 0 as *mut _;
@@ -951,6 +1058,18 @@ mod dynamic_fns {
(::std::mem::transmute::<_, extern "C" fn(*mut pa_stream) -> c_int>(PA_STREAM_CANCEL_WRITE))(p)
}
+ static mut PA_STREAM_IS_SUSPENDED: *mut ::libc::c_void = 0 as *mut _;
+ #[inline]
+ pub unsafe fn pa_stream_is_suspended(s: *const pa_stream) -> c_int {
+ (::std::mem::transmute::<_, extern "C" fn(*const pa_stream) -> c_int>(PA_STREAM_IS_SUSPENDED))(s)
+ }
+
+ static mut PA_STREAM_IS_CORKED: *mut ::libc::c_void = 0 as *mut _;
+ #[inline]
+ pub unsafe fn pa_stream_is_corked(s: *const pa_stream) -> c_int {
+ (::std::mem::transmute::<_, extern "C" fn(*const pa_stream) -> c_int>(PA_STREAM_IS_CORKED))(s)
+ }
+
static mut PA_STREAM_CONNECT_PLAYBACK: *mut ::libc::c_void = 0 as *mut _;
#[inline]
pub unsafe fn pa_stream_connect_playback(s: *mut pa_stream,
@@ -1066,6 +1185,12 @@ mod dynamic_fns {
(::std::mem::transmute::<_, extern "C" fn(*const pa_stream) -> pa_stream_state_t>(PA_STREAM_GET_STATE))(p)
}
+ static mut PA_STREAM_GET_CONTEXT: *mut ::libc::c_void = 0 as *mut _;
+ #[inline]
+ pub unsafe fn pa_stream_get_context(s: *const pa_stream) -> *mut pa_context {
+ (::std::mem::transmute::<_, extern "C" fn(*const pa_stream) -> *mut pa_context>(PA_STREAM_GET_CONTEXT))(s)
+ }
+
static mut PA_STREAM_GET_TIME: *mut ::libc::c_void = 0 as *mut _;
#[inline]
pub unsafe fn pa_stream_get_time(s: *const pa_stream, r_usec: *mut pa_usec_t) -> c_int {
@@ -1132,6 +1257,12 @@ mod dynamic_fns {
*mut c_void)>(PA_STREAM_SET_READ_CALLBACK))(p, cb, userdata)
}
+ static mut PA_STREAM_REF: *mut ::libc::c_void = 0 as *mut _;
+ #[inline]
+ pub unsafe fn pa_stream_ref(s: *mut pa_stream) -> *mut pa_stream {
+ (::std::mem::transmute::<_, extern "C" fn(*mut pa_stream) -> *mut pa_stream>(PA_STREAM_REF))(s)
+ }
+
static mut PA_STREAM_UNREF: *mut ::libc::c_void = 0 as *mut _;
#[inline]
pub unsafe fn pa_stream_unref(s: *mut pa_stream) {
@@ -1253,18 +1384,6 @@ mod dynamic_fns {
spec)
}
- static mut PA_XFREE: *mut ::libc::c_void = 0 as *mut _;
- #[inline]
- pub unsafe fn pa_xfree(ptr: *mut c_void) {
- (::std::mem::transmute::<_, extern "C" fn(*mut c_void)>(PA_XFREE))(ptr)
- }
-
- static mut PA_XSTRDUP: *mut ::libc::c_void = 0 as *mut _;
- #[inline]
- pub unsafe fn pa_xstrdup(str: *const c_char) -> *mut c_char {
- (::std::mem::transmute::<_, extern "C" fn(*const c_char) -> *mut c_char>(PA_XSTRDUP))(str)
- }
-
static mut PA_XREALLOC: *mut ::libc::c_void = 0 as *mut _;
#[inline]
pub unsafe fn pa_xrealloc(ptr: *mut c_void, size: usize) -> *mut c_void {
diff -up firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-ffi/src/ffi_types.rs.cubeb-pulse-arm firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-ffi/src/ffi_types.rs
--- firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-ffi/src/ffi_types.rs.cubeb-pulse-arm 2017-07-31 18:20:49.000000000 +0200
+++ firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-ffi/src/ffi_types.rs 2017-08-04 13:37:46.384821737 +0200
@@ -1,6 +1,6 @@
#![allow(non_camel_case_types)]
-use std::os::raw::{c_char, c_int, c_long, c_ulong, c_void};
+use std::os::raw::{c_char, c_int, c_long, c_uint, c_ulong, c_void};
/* automatically generated by rust-bindgen */
pub const PA_RATE_MAX: u32 = 48000 * 8;
@@ -74,10 +74,10 @@ pub const PA_OPERATION_DONE: c_int = 1;
pub const PA_OPERATION_CANCELLED: c_int = 2;
pub type pa_operation_state_t = c_int;
-pub const PA_CONTEXT_NOFLAGS: c_int = 0;
-pub const PA_CONTEXT_NOAUTOSPAWN: c_int = 1;
-pub const PA_CONTEXT_NOFAIL: c_int = 2;
-pub type pa_context_flags_t = c_int;
+pub const PA_CONTEXT_NOFLAGS: c_uint = 0;
+pub const PA_CONTEXT_NOAUTOSPAWN: c_uint = 1;
+pub const PA_CONTEXT_NOFAIL: c_uint = 2;
+pub type pa_context_flags_t = c_uint;
pub const PA_DIRECTION_OUTPUT: c_int = 1;
pub const PA_DIRECTION_INPUT: c_int = 2;
@@ -93,28 +93,28 @@ pub const PA_STREAM_RECORD: c_int = 2;
pub const PA_STREAM_UPLOAD: c_int = 3;
pub type pa_stream_direction_t = c_int;
-pub const PA_STREAM_NOFLAGS: c_int = 0x0_0000;
-pub const PA_STREAM_START_CORKED: c_int = 0x0_0001;
-pub const PA_STREAM_INTERPOLATE_TIMING: c_int = 0x0_0002;
-pub const PA_STREAM_NOT_MONOTONIC: c_int = 0x0_0004;
-pub const PA_STREAM_AUTO_TIMING_UPDATE: c_int = 0x0_0008;
-pub const PA_STREAM_NO_REMAP_CHANNELS: c_int = 0x0_0010;
-pub const PA_STREAM_NO_REMIX_CHANNELS: c_int = 0x0_0020;
-pub const PA_STREAM_FIX_FORMAT: c_int = 0x0_0040;
-pub const PA_STREAM_FIX_RATE: c_int = 0x0_0080;
-pub const PA_STREAM_FIX_CHANNELS: c_int = 0x0_0100;
-pub const PA_STREAM_DONT_MOVE: c_int = 0x0_0200;
-pub const PA_STREAM_VARIABLE_RATE: c_int = 0x0_0400;
-pub const PA_STREAM_PEAK_DETECT: c_int = 0x0_0800;
-pub const PA_STREAM_START_MUTED: c_int = 0x0_1000;
-pub const PA_STREAM_ADJUST_LATENCY: c_int = 0x0_2000;
-pub const PA_STREAM_EARLY_REQUESTS: c_int = 0x0_4000;
-pub const PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND: c_int = 0x0_8000;
-pub const PA_STREAM_START_UNMUTED: c_int = 0x1_0000;
-pub const PA_STREAM_FAIL_ON_SUSPEND: c_int = 0x2_0000;
-pub const PA_STREAM_RELATIVE_VOLUME: c_int = 0x4_0000;
-pub const PA_STREAM_PASSTHROUGH: c_int = 0x8_0000;
-pub type pa_stream_flags_t = c_int;
+pub const PA_STREAM_NOFLAGS: c_uint = 0x0_0000;
+pub const PA_STREAM_START_CORKED: c_uint = 0x0_0001;
+pub const PA_STREAM_INTERPOLATE_TIMING: c_uint = 0x0_0002;
+pub const PA_STREAM_NOT_MONOTONIC: c_uint = 0x0_0004;
+pub const PA_STREAM_AUTO_TIMING_UPDATE: c_uint = 0x0_0008;
+pub const PA_STREAM_NO_REMAP_CHANNELS: c_uint = 0x0_0010;
+pub const PA_STREAM_NO_REMIX_CHANNELS: c_uint = 0x0_0020;
+pub const PA_STREAM_FIX_FORMAT: c_uint = 0x0_0040;
+pub const PA_STREAM_FIX_RATE: c_uint = 0x0_0080;
+pub const PA_STREAM_FIX_CHANNELS: c_uint = 0x0_0100;
+pub const PA_STREAM_DONT_MOVE: c_uint = 0x0_0200;
+pub const PA_STREAM_VARIABLE_RATE: c_uint = 0x0_0400;
+pub const PA_STREAM_PEAK_DETECT: c_uint = 0x0_0800;
+pub const PA_STREAM_START_MUTED: c_uint = 0x0_1000;
+pub const PA_STREAM_ADJUST_LATENCY: c_uint = 0x0_2000;
+pub const PA_STREAM_EARLY_REQUESTS: c_uint = 0x0_4000;
+pub const PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND: c_uint = 0x0_8000;
+pub const PA_STREAM_START_UNMUTED: c_uint = 0x1_0000;
+pub const PA_STREAM_FAIL_ON_SUSPEND: c_uint = 0x2_0000;
+pub const PA_STREAM_RELATIVE_VOLUME: c_uint = 0x4_0000;
+pub const PA_STREAM_PASSTHROUGH: c_uint = 0x8_0000;
+pub type pa_stream_flags_t = c_uint;
#[repr(C)]
#[derive(Clone, Copy, Debug)]
@@ -162,19 +162,19 @@ pub const PA_ERR_BUSY: c_int = 26;
pub const PA_ERR_MAX: c_int = 27;
pub type pa_error_code_t = c_int;
-pub const PA_SUBSCRIPTION_MASK_NULL: c_int = 0;
-pub const PA_SUBSCRIPTION_MASK_SINK: c_int = 1;
-pub const PA_SUBSCRIPTION_MASK_SOURCE: c_int = 2;
-pub const PA_SUBSCRIPTION_MASK_SINK_INPUT: c_int = 4;
-pub const PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT: c_int = 8;
-pub const PA_SUBSCRIPTION_MASK_MODULE: c_int = 16;
-pub const PA_SUBSCRIPTION_MASK_CLIENT: c_int = 32;
-pub const PA_SUBSCRIPTION_MASK_SAMPLE_CACHE: c_int = 64;
-pub const PA_SUBSCRIPTION_MASK_SERVER: c_int = 128;
-pub const PA_SUBSCRIPTION_MASK_AUTOLOAD: c_int = 256;
-pub const PA_SUBSCRIPTION_MASK_CARD: c_int = 512;
-pub const PA_SUBSCRIPTION_MASK_ALL: c_int = 767;
-pub type pa_subscription_mask_t = c_int;
+pub const PA_SUBSCRIPTION_MASK_NULL: c_uint = 0x0;
+pub const PA_SUBSCRIPTION_MASK_SINK: c_uint = 0x1;
+pub const PA_SUBSCRIPTION_MASK_SOURCE: c_uint = 0x2;
+pub const PA_SUBSCRIPTION_MASK_SINK_INPUT: c_uint = 0x4;
+pub const PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT: c_uint = 0x8;
+pub const PA_SUBSCRIPTION_MASK_MODULE: c_uint = 0x10;
+pub const PA_SUBSCRIPTION_MASK_CLIENT: c_uint = 0x20;
+pub const PA_SUBSCRIPTION_MASK_SAMPLE_CACHE: c_uint = 0x40;
+pub const PA_SUBSCRIPTION_MASK_SERVER: c_uint = 0x80;
+pub const PA_SUBSCRIPTION_MASK_AUTOLOAD: c_uint = 0x100;
+pub const PA_SUBSCRIPTION_MASK_CARD: c_uint = 0x200;
+pub const PA_SUBSCRIPTION_MASK_ALL: c_uint = 0x3FF;
+pub type pa_subscription_mask_t = c_uint;
pub const PA_SUBSCRIPTION_EVENT_SINK: c_int = 0;
pub const PA_SUBSCRIPTION_EVENT_SOURCE: c_int = 1;
@@ -244,17 +244,17 @@ pub const PA_SEEK_RELATIVE_ON_READ: c_in
pub const PA_SEEK_RELATIVE_END: c_int = 3;
pub type pa_seek_mode_t = c_int;
-pub const PA_SINK_NOFLAGS: c_int = 0;
-pub const PA_SINK_HW_VOLUME_CTRL: c_int = 1;
-pub const PA_SINK_LATENCY: c_int = 2;
-pub const PA_SINK_HARDWARE: c_int = 4;
-pub const PA_SINK_NETWORK: c_int = 8;
-pub const PA_SINK_HW_MUTE_CTRL: c_int = 16;
-pub const PA_SINK_DECIBEL_VOLUME: c_int = 32;
-pub const PA_SINK_FLAT_VOLUME: c_int = 64;
-pub const PA_SINK_DYNAMIC_LATENCY: c_int = 128;
-pub const PA_SINK_SET_FORMATS: c_int = 256;
-pub type pa_sink_flags_t = c_int;
+pub const PA_SINK_NOFLAGS: c_uint = 0x000;
+pub const PA_SINK_HW_VOLUME_CTRL: c_uint = 0x001;
+pub const PA_SINK_LATENCY: c_uint = 0x002;
+pub const PA_SINK_HARDWARE: c_uint = 0x004;
+pub const PA_SINK_NETWORK: c_uint = 0x008;
+pub const PA_SINK_HW_MUTE_CTRL: c_uint = 0x010;
+pub const PA_SINK_DECIBEL_VOLUME: c_uint = 0x020;
+pub const PA_SINK_FLAT_VOLUME: c_uint = 0x040;
+pub const PA_SINK_DYNAMIC_LATENCY: c_uint = 0x080;
+pub const PA_SINK_SET_FORMATS: c_uint = 0x100;
+pub type pa_sink_flags_t = c_uint;
pub const PA_SINK_INVALID_STATE: c_int = -1;
pub const PA_SINK_RUNNING: c_int = 0;
@@ -264,16 +264,16 @@ pub const PA_SINK_INIT: c_int = -2;
pub const PA_SINK_UNLINKED: c_int = -3;
pub type pa_sink_state_t = c_int;
-pub const PA_SOURCE_NOFLAGS: c_int = 0x00;
-pub const PA_SOURCE_HW_VOLUME_CTRL: c_int = 0x01;
-pub const PA_SOURCE_LATENCY: c_int = 0x02;
-pub const PA_SOURCE_HARDWARE: c_int = 0x04;
-pub const PA_SOURCE_NETWORK: c_int = 0x08;
-pub const PA_SOURCE_HW_MUTE_CTRL: c_int = 0x10;
-pub const PA_SOURCE_DECIBEL_VOLUME: c_int = 0x20;
-pub const PA_SOURCE_DYNAMIC_LATENCY: c_int = 0x40;
-pub const PA_SOURCE_FLAT_VOLUME: c_int = 0x80;
-pub type pa_source_flags_t = c_int;
+pub const PA_SOURCE_NOFLAGS: c_uint = 0x00;
+pub const PA_SOURCE_HW_VOLUME_CTRL: c_uint = 0x01;
+pub const PA_SOURCE_LATENCY: c_uint = 0x02;
+pub const PA_SOURCE_HARDWARE: c_uint = 0x04;
+pub const PA_SOURCE_NETWORK: c_uint = 0x08;
+pub const PA_SOURCE_HW_MUTE_CTRL: c_uint = 0x10;
+pub const PA_SOURCE_DECIBEL_VOLUME: c_uint = 0x20;
+pub const PA_SOURCE_DYNAMIC_LATENCY: c_uint = 0x40;
+pub const PA_SOURCE_FLAT_VOLUME: c_uint = 0x80;
+pub type pa_source_flags_t = c_uint;
pub const PA_SOURCE_INVALID_STATE: c_int = -1;
pub const PA_SOURCE_RUNNING: c_int = 0;
diff -up firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-rs/Cargo.toml.cubeb-pulse-arm firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-rs/Cargo.toml
--- firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-rs/Cargo.toml.cubeb-pulse-arm 2017-08-04 13:37:46.384821737 +0200
+++ firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-rs/Cargo.toml 2017-08-04 13:37:46.384821737 +0200
@@ -0,0 +1,8 @@
+[package]
+name = "pulse"
+version = "0.1.0"
+authors = ["Dan Glastonbury <dglastonbury@mozilla.com>"]
+
+[dependencies]
+bitflags = "^0.7.0"
+pulse-ffi = { path = "../pulse-ffi" }
diff -up firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-rs/src/context.rs.cubeb-pulse-arm firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-rs/src/context.rs
--- firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-rs/src/context.rs.cubeb-pulse-arm 2017-08-04 13:37:46.385821734 +0200
+++ firefox-55.0/media/libcubeb/cubeb-pulse-rs/pulse-rs/src/context.rs 2017-08-04 13:37:46.385821734 +0200
@@ -0,0 +1,394 @@
+// Copyright © 2017 Mozilla Foundation
+//
+// This program is made available under an ISC-style license. See the
+// accompanying file LICENSE for details.
+
+use ::*;
+use ffi;
+use std::ffi::CStr;
+use std::os::raw::{c_int, c_void};
+use std::ptr;
+use util::UnwrapCStr;
+
+// A note about `wrapped` functions
+//
+// C FFI demands `unsafe extern fn(*mut pa_context, ...) -> i32`, etc,
+// but we want to allow such callbacks to be safe. This means no
+// `unsafe` or `extern`, and callbacks should be called with a safe
+// wrapper of `*mut pa_context`. Since the callback doesn't take
+// ownership, this is `&Context`. `fn wrapped<T>(...)` defines a
+// function that converts from our safe signature to the unsafe
+// signature.
+//
+// Currently, we use a property of Rust, namely that each function
+// gets its own unique type. These unique types can't be written
+// directly, so we use generic and a type parameter, and let the Rust
+// compiler fill in the name for us:
+//
+// fn get_sink_input_info<CB>(&self, ..., _: CB, ...) -> ...
+// where CB: Fn(&Context, *const SinkInputInfo, i32, *mut c_void)
+//
+// Because we aren't storing or passing any state, we assert, at run-time :-(,
+// that our functions are zero-sized:
+//
+// assert!(mem::size_of::<F>() == 0);
+//
+// We need to obtain a value of type F in order to call it. Since we
+// can't name the function, we have to unsafely construct that value
+// somehow - we do this using mem::uninitialized. Then, we call that
+// function with a reference to the Context, and save the result:
+//
+// | generate value || call it |
+// let result = ::std::mem::uninitialized::<F>()(&mut object);
+//
+// Lastly, since our Object is an owned type, we need to avoid
+// dropping it, then return the result we just generated.
+//
+// mem::forget(object);
+// result
+
+// Aid in returning Operation from callbacks
+macro_rules! op_or_err {
+ ($self_:ident, $e:expr) => {{
+ let o = unsafe { $e };
+ if o.is_null() {
+ Err(ErrorCode::from_error_code($self_.errno()))
+ } else {
+ Ok(unsafe { operation::from_raw_ptr(o) })
+ }
+ }}
+}
+
+#[repr(C)]
+#[derive(Debug)]
+pub struct Context(*mut ffi::pa_context);
+
+impl Context {
+ pub fn new<'a, OPT>(api: &MainloopApi, name: OPT) -> Option<Self>
+ where OPT: Into<Option<&'a CStr>>
+ {
+ let ptr = unsafe { ffi::pa_context_new(api.raw_mut(), name.unwrap_cstr()) };
+ if ptr.is_null() {
+ None
+ } else {
+ Some(Context(ptr))
+ }
+ }
+
+ #[doc(hidden)]
+ pub fn raw_mut(&self) -> &mut ffi::pa_context {
+ unsafe { &mut *self.0 }
+ }
+
+ pub fn unref(self) {
+ unsafe {
+ ffi::pa_context_unref(self.raw_mut());
+ }
+ }
+
+ pub fn clear_state_callback(&self) {
+ unsafe {
+ ffi::pa_context_set_state_callback(self.raw_mut(), None, ptr::null_mut());
+ }
+ }
+
+ pub fn set_state_callback<CB>(&self, _: CB, userdata: *mut c_void)
+ where CB: Fn(&Context, *mut c_void)
+ {
+ debug_assert_eq!(::std::mem::size_of::<CB>(), 0);
+
+ // See: A note about `wrapped` functions
+ unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, userdata: *mut c_void)
+ where F: Fn(&Context, *mut c_void)
+ {
+ use std::mem::{forget, uninitialized};
+ let ctx = context::from_raw_ptr(c);
+ let result = uninitialized::<F>()(&ctx, userdata);
+ forget(ctx);
+
+ result
+ }
+
+ unsafe {
+ ffi::pa_context_set_state_callback(self.raw_mut(), Some(wrapped::<CB>), userdata);
+ }
+ }
+
+ pub fn errno(&self) -> ffi::pa_error_code_t {
+ unsafe { ffi::pa_context_errno(self.raw_mut()) }
+ }
+
+ pub fn get_state(&self) -> ContextState {
+ ContextState::try_from(unsafe {
+ ffi::pa_context_get_state(self.raw_mut())
+ }).expect("pa_context_get_state returned invalid ContextState")
+ }
+
+ pub fn connect<'a, OPT>(&self, server: OPT, flags: ContextFlags, api: *const ffi::pa_spawn_api) -> Result<()>
+ where OPT: Into<Option<&'a CStr>>
+ {
+ let r = unsafe {
+ ffi::pa_context_connect(self.raw_mut(),
+ server.into().unwrap_cstr(),
+ flags.into(),
+ api)
+ };
+ error_result!((), r)
+ }
+
+ pub fn disconnect(&self) {
+ unsafe {
+ ffi::pa_context_disconnect(self.raw_mut());
+ }
+ }
+
+
+ pub fn drain<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation>
+ where CB: Fn(&Context, *mut c_void)
+ {
+ debug_assert_eq!(::std::mem::size_of::<CB>(), 0);
+
+ // See: A note about `wrapped` functions
+ unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, userdata: *mut c_void)
+ where F: Fn(&Context, *mut c_void)
+ {
+ use std::mem::{forget, uninitialized};
+ let ctx = context::from_raw_ptr(c);
+ let result = uninitialized::<F>()(&ctx, userdata);
+ forget(ctx);
+
+ result
+ }
+
+ op_or_err!(self,
+ ffi::pa_context_drain(self.raw_mut(), Some(wrapped::<CB>), userdata))
+ }
+
+ pub fn rttime_new<CB>(&self, usec: USec, _: CB, userdata: *mut c_void) -> *mut ffi::pa_time_event
+ where CB: Fn(&MainloopApi, *mut ffi::pa_time_event, &TimeVal, *mut c_void)
+ {
+ debug_assert_eq!(::std::mem::size_of::<CB>(), 0);
+
+ // See: A note about `wrapped` functions
+ unsafe extern "C" fn wrapped<F>(a: *mut ffi::pa_mainloop_api,
+ e: *mut ffi::pa_time_event,
+ tv: *const TimeVal,
+ userdata: *mut c_void)
+ where F: Fn(&MainloopApi, *mut ffi::pa_time_event, &TimeVal, *mut c_void)
+ {
+ use std::mem::{forget, uninitialized};
+ let api = mainloop_api::from_raw_ptr(a);
+ let timeval = &*tv;
+ let result = uninitialized::<F>()(&api, e, timeval, userdata);
+ forget(api);
+
+ result
+ }
+
+ unsafe { ffi::pa_context_rttime_new(self.raw_mut(), usec, Some(wrapped::<CB>), userdata) }
+ }
+
+ pub fn get_server_info<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation>
+ where CB: Fn(&Context, &ServerInfo, *mut c_void)
+ {
+ debug_assert_eq!(::std::mem::size_of::<CB>(), 0);
+
+ // See: A note about `wrapped` functions
+ unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context, i: *const ffi::pa_server_info, userdata: *mut c_void)
+ where F: Fn(&Context, &ServerInfo, *mut c_void)
+ {
+ use std::mem::{forget, uninitialized};
+ debug_assert_ne!(i, ptr::null_mut());
+ let info = &*i;
+ let ctx = context::from_raw_ptr(c);
+ let result = uninitialized::<F>()(&ctx, info, userdata);
+ forget(ctx);
+
+ result
+ }
+
+ op_or_err!(self,
+ ffi::pa_context_get_server_info(self.raw_mut(), Some(wrapped::<CB>), userdata))
+ }
+
+ pub fn get_sink_info_by_name<CB>(&self, name: &CStr, _: CB, userdata: *mut c_void) -> Result<Operation>
+ where CB: Fn(&Context, *const SinkInfo, i32, *mut c_void)
+ {
+ debug_assert_eq!(::std::mem::size_of::<CB>(), 0);
+
+ // See: A note about `wrapped` functions
+ unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context,
+ info: *const ffi::pa_sink_info,
+ eol: c_int,
+ userdata: *mut c_void)
+ where F: Fn(&Context, *const SinkInfo, i32, *mut c_void)
+ {
+ use std::mem::{forget, uninitialized};
+ let ctx = context::from_raw_ptr(c);
+ let result = uninitialized::<F>()(&ctx, info, eol, userdata);
+ forget(ctx);
+
+ result
+ }
+
+ op_or_err!(self,
+ ffi::pa_context_get_sink_info_by_name(self.raw_mut(), name.as_ptr(), Some(wrapped::<CB>), userdata))
+ }
+
+ pub fn get_sink_info_list<CB>(&self, _: CB, userdata: *mut c_void) -> Result<Operation>
+ where CB: Fn(&Context, *const SinkInfo, i32, *mut c_void)
+ {
+ debug_assert_eq!(::std::mem::size_of::<CB>(), 0);
+
+ // See: A note about `wrapped` functions
+ unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context,
+ info: *const ffi::pa_sink_info,
+ eol: c_int,
+ userdata: *mut c_void)
+ where F: Fn(&Context, *const SinkInfo, i32, *mut c_void)
+ {
+ use std::mem::{forget, uninitialized};
+ let ctx = context::from_raw_ptr(c);
+ let result = uninitialized::<F>()(&ctx, info, eol, userdata);
+ forget(ctx);
+
+ result
+ }
+
+ op_or_err!(self,
+ ffi::pa_context_get_sink_info_list(self.raw_mut(), Some(wrapped::<CB>), userdata))
+ }
+
+ pub fn get_sink_input_info<CB>(&self, idx: u32, _: CB, userdata: *mut c_void) -> Result<Operation>
+ where CB: Fn(&Context, *const SinkInputInfo, i32, *mut c_void)
+ {
+ debug_assert_eq!(::std::mem::size_of::<CB>(), 0);
+
+ // See: A note about `wrapped` functions
+ unsafe extern "C" fn wrapped<F>(c: *mut ffi::pa_context,
+ info: *const ffi::pa_sink_input_info,
+ eol: c_int,
+ userdata: *mut c_void)
+ where F: Fn(&Context, *const SinkInputInfo, i32, *mut c_void)
+ {
+ use std::mem::{forget, uninitialized};
+ let ctx = context::from_raw_ptr(c);
+ let result = uninitialized::<F>()(&ctx, info, eol, userdata);
+ forget(ctx);
+
+ result
+ }