Ravenports generated: 11 May 2018 00:26
[ravenports.git] / bucket_E6 / rustless-firefox
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               rustless-firefox
4 VERSION=                52.7.3
5 REVISION=               1
6 KEYWORDS=               www
7 VARIANTS=               standard
8 SDESC[standard]=        Legacy web browser built without Rust compiler
9 HOMEPAGE=               https://www.mozilla.org/en-US/firefox/organizations/
10 CONTACT=                nobody
11
12 DOWNLOAD_GROUPS=        main
13 SITES[main]=            https://archive.mozilla.org/pub/firefox/releases/52.7.3esr/source/
14 DISTFILE[1]=            firefox-52.7.3esr.source.tar.xz:main
15 DF_INDEX=               1
16 SPKGS[standard]=        single
17
18 OPTIONS_AVAILABLE=      DBUS
19 OPTIONS_STANDARD=       DBUS
20 OPT_ON[all]=            DBUS
21
22 BUILD_DEPENDS=          python-sqlite3:single:py27
23                         video4linux:headers:standard
24                         autoconf213:single:standard
25                         bzip2:static:standard
26                         yasm:single:standard
27                         zip:single:standard
28 BUILDRUN_DEPENDS=       nss:primary:standard
29                         libevent:single:standard
30                         harfbuzz:primary:standard
31                         libvorbis:primary:standard
32                         libogg:primary:standard
33                         libvpx:single:standard
34                         libffi:single:standard
35                         sqlite:single:standard
36                         video4linux:primary:standard
37                         hunspell:single:standard
38                         icu:single:standard
39                         bzip2:shared:standard
40                         ffmpeg:primary:standard
41
42 USES=                   cpe gmake jpeg png pkgconfig zlib perl:build
43                         python:py27,build desktop-utils:single
44 GNOME_COMPONENTS=       gdkpixbuf gtk2 gtk3 gconf
45 XORG_COMPONENTS=        xcb pixman
46
47 DISTNAME=               firefox-52.7.3esr
48
49 CPE_VENDOR=             mozilla
50
51 MUST_CONFIGURE=         yes
52 CONFIGURE_OUTSOURCE=    yes
53
54 SUB_FILES=              firefox.desktop
55                         pkg-install-single
56                         pkg-deinstall-single
57 SUB_LIST=               FIREFOX_ICON=firefox.png
58                         MOZILLA=firefox
59                         MOZILLA_BIN=firefox-bin
60                         MOZILLA_NAME=Firefox
61                         MOZDIR={{PREFIX}}/lib/firefox
62
63 QMAKE_ARGS=             --prefix={{PREFIX:Q}}
64                         --disable-rust
65                         --disable-updater
66                         --disable-libproxy
67                         --disable-alsa
68                         --disable-jack
69                         --disable-pulseaudio
70                         --disable-debug
71                         --disable-debug-symbols
72                         --disable-dtrace
73                         --disable-profiling
74                         --disable-tests
75                         --disable-webrtc
76                         --enable-system-cairo
77                         --enable-system-ffi
78                         --enable-system-hunspell
79                         --enable-system-pixman
80                         --enable-system-sqlite
81                         --with-system-libevent
82                         --with-system-harfbuzz
83                         --with-system-graphite2
84                         --with-system-icu
85                         --with-system-nss
86                         --with-system-nspr
87                         --with-system-vorbis
88                         --with-system-ogg
89                         --with-system-libvpx
90                         --with-system-zlib
91                         --with-system-bz2
92                         --with-system-jpeg={{LOCALBASE}}
93                         --with-system-png={{LOCALBASE}}
94                         --with-intl-api
95                         --with-pthreads
96                         --enable-release
97                         --enable-chrome-format=omni
98                         --enable-default-toolkit=cairo-gtk3
99                         --enable-update-channel=esr
100                         --enable-optimize
101                         --enable-gconf
102                         --enable-pie
103                         --enable-strip
104                         --enable-install-strip
105                         --enable-application=browser
106                         --enable-official-branding
107 VAR_OPSYS[freebsd]=     CONFIGURE_ARGS=--enable-jemalloc=4
108
109 [DBUS].DESCRIPTION=                     D-Bus IPC system support
110 [DBUS].BUILDRUN_DEPENDS_ON=             dbus:single:standard
111                                         dbus-glib:primary:standard
112                                         startup-notification:single:standard
113                                         libnotify:primary:standard
114 [DBUS].QMAKE_ARGS_OFF=                  --disable-dbus
115 [DBUS].QMAKE_ARGS_ON=                   --enable-startup-notification
116
117 post-patch:
118         ${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \
119                 ${WRKSRC}/browser/app/nsBrowserApp.cpp
120         ${REINPLACE_CMD} -e 's|%%MOZILLA%%|firefox|g' \
121                 ${WRKSRC}/config/baseconfig.mk; \
122         ${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g ; \
123                 s|%%LOCALBASE%%|${LOCALBASE}|g' \
124                         ${WRKSRC}/build/unix/run-mozilla.sh
125         ${REINPLACE_CMD} -e 's|/usr/local/netscape|${LOCALBASE}|g ; \
126                 s|/usr/local/lib/netscape|${LOCALBASE}/lib|g' \
127                 ${WRKSRC}/xpcom/io/SpecialSystemDirectory.cpp
128         ${REINPLACE_CMD} -e 's|/etc|${PREFIX}&|g' \
129                 ${WRKSRC}/xpcom/build/nsXPCOMPrivate.h
130         ${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \
131                 -e 's|mozilla/plugins|browser_plugins|g' \
132                 -e 's|share/mozilla/extensions|lib/xpi|g' \
133                 ${WRKSRC}/xpcom/io/nsAppFileLocationProvider.cpp \
134                 ${WRKSRC}/toolkit/xre/nsXREDirProvider.cpp
135         ${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \
136                 ${WRKSRC}/extensions/spellcheck/hunspell/*/mozHunspell.cpp
137         ${REINPLACE_CMD} -Ee 's|-lc_r|-pthread|g ; \
138                         s|-l?pthread|-pthread|g ; \
139                         s|echo aout|echo elf|g ; \
140                         s|/usr/X11R6|${LOCALBASE}|g' \
141                 ${WRKSRC}/js/src/Makefile.in \
142                 ${WRKSRC}/js/src/configure \
143                 ${WRKSRC}/configure
144         ${REINPLACE_CMD} -Ee '/^MOZ_FIX_LINK_PATHS=/ s|"|"-Wl,-rpath,${PREFIX}/lib/firefox |' \
145                 ${WRKSRC}/js/src/old-configure.in \
146                 ${WRKSRC}/old-configure.in
147         # set configuration
148         for arg in ${QMAKE_ARGS} ; do \
149                 ${ECHO_CMD} ac_add_options $$arg >> ${WRKSRC}/.mozconfig ; \
150         done
151         ${ECHO_CMD} mk_add_options MOZ_OBJDIR="${BUILD_WRKSRC}" \
152                 >> ${WRKSRC}/.mozconfig
153         ${ECHO_CMD} export MOZ_OPTIMIZE_FLAGS="-O${OPTIMIZER_LEVEL}" \
154                 >> ${WRKSRC}/.mozconfig
155         ${ECHO_CMD} export PERL="${PERL}" >> ${WRKSRC}/.mozconfig
156
157 post-install:
158         @${MKDIR} ${STAGEDIR}${PREFIX}/share/pixmaps \
159                 ${STAGEDIR}${PREFIX}/share/applications
160         ${INSTALL_DATA} ${WRKDIR}/firefox.desktop \
161                 ${STAGEDIR}${PREFIX}/share/applications/
162         ${LN} -sf ${PREFIX}/lib/firefox/browser/chrome/icons/default/default48.png \
163                 ${STAGEDIR}${PREFIX}/share/pixmaps/firefox.png
164
165 pre-configure:
166         (cd ${WRKSRC} && ${LOCALBASE}/bin/autoconf-2.13)
167         (cd ${WRKSRC}/js/src/ && ${LOCALBASE}/bin/autoconf-2.13)
168
169 post-patch-freebsd:
170         ${ECHO_CMD} export MOZ_JEMALLOC4=1 >> ${WRKSRC}/.mozconfig
171         # API keys from www/chromium
172         # http://www.chromium.org/developers/how-tos/api-keys
173         # Note: these are for FreeBSD use ONLY. For another distribution,
174         # please obtain its key instead.
175         ${ECHO_CMD} export MOZ_GOOGLE_API_KEY=AIzaSyBsp9n41JLW8jCokwn7vhoaMejDFRd1mp8 \
176                 >> ${WRKSRC}/.mozconfig
177
178 [FILE:396:descriptions/desc.single]
179 Mozilla Firefox 52 is a fast, secure and easy to use web browser. It 
180 offers many advantages over other web browsers. This award-winning, open 
181 source web browser is packed with advanced security features designed to 
182 help you stay safe, and in control, online.
183
184 This is a legacy version with lots of active vulnerabilities.
185 It is the last Firefox that does not require a rust compiler to build.
186
187
188 [FILE:110:distinfo]
189 5cc68c1a7486cfbbf02aec0e9da9f87b55e7bfc68c7d5139bc1e578441aaf19f    213945524 firefox-52.7.3esr.source.tar.xz
190
191
192 [FILE:896:manifests/plist.single]
193 bin/firefox
194 lib/firefox/
195  application.ini
196  chrome.manifest
197  dependentlibs.list
198  firefox
199  firefox-bin
200  liblgpllibs.so
201  libmozavcodec.so
202  libmozavutil.so
203  libmozgtk.so
204  libxul.so
205  omni.ja
206  platform.ini
207  plugin-container
208  removed-files
209  run-mozilla.sh
210 lib/firefox/browser/
211  blocklist.xml
212  chrome.manifest
213  omni.ja
214 lib/firefox/browser/chrome/icons/default/
215  default16.png
216  default32.png
217  default48.png
218 lib/firefox/browser/extensions/{972ce4c6-7e08-4474-a285-3208198ce6fd}.xpi
219 lib/firefox/browser/features/
220  aushelper@mozilla.org.xpi
221  e10srollout@mozilla.org.xpi
222  firefox@getpocket.com.xpi
223  webcompat@mozilla.org.xpi
224 lib/firefox/browser/icons/mozicon128.png
225 lib/firefox/defaults/pref/channel-prefs.js
226 lib/firefox/dictionaries/
227  en-US.aff
228  en-US.dic
229 lib/firefox/gmp-clearkey/0.1/
230  clearkey.info
231  libclearkey.so
232 lib/firefox/gtk2/libmozgtk.so
233 share/applications/firefox.desktop
234 share/pixmaps/firefox.png
235
236
237 [FILE:445:patches/patch-browser-app-nsBrowserApp.cpp]
238 --- browser/app/nsBrowserApp.cpp.orig   2016-09-19 16:19:28 UTC
239 +++ browser/app/nsBrowserApp.cpp
240 @@ -324,6 +324,9 @@ int main(int argc, char* argv[], char* e
241  {
242    mozilla::TimeStamp start = mozilla::TimeStamp::Now();
243  
244 +  setenv("MOZ_GMP_PATH", "%%LOCALBASE%%/lib/browser_plugins/symlinks/gecko", 0);
245 +  setenv("MOZ_PLUGIN_PATH", "%%LOCALBASE%%/lib/browser_plugins/symlinks/gecko", 0);
246 +
247  #ifdef HAS_DLL_BLOCKLIST
248    DllBlocklist_Initialize();
249  
250
251
252 [FILE:35310:patches/patch-bug1021761]
253 diff --git build/moz.configure/old.configure build/moz.configure/old.configure
254 index b95dd2b..4cbefd5 100644
255 --- build/moz.configure/old.configure
256 +++ build/moz.configure/old.configure
257 @@ -305,6 +305,7 @@ def old_configure_options(*options):
258      '--with-nspr-prefix',
259      '--with-nss-exec-prefix',
260      '--with-nss-prefix',
261 +    '--with-oss',
262      '--with-pthreads',
263      '--with-qemu-exe',
264      '--with-servo',
265 diff --git old-configure.in configure.in
266 index 48e60c0..ec08417 100644
267 --- old-configure.in
268 +++ old-configure.in
269 @@ -5591,6 +5591,67 @@ fi
270  AC_SUBST(MOZ_WEBM_ENCODER)
271  
272  dnl ==================================
273 +dnl = Check OSS availability
274 +dnl ==================================
275 +
276 +dnl If using Linux, Solaris or BSDs, ensure that OSS is available
277 +case "$OS_TARGET" in
278 +Linux|SunOS|DragonFly|FreeBSD|NetBSD|GNU/kFreeBSD)
279 +    MOZ_OSS=1
280 +    ;;
281 +esac
282 +
283 +MOZ_ARG_WITH_STRING(oss,
284 +[  --with-oss[=PFX]        Enable OpenSoundSystem support [installed at prefix PFX]],
285 +   OSSPREFIX=$withval)
286 +
287 +if test -n "$OSSPREFIX"; then
288 +    if test "$OSSPREFIX" != "no"; then
289 +        MOZ_OSS=1
290 +    else
291 +        MOZ_OSS=
292 +    fi
293 +fi
294 +
295 +_SAVE_CFLAGS=$CFLAGS
296 +_SAVE_LIBS=$LIBS
297 +if test -n "$MOZ_OSS"; then
298 +    dnl Prefer 4Front implementation
299 +    AC_MSG_CHECKING([MOZ_OSS_CFLAGS])
300 +    if test "$OSSPREFIX" != "yes"; then
301 +        oss_conf=${OSSPREFIX%/usr}/etc/oss.conf
302 +        if test -f "$oss_conf"; then
303 +            . "$oss_conf"
304 +        else
305 +            OSSLIBDIR=$OSSPREFIX/lib/oss
306 +        fi
307 +        if test -d "$OSSLIBDIR"; then
308 +            MOZ_OSS_CFLAGS="$MOZ_OSS_CFLAGS -I$OSSLIBDIR/include"
309 +        fi
310 +    fi
311 +    AC_MSG_RESULT([$MOZ_OSS_CFLAGS])
312 +
313 +    CFLAGS="$CFLAGS $MOZ_OSS_CFLAGS"
314 +    MOZ_CHECK_HEADERS(sys/soundcard.h soundcard.h)
315 +
316 +    if test "$ac_cv_header_sys_soundcard_h" != "yes" -a \
317 +            "$ac_cv_header_soundcard_h" != "yes"; then
318 +        AC_MSG_ERROR([Need OSS for Ogg, Wave or WebM decoding on $OS_TARGET.  Disable with --without-oss.])
319 +    fi
320 +
321 +    dnl Assume NetBSD implementation over SunAudio
322 +    AC_CHECK_LIB(ossaudio, _oss_ioctl,
323 +        [AC_DEFINE_UNQUOTED(CUBEB_OSS_DEFAULT_OUTPUT, "/dev/sound")
324 +         MOZ_OSS_LIBS="$MOZ_OSS_LIBS -lossaudio"])
325 +fi
326 +CFLAGS=$_SAVE_CFLAGS
327 +LIBS=$_SAVE_LIBS
328 +
329 +AC_SUBST(MOZ_OSS)
330 +AC_SUBST_LIST(MOZ_OSS_CFLAGS)
331 +AC_SUBST_LIST(MOZ_OSS_LIBS)
332 +
333 +dnl ==================================
334  dnl = Check alsa availability on Linux
335  dnl ==================================
336  
337 diff --git media/libcubeb/AUTHORS media/libcubeb/AUTHORS
338 index b441e8a..950d9e5 100644
339 --- media/libcubeb/AUTHORS
340 +++ media/libcubeb/AUTHORS
341 @@ -4,3 +4,4 @@ Michael Wu <mwu@mozilla.com>
342  Paul Adenot <paul@paul.cx>
343  David Richards <drichards@mozilla.com>
344  Sebastien Alaiwan <sebastien.alaiwan@gmail.com>
345 +Evgeniy Vodolazskiy <waterlaz@gmail.com>
346 diff --git media/libcubeb/src/cubeb.c media/libcubeb/src/cubeb.c
347 index 9c3adcc..45d765b 100644
348 --- media/libcubeb/src/cubeb.c
349 +++ media/libcubeb/src/cubeb.c
350 @@ -54,6 +54,9 @@ int opensl_init(cubeb ** context, char const * context_name);
351  #if defined(USE_AUDIOTRACK)
352  int audiotrack_init(cubeb ** context, char const * context_name);
353  #endif
354 +#if defined(USE_OSS)
355 +int oss_init(cubeb ** context, char const * context_name);
356 +#endif
357  
358  int
359  validate_stream_params(cubeb_stream_params stream_params)
360 @@ -120,6 +123,9 @@ cubeb_init(cubeb ** context, char const * context_name)
361  #if defined(USE_AUDIOTRACK)
362      audiotrack_init,
363  #endif
364 +#if defined(USE_OSS)
365 +    oss_init,
366 +#endif
367    };
368    int i;
369  
370 diff --git media/libcubeb/src/cubeb_alsa.c media/libcubeb/src/cubeb_alsa.c
371 index a962553..1f780f4 100644
372 --- media/libcubeb/src/cubeb_alsa.c
373 +++ media/libcubeb/src/cubeb_alsa.c
374 @@ -11,6 +11,7 @@
375  #include <sys/time.h>
376  #include <assert.h>
377  #include <limits.h>
378 +#include <dlfcn.h>
379  #include <poll.h>
380  #include <unistd.h>
381  #include <alsa/asoundlib.h>
382 @@ -24,6 +25,50 @@
383  
384  #define ALSA_PA_PLUGIN "ALSA <-> PulseAudio PCM I/O Plugin"
385  
386 +#ifdef DISABLE_LIBASOUND_DLOPEN
387 +#define WRAP(x) x
388 +#else
389 +#define WRAP(x) cubeb_##x
390 +#define MAKE_TYPEDEF(x) static typeof(x) * cubeb_##x
391 +MAKE_TYPEDEF(snd_config);
392 +MAKE_TYPEDEF(snd_config_add);
393 +MAKE_TYPEDEF(snd_config_copy);
394 +MAKE_TYPEDEF(snd_config_delete);
395 +MAKE_TYPEDEF(snd_config_get_id);
396 +MAKE_TYPEDEF(snd_config_get_string);
397 +MAKE_TYPEDEF(snd_config_imake_integer);
398 +MAKE_TYPEDEF(snd_config_search);
399 +MAKE_TYPEDEF(snd_config_search_definition);
400 +MAKE_TYPEDEF(snd_lib_error_set_handler);
401 +MAKE_TYPEDEF(snd_pcm_avail_update);
402 +MAKE_TYPEDEF(snd_pcm_close);
403 +MAKE_TYPEDEF(snd_pcm_delay);
404 +MAKE_TYPEDEF(snd_pcm_drain);
405 +MAKE_TYPEDEF(snd_pcm_frames_to_bytes);
406 +MAKE_TYPEDEF(snd_pcm_get_params);
407 +/* snd_pcm_hw_params_alloca is actually a macro */
408 +/* MAKE_TYPEDEF(snd_pcm_hw_params_alloca); */
409 +MAKE_TYPEDEF(snd_pcm_hw_params_sizeof);
410 +#define snd_pcm_hw_params_sizeof cubeb_snd_pcm_hw_params_sizeof
411 +MAKE_TYPEDEF(snd_pcm_hw_params_any);
412 +MAKE_TYPEDEF(snd_pcm_hw_params_get_channels_max);
413 +MAKE_TYPEDEF(snd_pcm_hw_params_get_rate);
414 +MAKE_TYPEDEF(snd_pcm_hw_params_set_rate_near);
415 +MAKE_TYPEDEF(snd_pcm_nonblock);
416 +MAKE_TYPEDEF(snd_pcm_open);
417 +MAKE_TYPEDEF(snd_pcm_open_lconf);
418 +MAKE_TYPEDEF(snd_pcm_pause);
419 +MAKE_TYPEDEF(snd_pcm_poll_descriptors);
420 +MAKE_TYPEDEF(snd_pcm_poll_descriptors_count);
421 +MAKE_TYPEDEF(snd_pcm_poll_descriptors_revents);
422 +MAKE_TYPEDEF(snd_pcm_recover);
423 +MAKE_TYPEDEF(snd_pcm_set_params);
424 +MAKE_TYPEDEF(snd_pcm_state);
425 +MAKE_TYPEDEF(snd_pcm_writei);
426 +
427 +#undef MAKE_TYPEDEF
428 +#endif
429 +
430  /* ALSA is not thread-safe.  snd_pcm_t instances are individually protected
431     by the owning cubeb_stream's mutex.  snd_pcm_t creation and destruction
432     is not thread-safe until ALSA 1.0.24 (see alsa-lib.git commit 91c9c8f1),
433 @@ -64,6 +109,8 @@ struct cubeb {
434       workaround is not required. */
435    snd_config_t * local_config;
436    int is_pa;
437 +
438 +  void * libasound;
439  };
440  
441  enum stream_state {
442 @@ -260,10 +307,10 @@ alsa_refill_stream(cubeb_stream * stm)
443  
444    pthread_mutex_lock(&stm->mutex);
445  
446 -  avail = snd_pcm_avail_update(stm->pcm);
447 +  avail = WRAP(snd_pcm_avail_update)(stm->pcm);
448    if (avail < 0) {
449 -    snd_pcm_recover(stm->pcm, avail, 1);
450 -    avail = snd_pcm_avail_update(stm->pcm);
451 +    WRAP(snd_pcm_recover)(stm->pcm, avail, 1);
452 +    avail = WRAP(snd_pcm_avail_update)(stm->pcm);
453    }
454  
455    /* Failed to recover from an xrun, this stream must be broken. */
456 @@ -286,7 +333,7 @@ alsa_refill_stream(cubeb_stream * stm)
457      return RUNNING;
458    }
459  
460 -  p = calloc(1, snd_pcm_frames_to_bytes(stm->pcm, avail));
461 +  p = calloc(1, WRAP(snd_pcm_frames_to_bytes)(stm->pcm, avail));
462    assert(p);
463  
464    pthread_mutex_unlock(&stm->mutex);
465 @@ -312,10 +359,10 @@ alsa_refill_stream(cubeb_stream * stm)
466          b[i] *= stm->volume;
467        }
468      }
469 -    wrote = snd_pcm_writei(stm->pcm, p, got);
470 +    wrote = WRAP(snd_pcm_writei)(stm->pcm, p, got);
471      if (wrote < 0) {
472 -      snd_pcm_recover(stm->pcm, wrote, 1);
473 -      wrote = snd_pcm_writei(stm->pcm, p, got);
474 +      WRAP(snd_pcm_recover)(stm->pcm, wrote, 1);
475 +      wrote = WRAP(snd_pcm_writei)(stm->pcm, p, got);
476      }
477      assert(wrote >= 0 && wrote == got);
478      stm->write_position += wrote;
479 @@ -342,7 +389,7 @@ alsa_refill_stream(cubeb_stream * stm)
480  
481      /* Fill the remaining buffer with silence to guarantee one full period
482         has been written. */
483 -    snd_pcm_writei(stm->pcm, (char *) p + got, avail - got);
484 +    WRAP(snd_pcm_writei)(stm->pcm, (char *) p + got, avail - got);
485  
486      set_timeout(&stm->drain_timeout, buffer_time * 1000);
487  
488 @@ -453,26 +500,26 @@ get_slave_pcm_node(snd_config_t * lconf, snd_config_t * root_pcm)
489  
490    slave_def = NULL;
491  
492 -  r = snd_config_search(root_pcm, "slave", &slave_pcm);
493 +  r = WRAP(snd_config_search)(root_pcm, "slave", &slave_pcm);
494    if (r < 0) {
495      return NULL;
496    }
497  
498 -  r = snd_config_get_string(slave_pcm, &string);
499 +  r = WRAP(snd_config_get_string)(slave_pcm, &string);
500    if (r >= 0) {
501 -    r = snd_config_search_definition(lconf, "pcm_slave", string, &slave_def);
502 +    r = WRAP(snd_config_search_definition)(lconf, "pcm_slave", string, &slave_def);
503      if (r < 0) {
504        return NULL;
505      }
506    }
507  
508    do {
509 -    r = snd_config_search(slave_def ? slave_def : slave_pcm, "pcm", &pcm);
510 +    r = WRAP(snd_config_search)(slave_def ? slave_def : slave_pcm, "pcm", &pcm);
511      if (r < 0) {
512        break;
513      }
514  
515 -    r = snd_config_get_string(slave_def ? slave_def : slave_pcm, &string);
516 +    r = WRAP(snd_config_get_string)(slave_def ? slave_def : slave_pcm, &string);
517      if (r < 0) {
518        break;
519      }
520 @@ -481,7 +528,7 @@ get_slave_pcm_node(snd_config_t * lconf, snd_config_t * root_pcm)
521      if (r < 0 || r > (int) sizeof(node_name)) {
522        break;
523      }
524 -    r = snd_config_search(lconf, node_name, &pcm);
525 +    r = WRAP(snd_config_search)(lconf, node_name, &pcm);
526      if (r < 0) {
527        break;
528      }
529 @@ -490,7 +537,7 @@ get_slave_pcm_node(snd_config_t * lconf, snd_config_t * root_pcm)
530    } while (0);
531  
532    if (slave_def) {
533 -    snd_config_delete(slave_def);
534 +    WRAP(snd_config_delete)(slave_def);
535    }
536  
537    return NULL;
538 @@ -513,22 +560,22 @@ init_local_config_with_workaround(char const * pcm_name)
539  
540    lconf = NULL;
541  
542 -  if (snd_config == NULL) {
543 +  if (*WRAP(snd_config) == NULL) {
544      return NULL;
545    }
546  
547 -  r = snd_config_copy(&lconf, snd_config);
548 +  r = WRAP(snd_config_copy)(&lconf, *WRAP(snd_config));
549    if (r < 0) {
550      return NULL;
551    }
552  
553    do {
554 -    r = snd_config_search_definition(lconf, "pcm", pcm_name, &pcm_node);
555 +    r = WRAP(snd_config_search_definition)(lconf, "pcm", pcm_name, &pcm_node);
556      if (r < 0) {
557        break;
558      }
559  
560 -    r = snd_config_get_id(pcm_node, &string);
561 +    r = WRAP(snd_config_get_id)(pcm_node, &string);
562      if (r < 0) {
563        break;
564      }
565 @@ -537,7 +584,7 @@ init_local_config_with_workaround(char const * pcm_name)
566      if (r < 0 || r > (int) sizeof(node_name)) {
567        break;
568      }
569 -    r = snd_config_search(lconf, node_name, &pcm_node);
570 +    r = WRAP(snd_config_search)(lconf, node_name, &pcm_node);
571      if (r < 0) {
572        break;
573      }
574 @@ -548,12 +595,12 @@ init_local_config_with_workaround(char const * pcm_name)
575      }
576  
577      /* Fetch the PCM node's type, and bail out if it's not the PulseAudio plugin. */
578 -    r = snd_config_search(pcm_node, "type", &node);
579 +    r = WRAP(snd_config_search)(pcm_node, "type", &node);
580      if (r < 0) {
581        break;
582      }
583  
584 -    r = snd_config_get_string(node, &string);
585 +    r = WRAP(snd_config_get_string)(node, &string);
586      if (r < 0) {
587        break;
588      }
589 @@ -564,18 +611,18 @@ init_local_config_with_workaround(char const * pcm_name)
590  
591      /* Don't clobber an explicit existing handle_underrun value, set it only
592         if it doesn't already exist. */
593 -    r = snd_config_search(pcm_node, "handle_underrun", &node);
594 +    r = WRAP(snd_config_search)(pcm_node, "handle_underrun", &node);
595      if (r != -ENOENT) {
596        break;
597      }
598  
599      /* Disable pcm_pulse's asynchronous underrun handling. */
600 -    r = snd_config_imake_integer(&node, "handle_underrun", 0);
601 +    r = WRAP(snd_config_imake_integer)(&node, "handle_underrun", 0);
602      if (r < 0) {
603        break;
604      }
605  
606 -    r = snd_config_add(pcm_node, node);
607 +    r = WRAP(snd_config_add)(pcm_node, node);
608      if (r < 0) {
609        break;
610      }
611 @@ -583,7 +630,7 @@ init_local_config_with_workaround(char const * pcm_name)
612      return lconf;
613    } while (0);
614  
615 -  snd_config_delete(lconf);
616 +  WRAP(snd_config_delete)(lconf);
617  
618    return NULL;
619  }
620 @@ -595,9 +642,9 @@ alsa_locked_pcm_open(snd_pcm_t ** pcm, snd_pcm_stream_t stream, snd_config_t * l
621  
622    pthread_mutex_lock(&cubeb_alsa_mutex);
623    if (local_config) {
624 -    r = snd_pcm_open_lconf(pcm, CUBEB_ALSA_PCM_NAME, stream, SND_PCM_NONBLOCK, local_config);
625 +    r = WRAP(snd_pcm_open_lconf)(pcm, CUBEB_ALSA_PCM_NAME, stream, SND_PCM_NONBLOCK, local_config);
626    } else {
627 -    r = snd_pcm_open(pcm, CUBEB_ALSA_PCM_NAME, stream, SND_PCM_NONBLOCK);
628 +    r = WRAP(snd_pcm_open)(pcm, CUBEB_ALSA_PCM_NAME, stream, SND_PCM_NONBLOCK);
629    }
630    pthread_mutex_unlock(&cubeb_alsa_mutex);
631  
632 @@ -610,7 +657,7 @@ alsa_locked_pcm_close(snd_pcm_t * pcm)
633    int r;
634  
635    pthread_mutex_lock(&cubeb_alsa_mutex);
636 -  r = snd_pcm_close(pcm);
637 +  r = WRAP(snd_pcm_close)(pcm);
638    pthread_mutex_unlock(&cubeb_alsa_mutex);
639  
640    return r;
641 @@ -667,12 +714,65 @@ alsa_init(cubeb ** context, char const * context_name)
642    pthread_attr_t attr;
643    snd_pcm_t * dummy;
644  
645 +  void * libasound = NULL;
646 +
647 +#ifndef DISABLE_LIBASOUND_DLOPEN
648 +  libasound = dlopen("libasound.so", RTLD_LAZY);
649 +  if (!libasound) {
650 +    return CUBEB_ERROR;
651 +  }
652 +
653 +#define LOAD(x) do { \
654 +    cubeb_##x = dlsym(libasound, #x); \
655 +    if (!cubeb_##x) { \
656 +      dlclose(libasound); \
657 +      return CUBEB_ERROR; \
658 +    } \
659 +  } while(0)
660 +
661 +  LOAD(snd_config);
662 +  LOAD(snd_config_add);
663 +  LOAD(snd_config_copy);
664 +  LOAD(snd_config_delete);
665 +  LOAD(snd_config_get_id);
666 +  LOAD(snd_config_get_string);
667 +  LOAD(snd_config_imake_integer);
668 +  LOAD(snd_config_search);
669 +  LOAD(snd_config_search_definition);
670 +  LOAD(snd_lib_error_set_handler);
671 +  LOAD(snd_pcm_avail_update);
672 +  LOAD(snd_pcm_close);
673 +  LOAD(snd_pcm_delay);
674 +  LOAD(snd_pcm_drain);
675 +  LOAD(snd_pcm_frames_to_bytes);
676 +  LOAD(snd_pcm_get_params);
677 +  /* snd_pcm_hw_params_alloca is actually a macro */
678 +  /* LOAD(snd_pcm_hw_params_alloca); */
679 +  LOAD(snd_pcm_hw_params_sizeof);
680 +  LOAD(snd_pcm_hw_params_any);
681 +  LOAD(snd_pcm_hw_params_get_channels_max);
682 +  LOAD(snd_pcm_hw_params_get_rate);
683 +  LOAD(snd_pcm_hw_params_set_rate_near);
684 +  LOAD(snd_pcm_nonblock);
685 +  LOAD(snd_pcm_open);
686 +  LOAD(snd_pcm_open_lconf);
687 +  LOAD(snd_pcm_pause);
688 +  LOAD(snd_pcm_poll_descriptors);
689 +  LOAD(snd_pcm_poll_descriptors_count);
690 +  LOAD(snd_pcm_poll_descriptors_revents);
691 +  LOAD(snd_pcm_recover);
692 +  LOAD(snd_pcm_set_params);
693 +  LOAD(snd_pcm_state);
694 +  LOAD(snd_pcm_writei);
695 +
696 +#undef LOAD
697 +#endif
698    assert(context);
699    *context = NULL;
700  
701    pthread_mutex_lock(&cubeb_alsa_mutex);
702    if (!cubeb_alsa_error_handler_set) {
703 -    snd_lib_error_set_handler(silent_error_handler);
704 +    WRAP(snd_lib_error_set_handler)(silent_error_handler);
705      cubeb_alsa_error_handler_set = 1;
706    }
707    pthread_mutex_unlock(&cubeb_alsa_mutex);
708 @@ -680,6 +780,8 @@ alsa_init(cubeb ** context, char const * context_name)
709    ctx = calloc(1, sizeof(*ctx));
710    assert(ctx);
711  
712 +  ctx->libasound = libasound;
713 +
714    ctx->ops = &alsa_ops;
715  
716    r = pthread_mutex_init(&ctx->mutex, NULL);
717 @@ -729,7 +831,7 @@ alsa_init(cubeb ** context, char const * context_name)
718         config fails with EINVAL, the PA PCM is too old for this workaround. */
719      if (r == -EINVAL) {
720        pthread_mutex_lock(&cubeb_alsa_mutex);
721 -      snd_config_delete(ctx->local_config);
722 +      WRAP(snd_config_delete)(ctx->local_config);
723        pthread_mutex_unlock(&cubeb_alsa_mutex);
724        ctx->local_config = NULL;
725      } else if (r >= 0) {
726 @@ -768,9 +870,13 @@ alsa_destroy(cubeb * ctx)
727    pthread_mutex_destroy(&ctx->mutex);
728    free(ctx->fds);
729  
730 +  if (ctx->libasound) {
731 +    dlclose(ctx->libasound);
732 +  }
733 +
734    if (ctx->local_config) {
735      pthread_mutex_lock(&cubeb_alsa_mutex);
736 -    snd_config_delete(ctx->local_config);
737 +    WRAP(snd_config_delete)(ctx->local_config);
738      pthread_mutex_unlock(&cubeb_alsa_mutex);
739    }
740  
741 @@ -838,7 +944,7 @@ alsa_stream_init(cubeb * ctx, cubeb_stream ** stream, char const * stream_name,
742      return CUBEB_ERROR;
743    }
744  
745 -  r = snd_pcm_nonblock(stm->pcm, 1);
746 +  r = WRAP(snd_pcm_nonblock)(stm->pcm, 1);
747    assert(r == 0);
748  
749    latency_us = latency_frames * 1e6 / stm->params.rate;
750 @@ -855,7 +961,7 @@ alsa_stream_init(cubeb * ctx, cubeb_stre
751      latency_us = latency_us < min_latency ? min_latency: latency_us;
752    }
753  
754 -  r = snd_pcm_set_params(stm->pcm, format, SND_PCM_ACCESS_RW_INTERLEAVED,
755 +  r = WRAP(snd_pcm_set_params)(stm->pcm, format, SND_PCM_ACCESS_RW_INTERLEAVED,
756                           stm->params.channels, stm->params.rate, 1,
757                           latency_us);
758    if (r < 0) {
759 @@ -867,15 +973,15 @@ alsa_stream_init(cubeb * ctx, cubeb_stre
760      return CUBEB_ERROR_INVALID_FORMAT;
761    }
762  
763 -  r = snd_pcm_get_params(stm->pcm, &stm->buffer_size, &period_size);
764 +  r = WRAP(snd_pcm_get_params)(stm->pcm, &stm->buffer_size, &period_size);
765    assert(r == 0);
766  
767 -  stm->nfds = snd_pcm_poll_descriptors_count(stm->pcm);
768 +  stm->nfds = WRAP(snd_pcm_poll_descriptors_count)(stm->pcm);
769    assert(stm->nfds > 0);
770  
771    stm->saved_fds = calloc(stm->nfds, sizeof(struct pollfd));
772    assert(stm->saved_fds);
773 -  r = snd_pcm_poll_descriptors(stm->pcm, stm->saved_fds, stm->nfds);
774 +  r = WRAP(snd_pcm_poll_descriptors)(stm->pcm, stm->saved_fds, stm->nfds);
775    assert((nfds_t) r == stm->nfds);
776  
777    r = pthread_cond_init(&stm->cond, NULL);
778 @@ -895,7 +1001,7 @@ alsa_stream_destroy(cubeb_stream * stm)
779    pthread_mutex_lock(&stm->mutex);
780    if (stm->pcm) {
781      if (stm->state == DRAINING) {
782 -      snd_pcm_drain(stm->pcm);
783 +      WRAP(snd_pcm_drain)(stm->pcm);
784      }
785      alsa_locked_pcm_close(stm->pcm);
786      stm->pcm = NULL;
787 @@ -938,12 +1044,12 @@ alsa_get_max_channel_count(cubeb * ctx, uint32_t * max_channels)
788      return CUBEB_ERROR;
789    }
790  
791 -  r = snd_pcm_hw_params_any(stm->pcm, hw_params);
792 +  r = WRAP(snd_pcm_hw_params_any)(stm->pcm, hw_params);
793    if (r < 0) {
794      return CUBEB_ERROR;
795    }
796  
797 -  r = snd_pcm_hw_params_get_channels_max(hw_params, max_channels);
798 +  r = WRAP(snd_pcm_hw_params_get_channels_max)(hw_params, max_channels);
799    if (r < 0) {
800      return CUBEB_ERROR;
801    }
802 @@ -969,34 +1075,34 @@ alsa_get_preferred_sample_rate(cubeb * c
803  
804    /* get a pcm, disabling resampling, so we get a rate the
805     * hardware/dmix/pulse/etc. supports. */
806 -  r = snd_pcm_open(&pcm, CUBEB_ALSA_PCM_NAME, SND_PCM_STREAM_PLAYBACK, SND_PCM_NO_AUTO_RESAMPLE);
807 +  r = WRAP(snd_pcm_open)(&pcm, CUBEB_ALSA_PCM_NAME, SND_PCM_STREAM_PLAYBACK, SND_PCM_NO_AUTO_RESAMPLE);
808    if (r < 0) {
809      return CUBEB_ERROR;
810    }
811  
812 -  r = snd_pcm_hw_params_any(pcm, hw_params);
813 +  r = WRAP(snd_pcm_hw_params_any)(pcm, hw_params);
814    if (r < 0) {
815 -    snd_pcm_close(pcm);
816 +    WRAP(snd_pcm_close)(pcm);
817      return CUBEB_ERROR;
818    }
819  
820 -  r = snd_pcm_hw_params_get_rate(hw_params, rate, &dir);
821 +  r = WRAP(snd_pcm_hw_params_get_rate)(hw_params, rate, &dir);
822    if (r >= 0) {
823      /* There is a default rate: use it. */
824 -    snd_pcm_close(pcm);
825 +    WRAP(snd_pcm_close)(pcm);
826      return CUBEB_OK;
827    }
828  
829    /* Use a common rate, alsa may adjust it based on hw/etc. capabilities. */
830    *rate = 44100;
831  
832 -  r = snd_pcm_hw_params_set_rate_near(pcm, hw_params, rate, NULL);
833 +  r = WRAP(snd_pcm_hw_params_set_rate_near)(pcm, hw_params, rate, NULL);
834    if (r < 0) {
835 -    snd_pcm_close(pcm);
836 +    WRAP(snd_pcm_close)(pcm);
837      return CUBEB_ERROR;
838    }
839  
840 -  snd_pcm_close(pcm);
841 +  WRAP(snd_pcm_close)(pcm);
842  
843    return CUBEB_OK;
844  }
845 @@ -1013,7 +1119,7 @@ alsa_stream_start(cubeb_stream * stm)
846    ctx = stm->context;
847  
848    pthread_mutex_lock(&stm->mutex);
849 -  snd_pcm_pause(stm->pcm, 0);
850 +  WRAP(snd_pcm_pause)(stm->pcm, 0);
851    gettimeofday(&stm->last_activity, NULL);
852    pthread_mutex_unlock(&stm->mutex);
853  
854 @@ -1047,7 +1153,7 @@ alsa_stream_stop(cubeb_stream * stm)
855    pthread_mutex_unlock(&ctx->mutex);
856  
857    pthread_mutex_lock(&stm->mutex);
858 -  snd_pcm_pause(stm->pcm, 1);
859 +  WRAP(snd_pcm_pause)(stm->pcm, 1);
860    pthread_mutex_unlock(&stm->mutex);
861  
862    return CUBEB_OK;
863 @@ -1063,8 +1169,8 @@ alsa_stream_get_position(cubeb_stream * stm, uint64_t * position)
864    pthread_mutex_lock(&stm->mutex);
865  
866    delay = -1;
867 -  if (snd_pcm_state(stm->pcm) != SND_PCM_STATE_RUNNING ||
868 -      snd_pcm_delay(stm->pcm, &delay) != 0) {
869 +  if (WRAP(snd_pcm_state)(stm->pcm) != SND_PCM_STATE_RUNNING ||
870 +      WRAP(snd_pcm_delay)(stm->pcm, &delay) != 0) {
871      *position = stm->last_position;
872      pthread_mutex_unlock(&stm->mutex);
873      return CUBEB_OK;
874 @@ -1089,7 +1195,7 @@ alsa_stream_get_latency(cubeb_stream * stm, uint32_t * latency)
875    snd_pcm_sframes_t delay;
876    /* This function returns the delay in frames until a frame written using
877       snd_pcm_writei is sent to the DAC. The DAC delay should be < 1ms anyways. */
878 -  if (snd_pcm_delay(stm->pcm, &delay)) {
879 +  if (WRAP(snd_pcm_delay)(stm->pcm, &delay)) {
880      return CUBEB_ERROR;
881    }
882  
883 diff --git media/libcubeb/src/cubeb_oss.c media/libcubeb/src/cubeb_oss.c
884 new file mode 100644
885 index 0000000..5e38e27
886 --- /dev/null
887 +++ media/libcubeb/src/cubeb_oss.c
888 @@ -0,0 +1,442 @@
889 +/*
890 + * Copyright © 2014 Mozilla Foundation
891 + *
892 + * This program is made available under an ISC-style license.  See the
893 + * accompanying file LICENSE for details.
894 + */
895 +#if defined(HAVE_SYS_SOUNDCARD_H)
896 +#include <sys/soundcard.h>
897 +#else
898 +#include <soundcard.h>
899 +#endif
900 +#include <unistd.h>
901 +#include <stdlib.h>
902 +#include <sys/types.h>
903 +#include <sys/stat.h>
904 +#include <fcntl.h>
905 +#include <sys/ioctl.h>
906 +#include <errno.h>
907 +#include <pthread.h>
908 +#include <stdio.h>
909 +#include <assert.h>
910 +
911 +#include "cubeb/cubeb.h"
912 +#include "cubeb-internal.h"
913 +
914 +#ifndef CUBEB_OSS_DEFAULT_OUTPUT
915 +#define CUBEB_OSS_DEFAULT_OUTPUT "/dev/dsp"
916 +#endif
917 +
918 +#define OSS_BUFFER_SIZE 1024
919 +
920 +struct cubeb {
921 +  struct cubeb_ops const * ops;
922 +};
923 +
924 +struct cubeb_stream {
925 +  cubeb * context;
926 +
927 +  cubeb_data_callback data_callback;
928 +  cubeb_state_callback state_callback;
929 +  void * user_ptr;
930 +  float volume;
931 +  float panning;
932 +
933 +  pthread_mutex_t state_mutex;
934 +  pthread_cond_t state_cond;
935 +
936 +  int running;
937 +  int stopped;
938 +  int floating;
939 +
940 +  /* These two vars are needed to support old versions of OSS */
941 +  unsigned int position_bytes;
942 +  unsigned int last_position_bytes;
943 +
944 +  uint64_t written_frags; /* The number of fragments written to /dev/dsp */
945 +  uint64_t missed_frags; /* fragments output with stopped stream */
946 +
947 +  cubeb_stream_params params;
948 +  int fd;
949 +  pthread_t th;
950 +};
951 +
952 +static struct cubeb_ops const oss_ops;
953 +
954 +int oss_init(cubeb ** context, char const * context_name)
955 +{
956 +  cubeb* ctx = (cubeb*)malloc(sizeof(cubeb));
957 +  ctx->ops = &oss_ops;
958 +  *context = ctx;
959 +  return CUBEB_OK;
960 +}
961 +
962 +static void oss_destroy(cubeb *ctx)
963 +{
964 +  free(ctx);
965 +}
966 +
967 +static char const * oss_get_backend_id(cubeb * context)
968 +{
969 +  static char oss_name[] = "oss";
970 +  return oss_name;
971 +}
972 +
973 +static int oss_get_max_channel_count(cubeb * ctx, uint32_t * max_channels)
974 +{
975 +  *max_channels = 2; /* Let's support only stereo for now */
976 +  return CUBEB_OK;
977 +}
978 +
979 +static int oss_get_min_latency(cubeb * context, cubeb_stream_params params,
980 +                               uint32_t * latency_ms)
981 +{
982 +  /* 40ms is a big enough number to work ok */
983 +  *latency_ms = 40;
984 +  return CUBEB_OK;
985 +}
986 +
987 +static int oss_get_preferred_sample_rate(cubeb *context, uint32_t * rate)
988 +{
989 +  /* 48000 seems a prefered choice for most audio devices
990 +   * and a good choice for OSS */
991 +  *rate = 48000;
992 +  return CUBEB_OK;
993 +}
994 +
995 +static void run_state_callback(cubeb_stream *stream, cubeb_state state)
996 +{
997 +  if (stream->state_callback) {
998 +    stream->state_callback(stream, stream->user_ptr, state);
999 +  }
1000 +}
1001 +
1002 +static long run_data_callback(cubeb_stream *stream, void *buffer, long nframes)
1003 +{
1004 +  long got = 0;
1005 +  pthread_mutex_lock(&stream->state_mutex);
1006 +  if (stream->data_callback && stream->running && !stream->stopped) {
1007 +    pthread_mutex_unlock(&stream->state_mutex);
1008 +    got = stream->data_callback(stream, stream->user_ptr, NULL, buffer, nframes);
1009 +  } else {
1010 +    pthread_mutex_unlock(&stream->state_mutex);
1011 +  }
1012 +  return got;
1013 +}
1014 +
1015 +static void apply_volume_int(int16_t* buffer, unsigned int n,
1016 +                             float volume, float panning)
1017 +{
1018 +  float left = volume;
1019 +  float right = volume;
1020 +  unsigned int i;
1021 +  int pan[2];
1022 +  if (panning<0) {
1023 +    right *= (1+panning);
1024 +  } else {
1025 +    left *= (1-panning);
1026 +  }
1027 +  pan[0] = 128.0*left;
1028 +  pan[1] = 128.0*right;
1029 +  for(i=0; i<n; i++){
1030 +    buffer[i] = ((int)buffer[i])*pan[i%2]/128;
1031 +  }
1032 +}
1033 +
1034 +static void apply_volume_float(float* buffer, unsigned int n,
1035 +                               float volume, float panning)
1036 +{
1037 +  float left = volume;
1038 +  float right = volume;
1039 +  unsigned int i;
1040 +  float pan[2];
1041 +  if (panning<0) {
1042 +    right *= (1+panning);
1043 +  } else {
1044 +    left *= (1-panning);
1045 +  }
1046 +  pan[0] = left;
1047 +  pan[1] = right;
1048 +  for(i=0; i<n; i++){
1049 +    buffer[i] = buffer[i]*pan[i%2];
1050 +  }
1051 +}
1052 +
1053 +
1054 +static void *writer(void *stm)
1055 +{
1056 +  cubeb_stream* stream = (cubeb_stream*)stm;
1057 +  int16_t buffer[OSS_BUFFER_SIZE];
1058 +  float f_buffer[OSS_BUFFER_SIZE];
1059 +  int got;
1060 +  unsigned long i;
1061 +  while (stream->running) {
1062 +    pthread_mutex_lock(&stream->state_mutex);
1063 +    if (stream->stopped) {
1064 +      pthread_mutex_unlock(&stream->state_mutex);
1065 +      run_state_callback(stream, CUBEB_STATE_STOPPED);
1066 +      pthread_mutex_lock(&stream->state_mutex);
1067 +      while (stream->stopped) {
1068 +        pthread_cond_wait(&stream->state_cond, &stream->state_mutex);
1069 +      }
1070 +      pthread_mutex_unlock(&stream->state_mutex);
1071 +      run_state_callback(stream, CUBEB_STATE_STARTED);
1072 +      continue;
1073 +    }
1074 +    pthread_mutex_unlock(&stream->state_mutex);
1075 +    if (stream->floating) {
1076 +      got = run_data_callback(stream, f_buffer,
1077 +                              OSS_BUFFER_SIZE/stream->params.channels);
1078 +      apply_volume_float(f_buffer, got*stream->params.channels,
1079 +                                   stream->volume, stream->panning);
1080 +      for (i=0; i<((unsigned long)got)*stream->params.channels; i++) {
1081 +        /* Clipping is prefered to overflow */
1082 +       if(f_buffer[i]>=1.0){
1083 +         f_buffer[i]=1.0;
1084 +       }
1085 +        if(f_buffer[i]<=-1.0){
1086 +         f_buffer[i]=-1.0;
1087 +       }
1088 +        /* One might think that multipling by 32767.0 is logical but results in clipping */
1089 +        buffer[i] = f_buffer[i]*32767.0;
1090 +      }
1091 +    } else {
1092 +      got = run_data_callback(stream, buffer,
1093 +                              OSS_BUFFER_SIZE/stream->params.channels);
1094 +      apply_volume_int(buffer, got*stream->params.channels,
1095 +                               stream->volume, stream->panning);
1096 +    }
1097 +    if (got<0) {
1098 +      run_state_callback(stream, CUBEB_STATE_ERROR);
1099 +      break;
1100 +    }
1101 +    if (!got) {
1102 +      run_state_callback(stream, CUBEB_STATE_DRAINED);
1103 +    }
1104 +    if (got) {
1105 +      size_t i = 0;
1106 +      size_t s = got*stream->params.channels*sizeof(int16_t);
1107 +      while (i < s) {
1108 +        ssize_t n = write(stream->fd, ((char*)buffer) + i, s - i);
1109 +        if (n<=0) {
1110 +          run_state_callback(stream, CUBEB_STATE_ERROR);
1111 +          break;
1112 +        }
1113 +        i+=n;
1114 +      }
1115 +      stream->written_frags+=got;
1116 +    }
1117 +  }
1118 +  return NULL;
1119 +}
1120 +
1121 +static void oss_try_set_latency(cubeb_stream* stream, unsigned int latency)
1122 +{
1123 +  unsigned int latency_bytes, n_frag;
1124 +  int frag;
1125 +  /* fragment size of 1024 is a good choice with good chances to be accepted */
1126 +  unsigned int frag_size=1024;
1127 +  unsigned int frag_log=10; /* 2^frag_log = frag_size */
1128 +  latency_bytes =
1129 +    latency*stream->params.rate*stream->params.channels*sizeof(uint16_t)/1000;
1130 +  n_frag = latency_bytes>>frag_log;
1131 +  frag = (n_frag<<16) | frag_log;
1132 +  /* Even if this fails we wish to continue, not checking for errors */
1133 +  ioctl(stream->fd, SNDCTL_DSP_SETFRAGMENT, &frag);
1134 +}
1135 +
1136 +static int oss_stream_init(cubeb * context, cubeb_stream ** stm,
1137 +                           char const * stream_name,
1138 +                           cubeb_devid input_device,
1139 +                           cubeb_stream_params * input_stream_params,
1140 +                           cubeb_devid output_device,
1141 +                           cubeb_stream_params * output_stream_params,
1142 +                           unsigned int latency,
1143 +                           cubeb_data_callback data_callback,
1144 +                           cubeb_state_callback state_callback, void * user_ptr)
1145 +{
1146 +  cubeb_stream* stream = (cubeb_stream*)malloc(sizeof(cubeb_stream));
1147 +  stream->context = context;
1148 +  stream->data_callback = data_callback;
1149 +  stream->state_callback = state_callback;
1150 +  stream->user_ptr = user_ptr;
1151 +
1152 +  assert(!input_stream_params && "not supported.");
1153 +  if (input_device || output_device) {
1154 +    /* Device selection not yet implemented. */
1155 +    return CUBEB_ERROR_DEVICE_UNAVAILABLE;
1156 +  }
1157 +
1158 +  if ((stream->fd = open(CUBEB_OSS_DEFAULT_OUTPUT, O_WRONLY)) == -1) {
1159 +    free(stream);
1160 +    return CUBEB_ERROR;
1161 +  }
1162 +#define SET(what, to) do { unsigned int i = to; \
1163 +    int j = ioctl(stream->fd, what, &i); \
1164 +    if (j == -1 || i != to) { \
1165 +      close(stream->fd); \
1166 +      free(stream); \
1167 +      return CUBEB_ERROR_INVALID_FORMAT; } } while (0)
1168 +
1169 +  stream->params = *output_stream_params;
1170 +  stream->volume = 1.0;
1171 +  stream->panning = 0.0;
1172 +
1173 +  oss_try_set_latency(stream, latency); 
1174 +
1175 +  stream->floating = 0;
1176 +  SET(SNDCTL_DSP_CHANNELS, stream->params.channels);
1177 +  SET(SNDCTL_DSP_SPEED, stream->params.rate);
1178 +  switch (stream->params.format) {
1179 +    case CUBEB_SAMPLE_S16LE:
1180 +      SET(SNDCTL_DSP_SETFMT, AFMT_S16_LE);
1181 +    break;
1182 +    case CUBEB_SAMPLE_S16BE:
1183 +      SET(SNDCTL_DSP_SETFMT, AFMT_S16_BE);
1184 +    break;
1185 +    case CUBEB_SAMPLE_FLOAT32LE:
1186 +      SET(SNDCTL_DSP_SETFMT, AFMT_S16_NE);
1187 +      stream->floating = 1;
1188 +    break;
1189 +    default:
1190 +      close(stream->fd);
1191 +      free(stream);
1192 +      return CUBEB_ERROR;
1193 +  }
1194 +
1195 +
1196 +  pthread_mutex_init(&stream->state_mutex, NULL);
1197 +  pthread_cond_init(&stream->state_cond, NULL);
1198 +
1199 +  stream->running = 1;
1200 +  stream->stopped = 1;
1201 +  stream->position_bytes = 0;
1202 +  stream->last_position_bytes = 0;
1203 +  stream->written_frags = 0;
1204 +  stream->missed_frags = 0;
1205 +
1206 +  pthread_create(&stream->th, NULL, writer, (void*)stream);
1207 +
1208 +  *stm = stream;
1209 +
1210 +  return CUBEB_OK;
1211 +}
1212 +
1213 +static void oss_stream_destroy(cubeb_stream * stream)
1214 +{
1215 +  pthread_mutex_lock(&stream->state_mutex);
1216 +
1217 +  stream->running = 0;
1218 +  stream->stopped = 0;
1219 +  pthread_cond_signal(&stream->state_cond);
1220 +
1221 +  pthread_mutex_unlock(&stream->state_mutex);
1222 +
1223 +  pthread_join(stream->th, NULL);
1224 +
1225 +  pthread_mutex_destroy(&stream->state_mutex);
1226 +  pthread_cond_destroy(&stream->state_cond);
1227 +  close(stream->fd);
1228 +  free(stream);
1229 +}
1230 +
1231 +static int oss_stream_get_latency(cubeb_stream * stream, uint32_t * latency)
1232 +{
1233 +  if (ioctl(stream->fd, SNDCTL_DSP_GETODELAY, latency)==-1) {
1234 +    return CUBEB_ERROR;
1235 +  }
1236 +  /* Convert latency from bytes to frames */
1237 +  *latency /= stream->params.channels*sizeof(int16_t);
1238 +  return CUBEB_OK;
1239 +}
1240 +
1241 +
1242 +static int oss_stream_current_optr(cubeb_stream * stream, uint64_t * position)
1243 +{
1244 +  count_info ci;
1245 +  /* Unfortunately, this ioctl is only available in OSS 4.x */
1246 +#ifdef SNDCTL_DSP_CURRENT_OPTR
1247 +  oss_count_t count;
1248 +  if (ioctl(stream->fd, SNDCTL_DSP_CURRENT_OPTR, &count) != -1) {
1249 +    *position = count.samples;// + count.fifo_samples;
1250 +    return CUBEB_OK;
1251 +  }
1252 +#endif
1253 +  /* Fall back to this ioctl in case the previous one fails */
1254 +  if (ioctl(stream->fd, SNDCTL_DSP_GETOPTR, &ci) == -1) {
1255 +    return CUBEB_ERROR;
1256 +  }
1257 +  /* ci.bytes is only 32 bit and will start to wrap after arithmetic overflow */
1258 +  stream->position_bytes += ci.bytes - stream->last_position_bytes;
1259 +  stream->last_position_bytes = ci.bytes;
1260 +  *position = stream->position_bytes/stream->params.channels/sizeof(int16_t);
1261 +  return CUBEB_OK;
1262 +}
1263 +
1264 +static int oss_stream_get_position(cubeb_stream * stream, uint64_t * position)
1265 +{
1266 +  if ( oss_stream_current_optr(stream, position) == CUBEB_OK ){
1267 +    *position -= stream->missed_frags;
1268 +    return CUBEB_OK;
1269 +  }
1270 +  /* If no correct method to get position works we resort to this */
1271 +  *position = stream->written_frags;
1272 +  return CUBEB_OK;
1273 +}
1274 +
1275 +
1276 +static int oss_stream_start(cubeb_stream * stream)
1277 +{
1278 +  pthread_mutex_lock(&stream->state_mutex);
1279 +  if (stream->stopped) {
1280 +    uint64_t ptr;
1281 +    oss_stream_current_optr(stream, &ptr);
1282 +    stream->missed_frags = ptr - stream->written_frags;
1283 +    stream->stopped = 0;
1284 +    pthread_cond_signal(&stream->state_cond);
1285 +  }
1286 +  pthread_mutex_unlock(&stream->state_mutex);
1287 +  return CUBEB_OK;
1288 +}
1289 +
1290 +static int oss_stream_stop(cubeb_stream * stream)
1291 +{
1292 +  pthread_mutex_lock(&stream->state_mutex);
1293 +  stream->stopped = 1;
1294 +  pthread_mutex_unlock(&stream->state_mutex);
1295 +  return CUBEB_OK;
1296 +}
1297 +
1298 +int oss_stream_set_panning(cubeb_stream * stream, float panning)
1299 +{
1300 +  if (stream->params.channels == 2) {
1301 +    stream->panning=panning;
1302 +  }
1303 +  return CUBEB_OK;
1304 +}
1305 +
1306 +int oss_stream_set_volume(cubeb_stream * stream, float volume)
1307 +{
1308 +  stream->volume=volume;
1309 +  return CUBEB_OK;
1310 +}
1311 +
1312 +static struct cubeb_ops const oss_ops = {
1313 +  .init = oss_init,
1314 +  .get_backend_id = oss_get_backend_id,
1315 +  .get_max_channel_count = oss_get_max_channel_count,
1316 +  .get_min_latency = oss_get_min_latency,
1317 +  .get_preferred_sample_rate = oss_get_preferred_sample_rate,
1318 +  .destroy = oss_destroy,
1319 +  .stream_init = oss_stream_init,
1320 +  .stream_destroy = oss_stream_destroy,
1321 +  .stream_start = oss_stream_start,
1322 +  .stream_stop = oss_stream_stop,
1323 +  .stream_get_position = oss_stream_get_position,
1324 +  .stream_get_latency = oss_stream_get_latency,
1325 +  .stream_set_volume = oss_stream_set_volume,
1326 +  .stream_set_panning = oss_stream_set_panning,
1327 +  .stream_get_current_device = NULL,
1328 +  .stream_device_destroy = NULL,
1329 +  .stream_register_device_changed_callback = NULL
1330 +};
1331 diff --git media/libcubeb/src/moz.build media/libcubeb/src/moz.build
1332 index 8b7a0dd..31212ce 100644
1333 --- media/libcubeb/src/moz.build
1334 +++ media/libcubeb/src/moz.build
1335 @@ -17,6 +17,12 @@ if CONFIG['MOZ_ALSA']:
1336      ]
1337      DEFINES['USE_ALSA'] = True
1338  
1339 +if CONFIG['MOZ_OSS']:
1340 +    SOURCES += [
1341 +        'cubeb_oss.c',
1342 +    ]
1343 +    DEFINES['USE_OSS'] = True
1344 +
1345  if CONFIG['MOZ_PULSEAUDIO']:
1346      SOURCES += [
1347          'cubeb_pulse.c',
1348 @@ -75,5 +81,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
1349  
1350  FAIL_ON_WARNINGS = True
1351  
1352 +CFLAGS += CONFIG['MOZ_OSS_CFLAGS']
1353  CFLAGS += CONFIG['MOZ_ALSA_CFLAGS']
1354  CFLAGS += CONFIG['MOZ_PULSEAUDIO_CFLAGS']
1355  
1356 diff --git media/libcubeb/tests/moz.build media/libcubeb/tests/moz.build
1357 index 1b17c7b..48b56c2 100644
1358 --- media/libcubeb/tests/moz.build
1359 +++ media/libcubeb/tests/moz.build
1360 @@ -73,7 +73,6 @@ elif CONFIG['OS_TARGET'] == 'OpenBSD':
1361          'sndio',
1362      ]
1363  else:
1364 -    OS_LIBS += CONFIG['MOZ_ALSA_LIBS']
1365      OS_LIBS += CONFIG['MOZ_PULSEAUDIO_LIBS']
1366  
1367  if CONFIG['GNU_CXX']:
1368 diff --git media/libcubeb/update.sh media/libcubeb/update.sh
1369 index a96badd..2f9585e 100755
1370 --- media/libcubeb/update.sh
1371 +++ media/libcubeb/update.sh
1372 @@ -16,6 +16,7 @@ cp $1/src/cubeb_audiounit.cpp src
1373  cp $1/src/cubeb_osx_run_loop.h src
1374  cp $1/src/cubeb_jack.cpp src
1375  cp $1/src/cubeb_opensl.c src
1376 +cp $1/src/cubeb_oss.c src
1377  cp $1/src/cubeb_panner.cpp src
1378  cp $1/src/cubeb_panner.h src
1379  cp $1/src/cubeb_pulse.c src
1380 diff --git media/webrtc/signaling/test/common.build media/webrtc/signaling/test/common.build
1381 index 991f03f..3d99eb5 100644
1382 --- media/webrtc/signaling/test/common.build
1383 +++ media/webrtc/signaling/test/common.build
1384 @@ -102,8 +102,8 @@ USE_LIBS += ['mozglue']
1385  OS_LIBS += CONFIG['MOZ_WEBRTC_X11_LIBS']
1386  OS_LIBS += CONFIG['REALTIME_LIBS']
1387  
1388 -if CONFIG['MOZ_ALSA']:
1389 -    OS_LIBS += CONFIG['MOZ_ALSA_LIBS']
1390 +if CONFIG['MOZ_OSS']:
1391 +    OS_LIBS += CONFIG['MOZ_OSS_LIBS']
1392  
1393  if CONFIG['MOZ_SYSTEM_JPEG']:
1394      OS_LIBS += CONFIG['MOZ_JPEG_LIBS']
1395 diff --git toolkit/library/moz.build toolkit/library/moz.build
1396 index e191f13..4fb268a 100644
1397 --- toolkit/library/moz.build
1398 +++ toolkit/library/moz.build
1399 @@ -234,8 +234,8 @@ if CONFIG['MOZ_SYSTEM_LIBVPX']:
1400  if not CONFIG['MOZ_TREE_PIXMAN']:
1401      OS_LIBS += CONFIG['MOZ_PIXMAN_LIBS']
1402  
1403 -if CONFIG['MOZ_ALSA']:
1404 -    OS_LIBS += CONFIG['MOZ_ALSA_LIBS']
1405 +if CONFIG['MOZ_OSS']:
1406 +    OS_LIBS += CONFIG['MOZ_OSS_LIBS']
1407  
1408  if CONFIG['HAVE_CLOCK_MONOTONIC']:
1409      OS_LIBS += CONFIG['REALTIME_LIBS']
1410
1411
1412 [FILE:1562:patches/patch-bug1186967]
1413 commit 64bb4e051b50
1414 Author: Martin Stransky <stransky@redhat.com>
1415 Date:   Tue Oct 17 09:50:18 2017 +0200
1416
1417     Bug 1186967 - ignore double-click on WM without _NET_WM_MOVERESIZE support, r=jhorak
1418     
1419     MozReview-Commit-ID: 2Vs6i5leero
1420     
1421     --HG--
1422     extra : rebase_source : d8f2bbaf9ef9b2025478f029a68ee7e87e07de79
1423 ---
1424  widget/gtk/nsWindow.cpp | 16 ++++++++++++++++
1425  1 file changed, 16 insertions(+)
1426
1427 diff --git widget/gtk/nsWindow.cpp widget/gtk/nsWindow.cpp
1428 index eb2f0e5e95cd..955327297ac9 100644
1429 --- widget/gtk/nsWindow.cpp
1430 +++ widget/gtk/nsWindow.cpp
1431 @@ -6444,6 +6444,22 @@ nsWindow::GetDragInfo(WidgetMouseEvent* aMouseEvent,
1432          return false;
1433      }
1434  
1435 +    if (mIsX11Display) {
1436 +      // Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=789054
1437 +      // To avoid crashes disable double-click on WM without _NET_WM_MOVERESIZE.
1438 +      // See _should_perform_ewmh_drag() at gdkwindow-x11.c
1439 +      GdkScreen* screen = gdk_window_get_screen(gdk_window);
1440 +      GdkAtom atom = gdk_atom_intern("_NET_WM_MOVERESIZE", FALSE);
1441 +      if (!gdk_x11_screen_supports_net_wm_hint(screen, atom)) {
1442 +          static unsigned int lastTimeStamp = 0;
1443 +          if (lastTimeStamp != aMouseEvent->mTime) {
1444 +              lastTimeStamp = aMouseEvent->mTime;
1445 +          } else {
1446 +              return false;
1447 +          }
1448 +      }
1449 +    }
1450 +
1451      // FIXME: It would be nice to have the widget position at the time
1452      // of the event, but it's relatively unlikely that the widget has
1453      // moved since the mousedown.  (On the other hand, it's quite likely
1454
1455
1456 [FILE:2805:patches/patch-bug1288587]
1457 diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure
1458 index 855214a..1e91d51 100644
1459 --- build/moz.configure/init.configure
1460 +++ build/moz.configure/init.configure
1461 @@ -165,16 +165,17 @@ option(env='PYTHON', nargs=1, help='Python interpreter')
1462  # ==============================================================
1463  @depends('PYTHON', check_build_environment, mozconfig, '--help')
1464  @imports('os')
1465  @imports('sys')
1466  @imports('subprocess')
1467  @imports(_from='mozbuild.configure.util', _import='LineIO')
1468  @imports(_from='mozbuild.virtualenv', _import='VirtualenvManager')
1469  @imports(_from='mozbuild.virtualenv', _import='verify_python_version')
1470 +@imports(_from='__builtin__', _import='KeyError')
1471  @imports('distutils.sysconfig')
1472  def virtualenv_python(env_python, build_env, mozconfig, help):
1473      if help:
1474          return
1475  
1476      python = env_python[0] if env_python else None
1477  
1478      # Ideally we'd rely on the mozconfig injection from mozconfig_options,
1479 @@ -184,16 +185,22 @@ def virtualenv_python(env_python, build_env, mozconfig, help):
1480          if 'PYTHON' in mozconfig['env']['added']:
1481              python = mozconfig['env']['added']['PYTHON']
1482          elif 'PYTHON' in mozconfig['env']['modified']:
1483              python = mozconfig['env']['modified']['PYTHON'][1]
1484          elif 'PYTHON' in mozconfig['vars']['added']:
1485              python = mozconfig['vars']['added']['PYTHON']
1486          elif 'PYTHON' in mozconfig['vars']['modified']:
1487              python = mozconfig['vars']['modified']['PYTHON'][1]
1488 +        for i in ('env', 'vars'):
1489 +            for j in ('added', 'modified'):
1490 +                try:
1491 +                    del mozconfig[i][j]['PYTHON']
1492 +                except KeyError:
1493 +                    pass
1494  
1495      with LineIO(lambda l: log.error(l)) as out:
1496          verify_python_version(out)
1497      topsrcdir, topobjdir = build_env.topsrcdir, build_env.topobjdir
1498      if topobjdir.endswith('/js/src'):
1499          topobjdir = topobjdir[:-7]
1500  
1501      with LineIO(lambda l: log.info(l)) as out:
1502 @@ -219,17 +226,20 @@ def virtualenv_python(env_python, build_env, mozconfig, help):
1503          log.info('Creating Python environment')
1504          manager.build(python)
1505  
1506      python = normsep(manager.python_path)
1507  
1508      if python != normsep(sys.executable):
1509          log.info('Reexecuting in the virtualenv')
1510          if env_python:
1511 -            del os.environ['PYTHON']
1512 +            try:
1513 +                del os.environ['PYTHON']
1514 +            except KeyError:
1515 +                pass
1516          # One would prefer to use os.execl, but that's completely borked on
1517          # Windows.
1518          sys.exit(subprocess.call([python] + sys.argv))
1519  
1520      # We are now in the virtualenv
1521      if not distutils.sysconfig.get_python_lib():
1522          die('Could not determine python site packages directory')
1523  
1524
1525
1526 [FILE:1390:patches/patch-bug1321877]
1527 commit a13d95795217
1528 Author:  <tharvik@gmail.com>
1529 Date:   Thu Dec 8 18:20:12 2016 -0600
1530
1531     Bug 1321877. Fix compiler warnings in Downscaler.h when skia is not enabled. r=tnikkel
1532 ---
1533  image/Downscaler.h | 11 +++++++----
1534  1 file changed, 7 insertions(+), 4 deletions(-)
1535
1536 diff --git image/Downscaler.h image/Downscaler.h
1537 index 21179a38f200..0bdef0eaa646 100644
1538 --- image/Downscaler.h
1539 +++ image/Downscaler.h
1540 @@ -154,14 +154,14 @@ private:
1541  class Downscaler
1542  {
1543  public:
1544 -  explicit Downscaler(const nsIntSize&)
1545 +  explicit Downscaler(const nsIntSize&) : mScale(1.0, 1.0)
1546    {
1547      MOZ_RELEASE_ASSERT(false, "Skia is not enabled");
1548    }
1549  
1550 -  const nsIntSize& OriginalSize() const { return nsIntSize(); }
1551 -  const nsIntSize& TargetSize() const { return nsIntSize(); }
1552 -  const gfxSize& Scale() const { return gfxSize(1.0, 1.0); }
1553 +  const nsIntSize& OriginalSize() const { return mSize; }
1554 +  const nsIntSize& TargetSize() const { return mSize; }
1555 +  const gfxSize& Scale() const { return mScale; }
1556  
1557    nsresult BeginFrame(const nsIntSize&, const Maybe<nsIntRect>&, uint8_t*, bool, bool = false)
1558    {
1559 @@ -177,6 +177,9 @@ public:
1560    DownscalerInvalidRect TakeInvalidRect() { return DownscalerInvalidRect(); }
1561    void ResetForNextProgressivePass() { }
1562    const nsIntSize FrameSize() const { return nsIntSize(0, 0); }
1563 +private:
1564 +  nsIntSize mSize;
1565 +  gfxSize mScale;
1566  };
1567  
1568  #endif // MOZ_ENABLE_SKIA
1569
1570
1571 [FILE:2359:patches/patch-bug1338655]
1572 commit bbd48a5613c8
1573 Author: Ralph Giles <giles@mozilla.com>
1574 Date:   Fri Feb 10 12:58:18 2017 -0800
1575
1576     Bug 1338655 - Don't try to build mp4parse bindings. r=froydnj
1577     
1578     We use the cheddar crate to generate a C header file
1579     for our mp4parse_capi wrapper crate. Currently we
1580     do this at code check-in time via update-rust.sh.
1581     
1582     Cargo 0.18 and later will try to execute a build.rs
1583     file in the crate source tree regardless of whether
1584     it's specified in Cargo.toml so patching out that
1585     line just results in 'crate cheddar not found'.
1586     
1587     This change restores the old behaviour by substituting
1588     a 'build = false' line instead.
1589     
1590     We do have syntex vendored, but we don't currently build
1591     it by default, so I prefer this solution to just vendoring
1592     cheddar and generating the header at build time. The syntex
1593     crate is quite large and adds significantly to our compile
1594     time.
1595     
1596     MozReview-Commit-ID: InJRRODWAdP
1597     
1598     --HG--
1599     extra : rebase_source : 29378fcbc86015ce6cc22dc66d38a43ddbac204e
1600 ---
1601  media/libstagefright/binding/mp4parse-cargo.patch     | 5 +++--
1602  media/libstagefright/binding/mp4parse_capi/Cargo.toml | 2 ++
1603  2 files changed, 5 insertions(+), 2 deletions(-)
1604
1605 diff --git media/libstagefright/binding/mp4parse-cargo.patch media/libstagefright/binding/mp4parse-cargo.patch
1606 index 1dd13d20472a..bfa0ab74b424 100644
1607 --- media/libstagefright/binding/mp4parse-cargo.patch
1608 +++ media/libstagefright/binding/mp4parse-cargo.patch
1609 @@ -25,12 +25,13 @@ diff --git a/media/libstagefright/binding/mp4parse_cap
1610  index aeeebc65..5c0836a 100644
1611  --- a/media/libstagefright/binding/mp4parse_capi/Cargo.toml
1612  +++ b/media/libstagefright/binding/mp4parse_capi/Cargo.toml
1613 -@@ -18,17 +18,9 @@ exclude = [
1614 +@@ -18,17 +18,11 @@ exclude = [
1615     "*.mp4",
1616   ]
1617   
1618  -build = "build.rs"
1619 --
1620 ++build = false
1621
1622   [dependencies]
1623   "mp4parse" = {version = "0.6.0", path = "../mp4parse"}
1624   
1625 diff --git media/libstagefright/binding/mp4parse_capi/Cargo.toml media/libstagefright/binding/mp4parse_capi/Cargo.toml
1626 index aee7ee947151..d7e3f55119d3 100644
1627 --- media/libstagefright/binding/mp4parse_capi/Cargo.toml
1628 +++ media/libstagefright/binding/mp4parse_capi/Cargo.toml
1629 @@ -18,6 +18,8 @@ exclude = [
1630    "*.mp4",
1631  ]
1632  
1633 +build = false
1634 +
1635  [dependencies]
1636  byteorder = "1.0.0"
1637  "mp4parse" = {version = "0.6.0", path = "../mp4parse"}
1638
1639
1640 [FILE:1238:patches/patch-bug1380706]
1641 commit 10b55207992c
1642 Author: Kai Engert <kaie@kuix.de>
1643 Date:   Fri Jul 14 15:31:30 2017 +0200
1644
1645     Bug 1380706, PSM should depend on mozStorage, as a workaround for a sqlite3_config race, r=keeler
1646 ---
1647  security/manager/ssl/nsNSSComponent.cpp | 9 +++++++++
1648  1 file changed, 9 insertions(+)
1649
1650 diff --git security/manager/ssl/nsNSSComponent.cpp security/manager/ssl/nsNSSComponent.cpp
1651 index f51f8af47d51..a82c1ed61fba 100644
1652 --- security/manager/ssl/nsNSSComponent.cpp
1653 +++ security/manager/ssl/nsNSSComponent.cpp
1654 @@ -13,6 +13,7 @@
1655  #include "SharedSSLState.h"
1656  #include "cert.h"
1657  #include "certdb.h"
1658 +#include "mozStorageCID.h"
1659  #include "mozilla/ArrayUtils.h"
1660  #include "mozilla/Assertions.h"
1661  #include "mozilla/Casting.h"
1662 @@ -2032,6 +2033,14 @@ nsNSSComponent::Init()
1663      return NS_ERROR_NOT_AVAILABLE;
1664    }
1665  
1666 +  // To avoid a sqlite3_config race in NSS init, as a workaround for
1667 +  // bug 730495, we require the storage service to get initialized first.
1668 +  nsCOMPtr<nsISupports> storageService =
1669 +    do_GetService(MOZ_STORAGE_SERVICE_CONTRACTID);
1670 +  if (!storageService) {
1671 +    return NS_ERROR_NOT_AVAILABLE;
1672 +  }
1673 +
1674    MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("Beginning NSS initialization\n"));
1675  
1676    nsresult rv = InitializePIPNSSBundle();
1677
1678
1679 [FILE:341:patches/patch-bug1386957]
1680 https://github.com/kinetiknz/cubeb/commit/16f9ccc064f2
1681
1682 --- media/libcubeb/src/cubeb_jack.cpp.orig      2017-07-07 05:37:16 UTC
1683 +++ media/libcubeb/src/cubeb_jack.cpp
1684 @@ -8,7 +8,9 @@
1685   */
1686  #define _DEFAULT_SOURCE
1687  #define _BSD_SOURCE
1688 +#ifndef __FreeBSD__
1689  #define _POSIX_SOURCE
1690 +#endif
1691  #include <algorithm>
1692  #include <dlfcn.h>
1693  #include <limits>
1694
1695
1696 [FILE:2435:patches/patch-bug1412558]
1697 diff --git dom/media/flac/FlacDecoder.cpp dom/media/flac/FlacDecoder.cpp
1698 index 53fc3c9937f7..b23771ab80fa 100644
1699 --- dom/media/flac/FlacDecoder.cpp
1700 +++ dom/media/flac/FlacDecoder.cpp
1701 @@ -7,6 +7,7 @@
1702  #include "FlacDecoder.h"
1703  #include "MediaContainerType.h"
1704  #include "MediaPrefs.h"
1705 +#include "PDMFactory.h"
1706  
1707  namespace mozilla {
1708  
1709 @@ -15,6 +16,10 @@ FlacDecoder::IsEnabled()
1710  {
1711  #ifdef MOZ_FFVPX
1712    return MediaPrefs::FlacEnabled();
1713 +#elif defined(MOZ_FFMPEG)
1714 +  RefPtr<PDMFactory> platform = new PDMFactory();
1715 +  return MediaPrefs::FlacEnabled() && platform->SupportsMimeType(NS_LITERAL_CSTRING("audio/flac"),
1716 +                                    /* DecoderDoctorDiagnostics* */ nullptr);
1717  #else
1718    // Until bug 1295886 is fixed.
1719    return false;
1720 diff --git media/ffvpx/README_MOZILLA media/ffvpx/README_MOZILLA
1721 index 5d3a6037efe0..43144b726a92 100644
1722 --- media/ffvpx/README_MOZILLA
1723 +++ media/ffvpx/README_MOZILLA
1724 @@ -17,14 +17,6 @@ configuration files were generated as follow using the configure script:
1725  config*:
1726  replace: /HAVE_(MALLOC_H|ARC4RANDOM|LOCALTIME_R|MEMALIGN|POSIX_MEMALIGN)/d
1727  
1728 -config_darwin32.h:
1729 -add to configure command: --disable-asm --disable-yasm --cc='clang -m32'
1730 -
1731 -config_unix32.h:
1732 -add to configure command: --disable-asm --disable-yasm --cc='clang -m32'
1733 -replace: s/HAVE_SYSCTL 1/HAVE_SYSCTL 0/ and s/HAVE_MEMALIGN 1/HAVE_MEMALIGN 0/ and s/HAVE_POSIX_MEMALIGN 1/HAVE_POSIX_MEMALIGN 0/
1734 -
1735 -
1736  config_unix64.h/config_unix64.asm:
1737  replace: s/HAVE_SYSCTL 1/HAVE_SYSCTL 0
1738  
1739 diff --git media/ffvpx/config.h media/ffvpx/config.h
1740 index dab01e05cd65..26ebe529bd98 100644
1741 --- media/ffvpx/config.h
1742 +++ media/ffvpx/config.h
1743 @@ -27,17 +27,9 @@
1744  #define HAVE_LIBC_MSVCRT 0
1745  #endif
1746  #elif defined(XP_DARWIN)
1747 -#if defined(HAVE_64BIT_BUILD)
1748  #include "config_darwin64.h"
1749 -#else
1750 -#include "config_darwin32.h"
1751 -#endif
1752  #elif defined(XP_UNIX)
1753 -#if defined(HAVE_64BIT_BUILD)
1754  #include "config_unix64.h"
1755 -#else
1756 -#include "config_unix32.h"
1757 -#endif
1758  #endif
1759  #include "config_common.h"
1760  #endif // MOZ_FFVPX_CONFIG_H
1761 diff --git old-configure.in old-configure.in
1762 index b8ce71278548..410be683c2f6 100644
1763 --- old-configure.in
1764 +++ old-configure.in
1765 @@ -3279,11 +3279,11 @@ dnl = FFmpeg's ffvpx configuration
1766  dnl ========================================================
1767  
1768  MOZ_FFVPX=
1769 -case "$CPU_ARCH" in
1770 -  x86)
1771 +case "$OS_ARCH:$CPU_ARCH" in
1772 +  WINNT:x86)
1773        MOZ_FFVPX=1
1774    ;;
1775 -  x86_64)
1776 +  *:x86_64)
1777        MOZ_FFVPX=1
1778    ;;
1779  esac
1780
1781
1782 [FILE:3265:patches/patch-bug1414440]
1783 Always build libyuv x86 optimizations with Clang.
1784
1785 diff --git media/libyuv/include/libyuv/compare_row.h media/libyuv/include/libyuv/compare_row.h
1786 index 38a957b2ce33..59ec4b30c238 100644
1787 --- media/libyuv/include/libyuv/compare_row.h
1788 +++ media/libyuv/include/libyuv/compare_row.h
1789 @@ -19,7 +19,7 @@ extern "C" {
1790  #endif
1791  
1792  #if defined(__pnacl__) || defined(__CLR_VER) || \
1793 -    (defined(__i386__) && !defined(__SSE2__))
1794 +    (defined(__i386__) && !defined(__SSE__) && !defined(__clang__))
1795  #define LIBYUV_DISABLE_X86
1796  #endif
1797  // MemorySanitizer does not support assembly code yet. http://crbug.com/344505
1798 diff --git media/libyuv/include/libyuv/planar_functions.h media/libyuv/include/libyuv/planar_functions.h
1799 index 881b0c5c6473..491c022bfe8f 100644
1800 --- media/libyuv/include/libyuv/planar_functions.h
1801 +++ media/libyuv/include/libyuv/planar_functions.h
1802 @@ -450,7 +450,7 @@ int I420Interpolate(const uint8* src0_y, int src0_stride_y,
1803                      int width, int height, int interpolation);
1804  
1805  #if defined(__pnacl__) || defined(__CLR_VER) || \
1806 -    (defined(__i386__) && !defined(__SSE2__))
1807 +    (defined(__i386__) && !defined(__SSE__) && !defined(__clang__))
1808  #define LIBYUV_DISABLE_X86
1809  #endif
1810  // MemorySanitizer does not support assembly code yet. http://crbug.com/344505
1811 diff --git media/libyuv/include/libyuv/rotate_row.h media/libyuv/include/libyuv/rotate_row.h
1812 index ebc487f9abf4..59fbd10b573c 100644
1813 --- media/libyuv/include/libyuv/rotate_row.h
1814 +++ media/libyuv/include/libyuv/rotate_row.h
1815 @@ -19,7 +19,7 @@ extern "C" {
1816  #endif
1817  
1818  #if defined(__pnacl__) || defined(__CLR_VER) || \
1819 -    (defined(__i386__) && !defined(__SSE2__))
1820 +    (defined(__i386__) && !defined(__SSE__) && !defined(__clang__))
1821  #define LIBYUV_DISABLE_X86
1822  #endif
1823  // MemorySanitizer does not support assembly code yet. http://crbug.com/344505
1824 diff --git media/libyuv/include/libyuv/row.h media/libyuv/include/libyuv/row.h
1825 index 069d73bd3f2e..3616ecd81c3d 100644
1826 --- media/libyuv/include/libyuv/row.h
1827 +++ media/libyuv/include/libyuv/row.h
1828 @@ -38,7 +38,7 @@ extern "C" {
1829    var = 0
1830  
1831  #if defined(__pnacl__) || defined(__CLR_VER) || \
1832 -    (defined(__i386__) && !defined(__SSE2__))
1833 +    (defined(__i386__) && !defined(__SSE__) && !defined(__clang__))
1834  #define LIBYUV_DISABLE_X86
1835  #endif
1836  // MemorySanitizer does not support assembly code yet. http://crbug.com/344505
1837 diff --git media/libyuv/include/libyuv/scale_row.h media/libyuv/include/libyuv/scale_row.h
1838 index df699e6c2282..242f025b1e6e 100644
1839 --- media/libyuv/include/libyuv/scale_row.h
1840 +++ media/libyuv/include/libyuv/scale_row.h
1841 @@ -20,7 +20,7 @@ extern "C" {
1842  #endif
1843  
1844  #if defined(__pnacl__) || defined(__CLR_VER) || \
1845 -    (defined(__i386__) && !defined(__SSE2__))
1846 +    (defined(__i386__) && !defined(__SSE__) && !defined(__clang__))
1847  #define LIBYUV_DISABLE_X86
1848  #endif
1849  // MemorySanitizer does not support assembly code yet. http://crbug.com/344505
1850 diff --git media/libyuv/linux.mk media/libyuv/linux.mk
1851 index ee5a3a70705a..c1a45173c9ab 100644
1852 --- media/libyuv/linux.mk
1853 +++ media/libyuv/linux.mk
1854 @@ -78,4 +78,4 @@ cpuid: util/cpuid.c libyuv.a
1855         $(CC) $(CFLAGS) -o $@ util/cpuid.c libyuv.a
1856  
1857  clean:
1858 -       /bin/rm -f source/*.o *.ii *.s libyuv.a convert cpuid psnr
1859 +       /bin/rm -f source/*.o *.ii *.s libyuv.a yuvconvert cpuid psnr
1860
1861
1862 [FILE:445:patches/patch-bug702179]
1863 --- js/src/moz.build.orig       2015-12-16 12:32:04.574425000 +0100
1864 +++ js/src/moz.build    2015-12-16 12:32:09.032032000 +0100
1865 @@ -671,10 +671,6 @@ CFLAGS += CONFIG['MOZ_ICU_CFLAGS']
1866  CXXFLAGS += CONFIG['MOZ_ICU_CFLAGS']
1867  LOCAL_INCLUDES += CONFIG['MOZ_ICU_INCLUDES']
1868  
1869 -NO_EXPAND_LIBS = True
1870 -
1871 -DIST_INSTALL = True
1872 -
1873  # Prepare self-hosted JS code for embedding
1874  GENERATED_FILES += ['selfhosted.out.h']
1875  selfhosted = GENERATED_FILES['selfhosted.out.h']
1876
1877
1878 [FILE:6039:patches/patch-bug826985]
1879 commit 8024d93
1880 Author: Henrik Gulbrandsen <henrik@gulbra.net>
1881 Date:   Fri Jan 4 13:49:22 2013 +0100
1882
1883     Bug 826985 - Support more video formats for WebRTC via libv4l2 on Linux.
1884 ---
1885  config/system-headers                                   |  1 +
1886  old-configure.in                                        |  7 +++++++
1887  media/webrtc/signaling/test/Makefile.in                 |  1 +
1888  .../modules/video_capture/linux/device_info_linux.cc    | 17 +++++++++++++++++
1889  .../modules/video_capture/linux/video_capture_linux.cc  | 16 +++++++++++++++-
1890  .../webrtc/modules/video_capture/video_capture.gypi     | 11 +++++++++++
1891  toolkit/library/Makefile.in                             |  1 +
1892  6 files changed, 52 insertions(+), 1 deletion(-)
1893
1894 diff --git config/system-headers config/system-headers
1895 index 55e4cd1..76567b3 100644
1896 --- config/system-headers
1897 +++ config/system-headers
1898 @@ -624,6 +624,7 @@ libgnome/libgnome.h
1899  libgnomeui/gnome-icon-lookup.h
1900  libgnomeui/gnome-icon-theme.h
1901  libgnomeui/gnome-ui-init.h
1902 +libv4l2.h
1903  limits.h
1904  link.h
1905  #ifdef ANDROID
1906 diff --git old-configure.in configure.in
1907 index 55e4cd1..76567b3 100644
1908 --- old-configure.in
1909 +++ old-configure.in
1910 @@ -5309,6 +5309,9 @@ if test -n "$MOZ_WEBRTC"; then
1911      MOZ_VP8_ENCODER=1
1912      MOZ_VP8_ERROR_CONCEALMENT=1
1913  
1914 +    dnl with libv4l2 we can support more cameras
1915 +    PKG_CHECK_MODULES(MOZ_LIBV4L2, libv4l2)
1916 +
1917  dnl enable once Signaling lands
1918      MOZ_WEBRTC_SIGNALING=1
1919      AC_DEFINE(MOZ_WEBRTC_SIGNALING)
1920 diff --git build/gyp.mozbuild build/gyp.mozbuild
1921 index b483cd1..f1dd1f0 100644
1922 --- build/gyp.mozbuild
1923 +++ build/gyp.mozbuild
1924 @@ -11,6 +11,7 @@ gyp_vars = {
1925      'have_ethtool_cmd_speed_hi': 1 if CONFIG['MOZ_WEBRTC_HAVE_ETHTOOL_SPEED_HI'] else 0,
1926      'include_alsa_audio': 1 if CONFIG['MOZ_ALSA'] else 0,
1927      'include_pulse_audio': 1 if CONFIG['MOZ_PULSEAUDIO'] else 0,
1928 +    'use_libv4l2': 1 if CONFIG['MOZ_LIBV4L2_LIBS'] else 0,
1929      # basic stuff for everything
1930      'include_internal_video_render': 0,
1931      'clang_use_chrome_plugins': 0,
1932 diff --git media/webrtc/signaling/test/common.build media/webrtc/signaling/test/common.build
1933 index b483cd1..f1dd1f0 100644
1934 --- media/webrtc/signaling/test/common.build
1935 +++ media/webrtc/signaling/test/common.build
1936 @@ -99,6 +99,7 @@ if CONFIG['JS_SHARED_LIBRARY']:
1937  
1938  USE_LIBS += ['mozglue']
1939  
1940 +OS_LIBS += CONFIG['MOZ_LIBV4L2_LIBS']
1941  OS_LIBS += CONFIG['MOZ_WEBRTC_X11_LIBS']
1942  OS_LIBS += CONFIG['REALTIME_LIBS']
1943  
1944 diff --git media/webrtc/trunk/webrtc/modules/video_capture/linux/device_info_linux.cc media/webrtc/trunk/webrtc/modules/video_capture/linux/device_info_linux.cc
1945 index 239a292..bab496c 100644
1946 --- media/webrtc/trunk/webrtc/modules/video_capture/linux/device_info_linux.cc
1947 +++ media/webrtc/trunk/webrtc/modules/video_capture/linux/device_info_linux.cc
1948 @@ -25,6 +25,9 @@
1949  #else
1950  #include <linux/videodev2.h>
1951  #endif
1952 +#ifdef HAVE_LIBV4L2
1953 +#include <libv4l2.h>
1954 +#endif
1955  
1956  #include "webrtc/system_wrappers/interface/ref_count.h"
1957  #include "webrtc/system_wrappers/interface/trace.h"
1958 @@ -34,6 +37,15 @@
1959  #define BUF_LEN     ( 1024 * ( EVENT_SIZE + 16 ) )
1960  #endif
1961  
1962 +#ifdef HAVE_LIBV4L2
1963 +#define open   v4l2_open
1964 +#define close  v4l2_close
1965 +#define dup    v4l2_dup
1966 +#define ioctl  v4l2_ioctl
1967 +#define mmap   v4l2_mmap
1968 +#define munmap v4l2_munmap
1969 +#endif
1970 +
1971  namespace webrtc
1972  {
1973  namespace videocapturemodule
1974 @@ -274,6 +286,11 @@ int32_t DeviceInfoLinux::GetDeviceName(
1975      memset(deviceNameUTF8, 0, deviceNameLength);
1976      memcpy(cameraName, cap.card, sizeof(cap.card));
1977  
1978 +    if (cameraName[0] == '\0')
1979 +    {
1980 +        sprintf(cameraName, "Camera at /dev/video%d", deviceNumber);
1981 +    }
1982 +
1983      if (deviceNameLength >= strlen(cameraName))
1984      {
1985          memcpy(deviceNameUTF8, cameraName, strlen(cameraName));
1986 diff --git media/webrtc/trunk/webrtc/modules/video_capture/linux/video_capture_linux.cc media/webrtc/trunk/webrtc/modules/video_capture/linux/video_capture_linux.cc
1987 index 12df1b3..e9863ba 100644
1988 --- media/webrtc/trunk/webrtc/modules/video_capture/linux/video_capture_linux.cc
1989 +++ media/webrtc/trunk/webrtc/modules/video_capture/linux/video_capture_linux.cc
1990 @@ -25,6 +25,9 @@
1991  #else
1992  #include <linux/videodev2.h>
1993  #endif
1994 +#ifdef HAVE_LIBV4L2
1995 +#include <libv4l2.h>
1996 +#endif
1997  
1998  #include <new>
1999  
2000 @@ -26,6 +31,15 @@
2001  #include "critical_section_wrapper.h"
2002  #include "video_capture_linux.h"
2003  
2004 +#ifdef HAVE_LIBV4L2
2005 +#define open   v4l2_open
2006 +#define close  v4l2_close
2007 +#define dup    v4l2_dup
2008 +#define ioctl  v4l2_ioctl
2009 +#define mmap   v4l2_mmap
2010 +#define munmap v4l2_munmap
2011 +#endif
2012 +
2013  namespace webrtc
2014  {
2015  namespace videocapturemodule
2016 diff --git media/webrtc/trunk/webrtc/modules/video_capture/video_capture.gypi media/webrtc/trunk/webrtc/modules/video_capture/video_capture.gypi
2017 index d46b5aa..e452223 100644
2018 --- media/webrtc/trunk/webrtc/modules/video_capture/video_capture.gypi
2019 +++ media/webrtc/trunk/webrtc/modules/video_capture/video_capture.gypi
2020 @@ -7,6 +7,9 @@
2021  # be found in the AUTHORS file in the root of the source tree.
2022  
2023  {
2024 +  'variables': {
2025 +     'use_libv4l2%': 0,
2026 +  },
2027    'targets': [
2028      {
2029        'target_name': 'video_capture_module',
2030 @@ -75,6 +78,19 @@
2031                  'linux/video_capture_linux.cc',
2032                  'linux/video_capture_linux.h',
2033                ],
2034 +              'conditions': [
2035 +                ['use_libv4l2==1', {
2036 +                  'defines': [
2037 +                    'HAVE_LIBV4L2',
2038 +                  ],
2039 +                  'cflags_mozilla': [
2040 +                    '$(MOZ_LIBV4L2_CFLAGS)',
2041 +                  ],
2042 +                  'libraries': [
2043 +                    '-lv4l2',
2044 +                  ],
2045 +                }],
2046 +              ],
2047              }],  # linux
2048              ['OS=="mac"', {
2049                'sources': [
2050 diff --git toolkit/library/moz.build toolkit/library/moz.build
2051 index 9c16ffa..1db3794 100644
2052 --- toolkit/library/moz.build
2053 +++ toolkit/library/moz.build
2054 @@ -163,6 +163,7 @@ if CONFIG['OS_ARCH'] == 'Linux' and CONF
2055      ]
2056  
2057  OS_LIBS += CONFIG['MOZ_CAIRO_OSLIBS']
2058 +OS_LIBS += CONFIG['MOZ_LIBV4L2_LIBS']
2059  OS_LIBS += CONFIG['MOZ_WEBRTC_X11_LIBS']
2060  OS_LIBS += CONFIG['MOZ_APP_EXTRA_LIBS']
2061  
2062
2063
2064 [FILE:9436:patches/patch-bug847568]
2065 # Allow building against system-wide graphite2/harfbuzz.
2066
2067 diff --git config/Makefile.in config/Makefile.in
2068 index e2e11dc0e27e..a6206bb0ff30 100644
2069 --- config/Makefile.in
2070 +++ config/Makefile.in
2071 @@ -41,6 +41,8 @@ export:: $(export-preqs)
2072         $(PYTHON) -m mozbuild.action.preprocessor $(DEFINES) $(ACDEFINES) \
2073                 -DMOZ_TREE_CAIRO=$(MOZ_TREE_CAIRO) \
2074                 -DMOZ_TREE_PIXMAN=$(MOZ_TREE_PIXMAN) \
2075 +               -DMOZ_SYSTEM_GRAPHITE2=$(MOZ_SYSTEM_GRAPHITE2) \
2076 +               -DMOZ_SYSTEM_HARFBUZZ=$(MOZ_SYSTEM_HARFBUZZ) \
2077                 -DMOZ_SYSTEM_HUNSPELL=$(MOZ_SYSTEM_HUNSPELL) \
2078                 -DMOZ_SYSTEM_BZ2=$(MOZ_SYSTEM_BZ2) \
2079                 -DMOZ_SYSTEM_ZLIB=$(MOZ_SYSTEM_ZLIB) \
2080 diff --git config/system-headers config/system-headers
2081 index a0c53c651a3e..5ee7f71f9634 100644
2082 --- config/system-headers
2083 +++ config/system-headers
2084 @@ -1269,6 +1269,15 @@ libsn/sn-launcher.h
2085  libsn/sn-monitor.h
2086  libsn/sn-util.h
2087  #endif
2088 +#if MOZ_SYSTEM_GRAPHITE2==1
2089 +graphite2/Font.h
2090 +graphite2/Segment.h
2091 +#endif
2092 +#if MOZ_SYSTEM_HARFBUZZ==1
2093 +harfbuzz/hb-glib.h
2094 +harfbuzz/hb-ot.h
2095 +harfbuzz/hb.h
2096 +#endif
2097  #if MOZ_SYSTEM_HUNSPELL==1
2098  hunspell.hxx
2099  #endif
2100 diff --git dom/base/moz.build dom/base/moz.build
2101 index 8e19020315ae..2fcdbb6f7b42 100644
2102 --- dom/base/moz.build
2103 +++ dom/base/moz.build
2104 @@ -464,6 +464,9 @@ if CONFIG['MOZ_BUILD_APP'] in ['browser', 'mobile/android', 'xulrunner']:
2105  if CONFIG['MOZ_X11']:
2106      CXXFLAGS += CONFIG['TK_CFLAGS']
2107  
2108 +if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
2109 +    CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
2110 +
2111  GENERATED_FILES += [
2112      'PropertyUseCounterMap.inc',
2113      'UseCounterList.h',
2114 diff --git gfx/graphite2/moz-gr-update.sh gfx/graphite2/moz-gr-update.sh
2115 index faaab1b17971..04eff5f09882 100644
2116 --- gfx/graphite2/moz-gr-update.sh
2117 +++ gfx/graphite2/moz-gr-update.sh
2118 @@ -1,6 +1,7 @@
2119  #!/bin/bash
2120  
2121  # Script used to update the Graphite2 library in the mozilla source tree
2122 +# and bump version for --with-system-graphite2
2123  
2124  # This script lives in gfx/graphite2, along with the library source,
2125  # but must be run from the top level of the mozilla-central tree.
2126 @@ -37,12 +38,16 @@ echo "See" $0 "for update procedure." >> gfx/graphite2/README.mozilla
2127  #find gfx/graphite2/ -name "*.cpp" -exec perl -p -i -e "s/<cstdio>/<stdio.h>/;s/Windows.h/windows.h/;" {} \;
2128  #find gfx/graphite2/ -name "*.h" -exec perl -p -i -e "s/<cstdio>/<stdio.h>/;s/Windows.h/windows.h/;" {} \;
2129  
2130 +# chase version for --with-system-graphite2
2131 +perl -p -i -e "s/[0-9]+\,[0-9]+\,[0-9]+/$RELEASE/ and tr/./,/ \
2132 +  if /GR2_VERSION_REQUIRE/" old-configure.in
2133 +
2134  # summarize what's been touched
2135  echo Updated to $RELEASE.
2136  echo Here is what changed in the gfx/graphite2 directory:
2137  echo
2138  
2139 -hg stat gfx/graphite2
2140 +hg stat old-configure.in gfx/graphite2
2141  
2142  echo
2143  echo If gfx/graphite2/src/files.mk has changed, please make corresponding
2144 diff --git gfx/harfbuzz/README-mozilla gfx/harfbuzz/README-mozilla
2145 index 22c76a7df020..a01490bd49ee 100644
2146 --- gfx/harfbuzz/README-mozilla
2147 +++ gfx/harfbuzz/README-mozilla
2148 @@ -19,3 +19,8 @@ the mozilla tree.
2149  
2150  If the collection of source files changes, manual updates to moz.build may be
2151  needed, as we don't use the upstream makefiles.
2152 +
2153 +The in-tree copy may be omitted during build by --with-system-harfbuzz.
2154 +Make sure to keep pkg-config version check within toolkit/moz.configure in sync
2155 +with checkout version or increment latest tag by one if it's not based
2156 +on upstream release.
2157 diff --git gfx/moz.build gfx/moz.build
2158 index 771f652e837a..3b358d84e384 100644
2159 --- gfx/moz.build
2160 +++ gfx/moz.build
2161 @@ -10,6 +10,12 @@ with Files('**'):
2162  if CONFIG['MOZ_TREE_CAIRO']:
2163      DIRS += ['cairo']
2164  
2165 +if not CONFIG['MOZ_SYSTEM_GRAPHITE2']:
2166 +    DIRS += ['graphite2/src' ]
2167 +
2168 +if not CONFIG['MOZ_SYSTEM_HARFBUZZ']:
2169 +    DIRS += ['harfbuzz/src']
2170 +
2171  DIRS += [
2172      '2d',
2173      'ycbcr',
2174 @@ -18,8 +24,6 @@ DIRS += [
2175      'qcms',
2176      'gl',
2177      'layers',
2178 -    'graphite2/src',
2179 -    'harfbuzz/src',
2180      'ots/src',
2181      'thebes',
2182      'ipc',
2183 diff --git gfx/skia/generate_mozbuild.py gfx/skia/generate_mozbuild.py
2184 index e06ae3457a47..93faa61594a3 100755
2185 --- gfx/skia/generate_mozbuild.py
2186 +++ gfx/skia/generate_mozbuild.py
2187 @@ -143,6 +143,9 @@ if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
2188          '-Wno-unused-private-field',
2189      ]
2190  
2191 +if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
2192 +    CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
2193 +
2194  if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'android'):
2195      CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
2196      CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
2197 diff --git gfx/skia/moz.build gfx/skia/moz.build
2198 index 2118677ca3a8..e4978b413784 100644
2199 --- gfx/skia/moz.build
2200 +++ gfx/skia/moz.build
2201 @@ -753,6 +753,9 @@ if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
2202          '-Wno-unused-private-field',
2203      ]
2204  
2205 +if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
2206 +    CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
2207 +
2208  if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'android'):
2209      CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
2210      CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
2211 diff --git gfx/thebes/moz.build gfx/thebes/moz.build
2212 index dee9b7bfa2cb..bd801f3a468e 100644
2213 --- gfx/thebes/moz.build
2214 +++ gfx/thebes/moz.build
2215 @@ -273,7 +273,13 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
2216  
2217  LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
2218  
2219 -DEFINES['GRAPHITE2_STATIC'] = True
2220 +if CONFIG['MOZ_SYSTEM_GRAPHITE2']:
2221 +    CXXFLAGS += CONFIG['MOZ_GRAPHITE2_CFLAGS']
2222 +else:
2223 +    DEFINES['GRAPHITE2_STATIC'] = True
2224 +
2225 +if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
2226 +    CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
2227  
2228  if CONFIG['CLANG_CXX']:
2229      # Suppress warnings from Skia header files.
2230 diff --git intl/unicharutil/util/moz.build intl/unicharutil/util/moz.build
2231 index cb1233c56d7e..06fb1f9f174b 100644
2232 --- intl/unicharutil/util/moz.build
2233 +++ intl/unicharutil/util/moz.build
2234 @@ -40,4 +40,7 @@ if CONFIG['_MSC_VER']:
2235  if CONFIG['ENABLE_INTL_API']:
2236      USE_LIBS += ['icu']
2237  
2238 +if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
2239 +    CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
2240 +
2241  DIST_INSTALL = True
2242 diff --git netwerk/dns/moz.build netwerk/dns/moz.build
2243 index 79c26e3e7001..c4d93bc5f7dc 100644
2244 --- netwerk/dns/moz.build
2245 +++ netwerk/dns/moz.build
2246 @@ -69,6 +69,9 @@ LOCAL_INCLUDES += [
2247      '/netwerk/base',
2248  ]
2249  
2250 +if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
2251 +    CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
2252 +
2253  if CONFIG['ENABLE_INTL_API']:
2254      DEFINES['IDNA2008'] = True
2255      USE_LIBS += ['icu']
2256 diff --git old-configure.in old-configure.in
2257 index 95a58b634593..b614eef85c89 100644
2258 --- old-configure.in
2259 +++ old-configure.in
2260 @@ -4888,6 +4888,27 @@ dnl ========================================================
2261  AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
2262  
2263  dnl ========================================================
2264 +dnl Check for graphite2
2265 +dnl ========================================================
2266 +if test -n "$MOZ_SYSTEM_GRAPHITE2"; then
2267 +    dnl graphite2.pc has bogus version, check manually
2268 +    _SAVE_CFLAGS=$CFLAGS
2269 +    CFLAGS="$CFLAGS $MOZ_GRAPHITE2_CFLAGS"
2270 +    AC_TRY_COMPILE([ #include <graphite2/Font.h>
2271 +                     #define GR2_VERSION_REQUIRE(major,minor,bugfix)  \
2272 +                             ( GR2_VERSION_MAJOR * 10000 + GR2_VERSION_MINOR \
2273 +                               * 100 + GR2_VERSION_BUGFIX >= \
2274 +                               (major) * 10000 + (minor) * 100 + (bugfix) )
2275 +                   ], [
2276 +                     #if !GR2_VERSION_REQUIRE(1,3,8)
2277 +                     #error "Insufficient graphite2 version."
2278 +                     #endif
2279 +                   ], [],
2280 +                   [AC_MSG_ERROR([--with-system-graphite2 requested but no working libgraphite2 found])])
2281 +    CFLAGS=$_SAVE_CFLAGS
2282 +fi
2283 +
2284 +dnl ========================================================
2285  dnl Check for pixman and cairo
2286  dnl ========================================================
2287  
2288 diff --git toolkit/library/moz.build toolkit/library/moz.build
2289 index 24f940e1ed7e..079a575adec3 100644
2290 --- toolkit/library/moz.build
2291 +++ toolkit/library/moz.build
2292 @@ -228,6 +228,12 @@ if CONFIG['MOZ_SYSTEM_JPEG']:
2293  if CONFIG['MOZ_SYSTEM_PNG']:
2294      OS_LIBS += CONFIG['MOZ_PNG_LIBS']
2295  
2296 +if CONFIG['MOZ_SYSTEM_GRAPHITE2']:
2297 +    OS_LIBS += CONFIG['MOZ_GRAPHITE2_LIBS']
2298 +
2299 +if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
2300 +    OS_LIBS += CONFIG['MOZ_HARFBUZZ_LIBS']
2301 +
2302  if CONFIG['MOZ_SYSTEM_HUNSPELL']:
2303      OS_LIBS += CONFIG['MOZ_HUNSPELL_LIBS']
2304  
2305 diff --git toolkit/moz.configure toolkit/moz.configure
2306 index 9297e4d6f501..d8e273887e4b 100644
2307 --- toolkit/moz.configure
2308 +++ toolkit/moz.configure
2309 @@ -343,6 +343,26 @@ add_old_configure_assignment('FT2_LIBS',
2310  add_old_configure_assignment('FT2_CFLAGS',
2311                               delayed_getattr(ft2_info, 'cflags'))
2312  
2313 +# Graphite2
2314 +# ==============================================================
2315 +option('--with-system-graphite2',
2316 +       help="Use system graphite2 (located with pkgconfig)")
2317 +
2318 +system_graphite2 = pkg_check_modules('MOZ_GRAPHITE2', 'graphite2',
2319 +                                     when='--with-system-graphite2')
2320 +
2321 +set_config('MOZ_SYSTEM_GRAPHITE2', depends_if(system_graphite2)(lambda _: True))
2322 +
2323 +# HarfBuzz
2324 +# ==============================================================
2325 +option('--with-system-harfbuzz',
2326 +       help="Use system harfbuzz (located with pkgconfig)")
2327 +
2328 +system_harfbuzz = pkg_check_modules('MOZ_HARFBUZZ', 'harfbuzz >= 1.4.1',
2329 +                                    when='--with-system-harfbuzz')
2330 +
2331 +set_config('MOZ_SYSTEM_HARFBUZZ', depends_if(system_harfbuzz)(lambda _: True))
2332 +
2333  # Apple platform decoder support
2334  # ==============================================================
2335  @depends(toolkit)
2336
2337
2338 [FILE:2582:patches/patch-bug981348]
2339 diff --git dom/system/OSFileConstants.cpp dom/system/OSFileConstants.cpp
2340 index 88bba9baa401..99f240952dfe 100644
2341 --- dom/system/OSFileConstants.cpp
2342 +++ dom/system/OSFileConstants.cpp
2343 @@ -16,14 +16,17 @@
2344  #include "dirent.h"
2345  #include "poll.h"
2346  #include "sys/stat.h"
2347 -#if defined(ANDROID)
2348 +#if defined(XP_LINUX)
2349  #include <sys/vfs.h>
2350  #define statvfs statfs
2351 +#define f_frsize f_bsize
2352  #else
2353  #include "sys/statvfs.h"
2354 +#endif // defined(XP_LINUX)
2355 +#if !defined(ANDROID)
2356  #include "sys/wait.h"
2357  #include <spawn.h>
2358 -#endif // defined(ANDROID)
2359 +#endif // !defined(ANDROID)
2360  #endif // defined(XP_UNIX)
2361  
2362  #if defined(XP_LINUX)
2363 @@ -699,7 +702,7 @@ static const dom::ConstantSpec gLibcProperties[] =
2364  
2365    { "OSFILE_SIZEOF_STATVFS", JS::Int32Value(sizeof (struct statvfs)) },
2366  
2367 -  { "OSFILE_OFFSETOF_STATVFS_F_BSIZE", JS::Int32Value(offsetof (struct statvfs, f_bsize)) },
2368 +  { "OSFILE_OFFSETOF_STATVFS_F_FRSIZE", JS::Int32Value(offsetof (struct statvfs, f_frsize)) },
2369    { "OSFILE_OFFSETOF_STATVFS_F_BAVAIL", JS::Int32Value(offsetof (struct statvfs, f_bavail)) },
2370  
2371  #endif // defined(XP_UNIX)
2372 diff --git toolkit/components/osfile/modules/osfile_unix_back.jsm toolkit/components/osfile/modules/osfile_unix_back.jsm
2373 index a028dda7d5ec..f5c632e3d7e5 100644
2374 --- toolkit/components/osfile/modules/osfile_unix_back.jsm
2375 +++ toolkit/components/osfile/modules/osfile_unix_back.jsm
2376 @@ -228,8 +228,8 @@
2377           let statvfs = new SharedAll.HollowStructure("statvfs",
2378             Const.OSFILE_SIZEOF_STATVFS);
2379  
2380 -         statvfs.add_field_at(Const.OSFILE_OFFSETOF_STATVFS_F_BSIZE,
2381 -                        "f_bsize", Type.unsigned_long.implementation);
2382 +         statvfs.add_field_at(Const.OSFILE_OFFSETOF_STATVFS_F_FRSIZE,
2383 +                        "f_frsize", Type.unsigned_long.implementation);
2384           statvfs.add_field_at(Const.OSFILE_OFFSETOF_STATVFS_F_BAVAIL,
2385                          "f_bavail", Type.fsblkcnt_t.implementation);
2386  
2387 diff --git toolkit/components/osfile/modules/osfile_unix_front.jsm toolkit/components/osfile/modules/osfile_unix_front.jsm
2388 index bd60d4d8419c..a8cd6b546b0e 100644
2389 --- toolkit/components/osfile/modules/osfile_unix_front.jsm
2390 +++ toolkit/components/osfile/modules/osfile_unix_front.jsm
2391 @@ -399,7 +399,7 @@
2392         throw_on_negative("statvfs",  (UnixFile.statvfs || UnixFile.statfs)(sourcePath, fileSystemInfoPtr));
2393  
2394         let bytes = new Type.uint64_t.implementation(
2395 -                        fileSystemInfo.f_bsize * fileSystemInfo.f_bavail);
2396 +                        fileSystemInfo.f_frsize * fileSystemInfo.f_bavail);
2397  
2398         return bytes.value;
2399       };
2400
2401
2402 [FILE:610:patches/patch-bug991253]
2403 --- extensions/spellcheck/hunspell/glue/mozHunspell.cpp~
2404 +++ extensions/spellcheck/hunspell/glue/mozHunspell.cpp
2405 @@ -392,6 +392,14 @@ mozHunspell::LoadDictionaryList(bool aNo
2406      }
2407    }
2408  
2409 +  // load system hunspell dictionaries
2410 +  nsCOMPtr<nsIFile> hunDir;
2411 +  NS_NewNativeLocalFile(NS_LITERAL_CSTRING("%%LOCALBASE%%/share/hunspell"),
2412 +                        true, getter_AddRefs(hunDir));
2413 +  if (hunDir) {
2414 +      LoadDictionariesFromDir(hunDir);
2415 +  }
2416 +
2417    // find dictionaries from extensions requiring restart
2418    nsCOMPtr<nsISimpleEnumerator> dictDirs;
2419    rv = dirSvc->Get(DICTIONARY_SEARCH_DIRECTORY_LIST,
2420
2421
2422 [FILE:581:patches/patch-build-pgo-profileserver.py]
2423 --- build/pgo/profileserver.py.orig     2011-02-24 21:49:47.000000000 +0100
2424 +++ build/pgo/profileserver.py  2011-02-24 21:50:30.000000000 +0100
2425 @@ -59,7 +59,7 @@ if __name__ == '__main__':
2426        env["MOZ_JAR_LOG_FILE"] = os.path.abspath(jarlog)
2427        print "jarlog: %s" % env["MOZ_JAR_LOG_FILE"]
2428  
2429 -    cmdargs = ["http://localhost:%d/index.html" % PORT]
2430 +    cmdargs = ["http://127.0.0.1:%d/index.html" % PORT]
2431      runner = FirefoxRunner(profile=profile,
2432                             binary=build.get_binary_path(where="staged-package"),
2433                             cmdargs=cmdargs,
2434
2435
2436 [FILE:714:patches/patch-config-baseconfig.mk]
2437 --- config/baseconfig.mk~
2438 +++ config/baseconfig.mk
2439 @@ -2,10 +2,10 @@
2440  # directly in python/mozbuild/mozbuild/base.py for gmake validation.
2441  # We thus use INCLUDED_AUTOCONF_MK to enable/disable some parts depending
2442  # whether a normal build is happening or whether the check is running.
2443 -includedir := $(includedir)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
2444 -idldir = $(datadir)/idl/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
2445 -installdir = $(libdir)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)
2446 -sdkdir = $(libdir)/$(MOZ_APP_NAME)-devel-$(MOZ_APP_VERSION)
2447 +includedir := $(includedir)/%%MOZILLA%%
2448 +idldir = $(datadir)/idl/%%MOZILLA%%
2449 +installdir = $(libdir)/%%MOZILLA%%
2450 +sdkdir = $(libdir)/%%MOZILLA%%
2451  ifeq (.,$(DEPTH))
2452  DIST = dist
2453  else
2454
2455
2456 [FILE:886:patches/patch-env-api-keys]
2457 # Accept API keys from environment like before bug 1294585
2458
2459 --- build/moz.configure/keyfiles.configure
2460 +++ build/moz.configure/keyfiles.configure
2461 @@ -18,6 +18,7 @@ def keyfile(desc, help=None, callback=lambda x: x):
2462      @checking('for the %s key' % desc, lambda x: x and x is not no_key)
2463      @imports(_from='__builtin__', _import='open')
2464      @imports(_from='__builtin__', _import='IOError')
2465 +    @imports(_from='os', _import='environ')
2466      def keyfile(value):
2467          if value:
2468              try:
2469 @@ -28,7 +29,7 @@ def keyfile(desc, help=None, callback=lambda x: x):
2470                      raise FatalCheckError("'%s' is empty." % value[0])
2471              except IOError as e:
2472                  raise FatalCheckError("'%s': %s." % (value[0], e.strerror))
2473 -        return no_key
2474 +        return environ.get('MOZ_%s_KEY' % desc.upper().replace(' ', '_')) or no_key
2475  
2476      return keyfile
2477  
2478
2479
2480 [FILE:21645:patches/patch-ijg-libjpeg]
2481 # Partially revert bug 791305 to allow building with system IJG jpeg library
2482
2483 diff --git old-configure.in configure.in
2484 index f0aeb5d..1c01010 100644
2485 --- old-configure.in
2486 +++ old-configure.in
2487 @@ -4027,11 +4027,7 @@ if test "$MOZ_SYSTEM_JPEG" = 1; then
2488                       #include <jpeglib.h> ],
2489                     [ #if JPEG_LIB_VERSION < $MOZJPEG
2490                       #error "Insufficient JPEG library version ($MOZJPEG required)."
2491 -                     #endif
2492 -                     #ifndef JCS_EXTENSIONS
2493 -                     #error "libjpeg-turbo JCS_EXTENSIONS required"
2494 -                     #endif
2495 -                     ],
2496 +                     #endif ],
2497                     MOZ_SYSTEM_JPEG=1,
2498                     AC_MSG_ERROR([Insufficient JPEG library version for --with-system-jpeg]))
2499  fi
2500 diff --git image/decoders/nsJPEGDecoder.cpp image/decoders/nsJPEGDecoder.cpp
2501 index 8fa8200..1d2a259 100644
2502 --- image/decoders/nsJPEGDecoder.cpp
2503 +++ image/decoders/nsJPEGDecoder.cpp
2504 @@ -21,13 +21,28 @@
2505  
2506  extern "C" {
2507  #include "iccjpeg.h"
2508 -}
2509  
2510 +#ifdef JCS_EXTENSIONS
2511  #if MOZ_BIG_ENDIAN
2512  #define MOZ_JCS_EXT_NATIVE_ENDIAN_XRGB JCS_EXT_XRGB
2513  #else
2514  #define MOZ_JCS_EXT_NATIVE_ENDIAN_XRGB JCS_EXT_BGRX
2515  #endif
2516 +#else
2517 +/* Colorspace conversion (copied from jpegint.h) */
2518 +struct jpeg_color_deconverter {
2519 +  JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
2520 +  JMETHOD(void, color_convert, (j_decompress_ptr cinfo,
2521 +                               JSAMPIMAGE input_buf, JDIMENSION input_row,
2522 +                               JSAMPARRAY output_buf, int num_rows));
2523 +};
2524 +
2525 +METHODDEF(void)
2526 +ycc_rgb_convert_argb (j_decompress_ptr cinfo,
2527 +                 JSAMPIMAGE input_buf, JDIMENSION input_row,
2528 +                 JSAMPARRAY output_buf, int num_rows);
2529 +#endif
2530 +}
2531  
2532  static void cmyk_convert_rgb(JSAMPROW row, JDIMENSION width);
2533  
2534 @@ -367,6 +382,7 @@ nsJPEGDecoder::WriteInternal(const char*
2535          case JCS_GRAYSCALE:
2536          case JCS_RGB:
2537          case JCS_YCbCr:
2538 +#ifdef JCS_EXTENSIONS
2539            // if we're not color managing we can decode directly to
2540            // MOZ_JCS_EXT_NATIVE_ENDIAN_XRGB
2541            if (mCMSMode != eCMSMode_All) {
2542 @@ -375,6 +391,9 @@ nsJPEGDecoder::WriteInternal(const char*
2543            } else {
2544                mInfo.out_color_space = JCS_RGB;
2545            }
2546 +#else
2547 +          mInfo.out_color_space = JCS_RGB;
2548 +#endif
2549            break;
2550          case JCS_CMYK:
2551          case JCS_YCCK:
2552 @@ -448,6 +467,16 @@ nsJPEGDecoder::WriteInternal(const char*
2553        return; // I/O suspension
2554      }
2555  
2556 +#ifndef JCS_EXTENSIONS
2557 +    /* Force to use our YCbCr to Packed RGB converter when possible */
2558 +    if (!mTransform && (mCMSMode != eCMSMode_All) &&
2559 +        mInfo.jpeg_color_space == JCS_YCbCr && mInfo.out_color_space == JCS_RGB) {
2560 +      /* Special case for the most common case: transform from YCbCr direct into packed ARGB */
2561 +      mInfo.out_color_components = 4; /* Packed ARGB pixels are always 4 bytes...*/
2562 +      mInfo.cconvert->color_convert = ycc_rgb_convert_argb;
2563 +    }
2564 +#endif
2565 +
2566      // If this is a progressive JPEG ...
2567      mState = mInfo.buffered_image ?
2568               JPEG_DECOMPRESS_PROGRESSIVE : JPEG_DECOMPRESS_SEQUENTIAL;
2569 @@ -605,7 +633,11 @@ nsJPEGDecoder::OutputScanlines(bool* sus
2570        uint32_t* imageRow = ((uint32_t*)mImageData) +
2571                             (mInfo.output_scanline * mInfo.output_width);
2572  
2573 +#ifdef JCS_EXTENSIONS
2574        if (mInfo.out_color_space == MOZ_JCS_EXT_NATIVE_ENDIAN_XRGB) {
2575 +#else
2576 +      if (mInfo.cconvert->color_convert == ycc_rgb_convert_argb) {
2577 +#endif
2578          // Special case: scanline will be directly converted into packed ARGB
2579          if (jpeg_read_scanlines(&mInfo, (JSAMPARRAY)&imageRow, 1) != 1) {
2580            *suspend = true; // suspend
2581 @@ -920,6 +952,282 @@ term_source (j_decompress_ptr jd)
2582  } // namespace mozilla
2583  
2584  
2585 +#ifndef JCS_EXTENSIONS
2586 +/**************** YCbCr -> Cairo's RGB24/ARGB32 conversion: most common case **************/
2587 +
2588 +/*
2589 + * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
2590 + * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
2591 + * The conversion equations to be implemented are therefore
2592 + *      R = Y                + 1.40200 * Cr
2593 + *      G = Y - 0.34414 * Cb - 0.71414 * Cr
2594 + *      B = Y + 1.77200 * Cb
2595 + * where Cb and Cr represent the incoming values less CENTERJSAMPLE.
2596 + * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.)
2597 + *
2598 + * To avoid floating-point arithmetic, we represent the fractional constants
2599 + * as integers scaled up by 2^16 (about 4 digits precision); we have to divide
2600 + * the products by 2^16, with appropriate rounding, to get the correct answer.
2601 + * Notice that Y, being an integral input, does not contribute any fraction
2602 + * so it need not participate in the rounding.
2603 + *
2604 + * For even more speed, we avoid doing any multiplications in the inner loop
2605 + * by precalculating the constants times Cb and Cr for all possible values.
2606 + * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
2607 + * for 12-bit samples it is still acceptable.  It's not very reasonable for
2608 + * 16-bit samples, but if you want lossless storage you shouldn't be changing
2609 + * colorspace anyway.
2610 + * The Cr=>R and Cb=>B values can be rounded to integers in advance; the
2611 + * values for the G calculation are left scaled up, since we must add them
2612 + * together before rounding.
2613 + */
2614 +
2615 +#define SCALEBITS       16      /* speediest right-shift on some machines */
2616 +
2617 +/* Use static tables for color processing. */
2618 +/* Four tables, each 256 entries of 4 bytes totals 4K which is not bad... */
2619 +
2620 +const int Cr_r_tab[(MAXJSAMPLE+1) * sizeof(int)] ={
2621 +       -0xb3,       -0xb2,       -0xb1,       -0xaf,       -0xae,       -0xac,
2622 +       -0xab,       -0xaa,       -0xa8,       -0xa7,       -0xa5,       -0xa4,
2623 +       -0xa3,       -0xa1,       -0xa0,       -0x9e,       -0x9d,       -0x9c,
2624 +       -0x9a,       -0x99,       -0x97,       -0x96,       -0x95,       -0x93,
2625 +       -0x92,       -0x90,       -0x8f,       -0x8e,       -0x8c,       -0x8b,
2626 +       -0x89,       -0x88,       -0x87,       -0x85,       -0x84,       -0x82,
2627 +       -0x81,       -0x80,       -0x7e,       -0x7d,       -0x7b,       -0x7a,
2628 +       -0x79,       -0x77,       -0x76,       -0x74,       -0x73,       -0x72,
2629 +       -0x70,       -0x6f,       -0x6d,       -0x6c,       -0x6b,       -0x69,
2630 +       -0x68,       -0x66,       -0x65,       -0x64,       -0x62,       -0x61,
2631 +       -0x5f,       -0x5e,       -0x5d,       -0x5b,       -0x5a,       -0x58,
2632 +       -0x57,       -0x56,       -0x54,       -0x53,       -0x51,       -0x50,
2633 +       -0x4f,       -0x4d,       -0x4c,       -0x4a,       -0x49,       -0x48,
2634 +       -0x46,       -0x45,       -0x43,       -0x42,       -0x40,       -0x3f,
2635 +       -0x3e,       -0x3c,       -0x3b,       -0x39,       -0x38,       -0x37,
2636 +       -0x35,       -0x34,       -0x32,       -0x31,       -0x30,       -0x2e,
2637 +       -0x2d,       -0x2b,       -0x2a,       -0x29,       -0x27,       -0x26,
2638 +       -0x24,       -0x23,       -0x22,       -0x20,       -0x1f,       -0x1d,
2639 +       -0x1c,       -0x1b,       -0x19,       -0x18,       -0x16,       -0x15,
2640 +       -0x14,       -0x12,       -0x11,       -0x0f,       -0x0e,       -0x0d,
2641 +       -0x0b,       -0x0a,       -0x08,       -0x07,       -0x06,       -0x04,
2642 +       -0x03,       -0x01,        0x00,        0x01,        0x03,        0x04,
2643 +        0x06,        0x07,        0x08,        0x0a,        0x0b,        0x0d,
2644 +        0x0e,        0x0f,        0x11,        0x12,        0x14,        0x15,
2645 +        0x16,        0x18,        0x19,        0x1b,        0x1c,        0x1d,
2646 +        0x1f,        0x20,        0x22,        0x23,        0x24,        0x26,
2647 +        0x27,        0x29,        0x2a,        0x2b,        0x2d,        0x2e,
2648 +        0x30,        0x31,        0x32,        0x34,        0x35,        0x37,
2649 +        0x38,        0x39,        0x3b,        0x3c,        0x3e,        0x3f,
2650 +        0x40,        0x42,        0x43,        0x45,        0x46,        0x48,
2651 +        0x49,        0x4a,        0x4c,        0x4d,        0x4f,        0x50,
2652 +        0x51,        0x53,        0x54,        0x56,        0x57,        0x58,
2653 +        0x5a,        0x5b,        0x5d,        0x5e,        0x5f,        0x61,
2654 +        0x62,        0x64,        0x65,        0x66,        0x68,        0x69,
2655 +        0x6b,        0x6c,        0x6d,        0x6f,        0x70,        0x72,
2656 +        0x73,        0x74,        0x76,        0x77,        0x79,        0x7a,
2657 +        0x7b,        0x7d,        0x7e,        0x80,        0x81,        0x82,
2658 +        0x84,        0x85,        0x87,        0x88,        0x89,        0x8b,
2659 +        0x8c,        0x8e,        0x8f,        0x90,        0x92,        0x93,
2660 +        0x95,        0x96,        0x97,        0x99,        0x9a,        0x9c,
2661 +        0x9d,        0x9e,        0xa0,        0xa1,        0xa3,        0xa4,
2662 +        0xa5,        0xa7,        0xa8,        0xaa,        0xab,        0xac,
2663 +        0xae,        0xaf,        0xb1,        0xb2,
2664 +  };
2665 +
2666 +const int Cb_b_tab[(MAXJSAMPLE+1) * sizeof(int)] ={
2667 +       -0xe3,       -0xe1,       -0xdf,       -0xde,       -0xdc,       -0xda,
2668 +       -0xd8,       -0xd6,       -0xd5,       -0xd3,       -0xd1,       -0xcf,
2669 +       -0xce,       -0xcc,       -0xca,       -0xc8,       -0xc6,       -0xc5,
2670 +       -0xc3,       -0xc1,       -0xbf,       -0xbe,       -0xbc,       -0xba,
2671 +       -0xb8,       -0xb7,       -0xb5,       -0xb3,       -0xb1,       -0xaf,
2672 +       -0xae,       -0xac,       -0xaa,       -0xa8,       -0xa7,       -0xa5,
2673 +       -0xa3,       -0xa1,       -0x9f,       -0x9e,       -0x9c,       -0x9a,
2674 +       -0x98,       -0x97,       -0x95,       -0x93,       -0x91,       -0x90,
2675 +       -0x8e,       -0x8c,       -0x8a,       -0x88,       -0x87,       -0x85,
2676 +       -0x83,       -0x81,       -0x80,       -0x7e,       -0x7c,       -0x7a,
2677 +       -0x78,       -0x77,       -0x75,       -0x73,       -0x71,       -0x70,
2678 +       -0x6e,       -0x6c,       -0x6a,       -0x69,       -0x67,       -0x65,
2679 +       -0x63,       -0x61,       -0x60,       -0x5e,       -0x5c,       -0x5a,
2680 +       -0x59,       -0x57,       -0x55,       -0x53,       -0x52,       -0x50,
2681 +       -0x4e,       -0x4c,       -0x4a,       -0x49,       -0x47,       -0x45,
2682 +       -0x43,       -0x42,       -0x40,       -0x3e,       -0x3c,       -0x3a,
2683 +       -0x39,       -0x37,       -0x35,       -0x33,       -0x32,       -0x30,
2684 +       -0x2e,       -0x2c,       -0x2b,       -0x29,       -0x27,       -0x25,
2685 +       -0x23,       -0x22,       -0x20,       -0x1e,       -0x1c,       -0x1b,
2686 +       -0x19,       -0x17,       -0x15,       -0x13,       -0x12,       -0x10,
2687 +       -0x0e,       -0x0c,       -0x0b,       -0x09,       -0x07,       -0x05,
2688 +       -0x04,       -0x02,        0x00,        0x02,        0x04,        0x05,
2689 +        0x07,        0x09,        0x0b,        0x0c,        0x0e,        0x10,
2690 +        0x12,        0x13,        0x15,        0x17,        0x19,        0x1b,
2691 +        0x1c,        0x1e,        0x20,        0x22,        0x23,        0x25,
2692 +        0x27,        0x29,        0x2b,        0x2c,        0x2e,        0x30,
2693 +        0x32,        0x33,        0x35,        0x37,        0x39,        0x3a,
2694 +        0x3c,        0x3e,        0x40,        0x42,        0x43,        0x45,
2695 +        0x47,        0x49,        0x4a,        0x4c,        0x4e,        0x50,
2696 +        0x52,        0x53,        0x55,        0x57,        0x59,        0x5a,
2697 +        0x5c,        0x5e,        0x60,        0x61,        0x63,        0x65,
2698 +        0x67,        0x69,        0x6a,        0x6c,        0x6e,        0x70,
2699 +        0x71,        0x73,        0x75,        0x77,        0x78,        0x7a,
2700 +        0x7c,        0x7e,        0x80,        0x81,        0x83,        0x85,
2701 +        0x87,        0x88,        0x8a,        0x8c,        0x8e,        0x90,
2702 +        0x91,        0x93,        0x95,        0x97,        0x98,        0x9a,
2703 +        0x9c,        0x9e,        0x9f,        0xa1,        0xa3,        0xa5,
2704 +        0xa7,        0xa8,        0xaa,        0xac,        0xae,        0xaf,
2705 +        0xb1,        0xb3,        0xb5,        0xb7,        0xb8,        0xba,
2706 +        0xbc,        0xbe,        0xbf,        0xc1,        0xc3,        0xc5,
2707 +        0xc6,        0xc8,        0xca,        0xcc,        0xce,        0xcf,
2708 +        0xd1,        0xd3,        0xd5,        0xd6,        0xd8,        0xda,
2709 +        0xdc,        0xde,        0xdf,        0xe1,
2710 +  };
2711 +
2712 +const int Cr_g_tab[(MAXJSAMPLE+1) * sizeof(int)] ={
2713 +    0x5b6900,    0x5ab22e,    0x59fb5c,    0x59448a,    0x588db8,    0x57d6e6,
2714 +    0x572014,    0x566942,    0x55b270,    0x54fb9e,    0x5444cc,    0x538dfa,
2715 +    0x52d728,    0x522056,    0x516984,    0x50b2b2,    0x4ffbe0,    0x4f450e,
2716 +    0x4e8e3c,    0x4dd76a,    0x4d2098,    0x4c69c6,    0x4bb2f4,    0x4afc22,
2717 +    0x4a4550,    0x498e7e,    0x48d7ac,    0x4820da,    0x476a08,    0x46b336,
2718 +    0x45fc64,    0x454592,    0x448ec0,    0x43d7ee,    0x43211c,    0x426a4a,
2719 +    0x41b378,    0x40fca6,    0x4045d4,    0x3f8f02,    0x3ed830,    0x3e215e,
2720 +    0x3d6a8c,    0x3cb3ba,    0x3bfce8,    0x3b4616,    0x3a8f44,    0x39d872,
2721 +    0x3921a0,    0x386ace,    0x37b3fc,    0x36fd2a,    0x364658,    0x358f86,
2722 +    0x34d8b4,    0x3421e2,    0x336b10,    0x32b43e,    0x31fd6c,    0x31469a,
2723 +    0x308fc8,    0x2fd8f6,    0x2f2224,    0x2e6b52,    0x2db480,    0x2cfdae,
2724 +    0x2c46dc,    0x2b900a,    0x2ad938,    0x2a2266,    0x296b94,    0x28b4c2,
2725 +    0x27fdf0,    0x27471e,    0x26904c,    0x25d97a,    0x2522a8,    0x246bd6,
2726 +    0x23b504,    0x22fe32,    0x224760,    0x21908e,    0x20d9bc,    0x2022ea,
2727 +    0x1f6c18,    0x1eb546,    0x1dfe74,    0x1d47a2,    0x1c90d0,    0x1bd9fe,
2728 +    0x1b232c,    0x1a6c5a,    0x19b588,    0x18feb6,    0x1847e4,    0x179112,
2729 +    0x16da40,    0x16236e,    0x156c9c,    0x14b5ca,    0x13fef8,    0x134826,
2730 +    0x129154,    0x11da82,    0x1123b0,    0x106cde,    0x0fb60c,    0x0eff3a,
2731 +    0x0e4868,    0x0d9196,    0x0cdac4,    0x0c23f2,    0x0b6d20,    0x0ab64e,
2732 +    0x09ff7c,    0x0948aa,    0x0891d8,    0x07db06,    0x072434,    0x066d62,
2733 +    0x05b690,    0x04ffbe,    0x0448ec,    0x03921a,    0x02db48,    0x022476,
2734 +    0x016da4,    0x00b6d2,    0x000000,   -0x00b6d2,   -0x016da4,   -0x022476,
2735 +   -0x02db48,   -0x03921a,   -0x0448ec,   -0x04ffbe,   -0x05b690,   -0x066d62,
2736 +   -0x072434,   -0x07db06,   -0x0891d8,   -0x0948aa,   -0x09ff7c,   -0x0ab64e,
2737 +   -0x0b6d20,   -0x0c23f2,   -0x0cdac4,   -0x0d9196,   -0x0e4868,   -0x0eff3a,
2738 +   -0x0fb60c,   -0x106cde,   -0x1123b0,   -0x11da82,   -0x129154,   -0x134826,
2739 +   -0x13fef8,   -0x14b5ca,   -0x156c9c,   -0x16236e,   -0x16da40,   -0x179112,
2740 +   -0x1847e4,   -0x18feb6,   -0x19b588,   -0x1a6c5a,   -0x1b232c,   -0x1bd9fe,
2741 +   -0x1c90d0,   -0x1d47a2,   -0x1dfe74,   -0x1eb546,   -0x1f6c18,   -0x2022ea,
2742 +   -0x20d9bc,   -0x21908e,   -0x224760,   -0x22fe32,   -0x23b504,   -0x246bd6,
2743 +   -0x2522a8,   -0x25d97a,   -0x26904c,   -0x27471e,   -0x27fdf0,   -0x28b4c2,
2744 +   -0x296b94,   -0x2a2266,   -0x2ad938,   -0x2b900a,   -0x2c46dc,   -0x2cfdae,
2745 +   -0x2db480,   -0x2e6b52,   -0x2f2224,   -0x2fd8f6,   -0x308fc8,   -0x31469a,
2746 +   -0x31fd6c,   -0x32b43e,   -0x336b10,   -0x3421e2,   -0x34d8b4,   -0x358f86,
2747 +   -0x364658,   -0x36fd2a,   -0x37b3fc,   -0x386ace,   -0x3921a0,   -0x39d872,
2748 +   -0x3a8f44,   -0x3b4616,   -0x3bfce8,   -0x3cb3ba,   -0x3d6a8c,   -0x3e215e,
2749 +   -0x3ed830,   -0x3f8f02,   -0x4045d4,   -0x40fca6,   -0x41b378,   -0x426a4a,
2750 +   -0x43211c,   -0x43d7ee,   -0x448ec0,   -0x454592,   -0x45fc64,   -0x46b336,
2751 +   -0x476a08,   -0x4820da,   -0x48d7ac,   -0x498e7e,   -0x4a4550,   -0x4afc22,
2752 +   -0x4bb2f4,   -0x4c69c6,   -0x4d2098,   -0x4dd76a,   -0x4e8e3c,   -0x4f450e,
2753 +   -0x4ffbe0,   -0x50b2b2,   -0x516984,   -0x522056,   -0x52d728,   -0x538dfa,
2754 +   -0x5444cc,   -0x54fb9e,   -0x55b270,   -0x566942,   -0x572014,   -0x57d6e6,
2755 +   -0x588db8,   -0x59448a,   -0x59fb5c,   -0x5ab22e,
2756 + };
2757 +
2758 +const int Cb_g_tab[(MAXJSAMPLE+1) * sizeof(int)] ={
2759 +    0x2c8d00,    0x2c34e6,    0x2bdccc,    0x2b84b2,    0x2b2c98,    0x2ad47e,
2760 +    0x2a7c64,    0x2a244a,    0x29cc30,    0x297416,    0x291bfc,    0x28c3e2,
2761 +    0x286bc8,    0x2813ae,    0x27bb94,    0x27637a,    0x270b60,    0x26b346,
2762 +    0x265b2c,    0x260312,    0x25aaf8,    0x2552de,    0x24fac4,    0x24a2aa,
2763 +    0x244a90,    0x23f276,    0x239a5c,    0x234242,    0x22ea28,    0x22920e,
2764 +    0x2239f4,    0x21e1da,    0x2189c0,    0x2131a6,    0x20d98c,    0x208172,
2765 +    0x202958,    0x1fd13e,    0x1f7924,    0x1f210a,    0x1ec8f0,    0x1e70d6,
2766 +    0x1e18bc,    0x1dc0a2,    0x1d6888,    0x1d106e,    0x1cb854,    0x1c603a,
2767 +    0x1c0820,    0x1bb006,    0x1b57ec,    0x1affd2,    0x1aa7b8,    0x1a4f9e,
2768 +    0x19f784,    0x199f6a,    0x194750,    0x18ef36,    0x18971c,    0x183f02,
2769 +    0x17e6e8,    0x178ece,    0x1736b4,    0x16de9a,    0x168680,    0x162e66,
2770 +    0x15d64c,    0x157e32,    0x152618,    0x14cdfe,    0x1475e4,    0x141dca,
2771 +    0x13c5b0,    0x136d96,    0x13157c,    0x12bd62,    0x126548,    0x120d2e,
2772 +    0x11b514,    0x115cfa,    0x1104e0,    0x10acc6,    0x1054ac,    0x0ffc92,
2773 +    0x0fa478,    0x0f4c5e,    0x0ef444,    0x0e9c2a,    0x0e4410,    0x0debf6,
2774 +    0x0d93dc,    0x0d3bc2,    0x0ce3a8,    0x0c8b8e,    0x0c3374,    0x0bdb5a,
2775 +    0x0b8340,    0x0b2b26,    0x0ad30c,    0x0a7af2,    0x0a22d8,    0x09cabe,
2776 +    0x0972a4,    0x091a8a,    0x08c270,    0x086a56,    0x08123c,    0x07ba22,
2777 +    0x076208,    0x0709ee,    0x06b1d4,    0x0659ba,    0x0601a0,    0x05a986,
2778 +    0x05516c,    0x04f952,    0x04a138,    0x04491e,    0x03f104,    0x0398ea,
2779 +    0x0340d0,    0x02e8b6,    0x02909c,    0x023882,    0x01e068,    0x01884e,
2780 +    0x013034,    0x00d81a,    0x008000,    0x0027e6,   -0x003034,   -0x00884e,
2781 +   -0x00e068,   -0x013882,   -0x01909c,   -0x01e8b6,   -0x0240d0,   -0x0298ea,
2782 +   -0x02f104,   -0x03491e,   -0x03a138,   -0x03f952,   -0x04516c,   -0x04a986,
2783 +   -0x0501a0,   -0x0559ba,   -0x05b1d4,   -0x0609ee,   -0x066208,   -0x06ba22,
2784 +   -0x07123c,   -0x076a56,   -0x07c270,   -0x081a8a,   -0x0872a4,   -0x08cabe,
2785 +   -0x0922d8,   -0x097af2,   -0x09d30c,   -0x0a2b26,   -0x0a8340,   -0x0adb5a,
2786 +   -0x0b3374,   -0x0b8b8e,   -0x0be3a8,   -0x0c3bc2,   -0x0c93dc,   -0x0cebf6,
2787 +   -0x0d4410,   -0x0d9c2a,   -0x0df444,   -0x0e4c5e,   -0x0ea478,   -0x0efc92,
2788 +   -0x0f54ac,   -0x0facc6,   -0x1004e0,   -0x105cfa,   -0x10b514,   -0x110d2e,
2789 +   -0x116548,   -0x11bd62,   -0x12157c,   -0x126d96,   -0x12c5b0,   -0x131dca,
2790 +   -0x1375e4,   -0x13cdfe,   -0x142618,   -0x147e32,   -0x14d64c,   -0x152e66,
2791 +   -0x158680,   -0x15de9a,   -0x1636b4,   -0x168ece,   -0x16e6e8,   -0x173f02,
2792 +   -0x17971c,   -0x17ef36,   -0x184750,   -0x189f6a,   -0x18f784,   -0x194f9e,
2793 +   -0x19a7b8,   -0x19ffd2,   -0x1a57ec,   -0x1ab006,   -0x1b0820,   -0x1b603a,
2794 +   -0x1bb854,   -0x1c106e,   -0x1c6888,   -0x1cc0a2,   -0x1d18bc,   -0x1d70d6,
2795 +   -0x1dc8f0,   -0x1e210a,   -0x1e7924,   -0x1ed13e,   -0x1f2958,   -0x1f8172,
2796 +   -0x1fd98c,   -0x2031a6,   -0x2089c0,   -0x20e1da,   -0x2139f4,   -0x21920e,
2797 +   -0x21ea28,   -0x224242,   -0x229a5c,   -0x22f276,   -0x234a90,   -0x23a2aa,
2798 +   -0x23fac4,   -0x2452de,   -0x24aaf8,   -0x250312,   -0x255b2c,   -0x25b346,
2799 +   -0x260b60,   -0x26637a,   -0x26bb94,   -0x2713ae,   -0x276bc8,   -0x27c3e2,
2800 +   -0x281bfc,   -0x287416,   -0x28cc30,   -0x29244a,   -0x297c64,   -0x29d47e,
2801 +   -0x2a2c98,   -0x2a84b2,   -0x2adccc,   -0x2b34e6,
2802 + };
2803 +
2804 +
2805 +/* We assume that right shift corresponds to signed division by 2 with
2806 + * rounding towards minus infinity.  This is correct for typical "arithmetic
2807 + * shift" instructions that shift in copies of the sign bit.  But some
2808 + * C compilers implement >> with an unsigned shift.  For these machines you
2809 + * must define RIGHT_SHIFT_IS_UNSIGNED.
2810 + * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity.
2811 + * It is only applied with constant shift counts.  SHIFT_TEMPS must be
2812 + * included in the variables of any routine using RIGHT_SHIFT.
2813 + */
2814 +
2815 +#ifdef RIGHT_SHIFT_IS_UNSIGNED
2816 +#define SHIFT_TEMPS    INT32 shift_temp;
2817 +#define RIGHT_SHIFT(x,shft)  \
2818 +       ((shift_temp = (x)) < 0 ? \
2819 +        (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \
2820 +        (shift_temp >> (shft)))
2821 +#else
2822 +#define SHIFT_TEMPS
2823 +#define RIGHT_SHIFT(x,shft)    ((x) >> (shft))
2824 +#endif
2825 +
2826 +
2827 +METHODDEF(void)
2828 +ycc_rgb_convert_argb (j_decompress_ptr cinfo,
2829 +                 JSAMPIMAGE input_buf, JDIMENSION input_row,
2830 +                 JSAMPARRAY output_buf, int num_rows)
2831 +{
2832 +  JDIMENSION num_cols = cinfo->output_width;
2833 +  JSAMPLE * range_limit = cinfo->sample_range_limit;
2834 +
2835 +  SHIFT_TEMPS
2836 +
2837 +  /* This is used if we don't have SSE2 */
2838 +
2839 +  while (--num_rows >= 0) {
2840 +    JSAMPROW inptr0 = input_buf[0][input_row];
2841 +    JSAMPROW inptr1 = input_buf[1][input_row];
2842 +    JSAMPROW inptr2 = input_buf[2][input_row];
2843 +    input_row++;
2844 +    uint32_t *outptr = (uint32_t *) *output_buf++;
2845 +    for (JDIMENSION col = 0; col < num_cols; col++) {
2846 +      int y  = GETJSAMPLE(inptr0[col]);
2847 +      int cb = GETJSAMPLE(inptr1[col]);
2848 +      int cr = GETJSAMPLE(inptr2[col]);
2849 +      JSAMPLE * range_limit_y = range_limit + y;
2850 +      /* Range-limiting is essential due to noise introduced by DCT losses. */
2851 +      outptr[col] = 0xFF000000 |
2852 +                    ( range_limit_y[Cr_r_tab[cr]] << 16 ) |
2853 +                    ( range_limit_y[((int) RIGHT_SHIFT(Cb_g_tab[cb] + Cr_g_tab[cr], SCALEBITS))] << 8 ) |
2854 +                    ( range_limit_y[Cb_b_tab[cb]] );
2855 +    }
2856 +  }
2857 +}
2858 +#endif
2859 +
2860 +
2861  ///*************** Inverted CMYK -> RGB conversion *************************
2862  /// Input is (Inverted) CMYK stored as 4 bytes per pixel.
2863  /// Output is RGB stored as 3 bytes per pixel.
2864
2865
2866 [FILE:536:patches/patch-sample-type]
2867 # Let ports handle default sample type
2868
2869 --- old-configure.in~
2870 +++ old-configure.in
2871 @@ -5144,7 +5144,7 @@ dnl Use integers over floats for audio o
2872  dnl (regarless of the CPU architecture, because audio
2873  dnl backends for those platforms don't support floats. We also
2874  dnl use integers on ARM with other OS, because it's more efficient.
2875 -if test "$OS_TARGET" = "Android" -o "$CPU_ARCH" = "arm"; then
2876 +if test -n "$MOZ_INTEGER_SAMPLES"; then
2877      MOZ_SAMPLE_TYPE_S16=1
2878      AC_DEFINE(MOZ_SAMPLE_TYPE_S16)
2879      AC_SUBST(MOZ_SAMPLE_TYPE_S16)
2880
2881
2882 [FILE:675:patches/patch-toolkit_mozapps_installer_packager_mk]
2883 $OpenBSD: patch-toolkit_mozapps_installer_packager_mk,v 1.11 2012/06/11 15:29:56 landry Exp $
2884 install headers/idl/sdk libs only if xulrunner
2885 --- toolkit/mozapps/installer/packager.mk.orig  Fri Jun  1 14:04:20 2012
2886 +++ toolkit/mozapps/installer/packager.mk       Tue Jun  5 07:55:51 2012
2887 @@ -127,7 +127,7 @@ endif
2888         $(NSINSTALL) -D $(DESTDIR)$(bindir)
2889         $(RM) -f $(DESTDIR)$(bindir)/$(MOZ_APP_NAME)
2890         ln -s $(installdir)/$(MOZ_APP_NAME) $(DESTDIR)$(bindir)
2891 -ifdef INSTALL_SDK # Here comes the hard part
2892 +ifeq ($(MOZ_APP_NAME),xulrunner)
2893         $(NSINSTALL) -D $(DESTDIR)$(includedir)
2894         (cd $(DIST)/include && tar $(TAR_CREATE_FLAGS) - .) | \
2895           (cd $(DESTDIR)$(includedir) && tar -xf -)
2896
2897
2898 [FILE:16913:patches/patch-z-bug517422]
2899 # Allow more config/external/ libs built against system-wide version.
2900
2901 diff --git build/moz.configure/old.configure build/moz.configure/old.configure
2902 index d0fe7accffe6..c46bdd023225 100644
2903 --- build/moz.configure/old.configure
2904 +++ build/moz.configure/old.configure
2905 @@ -288,7 +288,12 @@ def old_configure_options(*options):
2906      '--with-system-libvpx',
2907      '--with-system-nspr',
2908      '--with-system-nss',
2909 +    '--with-system-ogg',
2910      '--with-system-png',
2911 +    '--with-system-soundtouch',
2912 +    '--with-system-theora',
2913 +    '--with-system-tremor',
2914 +    '--with-system-vorbis',
2915      '--with-system-zlib',
2916      '--with-thumb',
2917      '--with-thumb-interwork',
2918 diff --git config/Makefile.in config/Makefile.in
2919 index a6206bb0ff30..f20987c61754 100644
2920 --- config/Makefile.in
2921 +++ config/Makefile.in
2922 @@ -51,6 +51,11 @@ export:: $(export-preqs)
2923                 -DMOZ_SYSTEM_LIBEVENT=$(MOZ_SYSTEM_LIBEVENT) \
2924                 -DMOZ_SYSTEM_LIBVPX=$(MOZ_SYSTEM_LIBVPX) \
2925                 -DMOZ_SYSTEM_ICU=$(MOZ_SYSTEM_ICU) \
2926 +               -DMOZ_SYSTEM_OGG=$(MOZ_SYSTEM_OGG) \
2927 +               -DMOZ_SYSTEM_THEORA=$(MOZ_SYSTEM_THEORA) \
2928 +               -DMOZ_SYSTEM_VORBIS=$(MOZ_SYSTEM_VORBIS) \
2929 +               -DMOZ_SYSTEM_TREMOR=$(MOZ_SYSTEM_TREMOR) \
2930 +               -DMOZ_SYSTEM_SOUNDTOUCH=$(MOZ_SYSTEM_SOUNDTOUCH) \
2931                 $(srcdir)/system-headers $(srcdir)/stl-headers | $(PERL) $(topsrcdir)/nsprpub/config/make-system-wrappers.pl system_wrappers
2932         $(INSTALL) system_wrappers $(DIST)
2933  
2934 diff --git config/external/moz.build config/external/moz.build
2935 index 029ff8504795..2c3a40caa1ba 100644
2936 --- config/external/moz.build
2937 +++ config/external/moz.build
2938 @@ -21,12 +21,21 @@ if CONFIG['MOZ_UPDATER']:
2939  external_dirs += ['modules/brotli']
2940  external_dirs += ['modules/woff2']
2941  
2942 -if CONFIG['MOZ_VORBIS']:
2943 +if not CONFIG['MOZ_SYSTEM_OGG']:
2944 +    external_dirs += ['media/libogg']
2945 +
2946 +if CONFIG['MOZ_VORBIS'] and not CONFIG['MOZ_SYSTEM_VORBIS']:
2947      external_dirs += ['media/libvorbis']
2948  
2949 -if CONFIG['MOZ_TREMOR']:
2950 +if CONFIG['MOZ_TREMOR'] and not CONFIG['MOZ_SYSTEM_TREMOR']:
2951      external_dirs += ['media/libtremor']
2952  
2953 +if not CONFIG['MOZ_SYSTEM_THEORA']:
2954 +    external_dirs += ['media/libtheora']
2955 +
2956 +if not CONFIG['MOZ_SYSTEM_SOUNDTOUCH']:
2957 +    external_dirs += ['media/libsoundtouch']
2958 +
2959  if CONFIG['MOZ_WEBM_ENCODER']:
2960      external_dirs += ['media/libmkv']
2961  
2962 @@ -52,12 +61,9 @@ external_dirs += [
2963      'media/kiss_fft',
2964      'media/libcubeb',
2965      'media/libnestegg',
2966 -    'media/libogg',
2967      'media/libopus',
2968 -    'media/libtheora',
2969      'media/libspeex_resampler',
2970      'media/libstagefright',
2971 -    'media/libsoundtouch',
2972      'media/psshparser'
2973  ]
2974  
2975 diff --git config/system-headers config/system-headers
2976 index 5ee7f71f9634..13178ac3b3ab 100644
2977 --- config/system-headers
2978 +++ config/system-headers
2979 @@ -1348,3 +1348,17 @@ unicode/utypes.h
2980  libutil.h
2981  unwind.h
2982  fenv.h
2983 +#if MOZ_SYSTEM_OGG==1
2984 +ogg/ogg.h
2985 +ogg/os_types.h
2986 +#endif
2987 +#if MOZ_SYSTEM_THEORA==1
2988 +theora/theoradec.h
2989 +#endif
2990 +#if MOZ_SYSTEM_VORBIS==1
2991 +vorbis/codec.h
2992 +vorbis/vorbisenc.h
2993 +#endif
2994 +#if MOZ_SYSTEM_TREMOR==1
2995 +tremor/ivorbiscodec.h
2996 +#endif
2997 diff --git dom/media/AudioStream.cpp dom/media/AudioStream.cpp
2998 index 93ecda4319af..ff674c64ea07 100644
2999 --- dom/media/AudioStream.cpp
3000 +++ dom/media/AudioStream.cpp
3001 @@ -115,7 +115,9 @@ AudioStream::AudioStream(DataSource& aSource)
3002    : mMonitor("AudioStream")
3003    , mChannels(0)
3004    , mOutChannels(0)
3005 +#ifndef MOZ_SYSTEM_SOUNDTOUCH
3006    , mTimeStretcher(nullptr)
3007 +#endif
3008    , mDumpFile(nullptr)
3009    , mState(INITIALIZED)
3010    , mDataSource(aSource)
3011 @@ -130,9 +132,11 @@ AudioStream::~AudioStream()
3012    if (mDumpFile) {
3013      fclose(mDumpFile);
3014    }
3015 +#ifndef MOZ_SYSTEM_SOUNDTOUCH
3016    if (mTimeStretcher) {
3017      soundtouch::destroySoundTouchObj(mTimeStretcher);
3018    }
3019 +#endif
3020  }
3021  
3022  size_t
3023 @@ -151,7 +155,11 @@ nsresult AudioStream::EnsureTimeStretcherInitializedUnlocked()
3024  {
3025    mMonitor.AssertCurrentThreadOwns();
3026    if (!mTimeStretcher) {
3027 +#ifdef MOZ_SYSTEM_SOUNDTOUCH
3028 +    mTimeStretcher = new soundtouch::SoundTouch();
3029 +#else
3030      mTimeStretcher = soundtouch::createSoundTouchObj();
3031 +#endif
3032      mTimeStretcher->setSampleRate(mAudioClock.GetInputRate());
3033      mTimeStretcher->setChannels(mOutChannels);
3034      mTimeStretcher->setPitch(1.0);
3035 diff --git dom/media/AudioStream.h dom/media/AudioStream.h
3036 index 7dc1f60f95cc..67d402a4117f 100644
3037 --- dom/media/AudioStream.h
3038 +++ dom/media/AudioStream.h
3039 @@ -16,7 +16,11 @@
3040  #include "mozilla/TimeStamp.h"
3041  #include "mozilla/UniquePtr.h"
3042  #include "CubebUtils.h"
3043 +#ifdef MOZ_SYSTEM_SOUNDTOUCH
3044 +#include "soundtouch/SoundTouch.h"
3045 +#else
3046  #include "soundtouch/SoundTouchFactory.h"
3047 +#endif
3048  
3049  namespace mozilla {
3050  
3051 @@ -287,7 +291,11 @@ private:
3052    uint32_t mChannels;
3053    uint32_t mOutChannels;
3054    AudioClock mAudioClock;
3055 +#ifdef MOZ_SYSTEM_SOUNDTOUCH
3056 +  nsAutoPtr<soundtouch::SoundTouch> mTimeStretcher;
3057 +#else
3058    soundtouch::SoundTouch* mTimeStretcher;
3059 +#endif
3060  
3061    // Output file for dumping audio
3062    FILE* mDumpFile;
3063 diff --git dom/media/moz.build dom/media/moz.build
3064 index 86b051c58d33..fb6186dce78b 100644
3065 --- dom/media/moz.build
3066 +++ dom/media/moz.build
3067 @@ -308,6 +308,21 @@ if CONFIG['MOZ_WEBRTC']:
3068  
3069  DEFINES['MOZILLA_INTERNAL_API'] = True
3070  
3071 +if CONFIG['MOZ_SYSTEM_OGG']:
3072 +    CXXFLAGS += CONFIG['MOZ_OGG_CFLAGS']
3073 +
3074 +if CONFIG['MOZ_SYSTEM_THEORA']:
3075 +    CXXFLAGS += CONFIG['MOZ_THEORA_CFLAGS']
3076 +
3077 +if CONFIG['MOZ_SYSTEM_VORBIS']:
3078 +    CXXFLAGS += CONFIG['MOZ_VORBIS_CFLAGS']
3079 +
3080 +if CONFIG['MOZ_SYSTEM_TREMOR']:
3081 +    CXXFLAGS += CONFIG['MOZ_TREMOR_CFLAGS']
3082 +
3083 +if CONFIG['MOZ_SYSTEM_SOUNDTOUCH']:
3084 +    CXXFLAGS += CONFIG['MOZ_SOUNDTOUCH_CFLAGS']
3085 +
3086  if CONFIG['OS_TARGET'] == 'WINNT':
3087      DEFINES['WEBRTC_WIN'] = True
3088  else:
3089 diff --git dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
3090 index 078f6ea5ef60..c600db067539 100644
3091 --- dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
3092 +++ dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp
3093 @@ -11,9 +11,13 @@
3094  #include "prmem.h"
3095  #include "prlink.h"
3096  
3097 +#ifdef MOZ_SYSTEM_SOUNDTOUCH
3098 +#include "nsXPCOMPrivate.h" // for XUL_DLL
3099 +#else
3100  // We use a known symbol located in lgpllibs to determine its location.
3101  // soundtouch happens to be always included in lgpllibs
3102  #include "soundtouch/SoundTouch.h"
3103 +#endif
3104  
3105  namespace mozilla {
3106  
3107 @@ -50,6 +54,12 @@ FFVPXRuntimeLinker::Init()
3108  
3109    sLinkStatus = LinkStatus_FAILED;
3110  
3111 +#ifdef MOZ_SYSTEM_SOUNDTOUCH
3112 +  // We retrieve the path of the XUL library as this is where mozavcodec and
3113 +  // mozavutil libs are located.
3114 +  char* path =
3115 +    PR_GetLibraryFilePathname(XUL_DLL, (PRFuncPtr)&FFVPXRuntimeLinker::Init);
3116 +#else
3117    // We retrieve the path of the lgpllibs library as this is where mozavcodec
3118    // and mozavutil libs are located.
3119    char* lgpllibsname = PR_GetLibraryName(nullptr, "lgpllibs");
3120 @@ -60,6 +70,7 @@ FFVPXRuntimeLinker::Init()
3121      PR_GetLibraryFilePathname(lgpllibsname,
3122                                (PRFuncPtr)&soundtouch::SoundTouch::getVersionId);
3123    PR_FreeLibraryName(lgpllibsname);
3124 +#endif
3125    if (!path) {
3126      return false;
3127    }
3128 diff --git media/libogg/README_MOZILLA media/libogg/README_MOZILLA
3129 index 6213fdc7770c..ada799916a17 100644
3130 --- media/libogg/README_MOZILLA
3131 +++ media/libogg/README_MOZILLA
3132 @@ -6,3 +6,6 @@ package downloaded from xiph.org and copied using the update.sh script.
3133  The int-types.patch address a bug that config_types.h generated from
3134  Linux platform can't be used on OpenSolaris directly see Mozilla bug
3135  449754
3136 +
3137 +The in-tree copy may be omitted during build by --with-system-ogg.
3138 +Keep version in old-configure.in in sync on updates.
3139 diff --git media/libsoundtouch/README_MOZILLA media/libsoundtouch/README_MOZILLA
3140 index dc0dbe8f6886..ea73b55e3e39 100644
3141 --- media/libsoundtouch/README_MOZILLA
3142 +++ media/libsoundtouch/README_MOZILLA
3143 @@ -6,3 +6,5 @@ The whole library is not used, only the relevant files are imported in the tree,
3144  using the script `update.sh`. Some changes have been made to the files, using
3145  the patch `moz-libsoundtouch.patch`. We also use a custom soundtouch_config.h.
3146  
3147 +The in-tree copy may be omitted during build by --with-system-soundtouch.
3148 +Keep version in old-configure.in in sync on updates.
3149 diff --git media/libsoundtouch/src/soundtouch_perms.h media/libsoundtouch/src/soundtouch_perms.h
3150 index 0af2fe618311..10973564e7a4 100644
3151 --- media/libsoundtouch/src/soundtouch_perms.h
3152 +++ media/libsoundtouch/src/soundtouch_perms.h
3153 @@ -12,7 +12,9 @@
3154  
3155  #pragma GCC visibility push(default)
3156  #include "SoundTouch.h"
3157 +#ifndef MOZ_SYSTEM_SOUNDTOUCH
3158  #include "SoundTouchFactory.h"
3159 +#endif
3160  #pragma GCC visibility pop
3161  
3162  #endif // MOZILLA_SOUNDTOUCH_PERMS_H
3163 diff --git media/libtheora/README_MOZILLA media/libtheora/README_MOZILLA
3164 index d48dbfa6f63d..6f30f250220e 100644
3165 --- media/libtheora/README_MOZILLA
3166 +++ media/libtheora/README_MOZILLA
3167 @@ -3,3 +3,6 @@ using the update.sh script. The changes made were those applied by update.sh,
3168  the addition/update of Makefile.in files for the Mozilla build system.
3169  
3170  The subversion revision used was r17578.
3171 +
3172 +The in-tree copy may be omitted during build by --with-system-theora.
3173 +Keep version in old-configure.in in sync on updates.
3174 diff --git media/libtheora/moz.build media/libtheora/moz.build
3175 index c7f85eebff95..aae7b814adb5 100644
3176 --- media/libtheora/moz.build
3177 +++ media/libtheora/moz.build
3178 @@ -21,6 +21,9 @@ FINAL_LIBRARY = 'gkmedias'
3179  # The encoder is currently not included.
3180  DEFINES['THEORA_DISABLE_ENCODE'] = True
3181  
3182 +if CONFIG['MOZ_SYSTEM_OGG']:
3183 +    CFLAGS += CONFIG['MOZ_OGG_CFLAGS']
3184 +
3185  # Suppress warnings in third-party code.
3186  if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
3187      CFLAGS += ['-Wno-type-limits']
3188 diff --git media/libtremor/README_MOZILLA media/libtremor/README_MOZILLA
3189 index ee67b53a05c5..81c971773d55 100644
3190 --- media/libtremor/README_MOZILLA
3191 +++ media/libtremor/README_MOZILLA
3192 @@ -5,3 +5,6 @@ Makefile.in files for the Mozilla build system.
3193  
3194  The upstream release used was http://svn.xiph.org/trunk/Tremor/
3195  The subversion revision used was r17547.
3196 +
3197 +The in-tree copy may be omitted during build by --with-system-tremor.
3198 +Keep version in old-configure.in in sync on updates.
3199 diff --git media/libtremor/moz.build media/libtremor/moz.build
3200 index 83afc8e37c64..71ef159da3d7 100644
3201 --- media/libtremor/moz.build
3202 +++ media/libtremor/moz.build
3203 @@ -9,3 +9,5 @@ with Files('*'):
3204  
3205  DIRS += ['include/tremor', 'lib']
3206  
3207 +if CONFIG['MOZ_SYSTEM_OGG']:
3208 +    CFLAGS += CONFIG['MOZ_OGG_CFLAGS']
3209 diff --git media/libvorbis/README_MOZILLA media/libvorbis/README_MOZILLA
3210 index 1211ac074b33..eb31084aed25 100644
3211 --- media/libvorbis/README_MOZILLA
3212 +++ media/libvorbis/README_MOZILLA
3213 @@ -8,3 +8,6 @@ https://svn.xiph.org/tags/vorbis/libvorbis-1.3.5@19464
3214  
3215  Some files are renamed during the copy to prevent clashes with object
3216  file names with other Mozilla libraries.
3217 +
3218 +The in-tree copy may be omitted during build by --with-system-vorbis.
3219 +Keep version in old-configure.in in sync on updates.
3220 diff --git media/libvorbis/moz.build media/libvorbis/moz.build
3221 index adf393782cc9..923b76231107 100644
3222 --- media/libvorbis/moz.build
3223 +++ media/libvorbis/moz.build
3224 @@ -56,3 +56,6 @@ FINAL_LIBRARY = 'gkmedias'
3225  # Suppress warnings in third-party code.
3226  if CONFIG['GNU_CC']:
3227      CFLAGS += ['-Wno-uninitialized']
3228 +
3229 +if CONFIG['MOZ_SYSTEM_OGG']:
3230 +    CFLAGS += CONFIG['MOZ_OGG_CFLAGS']
3231 diff --git old-configure.in old-configure.in
3232 index b614eef85c89..85f9099dba4d 100644
3233 --- old-configure.in
3234 +++ old-configure.in
3235 @@ -2941,6 +2941,111 @@ if test -n "$MOZ_OMX_PLUGIN"; then
3236      fi
3237  fi
3238  
3239 +dnl ========================================================
3240 +dnl Check for libogg
3241 +dnl ========================================================
3242 +
3243 +MOZ_ARG_WITH_BOOL(system-ogg,
3244 +[  --with-system-ogg       Use system libogg (located with pkgconfig)],
3245 +MOZ_SYSTEM_OGG=1,
3246 +MOZ_SYSTEM_OGG=)
3247 +
3248 +if test -n "$MOZ_SYSTEM_OGG"; then
3249 +    PKG_CHECK_MODULES(MOZ_OGG, ogg >= 1.3.0)
3250 +
3251 +    _SAVE_LIBS=$LIBS
3252 +    LIBS="$LIBS $MOZ_OGG_LIBS"
3253 +    AC_CHECK_FUNC(ogg_set_mem_functions, [],
3254 +      [AC_DEFINE(MOZ_OGG_NO_MEM_REPORTING)])
3255 +    LIBS=$_SAVE_LIBS
3256 +fi
3257 +
3258 +AC_SUBST(MOZ_SYSTEM_OGG)
3259 +
3260 +dnl ========================================================
3261 +dnl Check for libvorbis
3262 +dnl ========================================================
3263 +
3264 +MOZ_ARG_WITH_BOOL(system-vorbis,
3265 +[  --with-system-vorbis    Use system libvorbis (located with pkgconfig)],
3266 +MOZ_SYSTEM_VORBIS=1,
3267 +MOZ_SYSTEM_VORBIS=)
3268 +
3269 +if test -n "$MOZ_SYSTEM_VORBIS"; then
3270 +    PKG_CHECK_MODULES(MOZ_VORBIS, vorbis vorbisenc >= 1.3.5)
3271 +fi
3272 +
3273 +AC_SUBST(MOZ_SYSTEM_VORBIS)
3274 +
3275 +dnl ========================================================
3276 +dnl Check for integer-only libvorbis aka tremor
3277 +dnl ========================================================
3278 +
3279 +MOZ_ARG_WITH_BOOL(system-tremor,
3280 +[  --with-system-tremor    Use system libtremor (located with pkgconfig)],
3281 +MOZ_SYSTEM_TREMOR=1,
3282 +MOZ_SYSTEM_TREMOR=)
3283 +
3284 +if test -n "$MOZ_SYSTEM_TREMOR"; then
3285 +    PKG_CHECK_MODULES(MOZ_TREMOR, vorbisidec >= 1.2.1)
3286 +fi
3287 +
3288 +AC_SUBST(MOZ_SYSTEM_TREMOR)
3289 +
3290 +dnl ========================================================
3291 +dnl Check for libtheora
3292 +dnl ========================================================
3293 +
3294 +MOZ_ARG_WITH_BOOL(system-theora,
3295 +[  --with-system-theora    Use system libtheora (located with pkgconfig)],
3296 +MOZ_SYSTEM_THEORA=1,
3297 +MOZ_SYSTEM_THEORA=)
3298 +
3299 +if test -n "$MOZ_SYSTEM_THEORA"; then
3300 +    PKG_CHECK_MODULES(MOZ_THEORA, theora >= 1.2)
3301 +fi
3302 +
3303 +AC_SUBST(MOZ_SYSTEM_THEORA)
3304 +
3305 +dnl ========================================================
3306 +dnl Check for libSoundTouch
3307 +dnl ========================================================
3308 +
3309 +MOZ_ARG_WITH_BOOL(system-soundtouch,
3310 +[  --with-system-soundtouch Use system libSoundTouch (located with pkgconfig)],
3311 +MOZ_SYSTEM_SOUNDTOUCH=1,
3312 +MOZ_SYSTEM_SOUNDTOUCH=)
3313 +
3314 +if test -n "$MOZ_SYSTEM_SOUNDTOUCH"; then
3315 +    PKG_CHECK_MODULES(MOZ_SOUNDTOUCH, soundtouch >= 1.9.0)
3316 +
3317 +    AC_LANG_SAVE
3318 +    AC_LANG_CPLUSPLUS
3319 +    _SAVE_CXXFLAGS=$CXXFLAGS
3320 +    CXXFLAGS="$CXXFLAGS $MOZ_SOUNDTOUCH_CFLAGS"
3321 +    AC_CACHE_CHECK(for soundtouch sample type,
3322 +                   ac_cv_soundtouch_sample_type,
3323 +                   [AC_TRY_COMPILE([#include <SoundTouch.h>
3324 +                                    #ifndef SOUNDTOUCH_INTEGER_SAMPLES
3325 +                                    #error soundtouch expects float samples
3326 +                                    #endif],
3327 +                                   [],
3328 +                                   [ac_cv_soundtouch_sample_type=short],
3329 +                                   [ac_cv_soundtouch_sample_type=float])])
3330 +    CXXFLAGS=$_SAVE_CXXFLAGS
3331 +    AC_LANG_RESTORE
3332 +
3333 +    if test \( -n "$MOZ_SAMPLE_TYPE_S16" -a "$ac_cv_soundtouch_sample_type" != short \) \
3334 +         -o \( -n "$MOZ_SAMPLE_TYPE_FLOAT32" -a "$ac_cv_soundtouch_sample_type" != float \) ; then
3335 +        AC_MSG_ERROR([SoundTouch library is built with incompatible sample type. Either rebuild the library with/without --enable-integer-samples, chase default Mozilla sample type or remove --with-system-soundtouch.])
3336 +    fi
3337 +fi
3338 +
3339 +if test -n "$MOZ_SYSTEM_SOUNDTOUCH"; then
3340 +    AC_DEFINE(MOZ_SYSTEM_SOUNDTOUCH)
3341 +fi
3342 +AC_SUBST(MOZ_SYSTEM_SOUNDTOUCH)
3343 +
3344  dnl system libvpx Support
3345  dnl ========================================================
3346  MOZ_ARG_WITH_BOOL(system-libvpx,
3347 diff --git toolkit/library/moz.build toolkit/library/moz.build
3348 index 079a575adec3..514d901195de 100644
3349 --- toolkit/library/moz.build
3350 +++ toolkit/library/moz.build
3351 @@ -237,6 +237,21 @@ if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
3352  if CONFIG['MOZ_SYSTEM_HUNSPELL']:
3353      OS_LIBS += CONFIG['MOZ_HUNSPELL_LIBS']
3354  
3355 +if CONFIG['MOZ_SYSTEM_OGG']:
3356 +    OS_LIBS += CONFIG['MOZ_OGG_LIBS']
3357 +
3358 +if CONFIG['MOZ_SYSTEM_THEORA']:
3359 +    OS_LIBS += CONFIG['MOZ_THEORA_LIBS']
3360 +
3361 +if CONFIG['MOZ_SYSTEM_VORBIS']:
3362 +    OS_LIBS += CONFIG['MOZ_VORBIS_LIBS']
3363 +
3364 +if CONFIG['MOZ_SYSTEM_TREMOR']:
3365 +    OS_LIBS += CONFIG['MOZ_TREMOR_LIBS']
3366 +
3367 +if CONFIG['MOZ_SYSTEM_SOUNDTOUCH']:
3368 +    OS_LIBS += CONFIG['MOZ_SOUNDTOUCH_LIBS']
3369 +
3370  if CONFIG['MOZ_SYSTEM_LIBEVENT']:
3371      OS_LIBS += CONFIG['MOZ_LIBEVENT_LIBS']
3372  
3373 diff --git xpcom/build/XPCOMInit.cpp xpcom/build/XPCOMInit.cpp
3374 index c083ab4bc4f3..62b917043a2c 100644
3375 --- xpcom/build/XPCOMInit.cpp
3376 +++ xpcom/build/XPCOMInit.cpp
3377 @@ -154,7 +154,9 @@ extern nsresult nsStringInputStreamConstructor(nsISupports*, REFNSIID, void**);
3378  
3379  #include "mozilla/ipc/GeckoChildProcessHost.h"
3380  
3381 +#ifndef MOZ_OGG_NO_MEM_REPORTING
3382  #include "ogg/ogg.h"
3383 +#endif
3384  #if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING)
3385  #if defined(HAVE_STDINT_H)
3386  // mozilla-config.h defines HAVE_STDINT_H, and then it's defined *again* in
3387 @@ -664,11 +666,13 @@ NS_InitXPCOM2(nsIServiceManager** aResult,
3388    // this oddness.
3389    mozilla::SetICUMemoryFunctions();
3390  
3391 +#ifndef MOZ_OGG_NO_MEM_REPORTING
3392    // Do the same for libogg.
3393    ogg_set_mem_functions(OggReporter::CountingMalloc,
3394                          OggReporter::CountingCalloc,
3395                          OggReporter::CountingRealloc,
3396                          OggReporter::CountingFree);
3397 +#endif
3398  
3399  #if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING)
3400    // And for VPX.
3401
3402
3403 [FILE:6900:files/firefox.desktop.in]
3404 [Desktop Entry]
3405 Encoding=UTF-8
3406 Name=@MOZILLA_NAME@ Web Browser
3407 Name[am]=
3408 Name[ar]=
3409 Name[az]=@MOZILLA_NAME@ Veb Səyyahı
3410 Name[be]=
3411 Name[bg]=Интернет браузър @MOZILLA_NAME@
3412 Name[bn]=
3413 Name[bs]=@MOZILLA_NAME@ web preglednik
3414 Name[ca]=Navegador web @MOZILLA_NAME@
3415 Name[cs]=Prohlížeč WWW @MOZILLA_NAME@
3416 Name[cy]=Y Porwr Gwe @MOZILLA_NAME@
3417 Name[da]=@MOZILLA_NAME@ - internetsurfning
3418 Name[de]=@MOZILLA_NAME@ Webbrowser
3419 Name[el]=Περιηγητής Διαδικτύου @MOZILLA_NAME@
3420 Name[en_CA]=@MOZILLA_NAME@ Web Browser
3421 Name[en_GB]=@MOZILLA_NAME@ Web Browser
3422 Name[es]=Navegador Web @MOZILLA_NAME@
3423 Name[et]=@MOZILLA_NAME@ veebibrauser
3424 Name[eu]=@MOZILLA_NAME@ web arakatzailea
3425 Name[fi]=@MOZILLA_NAME@, WWW-selain
3426 Name[fr]=Navigateur Web @MOZILLA_NAME@
3427 Name[ga]=Brabhsálaí Lín @MOZILLA_NAME@
3428 Name[gu]=એપીફની વૅબ બ્રાઉઝર
3429 Name[he]=דפדפן @MOZILLA_NAME@
3430 Name[hi]=
3431 Name[hr]=@MOZILLA_NAME@ Web preglednik
3432 Name[hu]=@MOZILLA_NAME@ webböngésző
3433 Name[id]=Web Browser @MOZILLA_NAME@
3434 Name[it]=Browser web @MOZILLA_NAME@
3435 Name[ja]=@MOZILLA_NAME@ ウェブ・ブラウザ
3436 Name[ko]=@MOZILLA_NAME@ 웹 브라우저
3437 Name[li]=@MOZILLA_NAME@ Web Browser
3438 Name[lt]=@MOZILLA_NAME@ web naršyklė
3439 Name[mk]=@MOZILLA_NAME@ веб прелистувач
3440 Name[ml]=എപ്പിഫാനി വെബ്ബ് ബ്രൌസ‌ര്
3441 Name[mn]=@MOZILLA_NAME@ веб хөтөч
3442 Name[ms]=Pelungsur Web @MOZILLA_NAME@
3443 Name[nb]=@MOZILLA_NAME@ nettleser
3444 Name[nl]=@MOZILLA_NAME@ Webbrowser
3445 Name[nn]=@MOZILLA_NAME@ nettlesar
3446 Name[no]=@MOZILLA_NAME@ nettleser
3447 Name[pa]=ਏਪੀਫਾਨੀ ਵੈੱਬ ਬਰਾਊਜ਼ਰ
3448 Name[pl]=Przeglądarka WWW @MOZILLA_NAME@
3449 Name[pt]=Navegador Web @MOZILLA_NAME@
3450 Name[pt_BR]=Navegador Web @MOZILLA_NAME@
3451 Name[ro]=Navigatorul @MOZILLA_NAME@
3452 Name[ru]=Веб-браузер @MOZILLA_NAME@
3453 Name[sk]=
3454 Name[sl]=Spletni brskalnik @MOZILLA_NAME@
3455 Name[sq]=@MOZILLA_NAME@ - Shfletuesi Web
3456 Name[sr]=
3457 Name[sr@Latn]=Veb čitač Spoznaja
3458 Name[sv]=Webbläsaren @MOZILLA_NAME@
3459 Name[ta]=எபிபனி வலை உலாவி
3460 Name[tk]=@MOZILLA_NAME@ Web Ahtarçisi
3461 Name[tr]=@MOZILLA_NAME@ Web Tarayıcı
3462 Name[uk]=Переглядач web @MOZILLA_NAME@
3463 Name[vi]=Trình Duyệt Web @MOZILLA_NAME@
3464 Name[wa]=Betchteu waibe epiphany
3465 Name[zh_CN]=@MOZILLA_NAME@ Web 浏览器
3466 Name[zh_TW]=@MOZILLA_NAME@ 網頁瀏覽器
3467 GenericName=Web Browser
3468 GenericName[ar]=متصفّح الانترنت
3469 GenericName[az]=Veb Səyyahı
3470 GenericName[be]=Вандроўнік па павуціньню
3471 GenericName[bg]=Браузър
3472 GenericName[bn]=ওয়েব ব্রাউজার
3473 GenericName[bs]=Web preglednik
3474 GenericName[ca]=Navegador web
3475 GenericName[cs]=Prohlížeč WWW
3476 GenericName[cy]=Porwr Gwe
3477 GenericName[da]=Internetsurfning
3478 GenericName[de]=Webbrowser
3479 GenericName[el]=Περιηγητής Ιστοσελίδων
3480 GenericName[en_CA]=Web Browser
3481 GenericName[en_GB]=Web Browser
3482 GenericName[es]=Navegador web
3483 GenericName[et]=Veebilehitseja
3484 GenericName[eu]=Web arakatzailea
3485 GenericName[fi]=WWW-selain
3486 GenericName[fr]=Navigateur Web @MOZILLA_NAME@
3487 GenericName[ga]=Brabhsálaí Lín
3488 GenericName[gu]=વેબ બ્રાઉઝર
3489 GenericName[he]=דפדפן אינטרנט
3490 GenericName[hi]=वेब ब्राउज़र
3491 GenericName[hr]=Web preglednik
3492 GenericName[hu]=Webböngésző
3493 GenericName[id]=Browser Web
3494 GenericName[it]=Browser web
3495 GenericName[ja]=GNOME ウェブ・ブラウザ
3496 GenericName[ko]=웹 브라우저
3497 GenericName[li]=Wèb Browser
3498 GenericName[lt]=Web naršyklė
3499 GenericName[mk]=Веб прелистувач
3500 GenericName[mn]=Веб хөтөч
3501 GenericName[ms]=Pelungsur Web
3502 GenericName[nb]=Nettleser
3503 GenericName[nl]=Web-browser
3504 GenericName[nn]=Nettlesar
3505 GenericName[no]=Nettleser
3506 GenericName[pa]=ਵੈਬ ਬਰਾਊਜ਼
3507 GenericName[pl]=Przeglądarka WWW
3508 GenericName[pt]=Navegador Web
3509 GenericName[pt_BR]=Navegador Web
3510 GenericName[ro]=Navigator Internet
3511 GenericName[ru]=Веб-браузер
3512 GenericName[sk]=WWW prehliadač
3513 GenericName[sl]=Spletni brskalnik
3514 GenericName[sq]=Shfletuesi Web
3515 GenericName[sr]=Веб читач
3516 GenericName[sr@Latn]=Veb čitač
3517 GenericName[sv]=Webbläsare
3518 GenericName[ta]=வலை உலாவி
3519 GenericName[th]=เว็บบราวเซอร์
3520 GenericName[tk]=Web Ahtarçysy
3521 GenericName[tr]=Web Tarayıcı
3522 GenericName[uk]=Переглядач web-сторінок
3523 GenericName[vi]=Trình duyệt Web
3524 GenericName[wa]=Betchteu waibe
3525 GenericName[zh_CN]=Web 浏览器
3526 GenericName[zh_TW]=網頁瀏覽器
3527 Comment=Browse the web
3528 Comment[ar]=تصفح الانترنت
3529 Comment[az]=Vebi gəzin
3530 Comment[be]=Вандраваць па павуціньню
3531 Comment[bg]=Сърфиране в интернет
3532 Comment[bn]=ওয়েব ব্রাউজ করুন
3533 Comment[bs]=Pregledaj na internetu
3534 Comment[ca]=Navegueu per la web
3535 Comment[cs]=Prohlížet WWW
3536 Comment[cy]=Pori'r we
3537 Comment[da]=Surf på internettet
3538 Comment[de]=Im Web surfen
3539 Comment[el]=Περιήγηση στον παγκόσμιο ιστό
3540 Comment[en_CA]=Browse the web
3541 Comment[en_GB]=Browse the web
3542 Comment[es]=Navegar por la web
3543 Comment[et]=Sirvi veebi
3544 Comment[eu]=Arakatu web-a
3545 Comment[fi]=Selaa WWW:tä
3546 Comment[fr]=Naviguer sur Internet
3547 Comment[ga]=Brabhsáil an Líon
3548 Comment[gu]=વેબમાં શોધો
3549 Comment[he]=גלוש ברשת
3550 Comment[hi]=वेब ब्राउज़ करें
3551 Comment[hr]=Pregledaj Web
3552 Comment[hu]=A világháló böngészése
3553 Comment[id]=Jelajah web
3554 Comment[it]=Esplora il web
3555 Comment[ja]=ウェブを閲覧します
3556 Comment[ko]=웹을 돌아 다닙니다
3557 Comment[li]=Blajere op internet
3558 Comment[lt]=Naršyti internete
3559 Comment[mk]=Прелистувајте на веб
3560 Comment[ml]=വലക്കെട്ട് തിരയുക
3561 Comment[mn]=Веб броузе хийх
3562 Comment[ms]=Layari web
3563 Comment[nb]=Surf på nettet
3564 Comment[nl]=Websurfen
3565 Comment[nn]=Surf på nettet
3566 Comment[no]=Surf på nettet
3567 Comment[pa]=ਵੈਬ ਬਰਾਊਜ਼
3568 Comment[pl]=Przeglądanie stron WWW
3569 Comment[pt]=Navegar na web
3570 Comment[pt_BR]=Navegar na web
3571 Comment[ro]=Navigare Internet
3572 Comment[ru]=Веб-браузер
3573 Comment[sk]=Prehliadať internet
3574 Comment[sl]=Brskaj po spletu
3575 Comment[sq]=Eksploro web-in
3576 Comment[sr]=Прегледај веб
3577 Comment[sr@Latn]=Pregledaj veb
3578 Comment[sv]=Surfa på nätet
3579 Comment[ta]=வலையில் உலாவு
3580 Comment[th]=ใช้งานเว็บบราวเซอร์ @MOZILLA_NAME@
3581 Comment[tk]=Webi Ahtar
3582 Comment[tr]=Web'e Gözat
3583 Comment[uk]=Програма перегляду web-сторінок
3584 Comment[vi]=Duyệt web
3585 Comment[wa]=Naivyî avå les waibes
3586 Comment[zh_CN]=浏览 Web
3587 Comment[zh_TW]=瀏覽網頁
3588 Exec=@MOZILLA@ %U
3589 Icon=@FIREFOX_ICON@
3590 StartupNotify=true
3591 Terminal=false
3592 Type=Application
3593 Categories=Network;WebBrowser;
3594 MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;
3595
3596
3597 [FILE:762:files/pkg-deinstall-single.in]
3598 #!/bin/sh
3599 #
3600 #    $MCom: ports/www/mozilla/pkg-deinstall.in,v 1.25 2008/07/26 19:07:07 ahze Exp $
3601 #
3602 # Date created:                 Mon Nov 29, 2003
3603 # Whom:                         Thierry Thomas (<thierry@pompo.net>)
3604 # Fix the chrome registry.
3605
3606 umask 022
3607 PATH=/bin:/usr/bin
3608
3609 [ "x$1" = "x" ] && exit 1
3610 [ "x$2" != "xDEINSTALL" ] && exit 0
3611
3612 MOZDIR=%%MOZDIR%%
3613
3614 rm -rf ${MOZDIR}/chrome/overlayinfo
3615 rm -f ${MOZDIR}/chrome/*.rdf
3616 rm -f ${MOZDIR}/component.reg
3617 rm -f ${MOZDIR}/components/*.dat
3618 rm -f ${MOZDIR}/components.ini
3619 rm -f ${MOZDIR}/defaults.ini
3620 rm -f ${MOZDIR}/chrome/app-chrome.manifest
3621 rm -rf ${MOZDIR}/updates
3622 find %%MOZDIR%%/plugins/ -depth 1 -type l -delete > /dev/null 2>&1
3623 find %%MOZDIR%%/extensions/ -depth 1 -type l -delete > /dev/null 2>&1
3624 rmdir ${MOZDIR}/chrome
3625 rmdir ${MOZDIR}
3626
3627 exit 0
3628
3629
3630 [FILE:914:files/pkg-install-single.in]
3631 #!/bin/sh
3632 #
3633 #    $MCom: ports/www/mozilla/pkg-install.in,v 1.26 2008/08/04 16:58:03 mezz Exp $
3634 #
3635 # Date created:                 Mon Nov 29, 2003
3636 # Whom:                         Thierry Thomas (<thierry@pompo.net>)
3637 # Fix the chrome registry.
3638
3639 umask 022
3640 PATH=/bin:/usr/bin
3641
3642 [ "x$1" = "x" ] && exit 1
3643 [ "x$2" != "xPOST-INSTALL" ] && exit 0
3644
3645 MOZDIR=%%MOZDIR%%
3646 MOZBIN=${MOZDIR}/%%MOZILLA_BIN%%
3647 REGXPCOM=${MOZDIR}/regxpcom
3648 REGCHROME=${MOZDIR}/regchrome
3649
3650 rm -rf ${MOZDIR}/chrome/overlayinfo
3651 rm -f ${MOZDIR}/chrome/*.rdf
3652 mkdir -p ${MOZDIR}/chrome/overlayinfo
3653 rm -f ${MOZDIR}/component.reg
3654
3655 cd ${MOZDIR} || exit 1
3656 if [ -f ${REGXPCOM} ]; then
3657         ./run-mozilla.sh ${REGXPCOM} || true
3658 fi
3659 if [ -f ${REGCHROME} ]; then
3660         ./run-mozilla.sh ${REGCHROME} || true
3661 fi
3662 if [ -f ${MOZBIN} -a "${1%-*}" = "nvu" ]; then
3663         ./run-mozilla.sh ${MOZBIN} -register > /dev/null 2>&1
3664 fi
3665 cp -R %%LOCALBASE%%/lib/xpi/symlinks/%%MOZILLA%%/ %%MOZDIR%%/extensions/ > /dev/null 2>&1
3666
3667 exit 0
3668
3669
3670 [FILE:1280:files/pkg-message-single]
3671 ======================================================================
3672
3673 Some features available on other platforms are not implemented:
3674 - Native audio (OSS backend is incomplete, doesn't support WebRTC)
3675 - Encrypted Media Extensions (requires Widevine CDM binary)
3676 - Process sandboxing (requires Capsicum backend)
3677 - Reduced memory usage (requires mozjemalloc)
3678 - Performance profiling (requires GeckoProfiler)
3679 - Gamepad API (requires libusbhid backend)
3680
3681 ======================================================================
3682
3683 To select non-default audio backend open about:config page and create
3684 media.cubeb.backend preference. Supported values are: alsa, jack,
3685 pulse, oss, sndio. Currently used backend can be inspected on
3686 about:support page.
3687
3688 ======================================================================
3689
3690 smb:// issues (Gvfs/GIO option):
3691 Network group, machine, and share browsing does not work correctly.
3692
3693 sftp:// (Gvfs/GIO option):
3694 Only sftp access using public key authentication works.  To easily
3695 setup public key authentication to "remote_host":
3696
3697 ssh-keygen
3698 cat ~/.ssh/id_rsa.pub | ssh remote_host "cat >> .ssh/authorized_keys"
3699
3700 The SSH server on remote_host must allow pub key authentication.
3701
3702 ======================================================================
3703
3704
3705 [FILE:539:dragonfly/patch-build_moz.configure_memory.configure]
3706 --- build/moz.configure/memory.configure.orig   2016-09-05 20:12:51 UTC
3707 +++ build/moz.configure/memory.configure
3708 @@ -66,7 +66,7 @@ def jemalloc_os_define(jemalloc, jemallo
3709              return 'MOZ_MEMORY_LINUX'
3710          if target.kernel == 'Darwin':
3711              return 'MOZ_MEMORY_DARWIN'
3712 -        if target.kernel in ('kFreeBSD', 'FreeBSD', 'NetBSD'):
3713 +        if target.kernel in ('kFreeBSD', 'FreeBSD', 'NetBSD','DragonFly'):
3714              return 'MOZ_MEMORY_BSD'
3715          die('--enable-jemalloc is not supported on %s', target.kernel)
3716  
3717
3718
3719 [FILE:390:dragonfly/patch-ipc_chromium_src_base_platform__thread__posix.cc]
3720 --- ipc/chromium/src/base/platform_thread_posix.cc.orig 2016-09-05 23:12:53.000000000 +0300
3721 +++ ipc/chromium/src/base/platform_thread_posix.cc
3722 @@ -16,6 +16,11 @@
3723  #elif defined(OS_LINUX)
3724  #include <sys/syscall.h>
3725  #include <sys/prctl.h>
3726 +#elif defined(OS_DRAGONFLY)
3727 +#include <sys/param.h>
3728 +#if __DragonFly_version >= 400709
3729 +#include <sys/lwp.h>
3730 +#endif
3731  #endif
3732  
3733  #if !defined(OS_MACOSX)
3734
3735
3736 [FILE:510:dragonfly/patch-js_src_jsnativestack.cpp]
3737 --- js/src/jsnativestack.cpp.orig       2016-05-12 17:13:19 UTC
3738 +++ js/src/jsnativestack.cpp
3739 @@ -102,7 +102,8 @@ js::GetNativeStackBaseImpl()
3740      pthread_attr_init(&sattr);
3741  #  if defined(__OpenBSD__)
3742      stack_t ss;
3743 -#  elif defined(PTHREAD_NP_H) || defined(_PTHREAD_NP_H_) || defined(NETBSD)
3744 +#  elif defined(PTHREAD_NP_H) || defined(_PTHREAD_NP_H_) || defined(NETBSD) \
3745 +     || defined(__DragonFly__)
3746      /* e.g. on FreeBSD 4.8 or newer, neundorf@kde.org */
3747      pthread_attr_get_np(thread, &sattr);
3748  #  else
3749
3750
3751 [FILE:579:dragonfly/patch-js_src_old-configure.in]
3752 --- js/src/old-configure.in.orig        2016-09-05 20:12:56 UTC
3753 +++ js/src/old-configure.in
3754 @@ -1305,7 +1305,7 @@ dnl Checks for header files.
3755  dnl ========================================================
3756  AC_HEADER_DIRENT
3757  case "$target_os" in
3758 -freebsd*)
3759 +freebsd*|dragonfly*)
3760  # for stuff like -lXshm
3761      CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
3762      ;;
3763 @@ -1448,7 +1448,7 @@ then
3764      fi
3765  
3766         case "$target" in
3767 -           *-*-freebsd*)
3768 +           *-*-freebsd*|*-*-dragonfly*)
3769                         AC_DEFINE(_REENTRANT)
3770                         AC_DEFINE(_THREAD_SAFE)
3771                         dnl -pthread links in -lpthread, so don't specify it explicitly.
3772
3773
3774 [FILE:285:dragonfly/patch-media_libcubeb_src_cubeb__jack.cpp]
3775 --- media/libcubeb/src/cubeb_jack.cpp.orig      2017-10-06 17:40:00 UTC
3776 +++ media/libcubeb/src/cubeb_jack.cpp
3777 @@ -8,9 +8,6 @@
3778   */
3779  #define _DEFAULT_SOURCE
3780  #define _BSD_SOURCE
3781 -#ifndef __FreeBSD__
3782 -#define _POSIX_SOURCE
3783 -#endif
3784  #include <algorithm>
3785  #include <dlfcn.h>
3786  #include <limits>
3787
3788
3789 [FILE:393:dragonfly/patch-media_webrtc_trunk_webrtc_base_thread__checker__impl.cc]
3790 --- media/webrtc/trunk/webrtc/base/thread_checker_impl.cc.orig  2016-05-12 20:13:19.000000000 +0300
3791 +++ media/webrtc/trunk/webrtc/base/thread_checker_impl.cc
3792 @@ -22,6 +22,11 @@
3793  #include <lwp.h>
3794  #elif defined(__FreeBSD__)
3795  #include <pthread_np.h>
3796 +#elif defined(__DragonFly__)
3797 +#include <sys/param.h>
3798 +#if __DragonFly_version >= 400709
3799 +#include <sys/lwp.h>
3800 +#endif
3801  #endif
3802  
3803  namespace rtc {
3804