OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, Google Inc. All rights reserved. | 2 * Copyright (C) 2011, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 27 matching lines...) Expand all Loading... |
38 class BaseAudioContext; | 38 class BaseAudioContext; |
39 class HTMLMediaElement; | 39 class HTMLMediaElement; |
40 class MediaElementAudioSourceOptions; | 40 class MediaElementAudioSourceOptions; |
41 | 41 |
42 class MediaElementAudioSourceHandler final : public AudioHandler { | 42 class MediaElementAudioSourceHandler final : public AudioHandler { |
43 public: | 43 public: |
44 static PassRefPtr<MediaElementAudioSourceHandler> create(AudioNode&, | 44 static PassRefPtr<MediaElementAudioSourceHandler> create(AudioNode&, |
45 HTMLMediaElement&); | 45 HTMLMediaElement&); |
46 ~MediaElementAudioSourceHandler() override; | 46 ~MediaElementAudioSourceHandler() override; |
47 | 47 |
48 HTMLMediaElement* mediaElement() { return m_mediaElement.get(); } | 48 HTMLMediaElement* mediaElement() const; |
49 | 49 |
50 // AudioHandler | 50 // AudioHandler |
51 void dispose() override; | 51 void dispose() override; |
52 void process(size_t framesToProcess) override; | 52 void process(size_t framesToProcess) override; |
53 | 53 |
54 // Helpers for AudioSourceProviderClient implementation of | 54 // Helpers for AudioSourceProviderClient implementation of |
55 // MediaElementAudioSourceNode. | 55 // MediaElementAudioSourceNode. |
56 void setFormat(size_t numberOfChannels, float sampleRate); | 56 void setFormat(size_t numberOfChannels, float sampleRate); |
57 void onCurrentSrcChanged(const KURL& currentSrc); | 57 void onCurrentSrcChanged(const KURL& currentSrc); |
58 void lock(); | 58 void lock(); |
(...skipping 10 matching lines...) Expand all Loading... |
69 // Must be called only on the main thread. | 69 // Must be called only on the main thread. |
70 bool passesCurrentSrcCORSAccessCheck(const KURL& currentSrc); | 70 bool passesCurrentSrcCORSAccessCheck(const KURL& currentSrc); |
71 | 71 |
72 // Print warning if CORS restrictions cause MediaElementAudioSource to output | 72 // Print warning if CORS restrictions cause MediaElementAudioSource to output |
73 // zeroes. | 73 // zeroes. |
74 void printCORSMessage(const String& message); | 74 void printCORSMessage(const String& message); |
75 | 75 |
76 // This Persistent doesn't make a reference cycle. The reference from | 76 // This Persistent doesn't make a reference cycle. The reference from |
77 // HTMLMediaElement to AudioSourceProvideClient, which | 77 // HTMLMediaElement to AudioSourceProvideClient, which |
78 // MediaElementAudioSourceNode implements, is weak. | 78 // MediaElementAudioSourceNode implements, is weak. |
79 Persistent<HTMLMediaElement> m_mediaElement; | 79 // |
| 80 // It is accessed by both audio and main thread. TODO: we really should |
| 81 // try to minimize or avoid the audio thread touching this element. |
| 82 CrossThreadPersistent<HTMLMediaElement> m_mediaElement; |
80 Mutex m_processLock; | 83 Mutex m_processLock; |
81 | 84 |
82 unsigned m_sourceNumberOfChannels; | 85 unsigned m_sourceNumberOfChannels; |
83 double m_sourceSampleRate; | 86 double m_sourceSampleRate; |
84 | 87 |
85 std::unique_ptr<MultiChannelResampler> m_multiChannelResampler; | 88 std::unique_ptr<MultiChannelResampler> m_multiChannelResampler; |
86 | 89 |
87 // |m_passesCurrentSrcCORSAccessCheck| holds the value of | 90 // |m_passesCurrentSrcCORSAccessCheck| holds the value of |
88 // context()->getSecurityOrigin() && | 91 // context()->getSecurityOrigin() && |
89 // context()->getSecurityOrigin()->canRequest(mediaElement()->currentSrc()), | 92 // context()->getSecurityOrigin()->canRequest(mediaElement()->currentSrc()), |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 void lock() override; | 129 void lock() override; |
127 void unlock() override; | 130 void unlock() override; |
128 | 131 |
129 private: | 132 private: |
130 MediaElementAudioSourceNode(BaseAudioContext&, HTMLMediaElement&); | 133 MediaElementAudioSourceNode(BaseAudioContext&, HTMLMediaElement&); |
131 }; | 134 }; |
132 | 135 |
133 } // namespace blink | 136 } // namespace blink |
134 | 137 |
135 #endif // MediaElementAudioSourceNode_h | 138 #endif // MediaElementAudioSourceNode_h |
OLD | NEW |