Bug 517422 - Allow more media/ libs built against their system-wide versions. r?glandium draft
authorJan Beich <jbeich@FreeBSD.org>
Sun, 13 Mar 2016 10:24:04 +0000
changeset 339848 13e8c5082ff3f1803e2eb4a75819c485ed9a4c19
parent 339847 1240830f5bf734456496cb8bddcdc84a2f9655fb
child 339849 14fbd0832db39f3d27950acec2a2f8b1f9aea849
push id12806
push userjbeich@FreeBSD.org
push dateSun, 13 Mar 2016 12:44:36 +0000
reviewersglandium
bugs517422
milestone48.0a1
Bug 517422 - Allow more media/ libs built against their system-wide versions. r?glandium MozReview-Commit-ID: BXpGm1wgCFQ
build/moz.configure/old.configure
config/Makefile.in
config/external/moz.build
config/system-headers
dom/media/AudioStream.cpp
dom/media/AudioStream.h
dom/media/moz.build
media/libogg/README_MOZILLA
media/libsoundtouch/README_MOZILLA
media/libsoundtouch/src/soundtouch_perms.h
media/libtheora/README_MOZILLA
media/libtheora/moz.build
media/libtremor/README_MOZILLA
media/libtremor/moz.build
media/libvorbis/README_MOZILLA
media/libvorbis/moz.build
old-configure.in
toolkit/library/moz.build
xpcom/build/XPCOMInit.cpp
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -341,17 +341,22 @@ def old_configure_options(*options):
     '--with-system-graphite2',
     '--with-system-harfbuzz',
     '--with-system-icu',
     '--with-system-jpeg',
     '--with-system-libevent',
     '--with-system-libvpx',
     '--with-system-nspr',
     '--with-system-nss',
+    '--with-system-ogg',
     '--with-system-png',
+    '--with-system-soundtouch',
+    '--with-system-theora',
+    '--with-system-tremor',
+    '--with-system-vorbis',
     '--with-system-zlib',
     '--with-thumb',
     '--with-thumb-interwork',
     '--with-unify-dist',
     '--with-user-appdir',
     '--with-windows-version',
     '--with-x',
     '--with-xulrunner-stub-name',
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -46,16 +46,21 @@ export:: $(export-preqs)
 		-DMOZ_SYSTEM_ZLIB=$(MOZ_SYSTEM_ZLIB) \
 		-DMOZ_SYSTEM_PNG=$(MOZ_SYSTEM_PNG) \
 		-DMOZ_SYSTEM_JPEG=$(MOZ_SYSTEM_JPEG) \
 		-DMOZ_SYSTEM_LIBEVENT=$(MOZ_SYSTEM_LIBEVENT) \
 		-DMOZ_SYSTEM_LIBVPX=$(MOZ_SYSTEM_LIBVPX) \
 		-DMOZ_SYSTEM_ICU=$(MOZ_SYSTEM_ICU) \
 		-DMOZ_SYSTEM_GRAPHITE2=$(MOZ_SYSTEM_GRAPHITE2) \
 		-DMOZ_SYSTEM_HARFBUZZ=$(MOZ_SYSTEM_HARFBUZZ) \
+		-DMOZ_SYSTEM_OGG=$(MOZ_SYSTEM_OGG) \
+		-DMOZ_SYSTEM_THEORA=$(MOZ_SYSTEM_THEORA) \
+		-DMOZ_SYSTEM_VORBIS=$(MOZ_SYSTEM_VORBIS) \
+		-DMOZ_SYSTEM_TREMOR=$(MOZ_SYSTEM_TREMOR) \
+		-DMOZ_SYSTEM_SOUNDTOUCH=$(MOZ_SYSTEM_SOUNDTOUCH) \
 		$(srcdir)/system-headers | $(PERL) $(topsrcdir)/nsprpub/config/make-system-wrappers.pl system_wrappers
 	$(INSTALL) system_wrappers $(DIST)
 
 GARBAGE_DIRS += system_wrappers
 endif
 
 ifdef WRAP_STL_INCLUDES
 ifdef GNU_CXX
