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

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

Issue 2159403002: Replace ASSERT with DCHECK in WebAudio (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 { 511 {
512 double listenerDistance = position.distanceTo(listenerPosition); 512 double listenerDistance = position.distanceTo(listenerPosition);
513 double distanceGain = m_distanceEffect.gain(listenerDistance); 513 double distanceGain = m_distanceEffect.gain(listenerDistance);
514 double coneGain = m_coneEffect.gain(position, orientation, listenerPosition) ; 514 double coneGain = m_coneEffect.gain(position, orientation, listenerPosition) ;
515 515
516 return float(distanceGain * coneGain); 516 return float(distanceGain * coneGain);
517 } 517 }
518 518
519 void PannerHandler::azimuthElevation(double* outAzimuth, double* outElevation) 519 void PannerHandler::azimuthElevation(double* outAzimuth, double* outElevation)
520 { 520 {
521 ASSERT(context()->isAudioThread()); 521 DCHECK(context()->isAudioThread());
522 522
523 // Calculate new azimuth and elevation if the panner or the listener changed 523 // Calculate new azimuth and elevation if the panner or the listener changed
524 // position or orientation in any way. 524 // position or orientation in any way.
525 if (isAzimuthElevationDirty() || listener()->isListenerDirty()) { 525 if (isAzimuthElevationDirty() || listener()->isListenerDirty()) {
526 calculateAzimuthElevation( 526 calculateAzimuthElevation(
527 &m_cachedAzimuth, 527 &m_cachedAzimuth,
528 &m_cachedElevation, 528 &m_cachedElevation,
529 position(), 529 position(),
530 listener()->position(), 530 listener()->position(),
531 listener()->orientation(), 531 listener()->orientation(),
532 listener()->upVector()); 532 listener()->upVector());
533 m_isAzimuthElevationDirty = false; 533 m_isAzimuthElevationDirty = false;
534 } 534 }
535 535
536 *outAzimuth = m_cachedAzimuth; 536 *outAzimuth = m_cachedAzimuth;
537 *outElevation = m_cachedElevation; 537 *outElevation = m_cachedElevation;
538 } 538 }
539 539
540 float PannerHandler::distanceConeGain() 540 float PannerHandler::distanceConeGain()
541 { 541 {
542 ASSERT(context()->isAudioThread()); 542 DCHECK(context()->isAudioThread());
543 543
544 // Calculate new distance and cone gain if the panner or the listener 544 // Calculate new distance and cone gain if the panner or the listener
545 // changed position or orientation in any way. 545 // changed position or orientation in any way.
546 if (isDistanceConeGainDirty() || listener()->isListenerDirty()) { 546 if (isDistanceConeGainDirty() || listener()->isListenerDirty()) {
547 m_cachedDistanceConeGain = calculateDistanceConeGain(position(), orienta tion(), listener()->position()); 547 m_cachedDistanceConeGain = calculateDistanceConeGain(position(), orienta tion(), listener()->position());
548 m_isDistanceConeGainDirty = false; 548 m_isDistanceConeGainDirty = false;
549 } 549 }
550 550
551 return m_cachedDistanceConeGain; 551 return m_cachedDistanceConeGain;
552 } 552 }
553 553
554 void PannerHandler::markPannerAsDirty(unsigned dirty) 554 void PannerHandler::markPannerAsDirty(unsigned dirty)
555 { 555 {
556 if (dirty & PannerHandler::AzimuthElevationDirty) 556 if (dirty & PannerHandler::AzimuthElevationDirty)
557 m_isAzimuthElevationDirty = true; 557 m_isAzimuthElevationDirty = true;
558 558
559 if (dirty & PannerHandler::DistanceConeGainDirty) 559 if (dirty & PannerHandler::DistanceConeGainDirty)
560 m_isDistanceConeGainDirty = true; 560 m_isDistanceConeGainDirty = true;
561 } 561 }
562 562
563 void PannerHandler::setChannelCount(unsigned long channelCount, ExceptionState& exceptionState) 563 void PannerHandler::setChannelCount(unsigned long channelCount, ExceptionState& exceptionState)
564 { 564 {
565 ASSERT(isMainThread()); 565 DCHECK(isMainThread());
566 AbstractAudioContext::AutoLocker locker(context()); 566 AbstractAudioContext::AutoLocker locker(context());
567 567
568 // A PannerNode only supports 1 or 2 channels 568 // A PannerNode only supports 1 or 2 channels
569 if (channelCount > 0 && channelCount <= 2) { 569 if (channelCount > 0 && channelCount <= 2) {
570 if (m_channelCount != channelCount) { 570 if (m_channelCount != channelCount) {
571 m_channelCount = channelCount; 571 m_channelCount = channelCount;
572 if (m_channelCountMode != Max) 572 if (m_channelCountMode != Max)
573 updateChannelsForInputs(); 573 updateChannelsForInputs();
574 } 574 }
575 } else { 575 } else {
576 exceptionState.throwDOMException( 576 exceptionState.throwDOMException(
577 NotSupportedError, 577 NotSupportedError,
578 ExceptionMessages::indexOutsideRange<unsigned long>( 578 ExceptionMessages::indexOutsideRange<unsigned long>(
579 "channelCount", 579 "channelCount",
580 channelCount, 580 channelCount,
581 1, 581 1,
582 ExceptionMessages::InclusiveBound, 582 ExceptionMessages::InclusiveBound,
583 2, 583 2,
584 ExceptionMessages::InclusiveBound)); 584 ExceptionMessages::InclusiveBound));
585 } 585 }
586 } 586 }
587 587
588 void PannerHandler::setChannelCountMode(const String& mode, ExceptionState& exce ptionState) 588 void PannerHandler::setChannelCountMode(const String& mode, ExceptionState& exce ptionState)
589 { 589 {
590 ASSERT(isMainThread()); 590 DCHECK(isMainThread());
591 AbstractAudioContext::AutoLocker locker(context()); 591 AbstractAudioContext::AutoLocker locker(context());
592 592
593 ChannelCountMode oldMode = m_channelCountMode; 593 ChannelCountMode oldMode = m_channelCountMode;
594 594
595 if (mode == "clamped-max") { 595 if (mode == "clamped-max") {
596 m_newChannelCountMode = ClampedMax; 596 m_newChannelCountMode = ClampedMax;
597 } else if (mode == "explicit") { 597 } else if (mode == "explicit") {
598 m_newChannelCountMode = Explicit; 598 m_newChannelCountMode = Explicit;
599 } else if (mode == "max") { 599 } else if (mode == "max") {
600 // This is not supported for a PannerNode, which can only handle 1 or 2 channels. 600 // This is not supported for a PannerNode, which can only handle 1 or 2 channels.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 visitor->trace(m_positionZ); 780 visitor->trace(m_positionZ);
781 781
782 visitor->trace(m_orientationX); 782 visitor->trace(m_orientationX);
783 visitor->trace(m_orientationY); 783 visitor->trace(m_orientationY);
784 visitor->trace(m_orientationZ); 784 visitor->trace(m_orientationZ);
785 785
786 AudioNode::trace(visitor); 786 AudioNode::trace(visitor);
787 } 787 }
788 788
789 } // namespace blink 789 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698