| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 pa_usec_t latency_micros = 0; | 142 pa_usec_t latency_micros = 0; |
| 143 if (pa_stream_get_latency(stream, &latency_micros, &negative) != 0) | 143 if (pa_stream_get_latency(stream, &latency_micros, &negative) != 0) |
| 144 return base::TimeDelta(); | 144 return base::TimeDelta(); |
| 145 | 145 |
| 146 if (negative) | 146 if (negative) |
| 147 return base::TimeDelta(); | 147 return base::TimeDelta(); |
| 148 | 148 |
| 149 return base::TimeDelta::FromMicroseconds(latency_micros); | 149 return base::TimeDelta::FromMicroseconds(latency_micros); |
| 150 } | 150 } |
| 151 | 151 |
| 152 int GetHardwareLatencyInBytes(pa_stream* stream, | |
| 153 int sample_rate, | |
| 154 int bytes_per_frame) { | |
| 155 DCHECK(stream); | |
| 156 return AudioTimestampHelper::TimeToFrames(GetHardwareLatency(stream), | |
| 157 sample_rate) * | |
| 158 bytes_per_frame; | |
| 159 } | |
| 160 | |
| 161 // Helper macro for CreateInput/OutputStream() to avoid code spam and | 152 // Helper macro for CreateInput/OutputStream() to avoid code spam and |
| 162 // string bloat. | 153 // string bloat. |
| 163 #define RETURN_ON_FAILURE(expression, message) do { \ | 154 #define RETURN_ON_FAILURE(expression, message) do { \ |
| 164 if (!(expression)) { \ | 155 if (!(expression)) { \ |
| 165 DLOG(ERROR) << message; \ | 156 DLOG(ERROR) << message; \ |
| 166 return false; \ | 157 return false; \ |
| 167 } \ | 158 } \ |
| 168 } while (0) | 159 } while (0) |
| 169 | 160 |
| 170 bool CreateInputStream(pa_threaded_mainloop* mainloop, | 161 bool CreateInputStream(pa_threaded_mainloop* mainloop, |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 } | 349 } |
| 359 | 350 |
| 360 return true; | 351 return true; |
| 361 } | 352 } |
| 362 | 353 |
| 363 #undef RETURN_ON_FAILURE | 354 #undef RETURN_ON_FAILURE |
| 364 | 355 |
| 365 } // namespace pulse | 356 } // namespace pulse |
| 366 | 357 |
| 367 } // namespace media | 358 } // namespace media |
| OLD | NEW |