--- a/config/external/moz.build
+++ b/config/external/moz.build
@@ -16,48 +16,54 @@ if not CONFIG['MOZ_SYSTEM_JPEG']:
 if CONFIG['MOZ_UPDATER']:
     if not CONFIG['MOZ_SYSTEM_BZ2']:
         external_dirs += ['modules/libbz2']
 
 # There's no "native" brotli or woff2 yet, but probably in the future...
 external_dirs += ['modules/brotli']
 external_dirs += ['modules/woff2']
 
-if CONFIG['MOZ_VORBIS']:
+if not CONFIG['MOZ_SYSTEM_OGG']:
+    external_dirs += ['media/libogg']
+
+if not CONFIG['MOZ_SYSTEM_THEORA']:
+    external_dirs += ['media/libtheora']
+
+if CONFIG['MOZ_VORBIS'] and not CONFIG['MOZ_SYSTEM_VORBIS']:
     external_dirs += ['media/libvorbis']
 
-if CONFIG['MOZ_TREMOR']:
+if CONFIG['MOZ_TREMOR'] and not CONFIG['MOZ_SYSTEM_TREMOR']:
     external_dirs += ['media/libtremor']
 
 if CONFIG['MOZ_WEBM_ENCODER']:
     external_dirs += ['media/libmkv']
 
 if not CONFIG['MOZ_SYSTEM_LIBVPX']:
     external_dirs += ['media/libvpx']
 
 if not CONFIG['MOZ_SYSTEM_PNG']:
     external_dirs += ['media/libpng']
 
 if CONFIG['CPU_ARCH'] == 'arm':
     external_dirs += ['media/openmax_dl']
 
+if not CONFIG['MOZ_SYSTEM_SOUNDTOUCH']:
+    external_dirs += ['media/libsoundtouch']
+
 if CONFIG['MOZ_WEBSPEECH_POCKETSPHINX']:
     external_dirs += [
         'media/sphinxbase',
         'media/pocketsphinx',
     ]
 
 if CONFIG['MOZ_FFVPX']:
     external_dirs += ['media/ffvpx']
 
 external_dirs += [
     'media/kiss_fft',
     'media/libcubeb',
     'media/libnestegg',
-    'media/libogg',
     'media/libopus',
-    'media/libtheora',
     'media/libspeex_resampler',
     'media/libstagefright',
-    'media/libsoundtouch',
 ]
 
 DIRS += ['../../' + i for i in external_dirs]
--- a/config/system-headers
+++ b/config/system-headers
@@ -1253,18 +1253,20 @@ X11/Xfuncproto.h
 X11/X.h
 X11/XKBlib.h
 X11/Xlib.h
 X11/Xlibint.h
 X11/Xlocale.h
 X11/Xos.h
 X11/Xutil.h
 zmouse.h
+#if MOZ_SYSTEM_SOUNDTOUCH==1
 soundtouch/SoundTouch.h
 soundtouch/SoundTouchFactory.h
+#endif
 #if MOZ_LIBAV_FFT==1
 libavcodec/avfft.h
 #endif
 #if MOZ_SYSTEM_PNG==1
 png.h
 #endif
 #if MOZ_SYSTEM_ZLIB==1
 zlib.h
@@ -1347,8 +1349,22 @@ unwind.h
 #if MOZ_SYSTEM_GRAPHITE2==1
 graphite2/Font.h
 graphite2/Segment.h
 #endif
 #if MOZ_SYSTEM_HARFBUZZ==1
 harfbuzz/hb-ot.h
 harfbuzz/hb.h
 #endif
+#if MOZ_SYSTEM_OGG==1
+ogg/ogg.h
+ogg/os_types.h
+#endif
+#if MOZ_SYSTEM_THEORA==1
+theora/theoradec.h
+#endif
+#if MOZ_SYSTEM_VORBIS==1
+vorbis/codec.h
+vorbis/vorbisenc.h
+#endif
+#if MOZ_SYSTEM_TREMOR==1
+tremor/ivorbiscodec.h
+#endif
--- a/dom/media/AudioStream.cpp
+++ b/dom/media/AudioStream.cpp
@@ -120,35 +120,39 @@ private:
 
 AudioStream::AudioStream(DataSource& aSource)
   : mMonitor("AudioStream")
   , mInRate(0)
   , mOutRate(0)
   , mChannels(0)
   , mOutChannels(0)
   , mAudioClock(this)
