Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/BaseAudioContext.cpp

Issue 2717613007: Set "Running" state only when actually running (Closed)
Patch Set: State must be set AFTER startRendering(). Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/BaseAudioContext.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 763
764 void BaseAudioContext::resolvePromisesForResumeOnMainThread() { 764 void BaseAudioContext::resolvePromisesForResumeOnMainThread() {
765 DCHECK(isMainThread()); 765 DCHECK(isMainThread());
766 AutoLocker locker(this); 766 AutoLocker locker(this);
767 767
768 for (auto& resolver : m_resumeResolvers) { 768 for (auto& resolver : m_resumeResolvers) {
769 if (m_contextState == Closed) { 769 if (m_contextState == Closed) {
770 resolver->reject(DOMException::create( 770 resolver->reject(DOMException::create(
771 InvalidStateError, "Cannot resume a context that has been closed")); 771 InvalidStateError, "Cannot resume a context that has been closed"));
772 } else { 772 } else {
773 setContextState(Running);
773 resolver->resolve(); 774 resolver->resolve();
774 } 775 }
775 } 776 }
776 777
777 m_resumeResolvers.clear(); 778 m_resumeResolvers.clear();
778 m_isResolvingResumePromises = false; 779 m_isResolvingResumePromises = false;
779 } 780 }
780 781
781 void BaseAudioContext::resolvePromisesForResume() { 782 void BaseAudioContext::resolvePromisesForResume() {
782 // This runs inside the BaseAudioContext's lock when handling pre-render 783 // This runs inside the BaseAudioContext's lock when handling pre-render
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 865
865 const AtomicString& BaseAudioContext::interfaceName() const { 866 const AtomicString& BaseAudioContext::interfaceName() const {
866 return EventTargetNames::AudioContext; 867 return EventTargetNames::AudioContext;
867 } 868 }
868 869
869 ExecutionContext* BaseAudioContext::getExecutionContext() const { 870 ExecutionContext* BaseAudioContext::getExecutionContext() const {
870 return SuspendableObject::getExecutionContext(); 871 return SuspendableObject::getExecutionContext();
871 } 872 }
872 873
873 void BaseAudioContext::startRendering() { 874 void BaseAudioContext::startRendering() {
874 // This is called for both online and offline contexts. 875 // This is called for both online and offline contexts. The caller
876 // must set the context state appropriately. In particular, resuming
877 // a context should wait until the context has actually resumed to
878 // set the state.
875 DCHECK(isMainThread()); 879 DCHECK(isMainThread());
876 DCHECK(m_destinationNode); 880 DCHECK(m_destinationNode);
877 DCHECK(isAllowedToStart()); 881 DCHECK(isAllowedToStart());
878 882
879 if (m_contextState == Suspended) { 883 if (m_contextState == Suspended) {
880 destination()->audioDestinationHandler().startRendering(); 884 destination()->audioDestinationHandler().startRendering();
881 setContextState(Running);
882 } 885 }
883 } 886 }
884 887
885 DEFINE_TRACE(BaseAudioContext) { 888 DEFINE_TRACE(BaseAudioContext) {
886 visitor->trace(m_destinationNode); 889 visitor->trace(m_destinationNode);
887 visitor->trace(m_listener); 890 visitor->trace(m_listener);
888 visitor->trace(m_activeSourceNodes); 891 visitor->trace(m_activeSourceNodes);
889 visitor->trace(m_resumeResolvers); 892 visitor->trace(m_resumeResolvers);
890 visitor->trace(m_decodeAudioResolvers); 893 visitor->trace(m_decodeAudioResolvers);
891 894
892 visitor->trace(m_periodicWaveSine); 895 visitor->trace(m_periodicWaveSine);
893 visitor->trace(m_periodicWaveSquare); 896 visitor->trace(m_periodicWaveSquare);
894 visitor->trace(m_periodicWaveSawtooth); 897 visitor->trace(m_periodicWaveSawtooth);
895 visitor->trace(m_periodicWaveTriangle); 898 visitor->trace(m_periodicWaveTriangle);
896 EventTargetWithInlineData::trace(visitor); 899 EventTargetWithInlineData::trace(visitor);
897 SuspendableObject::trace(visitor); 900 SuspendableObject::trace(visitor);
898 } 901 }
899 902
900 SecurityOrigin* BaseAudioContext::getSecurityOrigin() const { 903 SecurityOrigin* BaseAudioContext::getSecurityOrigin() const {
901 if (getExecutionContext()) 904 if (getExecutionContext())
902 return getExecutionContext()->getSecurityOrigin(); 905 return getExecutionContext()->getSecurityOrigin();
903 906
904 return nullptr; 907 return nullptr;
905 } 908 }
906 909
907 } // namespace blink 910 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/BaseAudioContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698