| 35 | class HRTFDatabaseLoader; |
| 36 | |
| 37 | class AudioContext |
| 38 | { |
| 39 | friend class ContextGraphLock; |
| 40 | friend class ContextRenderLock; |
| 41 | |
| 42 | public: |
| 43 | |
| 44 | // AudioNodes should not retain the AudioContext. The majority of |
| 45 | // methods that take AudioContext as a parameter do so via reference. |
| 46 | // |
| 47 | // If methods from the context, such as currentTime() are |
| 48 | // required in methods that do not take AudioContext as a parameter, |
| 49 | // they should instead retain a weak pointer to the |
| 50 | // AudioNodeInterface from the AudioContext they were instantiated from. |
| 51 | // |
| 52 | // Locking the AudioNodeInterface pointer is a way to check if the |
| 53 | // AudioContext is still instantiated. |
| 54 | // |
| 55 | // AudioContextInterface contains data that is safe for any thread, or |
| 56 | // audio processing callback to read, even if the audio context is in |
| 57 | // the process of stopping or destruction. |
| 58 | |
| 59 | class AudioContextInterface |
| 60 | { |
| 61 | friend class AudioContext; |
| 62 | |
| 63 | int _id = 0; |
| 64 | AudioContext * _ac = nullptr; |
| 65 | double _currentTime = 0; |
| 66 | |
| 67 | public: |
| 68 | AudioContextInterface(AudioContext * ac, int id) |
| 69 | : _id(id) |
| 70 | , _ac(ac) |
| 71 | { |
| 72 | } |
| 73 | |
| 74 | ~AudioContextInterface() { } |
| 75 | |
| 76 | // the contextId of two AudioNodeInterfaces can be compared |
| 77 | // to discover if they refer to the same context. |
| 78 | int contextId() const { return _id; } |
| 79 | double currentTime() const { return _currentTime; } |
| 80 | }; |
| 81 | |
| 82 | std::weak_ptr<AudioContextInterface> audioContextInterface() { return m_audioContextInterface; } |
| 83 | |
| 84 | // ctor/dtor |
| 85 | explicit AudioContext(bool isOffline); |
| 86 | explicit AudioContext(bool isOffline, bool autoDispatchEvents); |
| 87 | ~AudioContext(); |
| 88 | |
| 89 | // External users shouldn't use this; it should be called by |
| 90 | // LabSound::MakeRealtimeAudioContext(lab::Channels::Stereo) |
| 91 | // It *is* harmless to call it though, it's just not necessary. |
| 92 | void lazyInitialize(); |
| 93 | bool isInitialized() const; |
| 94 |
nothing calls this directly
no outgoing calls
no test coverage detected