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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 ASSERT(isMainThread()); | 783 ASSERT(isMainThread()); |
784 AutoLocker locker(this); | 784 AutoLocker locker(this); |
785 | 785 |
786 m_activeSourceNodes.append(node); | 786 m_activeSourceNodes.append(node); |
787 node->handler().makeConnection(); | 787 node->handler().makeConnection(); |
788 } | 788 } |
789 | 789 |
790 void AbstractAudioContext::releaseActiveSourceNodes() | 790 void AbstractAudioContext::releaseActiveSourceNodes() |
791 { | 791 { |
792 ASSERT(isMainThread()); | 792 ASSERT(isMainThread()); |
793 for (auto& sourceNode : m_activeSourceNodes) | 793 AutoLocker locker(this); |
| 794 |
| 795 for (AudioNode* sourceNode : m_activeSourceNodes) { |
| 796 // When the execution context is tearing down, we need to mark all the |
| 797 // active scheduled source nodes (i.e. Oscillator, BufferSource) as |
| 798 // 'available for GC' so they can be collected properly. |
| 799 if (sourceNode->handler().nodeType() == AudioHandler::NodeTypeOscillator |
| 800 || sourceNode->handler().nodeType() == AudioHandler::NodeTypeAudioBu
fferSource) { |
| 801 AudioScheduledSourceNode* scheduledSourceNode = static_cast<AudioSch
eduledSourceNode*>(sourceNode); |
| 802 scheduledSourceNode->markForGC(); |
| 803 } |
| 804 |
794 sourceNode->handler().breakConnection(); | 805 sourceNode->handler().breakConnection(); |
| 806 } |
795 | 807 |
796 m_activeSourceNodes.clear(); | 808 m_activeSourceNodes.clear(); |
797 } | 809 } |
798 | 810 |
799 void AbstractAudioContext::handleStoppableSourceNodes() | 811 void AbstractAudioContext::handleStoppableSourceNodes() |
800 { | 812 { |
801 ASSERT(isGraphOwner()); | 813 ASSERT(isGraphOwner()); |
802 | 814 |
803 // Find AudioBufferSourceNodes to see if we can stop playing them. | 815 // Find AudioBufferSourceNodes to see if we can stop playing them. |
804 for (AudioNode* node : m_activeSourceNodes) { | 816 for (AudioNode* node : m_activeSourceNodes) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 SecurityOrigin* AbstractAudioContext::securityOrigin() const | 959 SecurityOrigin* AbstractAudioContext::securityOrigin() const |
948 { | 960 { |
949 if (executionContext()) | 961 if (executionContext()) |
950 return executionContext()->securityOrigin(); | 962 return executionContext()->securityOrigin(); |
951 | 963 |
952 return nullptr; | 964 return nullptr; |
953 } | 965 } |
954 | 966 |
955 } // namespace blink | 967 } // namespace blink |
956 | 968 |
OLD | NEW |