Index: media/audio/pulse/pulse_util.cc |
diff --git a/media/audio/pulse/pulse_util.cc b/media/audio/pulse/pulse_util.cc |
index d5c699a09e28a821fd1e7107ca1cd6be9858d24a..f99eacc462b849fc8b222bc79e62452efda5e969 100644 |
--- a/media/audio/pulse/pulse_util.cc |
+++ b/media/audio/pulse/pulse_util.cc |
@@ -8,7 +8,6 @@ |
#include "base/logging.h" |
#include "base/macros.h" |
-#include "base/time/time.h" |
#include "media/audio/audio_device_description.h" |
#include "media/base/audio_parameters.h" |
@@ -136,20 +135,25 @@ void WaitForOperationCompletion(pa_threaded_mainloop* pa_mainloop, |
pa_operation_unref(operation); |
} |
-int GetHardwareLatencyInBytes(pa_stream* stream, |
- int sample_rate, |
- int bytes_per_frame) { |
+base::TimeDelta GetHardwareLatency(pa_stream* stream) { |
DCHECK(stream); |
int negative = 0; |
pa_usec_t latency_micros = 0; |
if (pa_stream_get_latency(stream, &latency_micros, &negative) != 0) |
- return 0; |
+ return base::TimeDelta(); |
if (negative) |
- return 0; |
+ return base::TimeDelta(); |
+ |
+ return base::TimeDelta::FromMicroseconds(latency_micros); |
+} |
- return latency_micros * sample_rate * bytes_per_frame / |
- base::Time::kMicrosecondsPerSecond; |
+int GetHardwareLatencyInBytes(pa_stream* stream, |
+ int sample_rate, |
+ int bytes_per_frame) { |
+ DCHECK(stream); |
+ return GetHardwareLatency(stream).InSecondsF() * sample_rate * |
+ bytes_per_frame; |
} |
// Helper macro for CreateInput/OutputStream() to avoid code spam and |