| 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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 (m_channelCountMode != Max) | 568 if (m_channelCountMode != 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 ChannelCountMode oldMode = m_channelCountMode; | 589 ChannelCountMode oldMode = m_channelCountMode; |
| 590 | 590 |
| 591 if (mode == "clamped-max") { | 591 if (mode == "clamped-max") { |
| 592 m_newChannelCountMode = ClampedMax; | 592 m_newChannelCountMode = ClampedMax; |
| 593 } else if (mode == "explicit") { | 593 } else if (mode == "explicit") { |
| 594 m_newChannelCountMode = Explicit; | 594 m_newChannelCountMode = Explicit; |
| 595 } else if (mode == "max") { | 595 } else if (mode == "max") { |
| 596 // This is not supported for a PannerNode, which can only handle 1 or 2
channels. | 596 // 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... |
| 776 visitor->trace(m_positionZ); | 776 visitor->trace(m_positionZ); |
| 777 | 777 |
| 778 visitor->trace(m_orientationX); | 778 visitor->trace(m_orientationX); |
| 779 visitor->trace(m_orientationY); | 779 visitor->trace(m_orientationY); |
| 780 visitor->trace(m_orientationZ); | 780 visitor->trace(m_orientationZ); |
| 781 | 781 |
| 782 AudioNode::trace(visitor); | 782 AudioNode::trace(visitor); |
| 783 } | 783 } |
| 784 | 784 |
| 785 } // namespace blink | 785 } // namespace blink |
| OLD | NEW |