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

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

Issue 8499029: make pulseaudio available for all posix platforms because it's not linux only (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/linux/pulse_output.h" 5 #include "media/audio/pulse/pulse_output.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "media/audio/audio_parameters.h" 9 #include "media/audio/audio_parameters.h"
10 #include "media/audio/audio_util.h" 10 #include "media/audio/audio_util.h"
11 #if defined(OS_LINUX)
11 #include "media/audio/linux/audio_manager_linux.h" 12 #include "media/audio/linux/audio_manager_linux.h"
13 #elif defined(OS_OPENBSD)
14 #include "media/audio/openbsd/audio_manager_openbsd.h"
15 #endif
12 #include "media/base/data_buffer.h" 16 #include "media/base/data_buffer.h"
13 #include "media/base/seekable_buffer.h" 17 #include "media/base/seekable_buffer.h"
14 18
15 static pa_sample_format_t BitsToPASampleFormat(int bits_per_sample) { 19 static pa_sample_format_t BitsToPASampleFormat(int bits_per_sample) {
16 switch (bits_per_sample) { 20 switch (bits_per_sample) {
17 // Unsupported sample formats shown for reference. I am assuming we want 21 // Unsupported sample formats shown for reference. I am assuming we want
18 // signed and little endian because that is what we gave to ALSA. 22 // signed and little endian because that is what we gave to ALSA.
19 case 8: 23 case 8:
20 return PA_SAMPLE_U8; 24 return PA_SAMPLE_U8;
21 // Also 8-bits: PA_SAMPLE_ALAW and PA_SAMPLE_ULAW 25 // Also 8-bits: PA_SAMPLE_ALAW and PA_SAMPLE_ULAW
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 125
122 DCHECK_EQ(stream->message_loop_, MessageLoop::current()); 126 DCHECK_EQ(stream->message_loop_, MessageLoop::current());
123 127
124 stream->write_callback_handled_ = true; 128 stream->write_callback_handled_ = true;
125 129
126 // Fulfill write request. 130 // Fulfill write request.
127 stream->FulfillWriteRequest(length); 131 stream->FulfillWriteRequest(length);
128 } 132 }
129 133
130 PulseAudioOutputStream::PulseAudioOutputStream(const AudioParameters& params, 134 PulseAudioOutputStream::PulseAudioOutputStream(const AudioParameters& params,
135 #if defined(OS_LINUX)
131 AudioManagerLinux* manager, 136 AudioManagerLinux* manager,
137 #elif defined(OS_OPENBSD)
138 AudioManagerOpenBSD* manager,
139 #endif
132 MessageLoop* message_loop) 140 MessageLoop* message_loop)
133 : channel_layout_(params.channel_layout), 141 : channel_layout_(params.channel_layout),
134 channel_count_(ChannelLayoutToChannelCount(channel_layout_)), 142 channel_count_(ChannelLayoutToChannelCount(channel_layout_)),
135 sample_format_(BitsToPASampleFormat(params.bits_per_sample)), 143 sample_format_(BitsToPASampleFormat(params.bits_per_sample)),
136 sample_rate_(params.sample_rate), 144 sample_rate_(params.sample_rate),
137 bytes_per_frame_(params.channels * params.bits_per_sample / 8), 145 bytes_per_frame_(params.channels * params.bits_per_sample / 8),
138 manager_(manager), 146 manager_(manager),
139 pa_context_(NULL), 147 pa_context_(NULL),
140 pa_mainloop_(NULL), 148 pa_mainloop_(NULL),
141 playback_handle_(NULL), 149 playback_handle_(NULL),
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 *volume = volume_; 419 *volume = volume_;
412 } 420 }
413 421
414 uint32 PulseAudioOutputStream::RunDataCallback( 422 uint32 PulseAudioOutputStream::RunDataCallback(
415 uint8* dest, uint32 max_size, AudioBuffersState buffers_state) { 423 uint8* dest, uint32 max_size, AudioBuffersState buffers_state) {
416 if (source_callback_) 424 if (source_callback_)
417 return source_callback_->OnMoreData(this, dest, max_size, buffers_state); 425 return source_callback_->OnMoreData(this, dest, max_size, buffers_state);
418 426
419 return 0; 427 return 0;
420 } 428 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698