| 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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 // touched as its handler may have been released already. | 683 // touched as its handler may have been released already. |
| 684 if (m_finishedSourceNodes.contains(node)) | 684 if (m_finishedSourceNodes.contains(node)) |
| 685 continue; | 685 continue; |
| 686 if (node->handler().getNodeType() == AudioHandler::NodeTypeAudioBufferSo
urce) { | 686 if (node->handler().getNodeType() == AudioHandler::NodeTypeAudioBufferSo
urce) { |
| 687 AudioBufferSourceNode* sourceNode = static_cast<AudioBufferSourceNod
e*>(node); | 687 AudioBufferSourceNode* sourceNode = static_cast<AudioBufferSourceNod
e*>(node); |
| 688 sourceNode->audioBufferSourceHandler().handleStoppableSourceNode(); | 688 sourceNode->audioBufferSourceHandler().handleStoppableSourceNode(); |
| 689 } | 689 } |
| 690 } | 690 } |
| 691 } | 691 } |
| 692 | 692 |
| 693 void AbstractAudioContext::handlePreRenderTasks() | 693 void AbstractAudioContext::handlePreRenderTasks(const WebAudioTimestamp& outputT
imestamp) |
| 694 { | 694 { |
| 695 ASSERT(isAudioThread()); | 695 ASSERT(isAudioThread()); |
| 696 | 696 |
| 697 // At the beginning of every render quantum, try to update the internal rend
ering graph state (from main thread changes). | 697 // At the beginning of every render quantum, try to update the internal rend
ering graph state (from main thread changes). |
| 698 // It's OK if the tryLock() fails, we'll just take slightly longer to pick u
p the changes. | 698 // It's OK if the tryLock() fails, we'll just take slightly longer to pick u
p the changes. |
| 699 if (tryLock()) { | 699 if (tryLock()) { |
| 700 deferredTaskHandler().handleDeferredTasks(); | 700 deferredTaskHandler().handleDeferredTasks(); |
| 701 | 701 |
| 702 resolvePromisesForResume(); | 702 resolvePromisesForResume(); |
| 703 | 703 |
| 704 // Check to see if source nodes can be stopped because the end time has
passed. | 704 // Check to see if source nodes can be stopped because the end time has
passed. |
| 705 handleStoppableSourceNodes(); | 705 handleStoppableSourceNodes(); |
| 706 | 706 |
| 707 // Update the dirty state of the listener. | 707 // Update the dirty state of the listener. |
| 708 listener()->updateState(); | 708 listener()->updateState(); |
| 709 | 709 |
| 710 // Update output timestamp. |
| 711 m_outputTimestamp = outputTimestamp; |
| 712 |
| 710 unlock(); | 713 unlock(); |
| 711 } | 714 } |
| 712 } | 715 } |
| 713 | 716 |
| 714 void AbstractAudioContext::handlePostRenderTasks() | 717 void AbstractAudioContext::handlePostRenderTasks() |
| 715 { | 718 { |
| 716 ASSERT(isAudioThread()); | 719 ASSERT(isAudioThread()); |
| 717 | 720 |
| 718 // Must use a tryLock() here too. Don't worry, the lock will very rarely be
contended and this method is called frequently. | 721 // Must use a tryLock() here too. Don't worry, the lock will very rarely be
contended and this method is called frequently. |
| 719 // 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 | 722 // 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 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 } | 769 } |
| 767 | 770 |
| 768 void AbstractAudioContext::rejectPendingDecodeAudioDataResolvers() | 771 void AbstractAudioContext::rejectPendingDecodeAudioDataResolvers() |
| 769 { | 772 { |
| 770 // Now reject any pending decodeAudioData resolvers | 773 // Now reject any pending decodeAudioData resolvers |
| 771 for (auto& resolver : m_decodeAudioResolvers) | 774 for (auto& resolver : m_decodeAudioResolvers) |
| 772 resolver->reject(DOMException::create(InvalidStateError, "Audio context
is going away")); | 775 resolver->reject(DOMException::create(InvalidStateError, "Audio context
is going away")); |
| 773 m_decodeAudioResolvers.clear(); | 776 m_decodeAudioResolvers.clear(); |
| 774 } | 777 } |
| 775 | 778 |
| 779 WebAudioTimestamp AbstractAudioContext::outputTimestamp() |
| 780 { |
| 781 AutoLocker locker(this); |
| 782 return m_outputTimestamp; |
| 783 } |
| 784 |
| 776 void AbstractAudioContext::rejectPendingResolvers() | 785 void AbstractAudioContext::rejectPendingResolvers() |
| 777 { | 786 { |
| 778 ASSERT(isMainThread()); | 787 ASSERT(isMainThread()); |
| 779 | 788 |
| 780 // Audio context is closing down so reject any resume promises that are stil
l pending. | 789 // Audio context is closing down so reject any resume promises that are stil
l pending. |
| 781 | 790 |
| 782 for (auto& resolver : m_resumeResolvers) { | 791 for (auto& resolver : m_resumeResolvers) { |
| 783 resolver->reject(DOMException::create(InvalidStateError, "Audio context
is going away")); | 792 resolver->reject(DOMException::create(InvalidStateError, "Audio context
is going away")); |
| 784 } | 793 } |
| 785 m_resumeResolvers.clear(); | 794 m_resumeResolvers.clear(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 | 839 |
| 831 SecurityOrigin* AbstractAudioContext::getSecurityOrigin() const | 840 SecurityOrigin* AbstractAudioContext::getSecurityOrigin() const |
| 832 { | 841 { |
| 833 if (getExecutionContext()) | 842 if (getExecutionContext()) |
| 834 return getExecutionContext()->getSecurityOrigin(); | 843 return getExecutionContext()->getSecurityOrigin(); |
| 835 | 844 |
| 836 return nullptr; | 845 return nullptr; |
| 837 } | 846 } |
| 838 | 847 |
| 839 } // namespace blink | 848 } // namespace blink |
| OLD | NEW |