blob: 16ec27852f8a4de2d5d9923ba85183b81c172b3d [file] [log] [blame]
Eric Laurent1c333e22014-05-20 10:48:17 -07001/*
2**
3** Copyright 2014, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#ifndef INCLUDING_FROM_AUDIOFLINGER_H
19 #error This header file should only be included from AudioFlinger.h
20#endif
21
22class PatchPanel : public RefBase {
23public:
Eric Laurent83b88082014-06-20 18:31:16 -070024
25 class Patch;
26
Eric Laurent1c333e22014-05-20 10:48:17 -070027 PatchPanel(const sp<AudioFlinger>& audioFlinger);
28 virtual ~PatchPanel();
29
30 /* List connected audio ports and their attributes */
31 status_t listAudioPorts(unsigned int *num_ports,
32 struct audio_port *ports);
33
34 /* Get supported attributes for a given audio port */
35 status_t getAudioPort(struct audio_port *port);
36
37 /* Create a patch between several source and sink ports */
38 status_t createAudioPatch(const struct audio_patch *patch,
39 audio_patch_handle_t *handle);
40
41 /* Release a patch */
42 status_t releaseAudioPatch(audio_patch_handle_t handle);
43
44 /* List connected audio devices and they attributes */
45 status_t listAudioPatches(unsigned int *num_patches,
46 struct audio_patch *patches);
47
48 /* Set audio port configuration */
49 status_t setAudioPortConfig(const struct audio_port_config *config);
50
Eric Laurent83b88082014-06-20 18:31:16 -070051 status_t createPatchConnections(Patch *patch,
52 const struct audio_patch *audioPatch);
53 void clearPatchConnections(Patch *patch);
54
Eric Laurent1c333e22014-05-20 10:48:17 -070055 class Patch {
56 public:
57 Patch(const struct audio_patch *patch) :
Eric Laurent83b88082014-06-20 18:31:16 -070058 mAudioPatch(*patch), mHandle(AUDIO_PATCH_HANDLE_NONE),
59 mHalHandle(AUDIO_PATCH_HANDLE_NONE), mRecordPatchHandle(AUDIO_PATCH_HANDLE_NONE),
60 mPlaybackPatchHandle(AUDIO_PATCH_HANDLE_NONE) {}
61 ~Patch() {}
Eric Laurent1c333e22014-05-20 10:48:17 -070062
Eric Laurent83b88082014-06-20 18:31:16 -070063 struct audio_patch mAudioPatch;
64 audio_patch_handle_t mHandle;
Eric Laurentb997d3a2016-06-07 18:23:45 -070065 // handle for audio HAL patch handle present only when the audio HAL version is >= 3.0
Eric Laurent83b88082014-06-20 18:31:16 -070066 audio_patch_handle_t mHalHandle;
Eric Laurentb997d3a2016-06-07 18:23:45 -070067 // below members are used by a software audio patch connecting a source device from a
68 // given audio HW module to a sink device on an other audio HW module.
69 // playback thread created by createAudioPatch() and released by clearPatchConnections() if
70 // no existing playback thread can be used by the software patch
Eric Laurent83b88082014-06-20 18:31:16 -070071 sp<PlaybackThread> mPlaybackThread;
Eric Laurentb997d3a2016-06-07 18:23:45 -070072 // audio track created by createPatchConnections() and released by clearPatchConnections()
Eric Laurent83b88082014-06-20 18:31:16 -070073 sp<PlaybackThread::PatchTrack> mPatchTrack;
Eric Laurentb997d3a2016-06-07 18:23:45 -070074 // record thread created by createAudioPatch() and released by clearPatchConnections()
Eric Laurent83b88082014-06-20 18:31:16 -070075 sp<RecordThread> mRecordThread;
Eric Laurentb997d3a2016-06-07 18:23:45 -070076 // audio record created by createPatchConnections() and released by clearPatchConnections()
Eric Laurent83b88082014-06-20 18:31:16 -070077 sp<RecordThread::PatchRecord> mPatchRecord;
Eric Laurentb997d3a2016-06-07 18:23:45 -070078 // handle for audio patch connecting source device to record thread input.
79 // created by createPatchConnections() and released by clearPatchConnections()
Eric Laurent83b88082014-06-20 18:31:16 -070080 audio_patch_handle_t mRecordPatchHandle;
Eric Laurentb997d3a2016-06-07 18:23:45 -070081 // handle for audio patch connecting playback thread output to sink device
82 // created by createPatchConnections() and released by clearPatchConnections()
Eric Laurent83b88082014-06-20 18:31:16 -070083 audio_patch_handle_t mPlaybackPatchHandle;
84
Eric Laurent1c333e22014-05-20 10:48:17 -070085 };
Eric Laurent83b88082014-06-20 18:31:16 -070086
Eric Laurent1c333e22014-05-20 10:48:17 -070087private:
Eric Laurent83b88082014-06-20 18:31:16 -070088 const wp<AudioFlinger> mAudioFlinger;
89 SortedVector <Patch *> mPatches;
Eric Laurent1c333e22014-05-20 10:48:17 -070090};