From 83b8808faad1e91690c64d7007348be8d9ebde73 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Fri, 20 Jun 2014 18:31:16 -0700 Subject: 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 --- services/audioflinger/RecordTracks.h | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'services/audioflinger/RecordTracks.h') diff --git a/services/audioflinger/RecordTracks.h b/services/audioflinger/RecordTracks.h index fe15571..204a9d6 100644 --- a/services/audioflinger/RecordTracks.h +++ b/services/audioflinger/RecordTracks.h @@ -28,9 +28,11 @@ public: audio_format_t format, audio_channel_mask_t channelMask, size_t frameCount, + void *buffer, int sessionId, int uid, - IAudioFlinger::track_flags_t flags); + IAudioFlinger::track_flags_t flags, + track_type type); virtual ~RecordTrack(); virtual status_t start(AudioSystem::sync_event_t event, int triggerSession); @@ -93,3 +95,34 @@ private: // used by resampler to find source frames ResamplerBufferProvider *mResamplerBufferProvider; }; + +// playback track, used by PatchPanel +class PatchRecord : virtual public RecordTrack, public PatchProxyBufferProvider { +public: + + PatchRecord(RecordThread *recordThread, + uint32_t sampleRate, + audio_channel_mask_t channelMask, + audio_format_t format, + size_t frameCount, + void *buffer, + IAudioFlinger::track_flags_t flags); + virtual ~PatchRecord(); + + // AudioBufferProvider interface + virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer, + int64_t pts); + virtual void releaseBuffer(AudioBufferProvider::Buffer* buffer); + + // PatchProxyBufferProvider interface + virtual status_t obtainBuffer(Proxy::Buffer *buffer, + const struct timespec *timeOut = NULL); + virtual void releaseBuffer(Proxy::Buffer *buffer); + + void setPeerProxy(PatchProxyBufferProvider *proxy) { mPeerProxy = proxy; } + +private: + sp mProxy; + PatchProxyBufferProvider* mPeerProxy; + struct timespec mPeerTimeout; +}; // end of PatchRecord -- cgit v1.1