summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/TrackBase.h
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2014-06-20 18:31:16 -0700
committerEric Laurent <elaurent@google.com>2014-07-24 02:56:47 +0000
commit83b8808faad1e91690c64d7007348be8d9ebde73 (patch)
treeb541b1172f804e04bd19b29f7878a1becf6205d7 /services/audioflinger/TrackBase.h
parentc15c265676da2226a18a5373812608b19d4719d7 (diff)
downloadframeworks_av-83b8808faad1e91690c64d7007348be8d9ebde73.zip
frameworks_av-83b8808faad1e91690c64d7007348be8d9ebde73.tar.gz
frameworks_av-83b8808faad1e91690c64d7007348be8d9ebde73.tar.bz2
audio flinger: add patch connection between hw modules
Add support for audio device connections between different audio hw modules. The patch is performed by creating a bridge between the playback thread connected to the sink device and the record thread connected to the source device using a pair of specialized PlaybackTrack and RecordTrack. - Added PatchTrack and PatchRecord classes. - Added TrackBase type to indicate more clearly the track behavior. - A TrackBase can allocate the buffer or reuse an existing one. - Factored some code in openOutput() and openInput() for internal use by PatchPanel. Bug: 14815883. Change-Id: Ib9515fcda864610458a4bc81fa8f59096ff4d7db
Diffstat (limited to 'services/audioflinger/TrackBase.h')
-rw-r--r--services/audioflinger/TrackBase.h35
1 files changed, 32 insertions, 3 deletions
diff --git a/services/audioflinger/TrackBase.h b/services/audioflinger/TrackBase.h
index 4cba3fd..864daa5 100644
--- a/services/audioflinger/TrackBase.h
+++ b/services/audioflinger/TrackBase.h
@@ -44,6 +44,15 @@ public:
ALLOC_CBLK, // allocate immediately after control block
ALLOC_READONLY, // allocate from a separate read-only heap per thread
ALLOC_PIPE, // do not allocate; use the pipe buffer
+ ALLOC_LOCAL, // allocate a local buffer
+ ALLOC_NONE, // do not allocate:use the buffer passed to TrackBase constructor
+ };
+
+ enum track_type {
+ TYPE_DEFAULT,
+ TYPE_TIMED,
+ TYPE_OUTPUT,
+ TYPE_PATCH,
};
TrackBase(ThreadBase *thread,
@@ -52,14 +61,15 @@ public:
audio_format_t format,
audio_channel_mask_t channelMask,
size_t frameCount,
- const sp<IMemory>& sharedBuffer,
+ void *buffer,
int sessionId,
int uid,
IAudioFlinger::track_flags_t flags,
bool isOut,
- alloc_type alloc = ALLOC_CBLK);
+ alloc_type alloc = ALLOC_CBLK,
+ track_type type = TYPE_DEFAULT);
virtual ~TrackBase();
- virtual status_t initCheck() const { return getCblk() != 0 ? NO_ERROR : NO_MEMORY; }
+ virtual status_t initCheck() const;
virtual status_t start(AudioSystem::sync_event_t event,
int triggerSession) = 0;
@@ -71,7 +81,12 @@ public:
virtual status_t setSyncEvent(const sp<SyncEvent>& event);
sp<IMemory> getBuffers() const { return mBufferMemory; }
+ void* buffer() const { return mBuffer; }
bool isFastTrack() const { return (mFlags & IAudioFlinger::TRACK_FAST) != 0; }
+ bool isTimedTrack() const { return (mType == TYPE_TIMED); }
+ bool isOutputTrack() const { return (mType == TYPE_OUTPUT); }
+ bool isPatchTrack() const { return (mType == TYPE_PATCH); }
+ bool isExternalTrack() const { return !isOutputTrack() && !isPatchTrack(); }
protected:
TrackBase(const TrackBase&);
@@ -150,4 +165,18 @@ protected:
sp<NBAIO_Sink> mTeeSink;
sp<NBAIO_Source> mTeeSource;
bool mTerminated;
+ track_type mType; // must be one of TYPE_DEFAULT, TYPE_OUTPUT, TYPE_PATCH ...
+};
+
+// PatchProxyBufferProvider interface is implemented by PatchTrack and PatchRecord.
+// it provides buffer access methods that map those of a ClientProxy (see AudioTrackShared.h)
+class PatchProxyBufferProvider
+{
+public:
+
+ virtual ~PatchProxyBufferProvider() {}
+
+ virtual status_t obtainBuffer(Proxy::Buffer* buffer,
+ const struct timespec *requested = NULL) = 0;
+ virtual void releaseBuffer(Proxy::Buffer* buffer) = 0;
};