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

Unified Diff: media/audio/pulse/pulse_util.cc

Issue 2101303004: Pass delay and timestamp to AudioSourceCallback::OnMoreData. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fix Mac CQ errors. Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
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..8d6b06cebd9d745fb6a7fa6e0ebc2e512b2757a6 100644
--- a/media/audio/pulse/pulse_util.cc
+++ b/media/audio/pulse/pulse_util.cc
@@ -8,9 +8,9 @@
#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"
+#include "media/base/audio_timestamp_helper.h"
namespace media {
@@ -136,20 +136,26 @@ 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 AudioTimestampHelper::TimeToFrames(GetHardwareLatency(stream),
+ sample_rate) *
+ bytes_per_frame;
}
// Helper macro for CreateInput/OutputStream() to avoid code spam and

Powered by Google App Engine
This is Rietveld 408576698