Home | History | Annotate | Download | only in audioflinger
      1 /*
      2 **
      3 ** Copyright 2017, 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 // playback track
     23 class MmapTrack : public TrackBase {
     24 public:
     25                 MmapTrack(ThreadBase *thread,
     26                             const audio_attributes_t& attr,
     27                             uint32_t sampleRate,
     28                             audio_format_t format,
     29                             audio_channel_mask_t channelMask,
     30                             audio_session_t sessionId,
     31                             uid_t uid,
     32                             pid_t pid,
     33                             audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE);
     34     virtual             ~MmapTrack();
     35 
     36                         // TrackBase virtual
     37     virtual status_t    initCheck() const;
     38     virtual status_t    start(AudioSystem::sync_event_t event,
     39                               audio_session_t triggerSession);
     40     virtual void        stop();
     41     virtual bool        isFastTrack() const { return false; }
     42 
     43      static void        appendDumpHeader(String8& result);
     44             void        appendDump(String8& result, bool active);
     45 
     46                         // protected by MMapThread::mLock
     47             void        setSilenced_l(bool silenced) { mSilenced = silenced;
     48                                                        mSilencedNotified = false;}
     49                         // protected by MMapThread::mLock
     50             bool        isSilenced_l() const { return mSilenced; }
     51                         // protected by MMapThread::mLock
     52             bool        getAndSetSilencedNotified_l() { bool silencedNotified = mSilencedNotified;
     53                                                         mSilencedNotified = true;
     54                                                         return silencedNotified; }
     55 private:
     56     friend class MmapThread;
     57 
     58     DISALLOW_COPY_AND_ASSIGN(MmapTrack);
     59 
     60     // AudioBufferProvider interface
     61     virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer);
     62     // releaseBuffer() not overridden
     63 
     64     // ExtendedAudioBufferProvider interface
     65     virtual size_t framesReady() const;
     66     virtual int64_t framesReleased() const;
     67     virtual void onTimestamp(const ExtendedTimestamp &timestamp);
     68 
     69     pid_t mPid;
     70     bool  mSilenced;            // protected by MMapThread::mLock
     71     bool  mSilencedNotified;    // protected by MMapThread::mLock
     72 };  // end of Track
     73 
     74