summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/media/ExtendedAudioBufferProvider.h8
-rw-r--r--include/media/nbaio/AudioStreamOutSink.h2
-rw-r--r--include/media/nbaio/MonoPipe.h10
-rw-r--r--include/media/nbaio/MonoPipeReader.h2
-rw-r--r--include/media/nbaio/NBAIO.h10
-rw-r--r--include/media/nbaio/SourceAudioBufferProvider.h3
6 files changed, 35 insertions, 0 deletions
diff --git a/include/media/ExtendedAudioBufferProvider.h b/include/media/ExtendedAudioBufferProvider.h
index 00c4444..2539ed3 100644
--- a/include/media/ExtendedAudioBufferProvider.h
+++ b/include/media/ExtendedAudioBufferProvider.h
@@ -18,12 +18,20 @@
#define ANDROID_EXTENDED_AUDIO_BUFFER_PROVIDER_H
#include <media/AudioBufferProvider.h>
+#include <media/AudioTimestamp.h>
namespace android {
class ExtendedAudioBufferProvider : public AudioBufferProvider {
public:
virtual size_t framesReady() const = 0; // see description at AudioFlinger.h
+
+ // Return the total number of frames that have been obtained and released
+ virtual size_t framesReleased() const { return 0; }
+
+ // Invoked by buffer consumer when a new timestamp is available.
+ // Default implementation ignores the timestamp.
+ virtual void onTimestamp(const AudioTimestamp& timestamp) { }
};
} // namespace android
diff --git a/include/media/nbaio/AudioStreamOutSink.h b/include/media/nbaio/AudioStreamOutSink.h
index 5976b18..7948d40 100644
--- a/include/media/nbaio/AudioStreamOutSink.h
+++ b/include/media/nbaio/AudioStreamOutSink.h
@@ -52,6 +52,8 @@ public:
// implementation of GNWT (if any)
virtual status_t getNextWriteTimestamp(int64_t *timestamp);
+ virtual status_t getTimestamp(AudioTimestamp& timestamp);
+
// NBAIO_Sink end
#if 0 // until necessary
diff --git a/include/media/nbaio/MonoPipe.h b/include/media/nbaio/MonoPipe.h
index 5fcfe9e..d3802fe 100644
--- a/include/media/nbaio/MonoPipe.h
+++ b/include/media/nbaio/MonoPipe.h
@@ -20,9 +20,12 @@
#include <time.h>
#include <utils/LinearTransform.h>
#include "NBAIO.h"
+#include <media/SingleStateQueue.h>
namespace android {
+typedef SingleStateQueue<AudioTimestamp> AudioTimestampSingleStateQueue;
+
// MonoPipe is similar to Pipe except:
// - supports only a single reader, called MonoPipeReader
// - write() cannot overrun; instead it will return a short actual count if insufficient space
@@ -88,6 +91,9 @@ public:
// Return true if the write side of a pipe is currently shutdown.
bool isShutdown();
+ // Return NO_ERROR if there is a timestamp available
+ status_t getTimestamp(AudioTimestamp& timestamp);
+
private:
// A pair of methods and a helper variable which allows the reader and the
// writer to update and observe the values of mFront and mNextRdPTS in an
@@ -127,6 +133,10 @@ private:
LinearTransform mSamplesToLocalTime;
bool mIsShutdown; // whether shutdown(true) was called, no barriers are needed
+
+ AudioTimestampSingleStateQueue::Shared mTimestampShared;
+ AudioTimestampSingleStateQueue::Mutator mTimestampMutator;
+ AudioTimestampSingleStateQueue::Observer mTimestampObserver;
};
} // namespace android
diff --git a/include/media/nbaio/MonoPipeReader.h b/include/media/nbaio/MonoPipeReader.h
index 0e1c992..78fe867 100644
--- a/include/media/nbaio/MonoPipeReader.h
+++ b/include/media/nbaio/MonoPipeReader.h
@@ -49,6 +49,8 @@ public:
virtual ssize_t read(void *buffer, size_t count, int64_t readPTS);
+ virtual void onTimestamp(const AudioTimestamp& timestamp);
+
// NBAIO_Source end
#if 0 // until necessary
diff --git a/include/media/nbaio/NBAIO.h b/include/media/nbaio/NBAIO.h
index f5d6eb5..1da0c73 100644
--- a/include/media/nbaio/NBAIO.h
+++ b/include/media/nbaio/NBAIO.h
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <utils/Errors.h>
#include <utils/RefBase.h>
+#include <media/AudioTimestamp.h>
namespace android {
@@ -213,6 +214,11 @@ public:
// <other> Something unexpected happened internally. Check the logs and start debugging.
virtual status_t getNextWriteTimestamp(int64_t *ts) { return INVALID_OPERATION; }
+ // Returns NO_ERROR if a timestamp is available. The timestamp includes the total number
+ // of frames presented to an external observer, together with the value of CLOCK_MONOTONIC
+ // as of this presentation count.
+ virtual status_t getTimestamp(AudioTimestamp& timestamp) { return INVALID_OPERATION; }
+
protected:
NBAIO_Sink(NBAIO_Format format = Format_Invalid) : NBAIO_Port(format), mFramesWritten(0) { }
virtual ~NBAIO_Sink() { }
@@ -300,6 +306,10 @@ public:
virtual ssize_t readVia(readVia_t via, size_t total, void *user,
int64_t readPTS, size_t block = 0);
+ // Invoked asynchronously by corresponding sink when a new timestamp is available.
+ // Default implementation ignores the timestamp.
+ virtual void onTimestamp(const AudioTimestamp& timestamp) { }
+
protected:
NBAIO_Source(NBAIO_Format format = Format_Invalid) : NBAIO_Port(format), mFramesRead(0) { }
virtual ~NBAIO_Source() { }
diff --git a/include/media/nbaio/SourceAudioBufferProvider.h b/include/media/nbaio/SourceAudioBufferProvider.h
index c08331b..cdfb6fe 100644
--- a/include/media/nbaio/SourceAudioBufferProvider.h
+++ b/include/media/nbaio/SourceAudioBufferProvider.h
@@ -36,6 +36,8 @@ public:
// ExtendedAudioBufferProvider interface
virtual size_t framesReady() const;
+ virtual size_t framesReleased() const;
+ virtual void onTimestamp(const AudioTimestamp& timestamp);
private:
const sp<NBAIO_Source> mSource; // the wrapped source
@@ -45,6 +47,7 @@ private:
size_t mOffset; // frame offset within mAllocated of valid data
size_t mRemaining; // frame count within mAllocated of valid data
size_t mGetCount; // buffer.frameCount of the most recent getNextBuffer
+ uint32_t mFramesReleased; // counter of the total number of frames released
};
} // namespace android