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