| 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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 } | 670 } |
| 671 | 671 |
| 672 void AudioContext::handlePreRenderTasks() | 672 void AudioContext::handlePreRenderTasks() |
| 673 { | 673 { |
| 674 ASSERT(isAudioThread()); | 674 ASSERT(isAudioThread()); |
| 675 | 675 |
| 676 // At the beginning of every render quantum, try to update the internal rend
ering graph state (from main thread changes). | 676 // At the beginning of every render quantum, try to update the internal rend
ering graph state (from main thread changes). |
| 677 // It's OK if the tryLock() fails, we'll just take slightly longer to pick u
p the changes. | 677 // It's OK if the tryLock() fails, we'll just take slightly longer to pick u
p the changes. |
| 678 bool mustReleaseLock; | 678 bool mustReleaseLock; |
| 679 if (tryLock(mustReleaseLock)) { | 679 if (tryLock(mustReleaseLock)) { |
| 680 // Update the channel count mode. |
| 681 updateChangedChannelCountMode(); |
| 682 |
| 680 // Fixup the state of any dirty AudioSummingJunctions and AudioNodeOutpu
ts. | 683 // Fixup the state of any dirty AudioSummingJunctions and AudioNodeOutpu
ts. |
| 681 handleDirtyAudioSummingJunctions(); | 684 handleDirtyAudioSummingJunctions(); |
| 682 handleDirtyAudioNodeOutputs(); | 685 handleDirtyAudioNodeOutputs(); |
| 683 | 686 |
| 684 updateAutomaticPullNodes(); | 687 updateAutomaticPullNodes(); |
| 685 | 688 |
| 686 if (mustReleaseLock) | 689 if (mustReleaseLock) |
| 687 unlock(); | 690 unlock(); |
| 688 } | 691 } |
| 689 } | 692 } |
| 690 | 693 |
| 691 void AudioContext::handlePostRenderTasks() | 694 void AudioContext::handlePostRenderTasks() |
| 692 { | 695 { |
| 693 ASSERT(isAudioThread()); | 696 ASSERT(isAudioThread()); |
| 694 | 697 |
| 695 // Must use a tryLock() here too. Don't worry, the lock will very rarely be
contended and this method is called frequently. | 698 // Must use a tryLock() here too. Don't worry, the lock will very rarely be
contended and this method is called frequently. |
| 696 // The worst that can happen is that there will be some nodes which will tak
e slightly longer than usual to be deleted or removed | 699 // The worst that can happen is that there will be some nodes which will tak
e slightly longer than usual to be deleted or removed |
| 697 // from the render graph (in which case they'll render silence). | 700 // from the render graph (in which case they'll render silence). |
| 698 bool mustReleaseLock; | 701 bool mustReleaseLock; |
| 699 if (tryLock(mustReleaseLock)) { | 702 if (tryLock(mustReleaseLock)) { |
| 703 // Update the channel count mode. |
| 704 updateChangedChannelCountMode(); |
| 705 |
| 700 // Take care of AudioNode tasks where the tryLock() failed previously. | 706 // Take care of AudioNode tasks where the tryLock() failed previously. |
| 701 handleDeferredAudioNodeTasks(); | 707 handleDeferredAudioNodeTasks(); |
| 702 | 708 |
| 703 // Dynamically clean up nodes which are no longer needed. | 709 // Dynamically clean up nodes which are no longer needed. |
| 704 derefFinishedSourceNodes(); | 710 derefFinishedSourceNodes(); |
| 705 | 711 |
| 706 // Fixup the state of any dirty AudioSummingJunctions and AudioNodeOutpu
ts. | 712 // Fixup the state of any dirty AudioSummingJunctions and AudioNodeOutpu
ts. |
| 707 handleDirtyAudioSummingJunctions(); | 713 handleDirtyAudioSummingJunctions(); |
| 708 handleDirtyAudioNodeOutputs(); | 714 handleDirtyAudioNodeOutputs(); |
| 709 | 715 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 { | 893 { |
| 888 visitor->trace(m_renderTarget); | 894 visitor->trace(m_renderTarget); |
| 889 visitor->trace(m_destinationNode); | 895 visitor->trace(m_destinationNode); |
| 890 visitor->trace(m_listener); | 896 visitor->trace(m_listener); |
| 891 visitor->trace(m_referencedNodes); | 897 visitor->trace(m_referencedNodes); |
| 892 visitor->trace(m_liveNodes); | 898 visitor->trace(m_liveNodes); |
| 893 visitor->trace(m_liveAudioSummingJunctions); | 899 visitor->trace(m_liveAudioSummingJunctions); |
| 894 EventTargetWithInlineData::trace(visitor); | 900 EventTargetWithInlineData::trace(visitor); |
| 895 } | 901 } |
| 896 | 902 |
| 903 void AudioContext::addChangedChannelCountMode(AudioNode* node) |
| 904 { |
| 905 ASSERT(isGraphOwner()); |
| 906 ASSERT(isMainThread()); |
| 907 m_deferredCountModeChange.add(node); |
| 908 } |
| 909 |
| 910 void AudioContext::removeChangedChannelCountMode(AudioNode* node) |
| 911 { |
| 912 ASSERT(isGraphOwner()); |
| 913 |
| 914 m_deferredCountModeChange.remove(node); |
| 915 } |
| 916 |
| 917 void AudioContext::updateChangedChannelCountMode() |
| 918 { |
| 919 ASSERT(isGraphOwner()); |
| 920 |
| 921 for (HashSet<AudioNode*>::iterator k = m_deferredCountModeChange.begin(); k
!= m_deferredCountModeChange.end(); ++k) |
| 922 (*k)->updateChannelCountMode(); |
| 923 |
| 924 m_deferredCountModeChange.clear(); |
| 925 } |
| 926 |
| 897 } // namespace blink | 927 } // namespace blink |
| 898 | 928 |
| 899 #endif // ENABLE(WEB_AUDIO) | 929 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |