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

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

Issue 1952793002: Move the exception logic to the AudioNode creator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 7 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
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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 if (context()->currentTime() > stopTime) { 574 if (context()->currentTime() > stopTime) {
575 // The context time has passed the time when the source nodes should have stopped 575 // The context time has passed the time when the source nodes should have stopped
576 // playing. Stop the node now and deref it. (But don't run the onEnd ed event because the 576 // playing. Stop the node now and deref it. (But don't run the onEnd ed event because the
577 // source never actually played.) 577 // source never actually played.)
578 finishWithoutOnEnded(); 578 finishWithoutOnEnded();
579 } 579 }
580 } 580 }
581 } 581 }
582 582
583 // ---------------------------------------------------------------- 583 // ----------------------------------------------------------------
584 AudioBufferSourceNode::AudioBufferSourceNode(AbstractAudioContext& context, floa t sampleRate) 584 AudioBufferSourceNode::AudioBufferSourceNode(AbstractAudioContext& context)
585 : AudioScheduledSourceNode(context) 585 : AudioScheduledSourceNode(context)
586 , m_playbackRate(AudioParam::create(context, ParamTypeAudioBufferSourcePlayb ackRate, 1.0)) 586 , m_playbackRate(AudioParam::create(context, ParamTypeAudioBufferSourcePlayb ackRate, 1.0))
587 , m_detune(AudioParam::create(context, ParamTypeAudioBufferSourceDetune, 0.0 )) 587 , m_detune(AudioParam::create(context, ParamTypeAudioBufferSourceDetune, 0.0 ))
588 { 588 {
589 setHandler(AudioBufferSourceHandler::create(*this, sampleRate, m_playbackRat e->handler(), m_detune->handler())); 589 setHandler(AudioBufferSourceHandler::create(
590 *this,
591 context.sampleRate(),
592 m_playbackRate->handler(),
593 m_detune->handler()));
590 } 594 }
591 595
592 AudioBufferSourceNode* AudioBufferSourceNode::create(AbstractAudioContext& conte xt, float sampleRate) 596 AudioBufferSourceNode* AudioBufferSourceNode::create(AbstractAudioContext& conte xt, ExceptionState& exceptionState)
593 { 597 {
594 return new AudioBufferSourceNode(context, sampleRate); 598 DCHECK(isMainThread());
599
600 if (context.isContextClosed()) {
601 context.throwExceptionForClosedState(exceptionState);
602 return nullptr;
603 }
604
605 return new AudioBufferSourceNode(context);
595 } 606 }
596 607
597 DEFINE_TRACE(AudioBufferSourceNode) 608 DEFINE_TRACE(AudioBufferSourceNode)
598 { 609 {
599 visitor->trace(m_playbackRate); 610 visitor->trace(m_playbackRate);
600 visitor->trace(m_detune); 611 visitor->trace(m_detune);
601 AudioScheduledSourceNode::trace(visitor); 612 AudioScheduledSourceNode::trace(visitor);
602 } 613 }
603 614
604 AudioBufferSourceHandler& AudioBufferSourceNode::audioBufferSourceHandler() cons t 615 AudioBufferSourceHandler& AudioBufferSourceNode::audioBufferSourceHandler() cons t
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 { 681 {
671 audioBufferSourceHandler().start(when, grainOffset, exceptionState); 682 audioBufferSourceHandler().start(when, grainOffset, exceptionState);
672 } 683 }
673 684
674 void AudioBufferSourceNode::start(double when, double grainOffset, double grainD uration, ExceptionState& exceptionState) 685 void AudioBufferSourceNode::start(double when, double grainOffset, double grainD uration, ExceptionState& exceptionState)
675 { 686 {
676 audioBufferSourceHandler().start(when, grainOffset, grainDuration, exception State); 687 audioBufferSourceHandler().start(when, grainOffset, grainDuration, exception State);
677 } 688 }
678 689
679 } // namespace blink 690 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698