Mon Oct 23 15:25:28 2017 UTC ()
forefox: fix a build error with "alsa" option on NetBSD.


(tsutsui)
diff -r1.297 -r1.298 pkgsrc/www/firefox/distinfo
diff -r1.24 -r1.25 pkgsrc/www/firefox/patches/patch-media_libcubeb_src_cubeb__alsa.c

cvs diff -r1.297 -r1.298 pkgsrc/www/firefox/distinfo (expand / switch to unified diff)

--- pkgsrc/www/firefox/distinfo 2017/10/17 03:39:04 1.297
+++ pkgsrc/www/firefox/distinfo 2017/10/23 15:25:28 1.298
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1$NetBSD: distinfo,v 1.297 2017/10/17 03:39:04 ryoon Exp $ 1$NetBSD: distinfo,v 1.298 2017/10/23 15:25:28 tsutsui Exp $
2 2
3SHA1 (firefox-56.0.source.tar.xz) = 806cb335752ee93b204750b89dc6940768408088 3SHA1 (firefox-56.0.source.tar.xz) = 806cb335752ee93b204750b89dc6940768408088
4RMD160 (firefox-56.0.source.tar.xz) = b5239242e55e3031838c9807bff47b5b9c9fb420 4RMD160 (firefox-56.0.source.tar.xz) = b5239242e55e3031838c9807bff47b5b9c9fb420
5SHA512 (firefox-56.0.source.tar.xz) = 3aeb0ff54e10c83894f61734daa4f0801a1bb499d4667adad9c78520e588eae809d0e4d61e9227206466d62c3b453e2ce9ca8198f59f5354cd1b6804c00f0990 5SHA512 (firefox-56.0.source.tar.xz) = 3aeb0ff54e10c83894f61734daa4f0801a1bb499d4667adad9c78520e588eae809d0e4d61e9227206466d62c3b453e2ce9ca8198f59f5354cd1b6804c00f0990
6Size (firefox-56.0.source.tar.xz) = 255389204 bytes 6Size (firefox-56.0.source.tar.xz) = 255389204 bytes
7SHA1 (patch-aa) = a2b7c767773f462452701237b2b06c9a4f01d1b5 7SHA1 (patch-aa) = a2b7c767773f462452701237b2b06c9a4f01d1b5
8SHA1 (patch-build_gyp.mozbuild) = bb3a2f8c1cad0e9cfdaefa721c5992cba2e2bf50 8SHA1 (patch-build_gyp.mozbuild) = bb3a2f8c1cad0e9cfdaefa721c5992cba2e2bf50
9SHA1 (patch-build_moz.configure_init.configure) = 5ec8da6b5aad7682a88b010a99e19f5d4403e6db 9SHA1 (patch-build_moz.configure_init.configure) = 5ec8da6b5aad7682a88b010a99e19f5d4403e6db
10SHA1 (patch-build_moz.configure_keyfiles.configure) = 4d346c6298e08853681aac018f9289190bc1841a 10SHA1 (patch-build_moz.configure_keyfiles.configure) = 4d346c6298e08853681aac018f9289190bc1841a
11SHA1 (patch-build_moz.configure_memory.configure) = 46237c1415eff3f99d4889a6300ec96af925f0a6 11SHA1 (patch-build_moz.configure_memory.configure) = 46237c1415eff3f99d4889a6300ec96af925f0a6
12SHA1 (patch-build_moz.configure_old.configure) = 2f452e717f0c9dc8224019b58e531e5e95cc7697 12SHA1 (patch-build_moz.configure_old.configure) = 2f452e717f0c9dc8224019b58e531e5e95cc7697
13SHA1 (patch-config_Makefile.in) = 2ad29cef869171aa29b6c3e4ba4a5c99311e0742 13SHA1 (patch-config_Makefile.in) = 2ad29cef869171aa29b6c3e4ba4a5c99311e0742
14SHA1 (patch-config_baseconfig.mk) = fbc3fd75bf5d794284e5703a9df227949e819136 14SHA1 (patch-config_baseconfig.mk) = fbc3fd75bf5d794284e5703a9df227949e819136
@@ -40,27 +40,27 @@ SHA1 (patch-ipc_chromium_src_base_lock__ @@ -40,27 +40,27 @@ SHA1 (patch-ipc_chromium_src_base_lock__
40SHA1 (patch-ipc_chromium_src_base_message__pump__libevent.cc) = 99b9f3f9dd88f1c8008d2fb6058450695394f5cf 40SHA1 (patch-ipc_chromium_src_base_message__pump__libevent.cc) = 99b9f3f9dd88f1c8008d2fb6058450695394f5cf
41SHA1 (patch-ipc_chromium_src_base_platform__thread.h) = 3ed4f482a8ccbd5db216c2623bf6dd93b0bbc1c9 41SHA1 (patch-ipc_chromium_src_base_platform__thread.h) = 3ed4f482a8ccbd5db216c2623bf6dd93b0bbc1c9
42SHA1 (patch-ipc_chromium_src_base_platform__thread__posix.cc) = 937a843a7acf3085056e309ea5ab047bd9b95088 42SHA1 (patch-ipc_chromium_src_base_platform__thread__posix.cc) = 937a843a7acf3085056e309ea5ab047bd9b95088
43SHA1 (patch-ipc_chromium_src_base_process__util.h) = 4b24c3467866a601d68bb83f44e5fd38fb27188d 43SHA1 (patch-ipc_chromium_src_base_process__util.h) = 4b24c3467866a601d68bb83f44e5fd38fb27188d
44SHA1 (patch-ipc_glue_CrossProcessSemaphore.h) = 778a569887d8ad082abc2fa2fe89a0a943e84d64 44SHA1 (patch-ipc_glue_CrossProcessSemaphore.h) = 778a569887d8ad082abc2fa2fe89a0a943e84d64
45SHA1 (patch-ipc_glue_CrossProcessSemaphore__posix.cpp) = 3052338871447cedaeafe8369afe82233183c884 45SHA1 (patch-ipc_glue_CrossProcessSemaphore__posix.cpp) = 3052338871447cedaeafe8369afe82233183c884
46SHA1 (patch-ipc_glue_GeckoChildProcessHost.cpp) = 260c29bacd8bf265951b7a412f850bf2b292c836 46SHA1 (patch-ipc_glue_GeckoChildProcessHost.cpp) = 260c29bacd8bf265951b7a412f850bf2b292c836
47SHA1 (patch-js_src_build_moz.build) = 4597a427262d0eb6ce8d14c0f557bfbe3f053e61 47SHA1 (patch-js_src_build_moz.build) = 4597a427262d0eb6ce8d14c0f557bfbe3f053e61
48SHA1 (patch-js_src_jit_arm_Architecture-arm.cpp) = f0b554c169643b8447b4f29168d61ea257b18782 48SHA1 (patch-js_src_jit_arm_Architecture-arm.cpp) = f0b554c169643b8447b4f29168d61ea257b18782
49SHA1 (patch-js_xpconnect_src_XPCConvert.cpp) = 915777e9bb5366be41866cdb6ea0ad2b1c006dde 49SHA1 (patch-js_xpconnect_src_XPCConvert.cpp) = 915777e9bb5366be41866cdb6ea0ad2b1c006dde
50SHA1 (patch-js_xpconnect_src_xpcprivate.h) = 97a221c76593be712f670aa409f2f1ad5dc20628 50SHA1 (patch-js_xpconnect_src_xpcprivate.h) = 97a221c76593be712f670aa409f2f1ad5dc20628
51SHA1 (patch-media_libcubeb_gtest_moz.build) = ebb4be6e6bca4a0ed6858516ec9fdb7828bbe2e1 51SHA1 (patch-media_libcubeb_gtest_moz.build) = ebb4be6e6bca4a0ed6858516ec9fdb7828bbe2e1
52SHA1 (patch-media_libcubeb_src_cubeb.c) = 1b1b8d57eb710cad13518ded79a0ddee2681881b 52SHA1 (patch-media_libcubeb_src_cubeb.c) = 1b1b8d57eb710cad13518ded79a0ddee2681881b
53SHA1 (patch-media_libcubeb_src_cubeb__alsa.c) = 1b2890eea9d1b69ace8e5d6806e49ce4eb011236 53SHA1 (patch-media_libcubeb_src_cubeb__alsa.c) = b19e380278ca875600e49b76021b20f1f9e81980
54SHA1 (patch-media_libcubeb_src_cubeb__jack.cpp) = 1b514a97e3c15d03acdc873d23ff665112984293 54SHA1 (patch-media_libcubeb_src_cubeb__jack.cpp) = 1b514a97e3c15d03acdc873d23ff665112984293
55SHA1 (patch-media_libcubeb_src_cubeb__oss.c) = 88cdfb9b9aa8c2607ca79bfa7fce4353e65638f7 55SHA1 (patch-media_libcubeb_src_cubeb__oss.c) = 88cdfb9b9aa8c2607ca79bfa7fce4353e65638f7
56SHA1 (patch-media_libcubeb_src_moz.build) = 5fca6701cc890120a04483f52c25242ee7b1c051 56SHA1 (patch-media_libcubeb_src_moz.build) = 5fca6701cc890120a04483f52c25242ee7b1c051
57SHA1 (patch-media_libcubeb_update.sh) = e8babe57ea7f0f32658b391e9c4f6310e57fc38c 57SHA1 (patch-media_libcubeb_update.sh) = e8babe57ea7f0f32658b391e9c4f6310e57fc38c
58SHA1 (patch-media_libsoundtouch_src_cpu__detect__x86.cpp) = db61737afa7773e8cbd82976de3a02c917174696 58SHA1 (patch-media_libsoundtouch_src_cpu__detect__x86.cpp) = db61737afa7773e8cbd82976de3a02c917174696
59SHA1 (patch-media_libsoundtouch_src_soundtouch__perms.h) = 2d08a3b4176c155c57b458cb78043318b68d8fe2 59SHA1 (patch-media_libsoundtouch_src_soundtouch__perms.h) = 2d08a3b4176c155c57b458cb78043318b68d8fe2
60SHA1 (patch-media_libtheora_lib_arm_armcpu.c) = 3ef05c05799d56b3c160634327d90dd33764c3df 60SHA1 (patch-media_libtheora_lib_arm_armcpu.c) = 3ef05c05799d56b3c160634327d90dd33764c3df
61SHA1 (patch-media_libtheora_moz.build) = cbcb61331fea274b720a4b5c51db1f763fc10d81 61SHA1 (patch-media_libtheora_moz.build) = cbcb61331fea274b720a4b5c51db1f763fc10d81
62SHA1 (patch-media_libtremor_moz.build) = 87f66296be4db8487eae95b2779a9c02463555cf 62SHA1 (patch-media_libtremor_moz.build) = 87f66296be4db8487eae95b2779a9c02463555cf
63SHA1 (patch-media_libvorbis_moz.build) = cad67e49169ddab075fbfae2e6f0f950c1eccaf0 63SHA1 (patch-media_libvorbis_moz.build) = cad67e49169ddab075fbfae2e6f0f950c1eccaf0
64SHA1 (patch-media_libyuv_libyuv_source_mjpeg__decoder.cc) = 8a264c439fa4749cd7c5acf96e1ae3f9bae0a886 64SHA1 (patch-media_libyuv_libyuv_source_mjpeg__decoder.cc) = 8a264c439fa4749cd7c5acf96e1ae3f9bae0a886
65SHA1 (patch-media_openmax__dl_dl_api_armCOMM__s.h) = 40b3fa8aaec77d3bfec810f0bc4e76eae449d7c7 65SHA1 (patch-media_openmax__dl_dl_api_armCOMM__s.h) = 40b3fa8aaec77d3bfec810f0bc4e76eae449d7c7
66SHA1 (patch-media_webrtc_trunk_webrtc_modules_video__capture_linux_device__info__linux.cc) = 0141dd1372c13ea1fce6e2f5ffb65e0cb0f3a13e 66SHA1 (patch-media_webrtc_trunk_webrtc_modules_video__capture_linux_device__info__linux.cc) = 0141dd1372c13ea1fce6e2f5ffb65e0cb0f3a13e

cvs diff -r1.24 -r1.25 pkgsrc/www/firefox/patches/Attic/patch-media_libcubeb_src_cubeb__alsa.c (expand / switch to unified diff)

--- pkgsrc/www/firefox/patches/Attic/patch-media_libcubeb_src_cubeb__alsa.c 2017/09/30 05:34:12 1.24
+++ pkgsrc/www/firefox/patches/Attic/patch-media_libcubeb_src_cubeb__alsa.c 2017/10/23 15:25:28 1.25
@@ -1,29 +1,34 @@ @@ -1,29 +1,34 @@
1$NetBSD: patch-media_libcubeb_src_cubeb__alsa.c,v 1.24 2017/09/30 05:34:12 ryoon Exp $ 1$NetBSD: patch-media_libcubeb_src_cubeb__alsa.c,v 1.25 2017/10/23 15:25:28 tsutsui Exp $
2 2
3* Support alsa audio under NetBSD 3* Support alsa audio under NetBSD
4* Avoid https://github.com/kinetiknz/cubeb/issues/226 4* Avoid https://github.com/kinetiknz/cubeb/issues/226
5 5
6--- media/libcubeb/src/cubeb_alsa.c.orig 2017-09-14 20:16:05.000000000 +0000 6--- media/libcubeb/src/cubeb_alsa.c.orig 2017-09-14 20:16:05.000000000 +0000
7+++ media/libcubeb/src/cubeb_alsa.c 7+++ media/libcubeb/src/cubeb_alsa.c
8@@ -12,6 +12,7 @@ 8@@ -8,10 +8,12 @@
 9 #define _DEFAULT_SOURCE
 10 #define _BSD_SOURCE
 11 #define _XOPEN_SOURCE 500
 12+#define _NETBSD_SOURCE
 13 #include <pthread.h>
9 #include <sys/time.h> 14 #include <sys/time.h>
10 #include <assert.h> 15 #include <assert.h>
11 #include <limits.h> 16 #include <limits.h>
12+#include <dlfcn.h> 17+#include <dlfcn.h>
13 #include <poll.h> 18 #include <poll.h>
14 #include <unistd.h> 19 #include <unistd.h>
15 #include <alsa/asoundlib.h> 20 #include <alsa/asoundlib.h>
16@@ -26,6 +27,52 @@ 21@@ -26,6 +28,52 @@
17  22
18 #define ALSA_PA_PLUGIN "ALSA <-> PulseAudio PCM I/O Plugin" 23 #define ALSA_PA_PLUGIN "ALSA <-> PulseAudio PCM I/O Plugin"
19  24
20+#ifdef DISABLE_LIBASOUND_DLOPEN 25+#ifdef DISABLE_LIBASOUND_DLOPEN
21+#define WRAP(x) x 26+#define WRAP(x) x
22+#else 27+#else
23+#define WRAP(x) cubeb_##x 28+#define WRAP(x) cubeb_##x
24+#define MAKE_TYPEDEF(x) static typeof(x) * cubeb_##x 29+#define MAKE_TYPEDEF(x) static typeof(x) * cubeb_##x
25+MAKE_TYPEDEF(snd_config); 30+MAKE_TYPEDEF(snd_config);
26+MAKE_TYPEDEF(snd_config_add); 31+MAKE_TYPEDEF(snd_config_add);
27+MAKE_TYPEDEF(snd_config_copy); 32+MAKE_TYPEDEF(snd_config_copy);
28+MAKE_TYPEDEF(snd_config_delete); 33+MAKE_TYPEDEF(snd_config_delete);
29+MAKE_TYPEDEF(snd_config_get_id); 34+MAKE_TYPEDEF(snd_config_get_id);
@@ -56,114 +61,114 @@ $NetBSD: patch-media_libcubeb_src_cubeb_ @@ -56,114 +61,114 @@ $NetBSD: patch-media_libcubeb_src_cubeb_
56+MAKE_TYPEDEF(snd_pcm_readi); 61+MAKE_TYPEDEF(snd_pcm_readi);
57+MAKE_TYPEDEF(snd_pcm_recover); 62+MAKE_TYPEDEF(snd_pcm_recover);
58+MAKE_TYPEDEF(snd_pcm_set_params); 63+MAKE_TYPEDEF(snd_pcm_set_params);
59+MAKE_TYPEDEF(snd_pcm_start); 64+MAKE_TYPEDEF(snd_pcm_start);
60+MAKE_TYPEDEF(snd_pcm_state); 65+MAKE_TYPEDEF(snd_pcm_state);
61+MAKE_TYPEDEF(snd_pcm_writei); 66+MAKE_TYPEDEF(snd_pcm_writei);
62+ 67+
63+#undef MAKE_TYPEDEF 68+#undef MAKE_TYPEDEF
64+#endif 69+#endif
65+ 70+
66 /* ALSA is not thread-safe. snd_pcm_t instances are individually protected 71 /* ALSA is not thread-safe. snd_pcm_t instances are individually protected
67 by the owning cubeb_stream's mutex. snd_pcm_t creation and destruction 72 by the owning cubeb_stream's mutex. snd_pcm_t creation and destruction
68 is not thread-safe until ALSA 1.0.24 (see alsa-lib.git commit 91c9c8f1), 73 is not thread-safe until ALSA 1.0.24 (see alsa-lib.git commit 91c9c8f1),
69@@ -66,6 +113,8 @@ struct cubeb { 74@@ -66,6 +114,8 @@ struct cubeb {
70 workaround is not required. */ 75 workaround is not required. */
71 snd_config_t * local_config; 76 snd_config_t * local_config;
72 int is_pa; 77 int is_pa;
73+ 78+
74+ void * libasound; 79+ void * libasound;
75 }; 80 };
76  81
77 enum stream_state { 82 enum stream_state {
78@@ -244,8 +293,8 @@ set_timeout(struct timeval * timeout, un 83@@ -244,8 +294,8 @@ set_timeout(struct timeval * timeout, un
79 static void 84 static void
80 stream_buffer_decrement(cubeb_stream * stm, long count) 85 stream_buffer_decrement(cubeb_stream * stm, long count)
81 { 86 {
82- char * bufremains = stm->buffer + snd_pcm_frames_to_bytes(stm->pcm, count); 87- char * bufremains = stm->buffer + snd_pcm_frames_to_bytes(stm->pcm, count);
83- memmove(stm->buffer, bufremains, snd_pcm_frames_to_bytes(stm->pcm, stm->bufframes - count)); 88- memmove(stm->buffer, bufremains, snd_pcm_frames_to_bytes(stm->pcm, stm->bufframes - count));
84+ char * bufremains = stm->buffer + WRAP(snd_pcm_frames_to_bytes)(stm->pcm, count); 89+ char * bufremains = stm->buffer + WRAP(snd_pcm_frames_to_bytes)(stm->pcm, count);
85+ memmove(stm->buffer, bufremains, WRAP(snd_pcm_frames_to_bytes)(stm->pcm, stm->bufframes - count)); 90+ memmove(stm->buffer, bufremains, WRAP(snd_pcm_frames_to_bytes)(stm->pcm, stm->bufframes - count));
86 stm->bufframes -= count; 91 stm->bufframes -= count;
87 } 92 }
88  93
89@@ -277,9 +326,9 @@ alsa_process_stream(cubeb_stream * stm) 94@@ -277,9 +327,9 @@ alsa_process_stream(cubeb_stream * stm)
90 /* Call _poll_descriptors_revents() even if we don't use it 95 /* Call _poll_descriptors_revents() even if we don't use it
91 to let underlying plugins clear null events. Otherwise poll() 96 to let underlying plugins clear null events. Otherwise poll()
92 may wake up again and again, producing unnecessary CPU usage. */ 97 may wake up again and again, producing unnecessary CPU usage. */
93- snd_pcm_poll_descriptors_revents(stm->pcm, stm->fds, stm->nfds, &revents); 98- snd_pcm_poll_descriptors_revents(stm->pcm, stm->fds, stm->nfds, &revents);
94+ WRAP(snd_pcm_poll_descriptors_revents)(stm->pcm, stm->fds, stm->nfds, &revents); 99+ WRAP(snd_pcm_poll_descriptors_revents)(stm->pcm, stm->fds, stm->nfds, &revents);
95  100
96- avail = snd_pcm_avail_update(stm->pcm); 101- avail = snd_pcm_avail_update(stm->pcm);
97+ avail = WRAP(snd_pcm_avail_update)(stm->pcm); 102+ avail = WRAP(snd_pcm_avail_update)(stm->pcm);
98  103
99 /* Got null event? Bail and wait for another wakeup. */ 104 /* Got null event? Bail and wait for another wakeup. */
100 if (avail == 0) { 105 if (avail == 0) {
101@@ -302,7 +351,7 @@ alsa_process_stream(cubeb_stream * stm) 106@@ -302,7 +352,7 @@ alsa_process_stream(cubeb_stream * stm)
102 // TODO: should it be marked as DRAINING? 107 // TODO: should it be marked as DRAINING?
103 } 108 }
104  109
105- got = snd_pcm_readi(stm->pcm, stm->buffer+stm->bufframes, avail); 110- got = snd_pcm_readi(stm->pcm, stm->buffer+stm->bufframes, avail);
106+ got = WRAP(snd_pcm_readi)(stm->pcm, stm->buffer+stm->bufframes, avail); 111+ got = WRAP(snd_pcm_readi)(stm->pcm, stm->buffer+stm->bufframes, avail);
107  112
108 if (got < 0) { 113 if (got < 0) {
109 avail = got; // the error handler below will recover us 114 avail = got; // the error handler below will recover us
110@@ -346,7 +395,7 @@ alsa_process_stream(cubeb_stream * stm) 115@@ -346,7 +396,7 @@ alsa_process_stream(cubeb_stream * stm)
111 (!stm->other_stream || stm->other_stream->bufframes > 0)) { 116 (!stm->other_stream || stm->other_stream->bufframes > 0)) {
112 long got = avail - stm->bufframes; 117 long got = avail - stm->bufframes;
113 void * other_buffer = stm->other_stream ? stm->other_stream->buffer : NULL; 118 void * other_buffer = stm->other_stream ? stm->other_stream->buffer : NULL;
114- char * buftail = stm->buffer + snd_pcm_frames_to_bytes(stm->pcm, stm->bufframes); 119- char * buftail = stm->buffer + snd_pcm_frames_to_bytes(stm->pcm, stm->bufframes);
115+ char * buftail = stm->buffer + WRAP(snd_pcm_frames_to_bytes)(stm->pcm, stm->bufframes); 120+ char * buftail = stm->buffer + WRAP(snd_pcm_frames_to_bytes)(stm->pcm, stm->bufframes);
116  121
117 /* Correct read size to the other stream available frames */ 122 /* Correct read size to the other stream available frames */
118 if (stm->other_stream && got > (snd_pcm_sframes_t) stm->other_stream->bufframes) { 123 if (stm->other_stream && got > (snd_pcm_sframes_t) stm->other_stream->bufframes) {
119@@ -373,8 +422,8 @@ alsa_process_stream(cubeb_stream * stm) 124@@ -373,8 +423,8 @@ alsa_process_stream(cubeb_stream * stm)
120 long drain_frames = avail - stm->bufframes; 125 long drain_frames = avail - stm->bufframes;
121 double drain_time = (double) drain_frames / stm->params.rate; 126 double drain_time = (double) drain_frames / stm->params.rate;
122  127
123- char * buftail = stm->buffer + snd_pcm_frames_to_bytes(stm->pcm, stm->bufframes); 128- char * buftail = stm->buffer + snd_pcm_frames_to_bytes(stm->pcm, stm->bufframes);
124- memset(buftail, 0, snd_pcm_frames_to_bytes(stm->pcm, drain_frames)); 129- memset(buftail, 0, snd_pcm_frames_to_bytes(stm->pcm, drain_frames));
125+ char * buftail = stm->buffer + WRAP(snd_pcm_frames_to_bytes)(stm->pcm, stm->bufframes); 130+ char * buftail = stm->buffer + WRAP(snd_pcm_frames_to_bytes)(stm->pcm, stm->bufframes);
126+ memset(buftail, 0, WRAP(snd_pcm_frames_to_bytes)(stm->pcm, drain_frames)); 131+ memset(buftail, 0, WRAP(snd_pcm_frames_to_bytes)(stm->pcm, drain_frames));
127 stm->bufframes = avail; 132 stm->bufframes = avail;
128  133
129 /* Mark as draining, unless we're waiting for capture */ 134 /* Mark as draining, unless we're waiting for capture */
130@@ -401,7 +450,7 @@ alsa_process_stream(cubeb_stream * stm) 135@@ -401,7 +451,7 @@ alsa_process_stream(cubeb_stream * stm)
131 } 136 }
132 } 137 }
133  138
134- wrote = snd_pcm_writei(stm->pcm, stm->buffer, avail); 139- wrote = snd_pcm_writei(stm->pcm, stm->buffer, avail);
135+ wrote = WRAP(snd_pcm_writei)(stm->pcm, stm->buffer, avail); 140+ wrote = WRAP(snd_pcm_writei)(stm->pcm, stm->buffer, avail);
136 if (wrote < 0) { 141 if (wrote < 0) {
137 avail = wrote; // the error handler below will recover us 142 avail = wrote; // the error handler below will recover us
138 } else { 143 } else {
139@@ -414,13 +463,13 @@ alsa_process_stream(cubeb_stream * stm) 144@@ -414,13 +464,13 @@ alsa_process_stream(cubeb_stream * stm)
140  145
141 /* Got some error? Let's try to recover the stream. */ 146 /* Got some error? Let's try to recover the stream. */
142 if (avail < 0) { 147 if (avail < 0) {
143- avail = snd_pcm_recover(stm->pcm, avail, 0); 148- avail = snd_pcm_recover(stm->pcm, avail, 0);
144+ avail = WRAP(snd_pcm_recover)(stm->pcm, avail, 0); 149+ avail = WRAP(snd_pcm_recover)(stm->pcm, avail, 0);
145  150
146 /* Capture pcm must be started after initial setup/recover */ 151 /* Capture pcm must be started after initial setup/recover */
147 if (avail >= 0 && 152 if (avail >= 0 &&
148 stm->stream_type == SND_PCM_STREAM_CAPTURE && 153 stm->stream_type == SND_PCM_STREAM_CAPTURE &&
149- snd_pcm_state(stm->pcm) == SND_PCM_STATE_PREPARED) { 154- snd_pcm_state(stm->pcm) == SND_PCM_STATE_PREPARED) {
150- avail = snd_pcm_start(stm->pcm); 155- avail = snd_pcm_start(stm->pcm);
151+ WRAP(snd_pcm_state)(stm->pcm) == SND_PCM_STATE_PREPARED) { 156+ WRAP(snd_pcm_state)(stm->pcm) == SND_PCM_STATE_PREPARED) {
152+ avail = WRAP(snd_pcm_start)(stm->pcm); 157+ avail = WRAP(snd_pcm_start)(stm->pcm);
153 } 158 }
154 } 159 }
155  160
156@@ -536,26 +585,26 @@ get_slave_pcm_node(snd_config_t * lconf, 161@@ -536,26 +586,26 @@ get_slave_pcm_node(snd_config_t * lconf,
157  162
158 slave_def = NULL; 163 slave_def = NULL;
159  164
160- r = snd_config_search(root_pcm, "slave", &slave_pcm); 165- r = snd_config_search(root_pcm, "slave", &slave_pcm);
161+ r = WRAP(snd_config_search)(root_pcm, "slave", &slave_pcm); 166+ r = WRAP(snd_config_search)(root_pcm, "slave", &slave_pcm);
162 if (r < 0) { 167 if (r < 0) {
163 return NULL; 168 return NULL;
164 } 169 }
165  170
166- r = snd_config_get_string(slave_pcm, &string); 171- r = snd_config_get_string(slave_pcm, &string);
167+ r = WRAP(snd_config_get_string)(slave_pcm, &string); 172+ r = WRAP(snd_config_get_string)(slave_pcm, &string);
168 if (r >= 0) { 173 if (r >= 0) {
169- r = snd_config_search_definition(lconf, "pcm_slave", string, &slave_def); 174- r = snd_config_search_definition(lconf, "pcm_slave", string, &slave_def);
@@ -175,148 +180,148 @@ $NetBSD: patch-media_libcubeb_src_cubeb_ @@ -175,148 +180,148 @@ $NetBSD: patch-media_libcubeb_src_cubeb_
175  180
176 do { 181 do {
177- r = snd_config_search(slave_def ? slave_def : slave_pcm, "pcm", &pcm); 182- r = snd_config_search(slave_def ? slave_def : slave_pcm, "pcm", &pcm);
178+ r = WRAP(snd_config_search)(slave_def ? slave_def : slave_pcm, "pcm", &pcm); 183+ r = WRAP(snd_config_search)(slave_def ? slave_def : slave_pcm, "pcm", &pcm);
179 if (r < 0) { 184 if (r < 0) {
180 break; 185 break;
181 } 186 }
182  187
183- r = snd_config_get_string(slave_def ? slave_def : slave_pcm, &string); 188- r = snd_config_get_string(slave_def ? slave_def : slave_pcm, &string);
184+ r = WRAP(snd_config_get_string)(slave_def ? slave_def : slave_pcm, &string); 189+ r = WRAP(snd_config_get_string)(slave_def ? slave_def : slave_pcm, &string);
185 if (r < 0) { 190 if (r < 0) {
186 break; 191 break;
187 } 192 }
188@@ -564,7 +613,7 @@ get_slave_pcm_node(snd_config_t * lconf, 193@@ -564,7 +614,7 @@ get_slave_pcm_node(snd_config_t * lconf,
189 if (r < 0 || r > (int) sizeof(node_name)) { 194 if (r < 0 || r > (int) sizeof(node_name)) {
190 break; 195 break;
191 } 196 }
192- r = snd_config_search(lconf, node_name, &pcm); 197- r = snd_config_search(lconf, node_name, &pcm);
193+ r = WRAP(snd_config_search)(lconf, node_name, &pcm); 198+ r = WRAP(snd_config_search)(lconf, node_name, &pcm);
194 if (r < 0) { 199 if (r < 0) {
195 break; 200 break;
196 } 201 }
197@@ -573,7 +622,7 @@ get_slave_pcm_node(snd_config_t * lconf, 202@@ -573,7 +623,7 @@ get_slave_pcm_node(snd_config_t * lconf,
198 } while (0); 203 } while (0);
199  204
200 if (slave_def) { 205 if (slave_def) {
201- snd_config_delete(slave_def); 206- snd_config_delete(slave_def);
202+ WRAP(snd_config_delete)(slave_def); 207+ WRAP(snd_config_delete)(slave_def);
203 } 208 }
204  209
205 return NULL; 210 return NULL;
206@@ -596,22 +645,22 @@ init_local_config_with_workaround(char c 211@@ -596,22 +646,22 @@ init_local_config_with_workaround(char c
207  212
208 lconf = NULL; 213 lconf = NULL;
209  214
210- if (snd_config == NULL) { 215- if (snd_config == NULL) {
211+ if (*WRAP(snd_config) == NULL) { 216+ if (*WRAP(snd_config) == NULL) {
212 return NULL; 217 return NULL;
213 } 218 }
214  219
215- r = snd_config_copy(&lconf, snd_config); 220- r = snd_config_copy(&lconf, snd_config);
216+ r = WRAP(snd_config_copy)(&lconf, *WRAP(snd_config)); 221+ r = WRAP(snd_config_copy)(&lconf, *WRAP(snd_config));
217 if (r < 0) { 222 if (r < 0) {
218 return NULL; 223 return NULL;
219 } 224 }
220  225
221 do { 226 do {
222- r = snd_config_search_definition(lconf, "pcm", pcm_name, &pcm_node); 227- r = snd_config_search_definition(lconf, "pcm", pcm_name, &pcm_node);
223+ r = WRAP(snd_config_search_definition)(lconf, "pcm", pcm_name, &pcm_node); 228+ r = WRAP(snd_config_search_definition)(lconf, "pcm", pcm_name, &pcm_node);
224 if (r < 0) { 229 if (r < 0) {
225 break; 230 break;
226 } 231 }
227  232
228- r = snd_config_get_id(pcm_node, &string); 233- r = snd_config_get_id(pcm_node, &string);
229+ r = WRAP(snd_config_get_id)(pcm_node, &string); 234+ r = WRAP(snd_config_get_id)(pcm_node, &string);
230 if (r < 0) { 235 if (r < 0) {
231 break; 236 break;
232 } 237 }
233@@ -620,7 +669,7 @@ init_local_config_with_workaround(char c 238@@ -620,7 +670,7 @@ init_local_config_with_workaround(char c
234 if (r < 0 || r > (int) sizeof(node_name)) { 239 if (r < 0 || r > (int) sizeof(node_name)) {
235 break; 240 break;
236 } 241 }
237- r = snd_config_search(lconf, node_name, &pcm_node); 242- r = snd_config_search(lconf, node_name, &pcm_node);
238+ r = WRAP(snd_config_search)(lconf, node_name, &pcm_node); 243+ r = WRAP(snd_config_search)(lconf, node_name, &pcm_node);
239 if (r < 0) { 244 if (r < 0) {
240 break; 245 break;
241 } 246 }
242@@ -631,12 +680,12 @@ init_local_config_with_workaround(char c 247@@ -631,12 +681,12 @@ init_local_config_with_workaround(char c
243 } 248 }
244  249
245 /* Fetch the PCM node's type, and bail out if it's not the PulseAudio plugin. */ 250 /* Fetch the PCM node's type, and bail out if it's not the PulseAudio plugin. */
246- r = snd_config_search(pcm_node, "type", &node); 251- r = snd_config_search(pcm_node, "type", &node);
247+ r = WRAP(snd_config_search)(pcm_node, "type", &node); 252+ r = WRAP(snd_config_search)(pcm_node, "type", &node);
248 if (r < 0) { 253 if (r < 0) {
249 break; 254 break;
250 } 255 }
251  256
252- r = snd_config_get_string(node, &string); 257- r = snd_config_get_string(node, &string);
253+ r = WRAP(snd_config_get_string)(node, &string); 258+ r = WRAP(snd_config_get_string)(node, &string);
254 if (r < 0) { 259 if (r < 0) {
255 break; 260 break;
256 } 261 }
257@@ -647,18 +696,18 @@ init_local_config_with_workaround(char c 262@@ -647,18 +697,18 @@ init_local_config_with_workaround(char c
258  263
259 /* Don't clobber an explicit existing handle_underrun value, set it only 264 /* Don't clobber an explicit existing handle_underrun value, set it only
260 if it doesn't already exist. */ 265 if it doesn't already exist. */
261- r = snd_config_search(pcm_node, "handle_underrun", &node); 266- r = snd_config_search(pcm_node, "handle_underrun", &node);
262+ r = WRAP(snd_config_search)(pcm_node, "handle_underrun", &node); 267+ r = WRAP(snd_config_search)(pcm_node, "handle_underrun", &node);
263 if (r != -ENOENT) { 268 if (r != -ENOENT) {
264 break; 269 break;
265 } 270 }
266  271
267 /* Disable pcm_pulse's asynchronous underrun handling. */ 272 /* Disable pcm_pulse's asynchronous underrun handling. */
268- r = snd_config_imake_integer(&node, "handle_underrun", 0); 273- r = snd_config_imake_integer(&node, "handle_underrun", 0);
269+ r = WRAP(snd_config_imake_integer)(&node, "handle_underrun", 0); 274+ r = WRAP(snd_config_imake_integer)(&node, "handle_underrun", 0);
270 if (r < 0) { 275 if (r < 0) {
271 break; 276 break;
272 } 277 }
273  278
274- r = snd_config_add(pcm_node, node); 279- r = snd_config_add(pcm_node, node);
275+ r = WRAP(snd_config_add)(pcm_node, node); 280+ r = WRAP(snd_config_add)(pcm_node, node);
276 if (r < 0) { 281 if (r < 0) {
277 break; 282 break;
278 } 283 }
279@@ -666,7 +715,7 @@ init_local_config_with_workaround(char c 284@@ -666,7 +716,7 @@ init_local_config_with_workaround(char c
280 return lconf; 285 return lconf;
281 } while (0); 286 } while (0);
282  287
283- snd_config_delete(lconf); 288- snd_config_delete(lconf);
284+ WRAP(snd_config_delete)(lconf); 289+ WRAP(snd_config_delete)(lconf);
285  290
286 return NULL; 291 return NULL;
287 } 292 }
288@@ -678,9 +727,9 @@ alsa_locked_pcm_open(snd_pcm_t ** pcm, c 293@@ -678,9 +728,9 @@ alsa_locked_pcm_open(snd_pcm_t ** pcm, c
289  294
290 pthread_mutex_lock(&cubeb_alsa_mutex); 295 pthread_mutex_lock(&cubeb_alsa_mutex);
291 if (local_config) { 296 if (local_config) {
292- r = snd_pcm_open_lconf(pcm, pcm_name, stream, SND_PCM_NONBLOCK, local_config); 297- r = snd_pcm_open_lconf(pcm, pcm_name, stream, SND_PCM_NONBLOCK, local_config);
293+ r = WRAP(snd_pcm_open_lconf)(pcm, pcm_name, stream, SND_PCM_NONBLOCK, local_config); 298+ r = WRAP(snd_pcm_open_lconf)(pcm, pcm_name, stream, SND_PCM_NONBLOCK, local_config);
294 } else { 299 } else {
295- r = snd_pcm_open(pcm, pcm_name, stream, SND_PCM_NONBLOCK); 300- r = snd_pcm_open(pcm, pcm_name, stream, SND_PCM_NONBLOCK);
296+ r = WRAP(snd_pcm_open)(pcm, pcm_name, stream, SND_PCM_NONBLOCK); 301+ r = WRAP(snd_pcm_open)(pcm, pcm_name, stream, SND_PCM_NONBLOCK);
297 } 302 }
298 pthread_mutex_unlock(&cubeb_alsa_mutex); 303 pthread_mutex_unlock(&cubeb_alsa_mutex);
299  304
300@@ -693,7 +742,7 @@ alsa_locked_pcm_close(snd_pcm_t * pcm) 305@@ -693,7 +743,7 @@ alsa_locked_pcm_close(snd_pcm_t * pcm)
301 int r; 306 int r;
302  307
303 pthread_mutex_lock(&cubeb_alsa_mutex); 308 pthread_mutex_lock(&cubeb_alsa_mutex);
304- r = snd_pcm_close(pcm); 309- r = snd_pcm_close(pcm);
305+ r = WRAP(snd_pcm_close)(pcm); 310+ r = WRAP(snd_pcm_close)(pcm);
306 pthread_mutex_unlock(&cubeb_alsa_mutex); 311 pthread_mutex_unlock(&cubeb_alsa_mutex);
307  312
308 return r; 313 return r;
309@@ -756,12 +805,65 @@ alsa_init(cubeb ** context, char const * 314@@ -756,12 +806,65 @@ alsa_init(cubeb ** context, char const *
310 pthread_attr_t attr; 315 pthread_attr_t attr;
311 snd_pcm_t * dummy; 316 snd_pcm_t * dummy;
312  317
313+ void * libasound = NULL; 318+ void * libasound = NULL;
314+ 319+
315+#ifndef DISABLE_LIBASOUND_DLOPEN 320+#ifndef DISABLE_LIBASOUND_DLOPEN
316+ libasound = dlopen("libasound.so", RTLD_LAZY); 321+ libasound = dlopen("libasound.so", RTLD_LAZY);
317+ if (!libasound) { 322+ if (!libasound) {
318+ return CUBEB_ERROR; 323+ return CUBEB_ERROR;
319+ } 324+ }
320+ 325+
321+#define LOAD(x) do { \ 326+#define LOAD(x) do { \
322+ cubeb_##x = dlsym(libasound, #x); \ 327+ cubeb_##x = dlsym(libasound, #x); \
@@ -363,127 +368,127 @@ $NetBSD: patch-media_libcubeb_src_cubeb_ @@ -363,127 +368,127 @@ $NetBSD: patch-media_libcubeb_src_cubeb_
363+ 368+
364+#undef LOAD 369+#undef LOAD
365+#endif 370+#endif
366 assert(context); 371 assert(context);
367 *context = NULL; 372 *context = NULL;
368  373
369 pthread_mutex_lock(&cubeb_alsa_mutex); 374 pthread_mutex_lock(&cubeb_alsa_mutex);
370 if (!cubeb_alsa_error_handler_set) { 375 if (!cubeb_alsa_error_handler_set) {
371- snd_lib_error_set_handler(silent_error_handler); 376- snd_lib_error_set_handler(silent_error_handler);
372+ WRAP(snd_lib_error_set_handler)(silent_error_handler); 377+ WRAP(snd_lib_error_set_handler)(silent_error_handler);
373 cubeb_alsa_error_handler_set = 1; 378 cubeb_alsa_error_handler_set = 1;
374 } 379 }
375 pthread_mutex_unlock(&cubeb_alsa_mutex); 380 pthread_mutex_unlock(&cubeb_alsa_mutex);
376@@ -769,6 +871,8 @@ alsa_init(cubeb ** context, char const * 381@@ -769,6 +872,8 @@ alsa_init(cubeb ** context, char const *
377 ctx = calloc(1, sizeof(*ctx)); 382 ctx = calloc(1, sizeof(*ctx));
378 assert(ctx); 383 assert(ctx);
379  384
380+ ctx->libasound = libasound; 385+ ctx->libasound = libasound;
381+ 386+
382 ctx->ops = &alsa_ops; 387 ctx->ops = &alsa_ops;
383  388
384 r = pthread_mutex_init(&ctx->mutex, NULL); 389 r = pthread_mutex_init(&ctx->mutex, NULL);
385@@ -818,7 +922,7 @@ alsa_init(cubeb ** context, char const * 390@@ -818,7 +923,7 @@ alsa_init(cubeb ** context, char const *
386 config fails with EINVAL, the PA PCM is too old for this workaround. */ 391 config fails with EINVAL, the PA PCM is too old for this workaround. */
387 if (r == -EINVAL) { 392 if (r == -EINVAL) {
388 pthread_mutex_lock(&cubeb_alsa_mutex); 393 pthread_mutex_lock(&cubeb_alsa_mutex);
389- snd_config_delete(ctx->local_config); 394- snd_config_delete(ctx->local_config);
390+ WRAP(snd_config_delete)(ctx->local_config); 395+ WRAP(snd_config_delete)(ctx->local_config);
391 pthread_mutex_unlock(&cubeb_alsa_mutex); 396 pthread_mutex_unlock(&cubeb_alsa_mutex);
392 ctx->local_config = NULL; 397 ctx->local_config = NULL;
393 } else if (r >= 0) { 398 } else if (r >= 0) {
394@@ -858,9 +962,13 @@ alsa_destroy(cubeb * ctx) 399@@ -858,9 +963,13 @@ alsa_destroy(cubeb * ctx)
395 pthread_mutex_destroy(&ctx->mutex); 400 pthread_mutex_destroy(&ctx->mutex);
396 free(ctx->fds); 401 free(ctx->fds);
397  402
398+ if (ctx->libasound) { 403+ if (ctx->libasound) {
399+ dlclose(ctx->libasound); 404+ dlclose(ctx->libasound);
400+ } 405+ }
401+ 406+
402 if (ctx->local_config) { 407 if (ctx->local_config) {
403 pthread_mutex_lock(&cubeb_alsa_mutex); 408 pthread_mutex_lock(&cubeb_alsa_mutex);
404- snd_config_delete(ctx->local_config); 409- snd_config_delete(ctx->local_config);
405+ WRAP(snd_config_delete)(ctx->local_config); 410+ WRAP(snd_config_delete)(ctx->local_config);
406 pthread_mutex_unlock(&cubeb_alsa_mutex); 411 pthread_mutex_unlock(&cubeb_alsa_mutex);
407 } 412 }
408  413
409@@ -943,7 +1051,7 @@ alsa_stream_init_single(cubeb * ctx, cub 414@@ -943,7 +1052,7 @@ alsa_stream_init_single(cubeb * ctx, cub
410 return CUBEB_ERROR; 415 return CUBEB_ERROR;
411 } 416 }
412  417
413- r = snd_pcm_nonblock(stm->pcm, 1); 418- r = snd_pcm_nonblock(stm->pcm, 1);
414+ r = WRAP(snd_pcm_nonblock)(stm->pcm, 1); 419+ r = WRAP(snd_pcm_nonblock)(stm->pcm, 1);
415 assert(r == 0); 420 assert(r == 0);
416  421
417 latency_us = latency_frames * 1e6 / stm->params.rate; 422 latency_us = latency_frames * 1e6 / stm->params.rate;
418@@ -956,7 +1064,7 @@ alsa_stream_init_single(cubeb * ctx, cub 423@@ -956,7 +1065,7 @@ alsa_stream_init_single(cubeb * ctx, cub
419 latency_us = latency_us < min_latency ? min_latency: latency_us; 424 latency_us = latency_us < min_latency ? min_latency: latency_us;
420 } 425 }
421  426
422- r = snd_pcm_set_params(stm->pcm, format, SND_PCM_ACCESS_RW_INTERLEAVED, 427- r = snd_pcm_set_params(stm->pcm, format, SND_PCM_ACCESS_RW_INTERLEAVED,
423+ r = WRAP(snd_pcm_set_params)(stm->pcm, format, SND_PCM_ACCESS_RW_INTERLEAVED, 428+ r = WRAP(snd_pcm_set_params)(stm->pcm, format, SND_PCM_ACCESS_RW_INTERLEAVED,
424 stm->params.channels, stm->params.rate, 1, 429 stm->params.channels, stm->params.rate, 1,
425 latency_us); 430 latency_us);
426 if (r < 0) { 431 if (r < 0) {
427@@ -964,20 +1072,20 @@ alsa_stream_init_single(cubeb * ctx, cub 432@@ -964,20 +1073,20 @@ alsa_stream_init_single(cubeb * ctx, cub
428 return CUBEB_ERROR_INVALID_FORMAT; 433 return CUBEB_ERROR_INVALID_FORMAT;
429 } 434 }
430  435
431- r = snd_pcm_get_params(stm->pcm, &stm->buffer_size, &period_size); 436- r = snd_pcm_get_params(stm->pcm, &stm->buffer_size, &period_size);
432+ r = WRAP(snd_pcm_get_params)(stm->pcm, &stm->buffer_size, &period_size); 437+ r = WRAP(snd_pcm_get_params)(stm->pcm, &stm->buffer_size, &period_size);
433 assert(r == 0); 438 assert(r == 0);
434  439
435 /* Double internal buffer size to have enough space when waiting for the other side of duplex connection */ 440 /* Double internal buffer size to have enough space when waiting for the other side of duplex connection */
436 stm->buffer_size *= 2; 441 stm->buffer_size *= 2;
437- stm->buffer = calloc(1, snd_pcm_frames_to_bytes(stm->pcm, stm->buffer_size)); 442- stm->buffer = calloc(1, snd_pcm_frames_to_bytes(stm->pcm, stm->buffer_size));
438+ stm->buffer = calloc(1, WRAP(snd_pcm_frames_to_bytes)(stm->pcm, stm->buffer_size)); 443+ stm->buffer = calloc(1, WRAP(snd_pcm_frames_to_bytes)(stm->pcm, stm->buffer_size));
439 assert(stm->buffer); 444 assert(stm->buffer);
440  445
441- stm->nfds = snd_pcm_poll_descriptors_count(stm->pcm); 446- stm->nfds = snd_pcm_poll_descriptors_count(stm->pcm);
442+ stm->nfds = WRAP(snd_pcm_poll_descriptors_count)(stm->pcm); 447+ stm->nfds = WRAP(snd_pcm_poll_descriptors_count)(stm->pcm);
443 assert(stm->nfds > 0); 448 assert(stm->nfds > 0);
444  449
445 stm->saved_fds = calloc(stm->nfds, sizeof(struct pollfd)); 450 stm->saved_fds = calloc(stm->nfds, sizeof(struct pollfd));
446 assert(stm->saved_fds); 451 assert(stm->saved_fds);
447- r = snd_pcm_poll_descriptors(stm->pcm, stm->saved_fds, stm->nfds); 452- r = snd_pcm_poll_descriptors(stm->pcm, stm->saved_fds, stm->nfds);
448+ r = WRAP(snd_pcm_poll_descriptors)(stm->pcm, stm->saved_fds, stm->nfds); 453+ r = WRAP(snd_pcm_poll_descriptors)(stm->pcm, stm->saved_fds, stm->nfds);
449 assert((nfds_t) r == stm->nfds); 454 assert((nfds_t) r == stm->nfds);
450  455
451 if (alsa_register_stream(ctx, stm) != 0) { 456 if (alsa_register_stream(ctx, stm) != 0) {
452@@ -1049,7 +1157,7 @@ alsa_stream_destroy(cubeb_stream * stm) 457@@ -1049,7 +1158,7 @@ alsa_stream_destroy(cubeb_stream * stm)
453 pthread_mutex_lock(&stm->mutex); 458 pthread_mutex_lock(&stm->mutex);
454 if (stm->pcm) { 459 if (stm->pcm) {
455 if (stm->state == DRAINING) { 460 if (stm->state == DRAINING) {
456- snd_pcm_drain(stm->pcm); 461- snd_pcm_drain(stm->pcm);
457+ WRAP(snd_pcm_drain)(stm->pcm); 462+ WRAP(snd_pcm_drain)(stm->pcm);
458 } 463 }
459 alsa_locked_pcm_close(stm->pcm); 464 alsa_locked_pcm_close(stm->pcm);
460 stm->pcm = NULL; 465 stm->pcm = NULL;
461@@ -1095,12 +1203,12 @@ alsa_get_max_channel_count(cubeb * ctx,  466@@ -1095,12 +1204,12 @@ alsa_get_max_channel_count(cubeb * ctx,
462  467
463 assert(stm); 468 assert(stm);
464  469
465- r = snd_pcm_hw_params_any(stm->pcm, hw_params); 470- r = snd_pcm_hw_params_any(stm->pcm, hw_params);
466+ r = WRAP(snd_pcm_hw_params_any)(stm->pcm, hw_params); 471+ r = WRAP(snd_pcm_hw_params_any)(stm->pcm, hw_params);
467 if (r < 0) { 472 if (r < 0) {
468 return CUBEB_ERROR; 473 return CUBEB_ERROR;
469 } 474 }
470  475
471- r = snd_pcm_hw_params_get_channels_max(hw_params, max_channels); 476- r = snd_pcm_hw_params_get_channels_max(hw_params, max_channels);
472+ r = WRAP(snd_pcm_hw_params_get_channels_max)(hw_params, max_channels); 477+ r = WRAP(snd_pcm_hw_params_get_channels_max)(hw_params, max_channels);
473 if (r < 0) { 478 if (r < 0) {
474 return CUBEB_ERROR; 479 return CUBEB_ERROR;
475 } 480 }
476@@ -1121,34 +1229,34 @@ alsa_get_preferred_sample_rate(cubeb * c 481@@ -1121,34 +1230,34 @@ alsa_get_preferred_sample_rate(cubeb * c
477  482
478 /* get a pcm, disabling resampling, so we get a rate the 483 /* get a pcm, disabling resampling, so we get a rate the
479 * hardware/dmix/pulse/etc. supports. */ 484 * hardware/dmix/pulse/etc. supports. */
480- r = snd_pcm_open(&pcm, CUBEB_ALSA_PCM_NAME, SND_PCM_STREAM_PLAYBACK, SND_PCM_NO_AUTO_RESAMPLE); 485- r = snd_pcm_open(&pcm, CUBEB_ALSA_PCM_NAME, SND_PCM_STREAM_PLAYBACK, SND_PCM_NO_AUTO_RESAMPLE);
481+ r = WRAP(snd_pcm_open)(&pcm, CUBEB_ALSA_PCM_NAME, SND_PCM_STREAM_PLAYBACK, SND_PCM_NO_AUTO_RESAMPLE); 486+ r = WRAP(snd_pcm_open)(&pcm, CUBEB_ALSA_PCM_NAME, SND_PCM_STREAM_PLAYBACK, SND_PCM_NO_AUTO_RESAMPLE);
482 if (r < 0) { 487 if (r < 0) {
483 return CUBEB_ERROR; 488 return CUBEB_ERROR;
484 } 489 }
485  490
486- r = snd_pcm_hw_params_any(pcm, hw_params); 491- r = snd_pcm_hw_params_any(pcm, hw_params);
487+ r = WRAP(snd_pcm_hw_params_any)(pcm, hw_params); 492+ r = WRAP(snd_pcm_hw_params_any)(pcm, hw_params);
488 if (r < 0) { 493 if (r < 0) {
489- snd_pcm_close(pcm); 494- snd_pcm_close(pcm);
@@ -506,56 +511,56 @@ $NetBSD: patch-media_libcubeb_src_cubeb_ @@ -506,56 +511,56 @@ $NetBSD: patch-media_libcubeb_src_cubeb_
506- r = snd_pcm_hw_params_set_rate_near(pcm, hw_params, rate, NULL); 511- r = snd_pcm_hw_params_set_rate_near(pcm, hw_params, rate, NULL);
507+ r = WRAP(snd_pcm_hw_params_set_rate_near)(pcm, hw_params, rate, NULL); 512+ r = WRAP(snd_pcm_hw_params_set_rate_near)(pcm, hw_params, rate, NULL);
508 if (r < 0) { 513 if (r < 0) {
509- snd_pcm_close(pcm); 514- snd_pcm_close(pcm);
510+ WRAP(snd_pcm_close)(pcm); 515+ WRAP(snd_pcm_close)(pcm);
511 return CUBEB_ERROR; 516 return CUBEB_ERROR;
512 } 517 }
513  518
514- snd_pcm_close(pcm); 519- snd_pcm_close(pcm);
515+ WRAP(snd_pcm_close)(pcm); 520+ WRAP(snd_pcm_close)(pcm);
516  521
517 return CUBEB_OK; 522 return CUBEB_OK;
518 } 523 }
519@@ -1181,10 +1289,10 @@ alsa_stream_start(cubeb_stream * stm) 524@@ -1181,10 +1290,10 @@ alsa_stream_start(cubeb_stream * stm)
520 pthread_mutex_lock(&stm->mutex); 525 pthread_mutex_lock(&stm->mutex);
521 /* Capture pcm must be started after initial setup/recover */ 526 /* Capture pcm must be started after initial setup/recover */
522 if (stm->stream_type == SND_PCM_STREAM_CAPTURE && 527 if (stm->stream_type == SND_PCM_STREAM_CAPTURE &&
523- snd_pcm_state(stm->pcm) == SND_PCM_STATE_PREPARED) { 528- snd_pcm_state(stm->pcm) == SND_PCM_STATE_PREPARED) {
524- snd_pcm_start(stm->pcm); 529- snd_pcm_start(stm->pcm);
525+ WRAP(snd_pcm_state)(stm->pcm) == SND_PCM_STATE_PREPARED) { 530+ WRAP(snd_pcm_state)(stm->pcm) == SND_PCM_STATE_PREPARED) {
526+ WRAP(snd_pcm_start)(stm->pcm); 531+ WRAP(snd_pcm_start)(stm->pcm);
527 } 532 }
528- snd_pcm_pause(stm->pcm, 0); 533- snd_pcm_pause(stm->pcm, 0);
529+ WRAP(snd_pcm_pause)(stm->pcm, 0); 534+ WRAP(snd_pcm_pause)(stm->pcm, 0);
530 gettimeofday(&stm->last_activity, NULL); 535 gettimeofday(&stm->last_activity, NULL);
531 pthread_mutex_unlock(&stm->mutex); 536 pthread_mutex_unlock(&stm->mutex);
532  537
533@@ -1224,7 +1332,7 @@ alsa_stream_stop(cubeb_stream * stm) 538@@ -1224,7 +1333,7 @@ alsa_stream_stop(cubeb_stream * stm)
534 pthread_mutex_unlock(&ctx->mutex); 539 pthread_mutex_unlock(&ctx->mutex);
535  540
536 pthread_mutex_lock(&stm->mutex); 541 pthread_mutex_lock(&stm->mutex);
537- snd_pcm_pause(stm->pcm, 1); 542- snd_pcm_pause(stm->pcm, 1);
538+ WRAP(snd_pcm_pause)(stm->pcm, 1); 543+ WRAP(snd_pcm_pause)(stm->pcm, 1);
539 pthread_mutex_unlock(&stm->mutex); 544 pthread_mutex_unlock(&stm->mutex);
540  545
541 return CUBEB_OK; 546 return CUBEB_OK;
542@@ -1240,8 +1348,8 @@ alsa_stream_get_position(cubeb_stream *  547@@ -1240,8 +1349,8 @@ alsa_stream_get_position(cubeb_stream *
543 pthread_mutex_lock(&stm->mutex); 548 pthread_mutex_lock(&stm->mutex);
544  549
545 delay = -1; 550 delay = -1;
546- if (snd_pcm_state(stm->pcm) != SND_PCM_STATE_RUNNING || 551- if (snd_pcm_state(stm->pcm) != SND_PCM_STATE_RUNNING ||
547- snd_pcm_delay(stm->pcm, &delay) != 0) { 552- snd_pcm_delay(stm->pcm, &delay) != 0) {
548+ if (WRAP(snd_pcm_state)(stm->pcm) != SND_PCM_STATE_RUNNING || 553+ if (WRAP(snd_pcm_state)(stm->pcm) != SND_PCM_STATE_RUNNING ||
549+ WRAP(snd_pcm_delay)(stm->pcm, &delay) != 0) { 554+ WRAP(snd_pcm_delay)(stm->pcm, &delay) != 0) {
550 *position = stm->last_position; 555 *position = stm->last_position;
551 pthread_mutex_unlock(&stm->mutex); 556 pthread_mutex_unlock(&stm->mutex);
552 return CUBEB_OK; 557 return CUBEB_OK;
553@@ -1266,7 +1374,7 @@ alsa_stream_get_latency(cubeb_stream * s 558@@ -1266,7 +1375,7 @@ alsa_stream_get_latency(cubeb_stream * s
554 snd_pcm_sframes_t delay; 559 snd_pcm_sframes_t delay;
555 /* This function returns the delay in frames until a frame written using 560 /* This function returns the delay in frames until a frame written using
556 snd_pcm_writei is sent to the DAC. The DAC delay should be < 1ms anyways. */ 561 snd_pcm_writei is sent to the DAC. The DAC delay should be < 1ms anyways. */
557- if (snd_pcm_delay(stm->pcm, &delay)) { 562- if (snd_pcm_delay(stm->pcm, &delay)) {
558+ if (WRAP(snd_pcm_delay)(stm->pcm, &delay)) { 563+ if (WRAP(snd_pcm_delay)(stm->pcm, &delay)) {
559 return CUBEB_ERROR; 564 return CUBEB_ERROR;
560 } 565 }
561  566