Home | History | Annotate | Download | only in audioflinger
      1 /*
      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 
     22 class PatchPanel : public RefBase {
     23 public:
     24 
     25     class Patch;
     26 
     27     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 
     51     status_t createPatchConnections(Patch *patch,
     52                                     const struct audio_patch *audioPatch);
     53     void clearPatchConnections(Patch *patch);
     54 
     55     class Patch {
     56     public:
     57         Patch(const struct audio_patch *patch) :
     58             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() {}
     62 
     63         struct audio_patch              mAudioPatch;
     64         audio_patch_handle_t            mHandle;
     65         audio_patch_handle_t            mHalHandle;
     66         sp<PlaybackThread>              mPlaybackThread;
     67         sp<PlaybackThread::PatchTrack>  mPatchTrack;
     68         sp<RecordThread>                mRecordThread;
     69         sp<RecordThread::PatchRecord>   mPatchRecord;
     70         audio_patch_handle_t            mRecordPatchHandle;
     71         audio_patch_handle_t            mPlaybackPatchHandle;
     72 
     73     };
     74 
     75 private:
     76     const wp<AudioFlinger>      mAudioFlinger;
     77     SortedVector <Patch *>      mPatches;
     78 };
     79