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

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: Rebase Created 4 years, 4 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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 { 507 {
508 double listenerDistance = position.distanceTo(listenerPosition); 508 double listenerDistance = position.distanceTo(listenerPosition);
509 double distanceGain = m_distanceEffect.gain(listenerDistance); 509 double distanceGain = m_distanceEffect.gain(listenerDistance);
510 double coneGain = m_coneEffect.gain(position, orientation, listenerPosition) ; 510 double coneGain = m_coneEffect.gain(position, orientation, listenerPosition) ;
511 511
512 return float(distanceGain * coneGain); 512 return float(distanceGain * coneGain);
513 } 513 }
514 514
515 void PannerHandler::azimuthElevation(double* outAzimuth, double* outElevation) 515 void PannerHandler::azimuthElevation(double* outAzimuth, double* outElevation)
516 { 516 {
517 ASSERT(context()->isAudioThread()); 517 DCHECK(context()->isAudioThread());
518 518
519 // Calculate new azimuth and elevation if the panner or the listener changed 519 // Calculate new azimuth and elevation if the panner or the listener changed
520 // position or orientation in any way. 520 // position or orientation in any way.
521 if (isAzimuthElevationDirty() || listener()->isListenerDirty()) { 521 if (isAzimuthElevationDirty() || listener()->isListenerDirty()) {
522 calculateAzimuthElevation( 522 calculateAzimuthElevation(
523 &m_cachedAzimuth, 523 &m_cachedAzimuth,
524 &m_cachedElevation, 524 &m_cachedElevation,
525 position(), 525 position(),
526 listener()->position(), 526 listener()->position(),
527 listener()->orientation(), 527 listener()->orientation(),
528 listener()->upVector()); 528 listener()->upVector());
529 m_isAzimuthElevationDirty = false; 529 m_isAzimuthElevationDirty = false;
530 } 530 }
531 531
532 *outAzimuth = m_cachedAzimuth; 532 *outAzimuth = m_cachedAzimuth;
533 *outElevation = m_cachedElevation; 533 *outElevation = m_cachedElevation;
534 } 534 }
535 535
536 float PannerHandler::distanceConeGain() 536 float PannerHandler::distanceConeGain()
537 { 537 {
538 ASSERT(context()->isAudioThread()); 538 DCHECK(context()->isAudioThread());
539 539
540 // Calculate new distance and cone gain if the panner or the listener 540 // Calculate new distance and cone gain if the panner or the listener
541 // changed position or orientation in any way. 541 // changed position or orientation in any way.
542 if (isDistanceConeGainDirty() || listener()->isListenerDirty()) { 542 if (isDistanceConeGainDirty() || listener()->isListenerDirty()) {
543 m_cachedDistanceConeGain = calculateDistanceConeGain(position(), orienta tion(), listener()->position()); 543 m_cachedDistanceConeGain = calculateDistanceConeGain(position(), orienta tion(), listener()->position());
544 m_isDistanceConeGainDirty = false; 544 m_isDistanceConeGainDirty = false;
545 } 545 }
546 546
547 return m_cachedDistanceConeGain; 547 return m_cachedDistanceConeGain;
548 } 548 }
549 549
550 void PannerHandler::markPannerAsDirty(unsigned dirty) 550 void PannerHandler::markPannerAsDirty(unsigned dirty)
551 { 551 {
552 if (dirty & PannerHandler::AzimuthElevationDirty) 552 if (dirty & PannerHandler::AzimuthElevationDirty)
553 m_isAzimuthElevationDirty = true; 553 m_isAzimuthElevationDirty = true;
554 554
555 if (dirty & PannerHandler::DistanceConeGainDirty) 555 if (dirty & PannerHandler::DistanceConeGainDirty)
556 m_isDistanceConeGainDirty = true; 556 m_isDistanceConeGainDirty = true;
557 } 557 }
558 558
559 void PannerHandler::setChannelCount(unsigned long channelCount, ExceptionState& exceptionState) 559 void PannerHandler::setChannelCount(unsigned long channelCount, ExceptionState& exceptionState)
560 { 560 {
561 ASSERT(isMainThread()); 561 DCHECK(isMainThread());
562 BaseAudioContext::AutoLocker locker(context()); 562 BaseAudioContext::AutoLocker locker(context());
563 563
564 // A PannerNode only supports 1 or 2 channels 564 // A PannerNode only supports 1 or 2 channels
565 if (channelCount > 0 && channelCount <= 2) { 565 if (channelCount > 0 && channelCount <= 2) {
566 if (m_channelCount != channelCount) { 566 if (m_channelCount != channelCount) {
567 m_channelCount = channelCount; 567 m_channelCount = channelCount;
568 if (internalChannelCountMode() != Max) 568 if (internalChannelCountMode() != Max)
569 updateChannelsForInputs(); 569 updateChannelsForInputs();
570 } 570 }
571 } else { 571 } else {
572 exceptionState.throwDOMException( 572 exceptionState.throwDOMException(
573 NotSupportedError, 573 NotSupportedError,
574 ExceptionMessages::indexOutsideRange<unsigned long>( 574 ExceptionMessages::indexOutsideRange<unsigned long>(
575 "channelCount", 575 "channelCount",
576 channelCount, 576 channelCount,
577 1, 577 1,
578 ExceptionMessages::InclusiveBound, 578 ExceptionMessages::InclusiveBound,
579 2, 579 2,
580 ExceptionMessages::InclusiveBound)); 580 ExceptionMessages::InclusiveBound));
581 } 581 }
582 } 582 }
583 583
584 void PannerHandler::setChannelCountMode(const String& mode, ExceptionState& exce ptionState) 584 void PannerHandler::setChannelCountMode(const String& mode, ExceptionState& exce ptionState)
585 { 585 {
586 ASSERT(isMainThread()); 586 DCHECK(isMainThread());
587 BaseAudioContext::AutoLocker locker(context()); 587 BaseAudioContext::AutoLocker locker(context());
588 588
589 if (mode == "clamped-max") { 589 if (mode == "clamped-max") {
590 setInternalChannelCountMode(ClampedMax); 590 setInternalChannelCountMode(ClampedMax);
591 } else if (mode == "explicit") { 591 } else if (mode == "explicit") {
592 setInternalChannelCountMode(Explicit); 592 setInternalChannelCountMode(Explicit);
593 } else if (mode == "max") { 593 } else if (mode == "max") {
594 // This is not supported for a PannerNode, which can only handle 1 or 2 channels. 594 // This is not supported for a PannerNode, which can only handle 1 or 2 channels.
595 exceptionState.throwDOMException( 595 exceptionState.throwDOMException(
596 NotSupportedError, 596 NotSupportedError,
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 visitor->trace(m_positionZ); 767 visitor->trace(m_positionZ);
768 768
769 visitor->trace(m_orientationX); 769 visitor->trace(m_orientationX);
770 visitor->trace(m_orientationY); 770 visitor->trace(m_orientationY);
771 visitor->trace(m_orientationZ); 771 visitor->trace(m_orientationZ);
772 772
773 AudioNode::trace(visitor); 773 AudioNode::trace(visitor);
774 } 774 }
775 775
776 } // namespace blink 776 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698