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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 } | 780 } |
781 m_finishedSourceNodes.clear(); | 781 m_finishedSourceNodes.clear(); |
782 } | 782 } |
783 | 783 |
784 void AbstractAudioContext::releaseFinishedSourceNodes() | 784 void AbstractAudioContext::releaseFinishedSourceNodes() |
785 { | 785 { |
786 ASSERT(isGraphOwner()); | 786 ASSERT(isGraphOwner()); |
787 ASSERT(isAudioThread()); | 787 ASSERT(isAudioThread()); |
788 bool didRemove = false; | 788 bool didRemove = false; |
789 for (AudioHandler* handler : m_finishedSourceHandlers) { | 789 for (AudioHandler* handler : m_finishedSourceHandlers) { |
790 for (unsigned i = 0; i < m_activeSourceNodes.size(); ++i) { | 790 for (AudioNode* node : m_activeSourceNodes) { |
791 if (handler == &m_activeSourceNodes[i]->handler()) { | 791 if (m_finishedSourceNodes.contains(node)) |
| 792 continue; |
| 793 if (handler == &node->handler()) { |
792 handler->breakConnection(); | 794 handler->breakConnection(); |
793 m_finishedSourceNodes.append(m_activeSourceNodes[i]); | 795 m_finishedSourceNodes.add(node); |
794 didRemove = true; | 796 didRemove = true; |
795 break; | 797 break; |
796 } | 798 } |
797 } | 799 } |
798 } | 800 } |
799 if (didRemove) | 801 if (didRemove) |
800 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, threadSafeBind(&AbstractAudioContext::removeFinishedSourceNodes, this))
; | 802 Platform::current()->mainThread()->getWebTaskRunner()->postTask(BLINK_FR
OM_HERE, threadSafeBind(&AbstractAudioContext::removeFinishedSourceNodes, this))
; |
801 | 803 |
802 m_finishedSourceHandlers.clear(); | 804 m_finishedSourceHandlers.clear(); |
803 } | 805 } |
(...skipping 15 matching lines...) Expand all Loading... |
819 | 821 |
820 m_activeSourceNodes.clear(); | 822 m_activeSourceNodes.clear(); |
821 } | 823 } |
822 | 824 |
823 void AbstractAudioContext::handleStoppableSourceNodes() | 825 void AbstractAudioContext::handleStoppableSourceNodes() |
824 { | 826 { |
825 ASSERT(isGraphOwner()); | 827 ASSERT(isGraphOwner()); |
826 | 828 |
827 // Find AudioBufferSourceNodes to see if we can stop playing them. | 829 // Find AudioBufferSourceNodes to see if we can stop playing them. |
828 for (AudioNode* node : m_activeSourceNodes) { | 830 for (AudioNode* node : m_activeSourceNodes) { |
| 831 // If the AudioNode has been marked as finished and released by |
| 832 // the audio thread, but not yet removed by the main thread |
| 833 // (see releaseActiveSourceNodes() above), |node| must not be |
| 834 // touched as its handler may have been released already. |
| 835 if (m_finishedSourceNodes.contains(node)) |
| 836 continue; |
829 if (node->handler().getNodeType() == AudioHandler::NodeTypeAudioBufferSo
urce) { | 837 if (node->handler().getNodeType() == AudioHandler::NodeTypeAudioBufferSo
urce) { |
830 AudioBufferSourceNode* sourceNode = static_cast<AudioBufferSourceNod
e*>(node); | 838 AudioBufferSourceNode* sourceNode = static_cast<AudioBufferSourceNod
e*>(node); |
831 sourceNode->audioBufferSourceHandler().handleStoppableSourceNode(); | 839 sourceNode->audioBufferSourceHandler().handleStoppableSourceNode(); |
832 } | 840 } |
833 } | 841 } |
834 } | 842 } |
835 | 843 |
836 void AbstractAudioContext::handlePreRenderTasks() | 844 void AbstractAudioContext::handlePreRenderTasks() |
837 { | 845 { |
838 ASSERT(isAudioThread()); | 846 ASSERT(isAudioThread()); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 | 976 |
969 SecurityOrigin* AbstractAudioContext::getSecurityOrigin() const | 977 SecurityOrigin* AbstractAudioContext::getSecurityOrigin() const |
970 { | 978 { |
971 if (getExecutionContext()) | 979 if (getExecutionContext()) |
972 return getExecutionContext()->getSecurityOrigin(); | 980 return getExecutionContext()->getSecurityOrigin(); |
973 | 981 |
974 return nullptr; | 982 return nullptr; |
975 } | 983 } |
976 | 984 |
977 } // namespace blink | 985 } // namespace blink |
978 | |
OLD | NEW |