Fix no_{global_constructors,exit_time_destructors} in audio device alsa.

Bug: webrtc:9693
Change-Id: Id37ef7e8c33830b494165202323ea65286052aae
Reviewed-on: https://webrtc-review.googlesource.com/100103
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24725}
This commit is contained in:
Mirko Bonadei 2018-09-13 11:58:23 +02:00 committed by Commit Bot
parent 1a03960e63
commit bfb72ad4f4
4 changed files with 20 additions and 17 deletions

View File

@ -304,7 +304,6 @@ rtc_source_set("audio_device_impl") {
defines += [ "WEBRTC_DUMMY_FILE_DEVICES" ]
} else {
if (is_linux) {
configs += [ "../../..:no_global_constructors" ]
sources += [
"linux/alsasymboltable_linux.cc",
"linux/alsasymboltable_linux.h",
@ -322,7 +321,10 @@ rtc_source_set("audio_device_impl") {
defines += [ "WEBRTC_USE_X11" ]
}
if (rtc_include_pulse_audio) {
configs += [ "../..:no_exit_time_destructors" ]
configs += [
"../..:no_exit_time_destructors",
"../..:no_global_constructors",
]
sources += [
"linux/audio_device_pulse_linux.cc",
"linux/audio_device_pulse_linux.h",

View File

@ -16,13 +16,11 @@
#include "rtc_base/system/arch.h"
#include "system_wrappers/include/event_wrapper.h"
#include "system_wrappers/include/sleep.h"
webrtc::adm_linux_alsa::AlsaSymbolTable AlsaSymbolTable;
// Accesses ALSA functions through our late-binding symbol table instead of
// directly. This way we don't have to link to libasound, which means our binary
// will work on systems that don't have it.
#define LATE(sym) \
LATESYM_GET(webrtc::adm_linux_alsa::AlsaSymbolTable, &AlsaSymbolTable, sym)
WebRTCAlsaSymbolTable* GetAlsaSymbolTable() {
static WebRTCAlsaSymbolTable* alsa_symbol_table = new WebRTCAlsaSymbolTable();
return alsa_symbol_table;
}
// Redefine these here to be able to do late-binding
#undef snd_ctl_card_info_alloca
@ -140,7 +138,7 @@ AudioDeviceGeneric::InitStatus AudioDeviceLinuxALSA::Init() {
rtc::CritScope lock(&_critSect);
// Load libasound
if (!AlsaSymbolTable.Load()) {
if (!GetAlsaSymbolTable()->Load()) {
// Alsa is not installed on this system
RTC_LOG(LS_ERROR) << "failed to load symbol table";
return InitStatus::OTHER_ERROR;

View File

@ -25,6 +25,16 @@
#include <sys/ioctl.h>
#include <sys/soundcard.h>
typedef webrtc::adm_linux_alsa::AlsaSymbolTable WebRTCAlsaSymbolTable;
WebRTCAlsaSymbolTable* GetAlsaSymbolTable();
// Accesses ALSA functions through our late-binding symbol table instead of
// directly. This way we don't have to link to libasound, which means our binary
// will work on systems that don't have it.
#define LATE(sym) \
LATESYM_GET(webrtc::adm_linux_alsa::AlsaSymbolTable, GetAlsaSymbolTable(), \
sym)
namespace webrtc {
class EventWrapper;

View File

@ -10,17 +10,10 @@
#include <assert.h>
#include "modules/audio_device/linux/audio_device_alsa_linux.h"
#include "modules/audio_device/linux/audio_mixer_manager_alsa_linux.h"
#include "rtc_base/logging.h"
extern webrtc::adm_linux_alsa::AlsaSymbolTable AlsaSymbolTable;
// Accesses ALSA functions through our late-binding symbol table instead of
// directly. This way we don't have to link to libalsa, which means our binary
// will work on systems that don't have it.
#define LATE(sym) \
LATESYM_GET(webrtc::adm_linux_alsa::AlsaSymbolTable, &AlsaSymbolTable, sym)
namespace webrtc {
AudioMixerManagerLinuxALSA::AudioMixerManagerLinuxALSA()