Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 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, |
Kevin Rocard | 1f564ac | 2018-03-29 13:53:10 -0700 | [diff] [blame] | 26 | const audio_attributes_t& attr, |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 27 | uint32_t sampleRate, |
| 28 | audio_format_t format, |
| 29 | audio_channel_mask_t channelMask, |
| 30 | audio_session_t sessionId, |
Kevin Rocard | 5f2136e | 2018-05-11 22:03:00 -0700 | [diff] [blame] | 31 | bool isOut, |
Philip P. Moltmann | bda4575 | 2020-07-17 16:41:18 -0700 | [diff] [blame] | 32 | const media::permission::Identity& identity, |
Eric Laurent | 09f1ed2 | 2019-04-24 17:45:17 -0700 | [diff] [blame] | 33 | pid_t creatorPid, |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 34 | audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE); |
| 35 | virtual ~MmapTrack(); |
| 36 | |
| 37 | // TrackBase virtual |
| 38 | virtual status_t initCheck() const; |
| 39 | virtual status_t start(AudioSystem::sync_event_t event, |
| 40 | audio_session_t triggerSession); |
| 41 | virtual void stop(); |
| 42 | virtual bool isFastTrack() const { return false; } |
Mikhail Naganov | 7c6ae98 | 2018-06-14 12:33:38 -0700 | [diff] [blame] | 43 | bool isDirect() const override { return true; } |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 44 | |
Kevin Rocard | 5f2136e | 2018-05-11 22:03:00 -0700 | [diff] [blame] | 45 | void appendDumpHeader(String8& result); |
Andy Hung | 2c6c3bb | 2017-06-16 14:01:45 -0700 | [diff] [blame] | 46 | void appendDump(String8& result, bool active); |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 47 | |
Eric Laurent | 331679c | 2018-04-16 17:03:16 -0700 | [diff] [blame] | 48 | // protected by MMapThread::mLock |
| 49 | void setSilenced_l(bool silenced) { mSilenced = silenced; |
| 50 | mSilencedNotified = false;} |
| 51 | // protected by MMapThread::mLock |
| 52 | bool isSilenced_l() const { return mSilenced; } |
| 53 | // protected by MMapThread::mLock |
| 54 | bool getAndSetSilencedNotified_l() { bool silencedNotified = mSilencedNotified; |
| 55 | mSilencedNotified = true; |
| 56 | return silencedNotified; } |
Mikhail Naganov | bf49308 | 2017-04-17 17:37:12 -0700 | [diff] [blame] | 57 | private: |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 58 | friend class MmapThread; |
| 59 | |
Mikhail Naganov | bf49308 | 2017-04-17 17:37:12 -0700 | [diff] [blame] | 60 | DISALLOW_COPY_AND_ASSIGN(MmapTrack); |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 61 | |
| 62 | // AudioBufferProvider interface |
| 63 | virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer); |
| 64 | // releaseBuffer() not overridden |
| 65 | |
| 66 | // ExtendedAudioBufferProvider interface |
| 67 | virtual size_t framesReady() const; |
| 68 | virtual int64_t framesReleased() const; |
| 69 | virtual void onTimestamp(const ExtendedTimestamp ×tamp); |
| 70 | |
Andy Hung | 2c6c3bb | 2017-06-16 14:01:45 -0700 | [diff] [blame] | 71 | pid_t mPid; |
Eric Laurent | 331679c | 2018-04-16 17:03:16 -0700 | [diff] [blame] | 72 | bool mSilenced; // protected by MMapThread::mLock |
| 73 | bool mSilencedNotified; // protected by MMapThread::mLock |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 74 | }; // end of Track |
| 75 | |