| Index: media/audio/cras/cras_unified.cc
|
| diff --git a/media/audio/cras/cras_unified.cc b/media/audio/cras/cras_unified.cc
|
| index 929854497c3987671e9c1f0a17147a7771055db8..346aa1e46010270ee1f542a56d6a667198e56265 100644
|
| --- a/media/audio/cras/cras_unified.cc
|
| +++ b/media/audio/cras/cras_unified.cc
|
| @@ -8,6 +8,7 @@
|
|
|
| #include "base/logging.h"
|
| #include "base/macros.h"
|
| +#include "base/strings/string_number_conversions.h"
|
| #include "media/audio/cras/audio_manager_cras.h"
|
|
|
| namespace media {
|
| @@ -52,7 +53,8 @@ namespace media {
|
| // of audio.
|
|
|
| CrasUnifiedStream::CrasUnifiedStream(const AudioParameters& params,
|
| - AudioManagerCras* manager)
|
| + AudioManagerCras* manager,
|
| + const std::string& device_id)
|
| : client_(NULL),
|
| stream_id_(0),
|
| params_(params),
|
| @@ -61,11 +63,17 @@ CrasUnifiedStream::CrasUnifiedStream(const AudioParameters& params,
|
| volume_(1.0),
|
| manager_(manager),
|
| source_callback_(NULL),
|
| - stream_direction_(CRAS_STREAM_OUTPUT) {
|
| + stream_direction_(CRAS_STREAM_OUTPUT),
|
| + pin_device_(NO_DEVICE) {
|
| DCHECK(manager_);
|
| DCHECK_GT(params_.channels(), 0);
|
|
|
| output_bus_ = AudioBus::Create(params);
|
| + if (!manager_->IsDefault(device_id, false)) {
|
| + uint64_t cras_node_id;
|
| + base::StringToUint64(device_id, &cras_node_id);
|
| + pin_device_ = dev_index_of(cras_node_id);
|
| + }
|
| }
|
|
|
| CrasUnifiedStream::~CrasUnifiedStream() {
|
| @@ -196,8 +204,9 @@ void CrasUnifiedStream::Start(AudioSourceCallback* callback) {
|
| bytes_per_frame_ = cras_client_format_bytes_per_frame(audio_format);
|
|
|
| // Adding the stream will start the audio callbacks requesting data.
|
| - if (cras_client_add_stream(client_, &stream_id_, stream_params) < 0) {
|
| - LOG(WARNING) << "Failed to add the stream";
|
| + if (cras_client_add_pinned_stream(client_, pin_device_, &stream_id_,
|
| + stream_params)) {
|
| + LOG(WARNING) << "Failed to add the stream.";
|
| callback->OnError(this);
|
| cras_audio_format_destroy(audio_format);
|
| cras_client_stream_params_destroy(stream_params);
|
|
|