Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: media/audio/pulse/pulse_unified.cc

Issue 15979015: Reland 15721002: Hook up the device selection to the WebAudio live audio (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed the comments. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/pulse/pulse_unified.h" 5 #include "media/audio/pulse/pulse_unified.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "media/audio/audio_manager_base.h" 9 #include "media/audio/audio_manager_base.h"
10 #include "media/audio/audio_parameters.h" 10 #include "media/audio/audio_parameters.h"
(...skipping 23 matching lines...) Expand all
34 34
35 pa_threaded_mainloop_signal(stream->pa_mainloop_, 0); 35 pa_threaded_mainloop_signal(stream->pa_mainloop_, 0);
36 } 36 }
37 37
38 // static, used by pa_stream_set_read_callback. 38 // static, used by pa_stream_set_read_callback.
39 void PulseAudioUnifiedStream::ReadCallback(pa_stream* handle, size_t length, 39 void PulseAudioUnifiedStream::ReadCallback(pa_stream* handle, size_t length,
40 void* user_data) { 40 void* user_data) {
41 static_cast<PulseAudioUnifiedStream*>(user_data)->ReadData(); 41 static_cast<PulseAudioUnifiedStream*>(user_data)->ReadData();
42 } 42 }
43 43
44 PulseAudioUnifiedStream::PulseAudioUnifiedStream(const AudioParameters& params, 44 PulseAudioUnifiedStream::PulseAudioUnifiedStream(
45 AudioManagerBase* manager) 45 const AudioParameters& params,
46 const std::string& input_device_id,
47 AudioManagerBase* manager)
46 : params_(params), 48 : params_(params),
49 input_device_id_(input_device_id),
47 manager_(manager), 50 manager_(manager),
48 pa_context_(NULL), 51 pa_context_(NULL),
49 pa_mainloop_(NULL), 52 pa_mainloop_(NULL),
50 input_stream_(NULL), 53 input_stream_(NULL),
51 output_stream_(NULL), 54 output_stream_(NULL),
52 volume_(1.0f), 55 volume_(1.0f),
53 source_callback_(NULL) { 56 source_callback_(NULL) {
54 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread()); 57 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
55 CHECK(params_.IsValid()); 58 CHECK(params_.IsValid());
56 input_bus_ = AudioBus::Create(params_); 59 input_bus_ = AudioBus::Create(params_);
(...skipping 13 matching lines...) Expand all
70 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread()); 73 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
71 // Prepare the recording buffers for the callbacks. 74 // Prepare the recording buffers for the callbacks.
72 fifo_.reset(new media::SeekableBuffer( 75 fifo_.reset(new media::SeekableBuffer(
73 0, kFifoSizeInPackets * params_.GetBytesPerBuffer())); 76 0, kFifoSizeInPackets * params_.GetBytesPerBuffer()));
74 input_data_buffer_.reset(new uint8[params_.GetBytesPerBuffer()]); 77 input_data_buffer_.reset(new uint8[params_.GetBytesPerBuffer()]);
75 78
76 if (!pulse::CreateOutputStream(&pa_mainloop_, &pa_context_, &output_stream_, 79 if (!pulse::CreateOutputStream(&pa_mainloop_, &pa_context_, &output_stream_,
77 params_, &StreamNotifyCallback, NULL, this)) 80 params_, &StreamNotifyCallback, NULL, this))
78 return false; 81 return false;
79 82
80 // TODO(xians): Add support for non-default device.
81 if (!pulse::CreateInputStream(pa_mainloop_, pa_context_, &input_stream_, 83 if (!pulse::CreateInputStream(pa_mainloop_, pa_context_, &input_stream_,
82 params_, AudioManagerBase::kDefaultDeviceId, 84 params_, input_device_id_,
83 &StreamNotifyCallback, this)) 85 &StreamNotifyCallback, this))
84 return false; 86 return false;
85 87
86 DCHECK(pa_mainloop_); 88 DCHECK(pa_mainloop_);
87 DCHECK(pa_context_); 89 DCHECK(pa_context_);
88 DCHECK(input_stream_); 90 DCHECK(input_stream_);
89 DCHECK(output_stream_); 91 DCHECK(output_stream_);
90 return true; 92 return true;
91 } 93 }
92 94
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 volume_ = static_cast<float>(volume); 284 volume_ = static_cast<float>(volume);
283 } 285 }
284 286
285 void PulseAudioUnifiedStream::GetVolume(double* volume) { 287 void PulseAudioUnifiedStream::GetVolume(double* volume) {
286 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread()); 288 DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
287 289
288 *volume = volume_; 290 *volume = volume_;
289 } 291 }
290 292
291 } // namespace media 293 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698