+#ifndef MOZ_SYSTEM_SOUNDTOUCH
   , mTimeStretcher(nullptr)
+#endif
   , mDumpFile(nullptr)
   , mState(INITIALIZED)
   , mIsMonoAudioEnabled(gfxPrefs::MonoAudio())
   , mDataSource(aSource)
 {
 }
 
 AudioStream::~AudioStream()
 {
   LOG("deleted, state %d", mState);
   MOZ_ASSERT(mState == SHUTDOWN && !mCubebStream,
              "Should've called Shutdown() before deleting an AudioStream");
   if (mDumpFile) {
     fclose(mDumpFile);
   }
+#ifndef MOZ_SYSTEM_SOUNDTOUCH
   if (mTimeStretcher) {
     soundtouch::destroySoundTouchObj(mTimeStretcher);
   }
+#endif
 }
 
 size_t
 AudioStream::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
 {
   size_t amount = aMallocSizeOf(this);
 
   // Possibly add in the future:
@@ -157,17 +161,21 @@ AudioStream::SizeOfIncludingThis(MallocS
 
   return amount;
 }
 
 nsresult AudioStream::EnsureTimeStretcherInitializedUnlocked()
 {
   mMonitor.AssertCurrentThreadOwns();
   if (!mTimeStretcher) {
+#ifdef MOZ_SYSTEM_SOUNDTOUCH
+    mTimeStretcher = new soundtouch::SoundTouch();
+#else
     mTimeStretcher = soundtouch::createSoundTouchObj();
+#endif
     mTimeStretcher->setSampleRate(mInRate);
     mTimeStretcher->setChannels(mOutChannels);
     mTimeStretcher->setPitch(1.0);
   }
   return NS_OK;
 }
 
 nsresult AudioStream::SetPlaybackRate(double aPlaybackRate)
--- a/dom/media/AudioStream.h
+++ b/dom/media/AudioStream.h
@@ -11,17 +11,21 @@
 #include "nsCOMPtr.h"
 #include "nsThreadUtils.h"
 #include "mozilla/dom/AudioChannelBinding.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/UniquePtr.h"
 #include "CubebUtils.h"
+#ifdef MOZ_SYSTEM_SOUNDTOUCH
+#include "soundtouch/SoundTouch.h"
+#else
 #include "soundtouch/SoundTouchFactory.h"
+#endif
 
 namespace mozilla {
 
 struct CubebDestroyPolicy
 {
   void operator()(cubeb_stream* aStream) const {
     cubeb_stream_destroy(aStream);
   }
@@ -342,17 +346,21 @@ private:
   // Output rate in Hz (characteristic of the playback rate)
   uint32_t mOutRate;
   uint32_t mChannels;
   uint32_t mOutChannels;
 #if defined(__ANDROID__)
   dom::AudioChannel mAudioChannel;
 #endif
   AudioClock mAudioClock;
+#ifdef MOZ_SYSTEM_SOUNDTOUCH
+  nsAutoPtr<soundtouch::SoundTouch> mTimeStretcher;
+#else
   soundtouch::SoundTouch* mTimeStretcher;
+#endif
 
   // Stream start time for stream open delay telemetry.
   TimeStamp mStartTime;
 
   // Output file for dumping audio
   FILE* mDumpFile;
 
   // Owning reference to a cubeb_stream.
--- a/dom/media/moz.build
+++ b/dom/media/moz.build
@@ -298,16 +298,31 @@ if CONFIG['MOZ_DIRECTSHOW']:
 if CONFIG['MOZ_WEBRTC']:
     LOCAL_INCLUDES += [
         '/media/webrtc/signaling/src/common',
         '/media/webrtc/trunk',
     ]
 
 DEFINES['MOZILLA_INTERNAL_API'] = True
 
+if CONFIG['MOZ_SYSTEM_OGG']:
+    CXXFLAGS += CONFIG['MOZ_OGG_CFLAGS']
+
+if CONFIG['MOZ_SYSTEM_THEORA']:
+    CXXFLAGS += CONFIG['MOZ_THEORA_CFLAGS']
+
+if CONFIG['MOZ_SYSTEM_VORBIS']:
+    CXXFLAGS += CONFIG['MOZ_VORBIS_CFLAGS']
+
+if CONFIG['MOZ_SYSTEM_TREMOR']:
+    CXXFLAGS += CONFIG['MOZ_TREMOR_CFLAGS']
+
+if CONFIG['MOZ_SYSTEM_SOUNDTOUCH']:
+    CXXFLAGS += CONFIG['MOZ_SOUNDTOUCH_CFLAGS']
+
 if CONFIG['OS_TARGET'] == 'WINNT':
     DEFINES['WEBRTC_WIN'] = True
 else:
     DEFINES['WEBRTC_POSIX'] = True
 
 if CONFIG['MOZ_OMX_DECODER']:
     DEFINES['MOZ_OMX_DECODER'] = True
 
--- a/media/libogg/README_MOZILLA
+++ b/media/libogg/README_MOZILLA
@@ -1,8 +1,11 @@
 The source from this directory was copied from the libogg subversion
 repository using the update.sh script.
 
 The svn revision number used was r17287.
 
 The int-types.patch address a bug that config_types.h generated from
 Linux platform can't be used on OpenSolaris directly see Mozilla bug
 449754
+
+The in-tree copy may be omitted during build by --with-system-ogg.
+Keep version in old-configure.in in sync on updates.
--- a/media/libsoundtouch/README_MOZILLA
+++ b/media/libsoundtouch/README_MOZILLA
@@ -1,8 +1,10 @@
 These files are from the SoundTouch library (http://www.surina.net/soundtouch/),
 and are extracted from the revision r222 of the svn repository at
 https://soundtouch.svn.sourceforge.net/svnroot/soundtouch/trunk.
 
 The whole library is not used, only the relevant files are imported in the tree,
 using the script `update.sh`. Some changes have been made to the files, using
 the patch `moz-libsoundtouch.patch`. We also use a custom soundtouch_config.h.
 
+The in-tree copy may be omitted during build by --with-system-soundtouch.
+Keep version in old-configure.in in sync on updates.
--- a/media/libsoundtouch/src/soundtouch_perms.h
+++ b/media/libsoundtouch/src/soundtouch_perms.h
@@ -7,12 +7,14 @@
 // Include file for fixing symbol visibility on non-windows platforms, until
 // system headers wrappers work uniformly across all of them.
 
 #ifndef MOZILLA_SOUNDTOUCH_PERMS_H
 #define MOZILLA_SOUNDTOUCH_PERMS_H
 
 #pragma GCC visibility push(default)
 #include "SoundTouch.h"
+#ifndef MOZ_SYSTEM_SOUNDTOUCH
 #include "SoundTouchFactory.h"
+#endif
 #pragma GCC visibility pop
 
 #endif // MOZILLA_SOUNDTOUCH_PERMS_H
--- a/media/libtheora/README_MOZILLA
+++ b/media/libtheora/README_MOZILLA
@@ -1,5 +1,8 @@
 The source from this directory was copied from the theora subversion trunk
 using the update.sh script. The changes made were those applied by update.sh,
 the addition/update of Makefile.in files for the Mozilla build system.
 
 The subversion revision used was r17578.
+
+The in-tree copy may be omitted during build by --with-system-theora.
+Keep version in old-configure.in in sync on updates.
--- a/media/libtheora/moz.build
+++ b/media/libtheora/moz.build
@@ -16,16 +16,19 @@ EXPORTS.theora += [
 # We allow warnings for third-party code that can be updated from upstream.
 ALLOW_COMPILER_WARNINGS = True
 
 FINAL_LIBRARY = 'gkmedias'
 
 # The encoder is currently not included.
 DEFINES['THEORA_DISABLE_ENCODE'] = True
 
+if CONFIG['MOZ_SYSTEM_OGG']:
+    CFLAGS += CONFIG['MOZ_OGG_CFLAGS']
+
 # Suppress warnings in third-party code.
 if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
     CFLAGS += ['-Wno-type-limits']
 if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
     CFLAGS += ['-Wno-tautological-compare']
 if CONFIG['CLANG_CL']:
     CFLAGS += [
         '-Wno-pointer-sign',
--- a/media/libtremor/README_MOZILLA
+++ b/media/libtremor/README_MOZILLA
@@ -1,7 +1,10 @@
 The source from this directory was copied from the libtremor
 subversion repository using the update.sh script. The only changes
 made were those applied by update.sh and the addition/upate of
 Makefile.in files for the Mozilla build system.
 
 The upstream release used was http://svn.xiph.org/trunk/Tremor/
 The subversion revision used was r17547.
+
+The in-tree copy may be omitted during build by --with-system-tremor.
+Keep version in old-configure.in in sync on updates.
--- a/media/libtremor/moz.build
+++ b/media/libtremor/moz.build
@@ -4,8 +4,10 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files('*'):
     BUG_COMPONENT = ('Core', 'Video/Audio')
 
 DIRS += ['include/tremor', 'lib']
 
+if CONFIG['MOZ_SYSTEM_OGG']:
+    CFLAGS += CONFIG['MOZ_OGG_CFLAGS']
--- a/media/libvorbis/README_MOZILLA
+++ b/media/libvorbis/README_MOZILLA
@@ -3,8 +3,11 @@ subversion repository using the update.s
 made were those applied by update.sh and the addition/update of
 Makefile.in and moz.build files for the Mozilla build system.
 
 The upstream version used was libvorbis 1.3.5.
 https://svn.xiph.org/tags/vorbis/libvorbis-1.3.5@19464
 
 Some files are renamed during the copy to prevent clashes with object
 file names with other Mozilla libraries.
+
+The in-tree copy may be omitted during build by --with-system-vorbis.
+Keep version in old-configure.in in sync on updates.
--- a/media/libvorbis/moz.build
+++ b/media/libvorbis/moz.build
@@ -51,8 +51,11 @@ if CONFIG['OS_ARCH'] == 'SunOS':
 # We allow warnings for third-party code that can be updated from upstream.
 ALLOW_COMPILER_WARNINGS = True
 
 FINAL_LIBRARY = 'gkmedias'
 
 # Suppress warnings in third-party code.
 if CONFIG['GNU_CC']:
     CFLAGS += ['-Wno-uninitialized']
+
+if CONFIG['MOZ_SYSTEM_OGG']:
+    CFLAGS += CONFIG['MOZ_OGG_CFLAGS']
--- a/old-configure.in
+++ b/old-configure.in
@@ -5175,16 +5175,121 @@ if test -n "$MOZ_BUILD_MOBILE_ANDROID_WI
         dnl Only allow building mobile/android with Gradle.
         AC_DEFINE(MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE)
     else
         dnl fail if we're not building mobile/android.
         AC_MSG_ERROR([Can only build mobile/android with Gradle])
     fi
 fi
 
+dnl ========================================================
+dnl Check for libogg
+dnl ========================================================
+
+MOZ_ARG_WITH_BOOL(system-ogg,
+[  --with-system-ogg       Use system libogg (located with pkgconfig)],
+MOZ_SYSTEM_OGG=1,
+MOZ_SYSTEM_OGG=)
+
+if test -n "$MOZ_SYSTEM_OGG"; then
+    PKG_CHECK_MODULES(MOZ_OGG, ogg >= 1.3.0)
+
+    _SAVE_LIBS=$LIBS
+    LIBS="$LIBS $MOZ_OGG_LIBS"
+    AC_CHECK_FUNC(ogg_set_mem_functions, [],
+      [AC_DEFINE(MOZ_OGG_NO_MEM_REPORTING)])
+    LIBS=$_SAVE_LIBS
+fi
+
+AC_SUBST(MOZ_SYSTEM_OGG)
+
+dnl ========================================================
+dnl Check for libvorbis
+dnl ========================================================
+
+MOZ_ARG_WITH_BOOL(system-vorbis,
+[  --with-system-vorbis    Use system libvorbis (located with pkgconfig)],
+MOZ_SYSTEM_VORBIS=1,
+MOZ_SYSTEM_VORBIS=)
+
+if test -n "$MOZ_SYSTEM_VORBIS"; then
+    PKG_CHECK_MODULES(MOZ_VORBIS, vorbis vorbisenc >= 1.3.5)
+fi
+
+AC_SUBST(MOZ_SYSTEM_VORBIS)
+
+dnl ========================================================
+dnl Check for integer-only libvorbis aka tremor
+dnl ========================================================
+
+MOZ_ARG_WITH_BOOL(system-tremor,
+[  --with-system-tremor    Use system libtremor (located with pkgconfig)],
+MOZ_SYSTEM_TREMOR=1,
+MOZ_SYSTEM_TREMOR=)
+
+if test -n "$MOZ_SYSTEM_TREMOR"; then
+    PKG_CHECK_MODULES(MOZ_TREMOR, vorbisidec >= 1.2.1)
+fi
+
+AC_SUBST(MOZ_SYSTEM_TREMOR)
+
+dnl ========================================================
+dnl Check for libtheora
+dnl ========================================================
+
+MOZ_ARG_WITH_BOOL(system-theora,
+[  --with-system-theora    Use system libtheora (located with pkgconfig)],
+MOZ_SYSTEM_THEORA=1,
+MOZ_SYSTEM_THEORA=)
+
+if test -n "$MOZ_SYSTEM_THEORA"; then
+    PKG_CHECK_MODULES(MOZ_THEORA, theora >= 1.2)
+fi
+
+AC_SUBST(MOZ_SYSTEM_THEORA)
+
+dnl ========================================================
+dnl Check for libSoundTouch
+dnl ========================================================
+
+MOZ_ARG_WITH_BOOL(system-soundtouch,
+[  --with-system-soundtouch Use system libSoundTouch (located with pkgconfig)],
+MOZ_SYSTEM_SOUNDTOUCH=1,
+MOZ_SYSTEM_SOUNDTOUCH=)
+
+if test -n "$MOZ_SYSTEM_SOUNDTOUCH"; then
+    PKG_CHECK_MODULES(MOZ_SOUNDTOUCH, soundtouch >= 1.9.0)
+
+    AC_LANG_SAVE
+    AC_LANG_CPLUSPLUS
+    _SAVE_CXXFLAGS=$CXXFLAGS
+    CXXFLAGS="$CXXFLAGS $MOZ_SOUNDTOUCH_CFLAGS"
+    AC_CACHE_CHECK(for soundtouch sample type,
+                   ac_cv_soundtouch_sample_type,
+                   [AC_TRY_COMPILE([#include <SoundTouch.h>
+                                    #ifndef SOUNDTOUCH_INTEGER_SAMPLES
+                                    #error soundtouch expects float samples
+                                    #endif],
+                                   [],
+                                   [ac_cv_soundtouch_sample_type=short],
+                                   [ac_cv_soundtouch_sample_type=float])])
+    CXXFLAGS=$_SAVE_CXXFLAGS
+    AC_LANG_RESTORE
+
+    if test \( -n "$MOZ_SAMPLE_TYPE_S16" -a "$ac_cv_soundtouch_sample_type" != short \) \
+         -o \( -n "$MOZ_SAMPLE_TYPE_FLOAT32" -a "$ac_cv_soundtouch_sample_type" != float \) ; then
+        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.])
+    fi
+fi
+
+if test -n "$MOZ_SYSTEM_SOUNDTOUCH"; then
+    AC_DEFINE(MOZ_SYSTEM_SOUNDTOUCH)
+fi
+AC_SUBST(MOZ_SYSTEM_SOUNDTOUCH)
+
 dnl system libvpx Support
 dnl ========================================================
 MOZ_ARG_WITH_BOOL(system-libvpx,
 [  --with-system-libvpx    Use system libvpx (located with pkgconfig)],
     MOZ_SYSTEM_LIBVPX=1)
 
 MOZ_LIBVPX_CFLAGS=
 MOZ_LIBVPX_LIBS=
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -218,16 +218,31 @@ if CONFIG['MOZ_SYSTEM_JPEG']:
     OS_LIBS += CONFIG['MOZ_JPEG_LIBS']
 
 if CONFIG['MOZ_SYSTEM_PNG']:
     OS_LIBS += CONFIG['MOZ_PNG_LIBS']
 
 if CONFIG['MOZ_SYSTEM_HUNSPELL']:
     OS_LIBS += CONFIG['MOZ_HUNSPELL_LIBS']
 
+if CONFIG['MOZ_SYSTEM_OGG']:
+    OS_LIBS += CONFIG['MOZ_OGG_LIBS']
+
+if CONFIG['MOZ_SYSTEM_THEORA']:
+    OS_LIBS += CONFIG['MOZ_THEORA_LIBS']
+
+if CONFIG['MOZ_SYSTEM_VORBIS']:
+    OS_LIBS += CONFIG['MOZ_VORBIS_LIBS']
+
+if CONFIG['MOZ_SYSTEM_TREMOR']:
+    OS_LIBS += CONFIG['MOZ_TREMOR_LIBS']
+
+if CONFIG['MOZ_SYSTEM_SOUNDTOUCH']:
+    OS_LIBS += CONFIG['MOZ_SOUNDTOUCH_LIBS']
+
 if CONFIG['MOZ_SYSTEM_LIBEVENT']:
     OS_LIBS += CONFIG['MOZ_LIBEVENT_LIBS']
 
 if CONFIG['MOZ_SYSTEM_LIBVPX']:
     OS_LIBS += CONFIG['MOZ_LIBVPX_LIBS']
 
 if not CONFIG['MOZ_TREE_PIXMAN']:
     OS_LIBS += CONFIG['MOZ_PIXMAN_LIBS']
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -133,17 +133,19 @@ extern nsresult nsStringInputStreamConst
 #include "mozilla/AvailableMemoryTracker.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/CountingAllocatorBase.h"
 #include "mozilla/SystemMemoryReporter.h"
 #include "mozilla/UniquePtr.h"
 
 #include "mozilla/ipc/GeckoChildProcessHost.h"
 
+#ifndef MOZ_OGG_NO_MEM_REPORTING
 #include "ogg/ogg.h"
+#endif
 #if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING)
 #if defined(HAVE_STDINT_H)
 // mozilla-config.h defines HAVE_STDINT_H, and then it's defined *again* in
 // vpx_config.h (which we include via vpx_mem.h, below). This redefinition
 // triggers a build warning on MSVC, so we have to #undef it first.
 #undef HAVE_STDINT_H
 #endif
 #include "vpx_mem/vpx_mem.h"
@@ -658,21 +660,23 @@ NS_InitXPCOM2(nsIServiceManager** aResul
   // Register ICU memory functions.  This really shouldn't be necessary: the
   // JS engine should do this on its own inside JS_Init, and memory-reporting
   // code should call a JSAPI function to observe ICU memory usage.  But we
   // can't define the alloc/free functions in the JS engine, because it can't
   // depend on the XPCOM-based memory reporting goop.  So for now, we have
   // this oddness.
   mozilla::SetICUMemoryFunctions();
 
+#ifndef MOZ_OGG_NO_MEM_REPORTING
   // Do the same for libogg.
   ogg_set_mem_functions(OggReporter::CountingMalloc,
                         OggReporter::CountingCalloc,
                         OggReporter::CountingRealloc,
                         OggReporter::CountingFree);
+#endif
 
 #if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING)
   // And for VPX.
   vpx_mem_set_functions(VPXReporter::CountingMalloc,
                         VPXReporter::CountingCalloc,
                         VPXReporter::CountingRealloc,
                         VPXReporter::CountingFree,
                         memcpy,