| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 , m_isCleared(false) | 103 , m_isCleared(false) |
| 104 , m_isInitialized(false) | 104 , m_isInitialized(false) |
| 105 , m_destinationNode(nullptr) | 105 , m_destinationNode(nullptr) |
| 106 , m_isResolvingResumePromises(false) | 106 , m_isResolvingResumePromises(false) |
| 107 , m_automaticPullNodesNeedUpdating(false) | 107 , m_automaticPullNodesNeedUpdating(false) |
| 108 , m_connectionCount(0) | 108 , m_connectionCount(0) |
| 109 , m_didInitializeContextGraphMutex(false) | 109 , m_didInitializeContextGraphMutex(false) |
| 110 , m_audioThread(0) | 110 , m_audioThread(0) |
| 111 , m_isOfflineContext(false) | 111 , m_isOfflineContext(false) |
| 112 , m_contextState(Suspended) | 112 , m_contextState(Suspended) |
| 113 , m_cachedSampleFrame(0) |
| 113 { | 114 { |
| 114 m_didInitializeContextGraphMutex = true; | 115 m_didInitializeContextGraphMutex = true; |
| 115 m_destinationNode = DefaultAudioDestinationNode::create(this); | 116 m_destinationNode = DefaultAudioDestinationNode::create(this); |
| 116 | 117 |
| 117 initialize(); | 118 initialize(); |
| 118 #if DEBUG_AUDIONODE_REFERENCES | 119 #if DEBUG_AUDIONODE_REFERENCES |
| 119 fprintf(stderr, "%p: AudioContext::AudioContext() #%u\n", this, AudioContext
::s_hardwareContextCount); | 120 fprintf(stderr, "%p: AudioContext::AudioContext() #%u\n", this, AudioContext
::s_hardwareContextCount); |
| 120 #endif | 121 #endif |
| 121 } | 122 } |
| 122 | 123 |
| 123 // Constructor for offline (non-realtime) rendering. | 124 // Constructor for offline (non-realtime) rendering. |
| 124 AudioContext::AudioContext(Document* document, unsigned numberOfChannels, size_t
numberOfFrames, float sampleRate) | 125 AudioContext::AudioContext(Document* document, unsigned numberOfChannels, size_t
numberOfFrames, float sampleRate) |
| 125 : ActiveDOMObject(document) | 126 : ActiveDOMObject(document) |
| 126 , m_isStopScheduled(false) | 127 , m_isStopScheduled(false) |
| 127 , m_isCleared(false) | 128 , m_isCleared(false) |
| 128 , m_isInitialized(false) | 129 , m_isInitialized(false) |
| 129 , m_destinationNode(nullptr) | 130 , m_destinationNode(nullptr) |
| 130 , m_isResolvingResumePromises(false) | 131 , m_isResolvingResumePromises(false) |
| 131 , m_automaticPullNodesNeedUpdating(false) | 132 , m_automaticPullNodesNeedUpdating(false) |
| 132 , m_connectionCount(0) | 133 , m_connectionCount(0) |
| 133 , m_didInitializeContextGraphMutex(false) | 134 , m_didInitializeContextGraphMutex(false) |
| 134 , m_audioThread(0) | 135 , m_audioThread(0) |
| 135 , m_isOfflineContext(true) | 136 , m_isOfflineContext(true) |
| 136 , m_contextState(Suspended) | 137 , m_contextState(Suspended) |
| 138 , m_cachedSampleFrame(0) |
| 137 { | 139 { |
| 138 m_didInitializeContextGraphMutex = true; | 140 m_didInitializeContextGraphMutex = true; |
| 139 // Create a new destination for offline rendering. | 141 // Create a new destination for offline rendering. |
| 140 m_renderTarget = AudioBuffer::create(numberOfChannels, numberOfFrames, sampl
eRate); | 142 m_renderTarget = AudioBuffer::create(numberOfChannels, numberOfFrames, sampl
eRate); |
| 141 if (m_renderTarget.get()) | 143 if (m_renderTarget.get()) |
| 142 m_destinationNode = OfflineAudioDestinationNode::create(this, m_renderTa
rget.get()); | 144 m_destinationNode = OfflineAudioDestinationNode::create(this, m_renderTa
rget.get()); |
| 143 | 145 |
| 144 initialize(); | 146 initialize(); |
| 145 } | 147 } |
| 146 | 148 |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 exceptionState.throwDOMException( | 551 exceptionState.throwDOMException( |
| 550 IndexSizeError, | 552 IndexSizeError, |
| 551 "length of imaginary array (" + String::number(imag->length()) | 553 "length of imaginary array (" + String::number(imag->length()) |
| 552 + ") exceeds allowed maximum of 4096"); | 554 + ") exceeds allowed maximum of 4096"); |
| 553 return 0; | 555 return 0; |
| 554 } | 556 } |
| 555 | 557 |
| 556 return PeriodicWave::create(sampleRate(), real, imag); | 558 return PeriodicWave::create(sampleRate(), real, imag); |
| 557 } | 559 } |
| 558 | 560 |
| 561 size_t AudioContext::cachedSampleFrame() const |
| 562 { |
| 563 ASSERT(isMainThread()); |
| 564 |
| 565 return m_cachedSampleFrame; |
| 566 } |
| 567 |
| 559 String AudioContext::state() const | 568 String AudioContext::state() const |
| 560 { | 569 { |
| 561 // These strings had better match the strings for AudioContextState in Audio
Context.idl. | 570 // These strings had better match the strings for AudioContextState in Audio
Context.idl. |
| 562 switch (m_contextState) { | 571 switch (m_contextState) { |
| 563 case Suspended: | 572 case Suspended: |
| 564 return "suspended"; | 573 return "suspended"; |
| 565 case Running: | 574 case Running: |
| 566 return "running"; | 575 return "running"; |
| 567 case Closed: | 576 case Closed: |
| 568 return "closed"; | 577 return "closed"; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 // Update the channel count mode. | 770 // Update the channel count mode. |
| 762 updateChangedChannelCountMode(); | 771 updateChangedChannelCountMode(); |
| 763 | 772 |
| 764 // Fixup the state of any dirty AudioSummingJunctions and AudioNodeOutpu
ts. | 773 // Fixup the state of any dirty AudioSummingJunctions and AudioNodeOutpu
ts. |
| 765 handleDirtyAudioSummingJunctions(); | 774 handleDirtyAudioSummingJunctions(); |
| 766 handleDirtyAudioNodeOutputs(); | 775 handleDirtyAudioNodeOutputs(); |
| 767 | 776 |
| 768 updateAutomaticPullNodes(); | 777 updateAutomaticPullNodes(); |
| 769 resolvePromisesForResume(); | 778 resolvePromisesForResume(); |
| 770 | 779 |
| 780 // Update the cached sample frame value. |
| 781 m_cachedSampleFrame = currentSampleFrame(); |
| 782 |
| 771 unlock(); | 783 unlock(); |
| 772 } | 784 } |
| 773 } | 785 } |
| 774 | 786 |
| 775 void AudioContext::handlePostRenderTasks() | 787 void AudioContext::handlePostRenderTasks() |
| 776 { | 788 { |
| 777 ASSERT(isAudioThread()); | 789 ASSERT(isAudioThread()); |
| 778 | 790 |
| 779 // Must use a tryLock() here too. Don't worry, the lock will very rarely be
contended and this method is called frequently. | 791 // Must use a tryLock() here too. Don't worry, the lock will very rarely be
contended and this method is called frequently. |
| 780 // 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 | 792 // 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 | 1125 |
| 1114 for (HashSet<AudioNode*>::iterator k = m_deferredCountModeChange.begin(); k
!= m_deferredCountModeChange.end(); ++k) | 1126 for (HashSet<AudioNode*>::iterator k = m_deferredCountModeChange.begin(); k
!= m_deferredCountModeChange.end(); ++k) |
| 1115 (*k)->updateChannelCountMode(); | 1127 (*k)->updateChannelCountMode(); |
| 1116 | 1128 |
| 1117 m_deferredCountModeChange.clear(); | 1129 m_deferredCountModeChange.clear(); |
| 1118 } | 1130 } |
| 1119 | 1131 |
| 1120 } // namespace blink | 1132 } // namespace blink |
| 1121 | 1133 |
| 1122 #endif // ENABLE(WEB_AUDIO) | 1134 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |