| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 ExceptionState& exceptionState) { | 83 ExceptionState& exceptionState) { |
| 84 return AudioContext::create(document, exceptionState); | 84 return AudioContext::create(document, exceptionState); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // FIXME(dominicc): Devolve these constructors to AudioContext | 87 // FIXME(dominicc): Devolve these constructors to AudioContext |
| 88 // and OfflineAudioContext respectively. | 88 // and OfflineAudioContext respectively. |
| 89 | 89 |
| 90 // Constructor for rendering to the audio hardware. | 90 // Constructor for rendering to the audio hardware. |
| 91 BaseAudioContext::BaseAudioContext(Document* document) | 91 BaseAudioContext::BaseAudioContext(Document* document) |
| 92 : ActiveScriptWrappable(this), | 92 : ActiveScriptWrappable(this), |
| 93 ActiveDOMObject(document), | 93 SuspendableObject(document), |
| 94 m_destinationNode(nullptr), | 94 m_destinationNode(nullptr), |
| 95 m_isCleared(false), | 95 m_isCleared(false), |
| 96 m_isResolvingResumePromises(false), | 96 m_isResolvingResumePromises(false), |
| 97 m_userGestureRequired(false), | 97 m_userGestureRequired(false), |
| 98 m_connectionCount(0), | 98 m_connectionCount(0), |
| 99 m_deferredTaskHandler(DeferredTaskHandler::create()), | 99 m_deferredTaskHandler(DeferredTaskHandler::create()), |
| 100 m_contextState(Suspended), | 100 m_contextState(Suspended), |
| 101 m_closedContextSampleRate(-1), | 101 m_closedContextSampleRate(-1), |
| 102 m_periodicWaveSine(nullptr), | 102 m_periodicWaveSine(nullptr), |
| 103 m_periodicWaveSquare(nullptr), | 103 m_periodicWaveSquare(nullptr), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 116 | 116 |
| 117 initialize(); | 117 initialize(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Constructor for offline (non-realtime) rendering. | 120 // Constructor for offline (non-realtime) rendering. |
| 121 BaseAudioContext::BaseAudioContext(Document* document, | 121 BaseAudioContext::BaseAudioContext(Document* document, |
| 122 unsigned numberOfChannels, | 122 unsigned numberOfChannels, |
| 123 size_t numberOfFrames, | 123 size_t numberOfFrames, |
| 124 float sampleRate) | 124 float sampleRate) |
| 125 : ActiveScriptWrappable(this), | 125 : ActiveScriptWrappable(this), |
| 126 ActiveDOMObject(document), | 126 SuspendableObject(document), |
| 127 m_destinationNode(nullptr), | 127 m_destinationNode(nullptr), |
| 128 m_isCleared(false), | 128 m_isCleared(false), |
| 129 m_isResolvingResumePromises(false), | 129 m_isResolvingResumePromises(false), |
| 130 m_userGestureRequired(false), | 130 m_userGestureRequired(false), |
| 131 m_connectionCount(0), | 131 m_connectionCount(0), |
| 132 m_deferredTaskHandler(DeferredTaskHandler::create()), | 132 m_deferredTaskHandler(DeferredTaskHandler::create()), |
| 133 m_contextState(Suspended), | 133 m_contextState(Suspended), |
| 134 m_closedContextSampleRate(-1), | 134 m_closedContextSampleRate(-1), |
| 135 m_periodicWaveSine(nullptr), | 135 m_periodicWaveSine(nullptr), |
| 136 m_periodicWaveSquare(nullptr), | 136 m_periodicWaveSquare(nullptr), |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 autoplayHistogram.count(m_autoplayStatus.value()); | 843 autoplayHistogram.count(m_autoplayStatus.value()); |
| 844 | 844 |
| 845 m_autoplayStatus.reset(); | 845 m_autoplayStatus.reset(); |
| 846 } | 846 } |
| 847 | 847 |
| 848 const AtomicString& BaseAudioContext::interfaceName() const { | 848 const AtomicString& BaseAudioContext::interfaceName() const { |
| 849 return EventTargetNames::AudioContext; | 849 return EventTargetNames::AudioContext; |
| 850 } | 850 } |
| 851 | 851 |
| 852 ExecutionContext* BaseAudioContext::getExecutionContext() const { | 852 ExecutionContext* BaseAudioContext::getExecutionContext() const { |
| 853 return ActiveDOMObject::getExecutionContext(); | 853 return SuspendableObject::getExecutionContext(); |
| 854 } | 854 } |
| 855 | 855 |
| 856 void BaseAudioContext::startRendering() { | 856 void BaseAudioContext::startRendering() { |
| 857 // This is called for both online and offline contexts. | 857 // This is called for both online and offline contexts. |
| 858 DCHECK(isMainThread()); | 858 DCHECK(isMainThread()); |
| 859 DCHECK(m_destinationNode); | 859 DCHECK(m_destinationNode); |
| 860 DCHECK(isAllowedToStart()); | 860 DCHECK(isAllowedToStart()); |
| 861 | 861 |
| 862 if (m_contextState == Suspended) { | 862 if (m_contextState == Suspended) { |
| 863 destination()->audioDestinationHandler().startRendering(); | 863 destination()->audioDestinationHandler().startRendering(); |
| 864 setContextState(Running); | 864 setContextState(Running); |
| 865 } | 865 } |
| 866 } | 866 } |
| 867 | 867 |
| 868 DEFINE_TRACE(BaseAudioContext) { | 868 DEFINE_TRACE(BaseAudioContext) { |
| 869 visitor->trace(m_destinationNode); | 869 visitor->trace(m_destinationNode); |
| 870 visitor->trace(m_listener); | 870 visitor->trace(m_listener); |
| 871 visitor->trace(m_activeSourceNodes); | 871 visitor->trace(m_activeSourceNodes); |
| 872 visitor->trace(m_resumeResolvers); | 872 visitor->trace(m_resumeResolvers); |
| 873 visitor->trace(m_decodeAudioResolvers); | 873 visitor->trace(m_decodeAudioResolvers); |
| 874 | 874 |
| 875 visitor->trace(m_periodicWaveSine); | 875 visitor->trace(m_periodicWaveSine); |
| 876 visitor->trace(m_periodicWaveSquare); | 876 visitor->trace(m_periodicWaveSquare); |
| 877 visitor->trace(m_periodicWaveSawtooth); | 877 visitor->trace(m_periodicWaveSawtooth); |
| 878 visitor->trace(m_periodicWaveTriangle); | 878 visitor->trace(m_periodicWaveTriangle); |
| 879 EventTargetWithInlineData::trace(visitor); | 879 EventTargetWithInlineData::trace(visitor); |
| 880 ActiveDOMObject::trace(visitor); | 880 SuspendableObject::trace(visitor); |
| 881 } | 881 } |
| 882 | 882 |
| 883 SecurityOrigin* BaseAudioContext::getSecurityOrigin() const { | 883 SecurityOrigin* BaseAudioContext::getSecurityOrigin() const { |
| 884 if (getExecutionContext()) | 884 if (getExecutionContext()) |
| 885 return getExecutionContext()->getSecurityOrigin(); | 885 return getExecutionContext()->getSecurityOrigin(); |
| 886 | 886 |
| 887 return nullptr; | 887 return nullptr; |
| 888 } | 888 } |
| 889 | 889 |
| 890 } // namespace blink | 890 } // namespace blink |
| OLD | NEW |