blob: b83f6b5b17c5c20edd5d4f029d2dbd14ce6e0fa0 [file] [log] [blame]
Eric Laurent6acd1d42017-01-04 14:23:29 -08001/*
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
23class MmapTrack : public TrackBase {
24public:
25 MmapTrack(ThreadBase *thread,
Kevin Rocard1f564ac2018-03-29 13:53:10 -070026 const audio_attributes_t& attr,
Eric Laurent6acd1d42017-01-04 14:23:29 -080027 uint32_t sampleRate,
28 audio_format_t format,
29 audio_channel_mask_t channelMask,
30 audio_session_t sessionId,
Kevin Rocard5f2136e2018-05-11 22:03:00 -070031 bool isOut,
Eric Laurent6acd1d42017-01-04 14:23:29 -080032 uid_t uid,
Andy Hung2c6c3bb2017-06-16 14:01:45 -070033 pid_t pid,
Eric Laurent09f1ed22019-04-24 17:45:17 -070034 pid_t creatorPid,
Eric Laurent6acd1d42017-01-04 14:23:29 -080035 audio_port_handle_t portId = AUDIO_PORT_HANDLE_NONE);
36 virtual ~MmapTrack();
37
38 // TrackBase virtual
39 virtual status_t initCheck() const;
40 virtual status_t start(AudioSystem::sync_event_t event,
41 audio_session_t triggerSession);
42 virtual void stop();
43 virtual bool isFastTrack() const { return false; }
Mikhail Naganov7c6ae982018-06-14 12:33:38 -070044 bool isDirect() const override { return true; }
Eric Laurent6acd1d42017-01-04 14:23:29 -080045
Kevin Rocard5f2136e2018-05-11 22:03:00 -070046 void appendDumpHeader(String8& result);
Andy Hung2c6c3bb2017-06-16 14:01:45 -070047 void appendDump(String8& result, bool active);
Eric Laurent6acd1d42017-01-04 14:23:29 -080048
Eric Laurent331679c2018-04-16 17:03:16 -070049 // protected by MMapThread::mLock
50 void setSilenced_l(bool silenced) { mSilenced = silenced;
51 mSilencedNotified = false;}
52 // protected by MMapThread::mLock
53 bool isSilenced_l() const { return mSilenced; }
54 // protected by MMapThread::mLock
55 bool getAndSetSilencedNotified_l() { bool silencedNotified = mSilencedNotified;
56 mSilencedNotified = true;
57 return silencedNotified; }
Mikhail Naganovbf493082017-04-17 17:37:12 -070058private:
Eric Laurent6acd1d42017-01-04 14:23:29 -080059 friend class MmapThread;
60
Mikhail Naganovbf493082017-04-17 17:37:12 -070061 DISALLOW_COPY_AND_ASSIGN(MmapTrack);
Eric Laurent6acd1d42017-01-04 14:23:29 -080062
63 // AudioBufferProvider interface
64 virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer);
65 // releaseBuffer() not overridden
66
67 // ExtendedAudioBufferProvider interface
68 virtual size_t framesReady() const;
69 virtual int64_t framesReleased() const;
70 virtual void onTimestamp(const ExtendedTimestamp &timestamp);
71
Andy Hung2c6c3bb2017-06-16 14:01:45 -070072 pid_t mPid;
Eric Laurent331679c2018-04-16 17:03:16 -070073 bool mSilenced; // protected by MMapThread::mLock
74 bool mSilencedNotified; // protected by MMapThread::mLock
Eric Laurent6acd1d42017-01-04 14:23:29 -080075}; // end of Track
76