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

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

Issue 2689483006: Switch browser side audio capture path to use base time primitives. (Closed)
Patch Set: Bloop Created 3 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
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_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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698