| 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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 break; | 588 break; |
| 589 case Running: | 589 case Running: |
| 590 DCHECK_EQ(m_contextState, Suspended); | 590 DCHECK_EQ(m_contextState, Suspended); |
| 591 break; | 591 break; |
| 592 case Closed: | 592 case Closed: |
| 593 DCHECK_NE(m_contextState, Closed); | 593 DCHECK_NE(m_contextState, Closed); |
| 594 break; | 594 break; |
| 595 } | 595 } |
| 596 | 596 |
| 597 if (newState == m_contextState) { | 597 if (newState == m_contextState) { |
| 598 // ASSERTs above failed; just return. | 598 // DCHECKs above failed; just return. |
| 599 return; | 599 return; |
| 600 } | 600 } |
| 601 | 601 |
| 602 m_contextState = newState; | 602 m_contextState = newState; |
| 603 | 603 |
| 604 // Notify context that state changed | 604 // Notify context that state changed |
| 605 if (getExecutionContext()) | 605 if (getExecutionContext()) |
| 606 getExecutionContext()->postTask(BLINK_FROM_HERE, createSameThreadTask(&B
aseAudioContext::notifyStateChange, wrapPersistent(this))); | 606 getExecutionContext()->postTask(BLINK_FROM_HERE, createSameThreadTask(&B
aseAudioContext::notifyStateChange, wrapPersistent(this))); |
| 607 } | 607 } |
| 608 | 608 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 626 for (AudioNode* node : m_finishedSourceNodes) { | 626 for (AudioNode* node : m_finishedSourceNodes) { |
| 627 size_t i = m_activeSourceNodes.find(node); | 627 size_t i = m_activeSourceNodes.find(node); |
| 628 if (i != kNotFound) | 628 if (i != kNotFound) |
| 629 m_activeSourceNodes.remove(i); | 629 m_activeSourceNodes.remove(i); |
| 630 } | 630 } |
| 631 m_finishedSourceNodes.clear(); | 631 m_finishedSourceNodes.clear(); |
| 632 } | 632 } |
| 633 | 633 |
| 634 void BaseAudioContext::releaseFinishedSourceNodes() | 634 void BaseAudioContext::releaseFinishedSourceNodes() |
| 635 { | 635 { |
| 636 ASSERT(isGraphOwner()); | 636 DCHECK(isGraphOwner()); |
| 637 DCHECK(isAudioThread()); | 637 DCHECK(isAudioThread()); |
| 638 bool didRemove = false; | 638 bool didRemove = false; |
| 639 for (AudioHandler* handler : m_finishedSourceHandlers) { | 639 for (AudioHandler* handler : m_finishedSourceHandlers) { |
| 640 for (AudioNode* node : m_activeSourceNodes) { | 640 for (AudioNode* node : m_activeSourceNodes) { |
| 641 if (m_finishedSourceNodes.contains(node)) | 641 if (m_finishedSourceNodes.contains(node)) |
| 642 continue; | 642 continue; |
| 643 if (handler == &node->handler()) { | 643 if (handler == &node->handler()) { |
| 644 handler->breakConnection(); | 644 handler->breakConnection(); |
| 645 m_finishedSourceNodes.add(node); | 645 m_finishedSourceNodes.add(node); |
| 646 didRemove = true; | 646 didRemove = true; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 667 { | 667 { |
| 668 DCHECK(isMainThread()); | 668 DCHECK(isMainThread()); |
| 669 for (auto& sourceNode : m_activeSourceNodes) | 669 for (auto& sourceNode : m_activeSourceNodes) |
| 670 sourceNode->handler().breakConnection(); | 670 sourceNode->handler().breakConnection(); |
| 671 | 671 |
| 672 m_activeSourceNodes.clear(); | 672 m_activeSourceNodes.clear(); |
| 673 } | 673 } |
| 674 | 674 |
| 675 void BaseAudioContext::handleStoppableSourceNodes() | 675 void BaseAudioContext::handleStoppableSourceNodes() |
| 676 { | 676 { |
| 677 ASSERT(isGraphOwner()); | 677 DCHECK(isGraphOwner()); |
| 678 | 678 |
| 679 // Find AudioBufferSourceNodes to see if we can stop playing them. | 679 // Find AudioBufferSourceNodes to see if we can stop playing them. |
| 680 for (AudioNode* node : m_activeSourceNodes) { | 680 for (AudioNode* node : m_activeSourceNodes) { |
| 681 // If the AudioNode has been marked as finished and released by | 681 // If the AudioNode has been marked as finished and released by |
| 682 // the audio thread, but not yet removed by the main thread | 682 // the audio thread, but not yet removed by the main thread |
| 683 // (see releaseActiveSourceNodes() above), |node| must not be | 683 // (see releaseActiveSourceNodes() above), |node| must not be |
| 684 // touched as its handler may have been released already. | 684 // touched as its handler may have been released already. |
| 685 if (m_finishedSourceNodes.contains(node)) | 685 if (m_finishedSourceNodes.contains(node)) |
| 686 continue; | 686 continue; |
| 687 if (node->handler().getNodeType() == AudioHandler::NodeTypeAudioBufferSo
urce) { | 687 if (node->handler().getNodeType() == AudioHandler::NodeTypeAudioBufferSo
urce) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 } | 748 } |
| 749 | 749 |
| 750 m_resumeResolvers.clear(); | 750 m_resumeResolvers.clear(); |
| 751 m_isResolvingResumePromises = false; | 751 m_isResolvingResumePromises = false; |
| 752 } | 752 } |
| 753 | 753 |
| 754 void BaseAudioContext::resolvePromisesForResume() | 754 void BaseAudioContext::resolvePromisesForResume() |
| 755 { | 755 { |
| 756 // This runs inside the BaseAudioContext's lock when handling pre-render tas
ks. | 756 // This runs inside the BaseAudioContext's lock when handling pre-render tas
ks. |
| 757 DCHECK(isAudioThread()); | 757 DCHECK(isAudioThread()); |
| 758 ASSERT(isGraphOwner()); | 758 DCHECK(isGraphOwner()); |
| 759 | 759 |
| 760 // Resolve any pending promises created by resume(). Only do this if we have
n't already started | 760 // Resolve any pending promises created by resume(). Only do this if we have
n't already started |
| 761 // resolving these promises. This gets called very often and it takes some t
ime to resolve the | 761 // resolving these promises. This gets called very often and it takes some t
ime to resolve the |
| 762 // promises in the main thread. | 762 // promises in the main thread. |
| 763 if (!m_isResolvingResumePromises && m_resumeResolvers.size() > 0) { | 763 if (!m_isResolvingResumePromises && m_resumeResolvers.size() > 0) { |
| 764 m_isResolvingResumePromises = true; | 764 m_isResolvingResumePromises = true; |
| 765 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, crossThreadBind(&BaseAudioContext::resolvePromisesForResumeOnMainThread
, wrapCrossThreadPersistent(this))); | 765 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, crossThreadBind(&BaseAudioContext::resolvePromisesForResumeOnMainThread
, wrapCrossThreadPersistent(this))); |
| 766 } | 766 } |
| 767 } | 767 } |
| 768 | 768 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 | 831 |
| 832 SecurityOrigin* BaseAudioContext::getSecurityOrigin() const | 832 SecurityOrigin* BaseAudioContext::getSecurityOrigin() const |
| 833 { | 833 { |
| 834 if (getExecutionContext()) | 834 if (getExecutionContext()) |
| 835 return getExecutionContext()->getSecurityOrigin(); | 835 return getExecutionContext()->getSecurityOrigin(); |
| 836 | 836 |
| 837 return nullptr; | 837 return nullptr; |
| 838 } | 838 } |
| 839 | 839 |
| 840 } // namespace blink | 840 } // namespace blink |
| OLD | NEW |