summaryrefslogtreecommitdiff
path: root/chromium/media/audio
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-06-02 10:15:40 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-06-02 08:41:08 +0000
commitb92421879c003a0857b2074f7e05b3bbbb326569 (patch)
treebdfd21ad74690ae4069e4a055191844994027b78 /chromium/media/audio
parent980b784afe75be22158126ac6a639c19459d3427 (diff)
downloadqtwebengine-chromium-b92421879c003a0857b2074f7e05b3bbbb326569.tar.gz
BASELINE: Update Chromium to 51.0.2704.79
Also adds a few files for url_parsing in extensions. Change-Id: Ie4820c3da75f0a56b3cc86dccc077d671227077b Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'chromium/media/audio')
-rw-r--r--chromium/media/audio/pulse/pulse_input.cc29
-rw-r--r--chromium/media/audio/pulse/pulse_input.h17
-rw-r--r--chromium/media/audio/pulse/pulse_output.cc94
-rw-r--r--chromium/media/audio/pulse/pulse_output.h19
-rw-r--r--chromium/media/audio/pulse/pulse_util.cc64
-rw-r--r--chromium/media/audio/pulse/pulse_util.h8
6 files changed, 57 insertions, 174 deletions
diff --git a/chromium/media/audio/pulse/pulse_input.cc b/chromium/media/audio/pulse/pulse_input.cc
index db13935d23a..8d4aeea2079 100644
--- a/chromium/media/audio/pulse/pulse_input.cc
+++ b/chromium/media/audio/pulse/pulse_input.cc
@@ -51,15 +51,8 @@ PulseAudioInputStream::~PulseAudioInputStream() {
bool PulseAudioInputStream::Open() {
DCHECK(thread_checker_.CalledOnValidThread());
AutoPulseLock auto_lock(pa_mainloop_);
- std::string device_name_to_use = device_name_;
- if (device_name_ == AudioManagerBase::kDefaultDeviceId) {
- GetSystemDefaultInputDevice();
- device_name_to_use = default_system_device_name_;
- }
-
if (!pulse::CreateInputStream(pa_mainloop_, pa_context_, &handle_, params_,
- device_name_to_use, &StreamNotifyCallback,
- this)) {
+ device_name_, &StreamNotifyCallback, this)) {
return false;
}
@@ -275,26 +268,6 @@ void PulseAudioInputStream::StreamNotifyCallback(pa_stream* s,
pa_threaded_mainloop_signal(stream->pa_mainloop_, 0);
}
-// static, used by pa_context_get_server_info.
-void PulseAudioInputStream::GetSystemDefaultInputDeviceCallback(
- pa_context* context,
- const pa_server_info* info,
- void* user_data) {
- media::PulseAudioInputStream* stream =
- static_cast<media::PulseAudioInputStream*>(user_data);
- stream->default_system_device_name_ = info->default_source_name;
- pa_threaded_mainloop_signal(stream->pa_mainloop_, 0);
-}
-
-void PulseAudioInputStream::GetSystemDefaultInputDevice() {
- DCHECK(pa_mainloop_);
- DCHECK(pa_context_);
- pa_operation* operation = pa_context_get_server_info(
- pa_context_, PulseAudioInputStream::GetSystemDefaultInputDeviceCallback,
- this);
- WaitForOperationCompletion(pa_mainloop_, operation);
-}
-
void PulseAudioInputStream::ReadData() {
uint32_t hardware_delay = pulse::GetHardwareLatencyInBytes(
handle_, params_.sample_rate(), params_.GetBytesPerFrame());
diff --git a/chromium/media/audio/pulse/pulse_input.h b/chromium/media/audio/pulse/pulse_input.h
index 4d087d2d16e..e0b2be9e2ef 100644
--- a/chromium/media/audio/pulse/pulse_input.h
+++ b/chromium/media/audio/pulse/pulse_input.h
@@ -52,16 +52,6 @@ class PulseAudioInputStream : public AgcAudioStream<AudioInputStream> {
int error,
void* user_data);
- // pa_context_get_server_info callback. It's used by
- // GetSystemDefaultInputDevice to set |default_system_device_name_| to the
- // default system input device.
- static void GetSystemDefaultInputDeviceCallback(pa_context* context,
- const pa_server_info* info,
- void* user_data);
-
- // Get default system input device for the input stream.
- void GetSystemDefaultInputDevice();
-
// Helper for the ReadCallback.
void ReadData();
@@ -70,12 +60,7 @@ class PulseAudioInputStream : public AgcAudioStream<AudioInputStream> {
AudioManagerPulse* audio_manager_;
AudioInputCallback* callback_;
- const std::string device_name_;
- // The name of the system default device. Set by
- // GetSystemDefaultInputDeviceCallback if |device_name_| is set to be the
- // default device.
- std::string default_system_device_name_;
-
+ std::string device_name_;
AudioParameters params_;
int channels_;
double volume_;
diff --git a/chromium/media/audio/pulse/pulse_output.cc b/chromium/media/audio/pulse/pulse_output.cc
index c06093e1f43..953f9acebfa 100644
--- a/chromium/media/audio/pulse/pulse_output.cc
+++ b/chromium/media/audio/pulse/pulse_output.cc
@@ -61,102 +61,10 @@ PulseAudioOutputStream::~PulseAudioOutputStream() {
DCHECK(!pa_mainloop_);
}
-bool PulseAudioOutputStream::InitializeMainloopAndContext() {
- DCHECK(!pa_mainloop_);
- DCHECK(!pa_context_);
- DCHECK(thread_checker_.CalledOnValidThread());
- pa_mainloop_ = pa_threaded_mainloop_new();
- if (!pa_mainloop_) {
- DLOG(ERROR) << "Failed to create PulseAudio main loop.";
- return false;
- }
-
- pa_mainloop_api* pa_mainloop_api = pa_threaded_mainloop_get_api(pa_mainloop_);
- std::string app_name = AudioManager::GetGlobalAppName();
- pa_context_ = pa_context_new(
- pa_mainloop_api, app_name.empty() ? "Chromium" : app_name.c_str());
- if (!pa_context_) {
- DLOG(ERROR) << "Failed to create PulseAudio context.";
- return false;
- }
-
- // A state callback must be set before calling pa_threaded_mainloop_lock() or
- // pa_threaded_mainloop_wait() calls may lead to dead lock.
- pa_context_set_state_callback(pa_context_, &pulse::ContextStateCallback,
- pa_mainloop_);
- {
- // Lock the main loop while setting up the context. Failure to do so may
- // lead to crashes as the PulseAudio thread tries to run before things are
- // ready.
- AutoPulseLock auto_lock(pa_mainloop_);
-
- if (pa_threaded_mainloop_start(pa_mainloop_) != 0) {
- DLOG(ERROR) << "Failed to start PulseAudio main loop.";
- return false;
- }
-
- if (pa_context_connect(pa_context_, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL) !=
- 0) {
- DLOG(ERROR) << "Failed to connect PulseAudio context.";
- return false;
- }
-
- // Wait until |pa_context_| is ready. pa_threaded_mainloop_wait() must be
- // called after pa_context_get_state() in case the context is already ready,
- // otherwise pa_threaded_mainloop_wait() will hang indefinitely.
- while (true) {
- pa_context_state_t context_state = pa_context_get_state(pa_context_);
- if (!PA_CONTEXT_IS_GOOD(context_state)) {
- DLOG(ERROR) << "Invalid PulseAudio context state.";
- return false;
- }
-
- if (context_state == PA_CONTEXT_READY)
- break;
- pa_threaded_mainloop_wait(pa_mainloop_);
- }
- }
-
- return true;
-}
-
-// static, used by pa_context_get_server_info.
-void PulseAudioOutputStream::GetSystemDefaultOutputDeviceCallback(
- pa_context* context,
- const pa_server_info* info,
- void* user_data) {
- media::PulseAudioOutputStream* stream =
- static_cast<media::PulseAudioOutputStream*>(user_data);
- stream->default_system_device_name_ = info->default_sink_name;
- pa_threaded_mainloop_signal(stream->pa_mainloop_, 0);
-}
-
-void PulseAudioOutputStream::GetSystemDefaultOutputDevice() {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(pa_mainloop_);
- DCHECK(pa_context_);
- pa_operation* operation = pa_context_get_server_info(
- pa_context_, PulseAudioOutputStream::GetSystemDefaultOutputDeviceCallback,
- this);
- WaitForOperationCompletion(pa_mainloop_, operation);
-}
-
bool PulseAudioOutputStream::Open() {
DCHECK(thread_checker_.CalledOnValidThread());
- if (!InitializeMainloopAndContext()) {
- return false;
- }
-
- AutoPulseLock auto_lock(pa_mainloop_);
-
- std::string device_name_to_use = device_id_;
- if (device_id_ == AudioManagerBase::kDefaultDeviceId) {
- GetSystemDefaultOutputDevice();
- device_name_to_use = default_system_device_name_;
- }
-
return pulse::CreateOutputStream(
- pa_mainloop_, pa_context_, &pa_stream_, params_, device_name_to_use,
+ &pa_mainloop_, &pa_context_, &pa_stream_, params_, device_id_,
AudioManager::GetGlobalAppName(), &StreamNotifyCallback,
&StreamRequestCallback, this);
}
diff --git a/chromium/media/audio/pulse/pulse_output.h b/chromium/media/audio/pulse/pulse_output.h
index 49f6abf28d1..ce9a58914ec 100644
--- a/chromium/media/audio/pulse/pulse_output.h
+++ b/chromium/media/audio/pulse/pulse_output.h
@@ -20,7 +20,6 @@
#ifndef MEDIA_AUDIO_PULSE_PULSE_OUTPUT_H_
#define MEDIA_AUDIO_PULSE_PULSE_OUTPUT_H_
-#include <pulse/pulseaudio.h>
#include <stddef.h>
#include <string>
@@ -64,20 +63,6 @@ class PulseAudioOutputStream : public AudioOutputStream {
// Called by PulseAudio when it needs more audio data.
static void StreamRequestCallback(pa_stream* s, size_t len, void* p_this);
- // pa_context_get_server_info callback. It's used by
- // GetSystemDefaultOutputDevice to set |default_system_device_name_| to the
- // default system output device.
- static void GetSystemDefaultOutputDeviceCallback(pa_context* context,
- const pa_server_info* info,
- void* user_data);
-
- // Initialize |pa_mainloop_| and |pa_context_| and prepare them for creating
- // an output stream.
- bool InitializeMainloopAndContext();
-
- // Get default system output device for the output stream.
- void GetSystemDefaultOutputDevice();
-
// Fulfill a write request from the write request callback. Outputs silence
// if the request could not be fulfilled.
void FulfillWriteRequest(size_t requested_bytes);
@@ -90,10 +75,6 @@ class PulseAudioOutputStream : public AudioOutputStream {
// The device ID for the device to open.
const std::string device_id_;
- // The name of the system default device. Set by
- // GetSystemDefaultOutputDeviceCallback if |device_id_| is set to be the
- // default device.
- std::string default_system_device_name_;
// Audio manager that created us. Used to report that we've closed.
AudioManagerBase* manager_;
diff --git a/chromium/media/audio/pulse/pulse_util.cc b/chromium/media/audio/pulse/pulse_util.cc
index a00769c220d..5044fa4d26e 100644
--- a/chromium/media/audio/pulse/pulse_util.cc
+++ b/chromium/media/audio/pulse/pulse_util.cc
@@ -170,7 +170,6 @@ bool CreateInputStream(pa_threaded_mainloop* mainloop,
void* user_data) {
DCHECK(mainloop);
DCHECK(context);
- DCHECK_NE(device_id, AudioManagerBase::kDefaultDeviceId);
// Set sample specifications.
pa_sample_spec sample_specifications;
@@ -212,8 +211,12 @@ bool CreateInputStream(pa_threaded_mainloop* mainloop,
PA_STREAM_ADJUST_LATENCY |
PA_STREAM_START_CORKED;
RETURN_ON_FAILURE(
- pa_stream_connect_record(*stream, device_id.c_str(), &buffer_attributes,
- static_cast<pa_stream_flags_t>(flags)) == 0,
+ pa_stream_connect_record(
+ *stream,
+ device_id == AudioManagerBase::kDefaultDeviceId ?
+ NULL : device_id.c_str(),
+ &buffer_attributes,
+ static_cast<pa_stream_flags_t>(flags)) == 0,
"pa_stream_connect_record FAILED ");
// Wait for the stream to be ready.
@@ -229,8 +232,8 @@ bool CreateInputStream(pa_threaded_mainloop* mainloop,
return true;
}
-bool CreateOutputStream(pa_threaded_mainloop* mainloop,
- pa_context* context,
+bool CreateOutputStream(pa_threaded_mainloop** mainloop,
+ pa_context** context,
pa_stream** stream,
const AudioParameters& params,
const std::string& device_id,
@@ -238,9 +241,42 @@ bool CreateOutputStream(pa_threaded_mainloop* mainloop,
pa_stream_notify_cb_t stream_callback,
pa_stream_request_cb_t write_callback,
void* user_data) {
- DCHECK(mainloop);
- DCHECK(context);
- DCHECK(device_id != AudioManagerBase::kDefaultDeviceId);
+ DCHECK(!*mainloop);
+ DCHECK(!*context);
+
+ *mainloop = pa_threaded_mainloop_new();
+ RETURN_ON_FAILURE(*mainloop, "Failed to create PulseAudio main loop.");
+
+ pa_mainloop_api* pa_mainloop_api = pa_threaded_mainloop_get_api(*mainloop);
+ *context = pa_context_new(pa_mainloop_api,
+ app_name.empty() ? "Chromium" : app_name.c_str());
+ RETURN_ON_FAILURE(*context, "Failed to create PulseAudio context.");
+
+ // A state callback must be set before calling pa_threaded_mainloop_lock() or
+ // pa_threaded_mainloop_wait() calls may lead to dead lock.
+ pa_context_set_state_callback(*context, &ContextStateCallback, *mainloop);
+
+ // Lock the main loop while setting up the context. Failure to do so may lead
+ // to crashes as the PulseAudio thread tries to run before things are ready.
+ AutoPulseLock auto_lock(*mainloop);
+
+ RETURN_ON_FAILURE(pa_threaded_mainloop_start(*mainloop) == 0,
+ "Failed to start PulseAudio main loop.");
+ RETURN_ON_FAILURE(
+ pa_context_connect(*context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL) == 0,
+ "Failed to connect PulseAudio context.");
+
+ // Wait until |pa_context_| is ready. pa_threaded_mainloop_wait() must be
+ // called after pa_context_get_state() in case the context is already ready,
+ // otherwise pa_threaded_mainloop_wait() will hang indefinitely.
+ while (true) {
+ pa_context_state_t context_state = pa_context_get_state(*context);
+ RETURN_ON_FAILURE(
+ PA_CONTEXT_IS_GOOD(context_state), "Invalid PulseAudio context state.");
+ if (context_state == PA_CONTEXT_READY)
+ break;
+ pa_threaded_mainloop_wait(*mainloop);
+ }
// Set sample specifications.
pa_sample_spec sample_specifications;
@@ -265,7 +301,7 @@ bool CreateOutputStream(pa_threaded_mainloop* mainloop,
pa_proplist_sets(property_list.get(), PA_PROP_APPLICATION_ICON_NAME,
kBrowserDisplayName);
*stream = pa_stream_new_with_proplist(
- context, "Playback", &sample_specifications, map, property_list.get());
+ *context, "Playback", &sample_specifications, map, property_list.get());
RETURN_ON_FAILURE(*stream, "failed to create PA playback stream");
pa_stream_set_state_callback(*stream, stream_callback, user_data);
@@ -296,12 +332,16 @@ bool CreateOutputStream(pa_threaded_mainloop* mainloop,
// and error.
RETURN_ON_FAILURE(
pa_stream_connect_playback(
- *stream, device_id.c_str(), &pa_buffer_attributes,
+ *stream,
+ device_id == AudioManagerBase::kDefaultDeviceId ?
+ NULL : device_id.c_str(),
+ &pa_buffer_attributes,
static_cast<pa_stream_flags_t>(
PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_ADJUST_LATENCY |
PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_NOT_MONOTONIC |
PA_STREAM_START_CORKED),
- NULL, NULL) == 0,
+ NULL,
+ NULL) == 0,
"pa_stream_connect_playback FAILED ");
// Wait for the stream to be ready.
@@ -311,7 +351,7 @@ bool CreateOutputStream(pa_threaded_mainloop* mainloop,
PA_STREAM_IS_GOOD(stream_state), "Invalid PulseAudio stream state");
if (stream_state == PA_STREAM_READY)
break;
- pa_threaded_mainloop_wait(mainloop);
+ pa_threaded_mainloop_wait(*mainloop);
}
return true;
diff --git a/chromium/media/audio/pulse/pulse_util.h b/chromium/media/audio/pulse/pulse_util.h
index a7fd875abcb..b8e5cdcda4c 100644
--- a/chromium/media/audio/pulse/pulse_util.h
+++ b/chromium/media/audio/pulse/pulse_util.h
@@ -53,8 +53,6 @@ int GetHardwareLatencyInBytes(pa_stream* stream,
// otherwise false. |mainloop| and |context| have to be from a valid Pulse
// threaded mainloop and the handle of the created stream will be returned by
// |stream|.
-// TODO(grunell): Move this function to PulseAudioInputStream class since it's
-// only used there.
bool CreateInputStream(pa_threaded_mainloop* mainloop,
pa_context* context,
pa_stream** stream,
@@ -67,10 +65,8 @@ bool CreateInputStream(pa_threaded_mainloop* mainloop,
// otherwise false. This function will create a new Pulse threaded mainloop,
// and the handles of the mainloop, context and stream will be returned by
// |mainloop|, |context| and |stream|.
-// TODO(grunell): Move this function to PulseAudioOutputStream class since it's
-// only used there.
-bool CreateOutputStream(pa_threaded_mainloop* mainloop,
- pa_context* context,
+bool CreateOutputStream(pa_threaded_mainloop** mainloop,
+ pa_context** context,
pa_stream** stream,
const AudioParameters& params,
const std::string& device_id,