| 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 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 // This is called for both online and offline contexts. | 819 // This is called for both online and offline contexts. |
| 820 ASSERT(isMainThread()); | 820 ASSERT(isMainThread()); |
| 821 ASSERT(m_destinationNode); | 821 ASSERT(m_destinationNode); |
| 822 | 822 |
| 823 if (m_contextState == Suspended) { | 823 if (m_contextState == Suspended) { |
| 824 destination()->audioDestinationHandler().startRendering(); | 824 destination()->audioDestinationHandler().startRendering(); |
| 825 setContextState(Running); | 825 setContextState(Running); |
| 826 } | 826 } |
| 827 } | 827 } |
| 828 | 828 |
| 829 void AbstractAudioContext::fireCompletionEvent() | |
| 830 { | |
| 831 ASSERT(isMainThread()); | |
| 832 if (!isMainThread()) | |
| 833 return; | |
| 834 | |
| 835 AudioBuffer* renderedBuffer = m_renderTarget.get(); | |
| 836 | |
| 837 // For an offline context, we set the state to closed here so that the oncom
plete handler sees | |
| 838 // that the context has been closed. | |
| 839 setContextState(Closed); | |
| 840 | |
| 841 ASSERT(renderedBuffer); | |
| 842 if (!renderedBuffer) | |
| 843 return; | |
| 844 | |
| 845 // Avoid firing the event if the document has already gone away. | |
| 846 if (executionContext()) { | |
| 847 // Call the offline rendering completion event listener and resolve the
promise too. | |
| 848 dispatchEvent(OfflineAudioCompletionEvent::create(renderedBuffer)); | |
| 849 m_offlineResolver->resolve(renderedBuffer); | |
| 850 } | |
| 851 } | |
| 852 | |
| 853 DEFINE_TRACE(AbstractAudioContext) | 829 DEFINE_TRACE(AbstractAudioContext) |
| 854 { | 830 { |
| 855 visitor->trace(m_offlineResolver); | |
| 856 visitor->trace(m_renderTarget); | 831 visitor->trace(m_renderTarget); |
| 857 visitor->trace(m_destinationNode); | 832 visitor->trace(m_destinationNode); |
| 858 visitor->trace(m_listener); | 833 visitor->trace(m_listener); |
| 859 // trace() can be called in AbstractAudioContext constructor, and | 834 // trace() can be called in AbstractAudioContext constructor, and |
| 860 // m_contextGraphMutex might be unavailable. | 835 // m_contextGraphMutex might be unavailable. |
| 861 if (m_didInitializeContextGraphMutex) { | 836 if (m_didInitializeContextGraphMutex) { |
| 862 AutoLocker lock(this); | 837 AutoLocker lock(this); |
| 863 visitor->trace(m_activeSourceNodes); | 838 visitor->trace(m_activeSourceNodes); |
| 864 } else { | 839 } else { |
| 865 visitor->trace(m_activeSourceNodes); | 840 visitor->trace(m_activeSourceNodes); |
| 866 } | 841 } |
| 867 visitor->trace(m_resumeResolvers); | 842 visitor->trace(m_resumeResolvers); |
| 868 RefCountedGarbageCollectedEventTargetWithInlineData<AbstractAudioContext>::t
race(visitor); | 843 RefCountedGarbageCollectedEventTargetWithInlineData<AbstractAudioContext>::t
race(visitor); |
| 869 ActiveDOMObject::trace(visitor); | 844 ActiveDOMObject::trace(visitor); |
| 870 } | 845 } |
| 871 | 846 |
| 872 SecurityOrigin* AbstractAudioContext::securityOrigin() const | 847 SecurityOrigin* AbstractAudioContext::securityOrigin() const |
| 873 { | 848 { |
| 874 if (executionContext()) | 849 if (executionContext()) |
| 875 return executionContext()->securityOrigin(); | 850 return executionContext()->securityOrigin(); |
| 876 | 851 |
| 877 return nullptr; | 852 return nullptr; |
| 878 } | 853 } |
| 879 | 854 |
| 880 } // namespace blink | 855 } // namespace blink |
| 881 | 856 |
| 882 #endif // ENABLE(WEB_AUDIO) | 857 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |