Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_util.h" | 5 #include "media/audio/pulse/pulse_util.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 pa_stream** stream, | 172 pa_stream** stream, |
| 173 const AudioParameters& params, | 173 const AudioParameters& params, |
| 174 const std::string& device_id, | 174 const std::string& device_id, |
| 175 pa_stream_notify_cb_t stream_callback, | 175 pa_stream_notify_cb_t stream_callback, |
| 176 void* user_data) { | 176 void* user_data) { |
| 177 DCHECK(mainloop); | 177 DCHECK(mainloop); |
| 178 DCHECK(context); | 178 DCHECK(context); |
| 179 | 179 |
| 180 // Set sample specifications. | 180 // Set sample specifications. |
| 181 pa_sample_spec sample_specifications; | 181 pa_sample_spec sample_specifications; |
| 182 #if 1 | |
|
DaleCurtis
2016/11/01 23:07:53
Fix?
Raymond Toy
2016/11/01 23:18:50
Done.
Do you want float input too? Not exactly su
| |
| 182 sample_specifications.format = BitsToPASampleFormat( | 183 sample_specifications.format = BitsToPASampleFormat( |
| 183 params.bits_per_sample()); | 184 params.bits_per_sample()); |
| 185 #else | |
| 186 sample_specifications.format = PA_SAMPLE_FLOAT32; | |
| 187 #endif | |
| 184 sample_specifications.rate = params.sample_rate(); | 188 sample_specifications.rate = params.sample_rate(); |
| 185 sample_specifications.channels = params.channels(); | 189 sample_specifications.channels = params.channels(); |
| 186 | 190 |
| 187 // Get channel mapping and open recording stream. | 191 // Get channel mapping and open recording stream. |
| 188 pa_channel_map source_channel_map = ChannelLayoutToPAChannelMap( | 192 pa_channel_map source_channel_map = ChannelLayoutToPAChannelMap( |
| 189 params.channel_layout()); | 193 params.channel_layout()); |
| 190 pa_channel_map* map = (source_channel_map.channels != 0) ? | 194 pa_channel_map* map = (source_channel_map.channels != 0) ? |
| 191 &source_channel_map : NULL; | 195 &source_channel_map : NULL; |
| 192 | 196 |
| 193 // Create a new recording stream and | 197 // Create a new recording stream and |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 pa_context_state_t context_state = pa_context_get_state(*context); | 282 pa_context_state_t context_state = pa_context_get_state(*context); |
| 279 RETURN_ON_FAILURE(PA_CONTEXT_IS_GOOD(context_state), | 283 RETURN_ON_FAILURE(PA_CONTEXT_IS_GOOD(context_state), |
| 280 "Invalid PulseAudio context state."); | 284 "Invalid PulseAudio context state."); |
| 281 if (context_state == PA_CONTEXT_READY) | 285 if (context_state == PA_CONTEXT_READY) |
| 282 break; | 286 break; |
| 283 pa_threaded_mainloop_wait(*mainloop); | 287 pa_threaded_mainloop_wait(*mainloop); |
| 284 } | 288 } |
| 285 | 289 |
| 286 // Set sample specifications. | 290 // Set sample specifications. |
| 287 pa_sample_spec sample_specifications; | 291 pa_sample_spec sample_specifications; |
| 288 sample_specifications.format = BitsToPASampleFormat( | 292 sample_specifications.format = PA_SAMPLE_FLOAT32; |
| 289 params.bits_per_sample()); | |
| 290 sample_specifications.rate = params.sample_rate(); | 293 sample_specifications.rate = params.sample_rate(); |
| 291 sample_specifications.channels = params.channels(); | 294 sample_specifications.channels = params.channels(); |
| 292 | 295 |
| 293 // Get channel mapping. | 296 // Get channel mapping. |
| 294 pa_channel_map* map = NULL; | 297 pa_channel_map* map = NULL; |
| 295 pa_channel_map source_channel_map = ChannelLayoutToPAChannelMap( | 298 pa_channel_map source_channel_map = ChannelLayoutToPAChannelMap( |
| 296 params.channel_layout()); | 299 params.channel_layout()); |
| 297 if (source_channel_map.channels != 0) { | 300 if (source_channel_map.channels != 0) { |
| 298 // The source data uses a supported channel map so we will use it rather | 301 // The source data uses a supported channel map so we will use it rather |
| 299 // than the default channel map (NULL). | 302 // than the default channel map (NULL). |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 } | 362 } |
| 360 | 363 |
| 361 return true; | 364 return true; |
| 362 } | 365 } |
| 363 | 366 |
| 364 #undef RETURN_ON_FAILURE | 367 #undef RETURN_ON_FAILURE |
| 365 | 368 |
| 366 } // namespace pulse | 369 } // namespace pulse |
| 367 | 370 |
| 368 } // namespace media | 371 } // namespace media |
| OLD | NEW |