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

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

Issue 129793012: Implement hook to change audio output device for PulseAudio. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build error. Created 6 years, 10 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
« no previous file with comments | « media/audio/pulse/pulse_output.h ('k') | media/audio/pulse/pulse_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_output.h" 5 #include "media/audio/pulse/pulse_output.h"
6 6
7 #include <pulse/pulseaudio.h> 7 #include <pulse/pulseaudio.h>
8 8
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "media/audio/audio_manager_base.h" 10 #include "media/audio/audio_manager_base.h"
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 // static, pa_stream_request_cb_t 34 // static, pa_stream_request_cb_t
35 void PulseAudioOutputStream::StreamRequestCallback(pa_stream* s, size_t len, 35 void PulseAudioOutputStream::StreamRequestCallback(pa_stream* s, size_t len,
36 void* p_this) { 36 void* p_this) {
37 // Fulfill write request; must always result in a pa_stream_write() call. 37 // Fulfill write request; must always result in a pa_stream_write() call.
38 static_cast<PulseAudioOutputStream*>(p_this)->FulfillWriteRequest(len); 38 static_cast<PulseAudioOutputStream*>(p_this)->FulfillWriteRequest(len);
39 } 39 }
40 40
41 PulseAudioOutputStream::PulseAudioOutputStream(const AudioParameters& params, 41 PulseAudioOutputStream::PulseAudioOutputStream(const AudioParameters& params,
42 const std::string& device_id,
42 AudioManagerBase* manager) 43 AudioManagerBase* manager)
43 : params_(params), 44 : params_(params),
45 device_id_(device_id),
44 manager_(manager), 46 manager_(manager),
45 pa_context_(NULL), 47 pa_context_(NULL),
46 pa_mainloop_(NULL), 48 pa_mainloop_(NULL),
47 pa_stream_(NULL), 49 pa_stream_(NULL),
48 volume_(1.0f), 50 volume_(1.0f),
49 source_callback_(NULL) { 51 source_callback_(NULL) {
50 DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread()); 52 DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
51 53
52 CHECK(params_.IsValid()); 54 CHECK(params_.IsValid());
53 audio_bus_ = AudioBus::Create(params_); 55 audio_bus_ = AudioBus::Create(params_);
54 } 56 }
55 57
56 PulseAudioOutputStream::~PulseAudioOutputStream() { 58 PulseAudioOutputStream::~PulseAudioOutputStream() {
57 // All internal structures should already have been freed in Close(), which 59 // All internal structures should already have been freed in Close(), which
58 // calls AudioManagerBase::ReleaseOutputStream() which deletes this object. 60 // calls AudioManagerBase::ReleaseOutputStream() which deletes this object.
59 DCHECK(!pa_stream_); 61 DCHECK(!pa_stream_);
60 DCHECK(!pa_context_); 62 DCHECK(!pa_context_);
61 DCHECK(!pa_mainloop_); 63 DCHECK(!pa_mainloop_);
62 } 64 }
63 65
64 bool PulseAudioOutputStream::Open() { 66 bool PulseAudioOutputStream::Open() {
65 DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread()); 67 DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
66 return pulse::CreateOutputStream(&pa_mainloop_, &pa_context_, &pa_stream_, 68 return pulse::CreateOutputStream(&pa_mainloop_, &pa_context_, &pa_stream_,
67 params_, &StreamNotifyCallback, 69 params_, device_id_, &StreamNotifyCallback,
68 &StreamRequestCallback, this); 70 &StreamRequestCallback, this);
69 } 71 }
70 72
71 void PulseAudioOutputStream::Reset() { 73 void PulseAudioOutputStream::Reset() {
72 if (!pa_mainloop_) { 74 if (!pa_mainloop_) {
73 DCHECK(!pa_stream_); 75 DCHECK(!pa_stream_);
74 DCHECK(!pa_context_); 76 DCHECK(!pa_context_);
75 return; 77 return;
76 } 78 }
77 79
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 volume_ = static_cast<float>(volume); 209 volume_ = static_cast<float>(volume);
208 } 210 }
209 211
210 void PulseAudioOutputStream::GetVolume(double* volume) { 212 void PulseAudioOutputStream::GetVolume(double* volume) {
211 DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread()); 213 DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread());
212 214
213 *volume = volume_; 215 *volume = volume_;
214 } 216 }
215 217
216 } // namespace media 218 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/pulse/pulse_output.h ('k') | media/audio/pulse/pulse_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698