Bug 943353 - Don't include X11 headers if USE_X11 is undefined. r=jesup
authorOleg Romashin <romaxa@gmail.com>
Thu, 23 Jan 2014 09:38:29 -0500
changeset 180864 532334f941089fc22241ed1ba5e18979d0c72d52
parent 180863 fc5112c72bba376ecc93191d196abbf4f0f7343b
child 180865 d6ff1c03c8e2f381d6da0c195e339c20952ea07b
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs943353
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 943353 - Don't include X11 headers if USE_X11 is undefined. r=jesup
media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc
media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_alsa_linux.h
media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc
media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_pulse_linux.h
--- a/media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc
+++ b/media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc
@@ -185,23 +185,25 @@ int32_t AudioDeviceLinuxALSA::Init()
         return -1;
     }
 
     if (_initialized)
     {
         return 0;
     }
 
+#ifdef USE_X11
     //Get X display handle for typing detection
     _XDisplay = XOpenDisplay(NULL);
     if (!_XDisplay)
     {
         WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
           "  failed to open X display, typing detection will not work");
     }
+#endif
 
     _playWarning = 0;
     _playError = 0;
     _recWarning = 0;
     _recError = 0;
 
     _initialized = true;
 
@@ -259,21 +261,23 @@ int32_t AudioDeviceLinuxALSA::Terminate(
         {
             WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
                          "  failed to close down the play audio thread");
         }
 
         _critSect.Enter();
     }
 
+#ifdef USE_X11
     if (_XDisplay)
     {
       XCloseDisplay(_XDisplay);
       _XDisplay = NULL;
     }
+#endif
 
     _initialized = false;
     _outputDeviceIsSpecified = false;
     _inputDeviceIsSpecified = false;
 
     return 0;
 }
 
@@ -2365,21 +2369,23 @@ bool AudioDeviceLinuxALSA::RecThreadProc
 
 
 bool AudioDeviceLinuxALSA::KeyPressed() const{
 
   char szKey[32];
   unsigned int i = 0;
   char state = 0;
 
+#ifdef USE_X11
   if (!_XDisplay)
     return false;
 
   // Check key map status
   XQueryKeymap(_XDisplay, szKey);
+#endif
 
   // A bit change in keymap means a key is pressed
   for (i = 0; i < sizeof(szKey); i++)
     state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i];
 
   // Save old state
   memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState));
   return (state != 0);
--- a/media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_alsa_linux.h
+++ b/media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_alsa_linux.h
@@ -11,17 +11,19 @@
 #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_ALSA_LINUX_H
 #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_ALSA_LINUX_H
 
 #include "webrtc/modules/audio_device/audio_device_generic.h"
 #include "webrtc/modules/audio_device/linux/audio_mixer_manager_alsa_linux.h"
 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
 
 
+#ifdef USE_X11
 #include <X11/Xlib.h>
+#endif
 #include <alsa/asoundlib.h>
 #include <sys/ioctl.h>
 #include <sys/soundcard.h>
 
 
 namespace webrtc
 {
 class EventWrapper;
@@ -248,14 +250,16 @@ private:
     uint16_t _playError;
     uint16_t _recWarning;
     uint16_t _recError;
 
     uint16_t _playBufDelay;                 // playback delay
     uint16_t _playBufDelayFixed;            // fixed playback delay
 
     char _oldKeyState[32];
+#ifdef USE_X11
     Display* _XDisplay;
+#endif
 };
 
 }
 
 #endif  // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_DEVICE_ALSA_LINUX_H_
--- a/media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc
+++ b/media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_pulse_linux.cc
@@ -226,23 +226,25 @@ int32_t AudioDeviceLinuxPulse::Init()
         return -1;
     }
 
     _playWarning = 0;
     _playError = 0;
     _recWarning = 0;
     _recError = 0;
 
+#ifdef USE_X11
     //Get X display handle for typing detection
     _XDisplay = XOpenDisplay(NULL);
     if (!_XDisplay)
     {
         WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
           "  failed to open X display, typing detection will not work");
     }
+#endif
 
     // RECORDING
     const char* threadName = "webrtc_audio_module_rec_thread";
     _ptrThreadRec = ThreadWrapper::CreateThread(RecThreadFunc, this,
                                                 kRealtimePriority, threadName);
     if (_ptrThreadRec == NULL)
     {
         WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id,
@@ -347,21 +349,23 @@ int32_t AudioDeviceLinuxPulse::Terminate
     // Terminate PulseAudio
     if (TerminatePulseAudio() < 0)
     {
         WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
                      "  failed to terminate PulseAudio");
         return -1;
     }
 
+#ifdef USE_X11
     if (_XDisplay)
     {
       XCloseDisplay(_XDisplay);
       _XDisplay = NULL;
     }
+#endif
 
     _initialized = false;
     _outputDeviceIsSpecified = false;
     _inputDeviceIsSpecified = false;
 
     return 0;
 }
 
@@ -3110,21 +3114,23 @@ bool AudioDeviceLinuxPulse::RecThreadPro
 }
 
 bool AudioDeviceLinuxPulse::KeyPressed() const{
 
   char szKey[32];
   unsigned int i = 0;
   char state = 0;
 
+#ifdef USE_X11
   if (!_XDisplay)
     return false;
 
   // Check key map status
   XQueryKeymap(_XDisplay, szKey);
+#endif
 
   // A bit change in keymap means a key is pressed
   for (i = 0; i < sizeof(szKey); i++)
     state |= (szKey[i] ^ _oldKeyState[i]) & szKey[i];
 
   // Save old state
   memcpy((char*)_oldKeyState, (char*)szKey, sizeof(_oldKeyState));
   return (state != 0);
--- a/media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_pulse_linux.h
+++ b/media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_pulse_linux.h
@@ -10,17 +10,19 @@
 
 #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_PULSE_LINUX_H
 #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_PULSE_LINUX_H
 
 #include "webrtc/modules/audio_device/audio_device_generic.h"
 #include "webrtc/modules/audio_device/linux/audio_mixer_manager_pulse_linux.h"
 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
 
+#ifdef USE_X11
 #include <X11/Xlib.h>
+#endif
 #include <pulse/pulseaudio.h>
 
 // We define this flag if it's missing from our headers, because we want to be
 // able to compile against old headers but still use PA_STREAM_ADJUST_LATENCY
 // if run against a recent version of the library.
 #ifndef PA_STREAM_ADJUST_LATENCY
 #define PA_STREAM_ADJUST_LATENCY 0x2000U
 #endif
@@ -376,14 +378,16 @@ private:
     pa_stream* _recStream;
     pa_stream* _playStream;
     uint32_t _recStreamFlags;
     uint32_t _playStreamFlags;
     pa_buffer_attr _playBufferAttr;
     pa_buffer_attr _recBufferAttr;
 
     char _oldKeyState[32];
+#ifdef USE_X11
     Display* _XDisplay;
+#endif
 };
 
 }
 
 #endif  // MODULES_AUDIO_DEVICE_MAIN_SOURCE_LINUX_AUDIO_DEVICE_PULSE_LINUX_H_