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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 // If the source node is not looping, and we have a buffer, we can determine | 598 // If the source node is not looping, and we have a buffer, we can determine |
599 // when the source would stop playing. This is intended to handle the | 599 // when the source would stop playing. This is intended to handle the |
600 // (uncommon) scenario where start() has been called but is never connected to | 600 // (uncommon) scenario where start() has been called but is never connected to |
601 // the destination (directly or indirectly). By stopping the node, the node | 601 // the destination (directly or indirectly). By stopping the node, the node |
602 // can be collected. Otherwise, the node will never get collected, leaking | 602 // can be collected. Otherwise, the node will never get collected, leaking |
603 // memory. | 603 // memory. |
604 // | 604 // |
605 // If looping was ever done (m_didSetLooping = true), give up. We can't | 605 // If looping was ever done (m_didSetLooping = true), give up. We can't |
606 // easily determine how long we looped so we don't know the actual duration | 606 // easily determine how long we looped so we don't know the actual duration |
607 // thus far, so don't try to do anything fancy. | 607 // thus far, so don't try to do anything fancy. |
608 if (!m_didSetLooping && buffer() && isPlayingOrScheduled() && | 608 if (!didSetLooping() && buffer() && isPlayingOrScheduled() && |
609 m_minPlaybackRate > 0) { | 609 m_minPlaybackRate > 0) { |
610 // Adjust the duration to include the playback rate. Only need to account | 610 // Adjust the duration to include the playback rate. Only need to account |
611 // for rate < 1 which makes the sound last longer. For rate >= 1, the | 611 // for rate < 1 which makes the sound last longer. For rate >= 1, the |
612 // source stops sooner, but that's ok. | 612 // source stops sooner, but that's ok. |
613 double actualDuration = buffer()->duration() / m_minPlaybackRate; | 613 double actualDuration = buffer()->duration() / m_minPlaybackRate; |
614 | 614 |
615 double stopTime = m_startTime + actualDuration; | 615 double stopTime = m_startTime + actualDuration; |
616 | 616 |
617 // See crbug.com/478301. If a source node is started via start(), the source | 617 // See crbug.com/478301. If a source node is started via start(), the source |
618 // may not start at that time but one quantum (128 frames) later. But we | 618 // may not start at that time but one quantum (128 frames) later. But we |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 | 754 |
755 void AudioBufferSourceNode::start(double when, | 755 void AudioBufferSourceNode::start(double when, |
756 double grainOffset, | 756 double grainOffset, |
757 double grainDuration, | 757 double grainDuration, |
758 ExceptionState& exceptionState) { | 758 ExceptionState& exceptionState) { |
759 audioBufferSourceHandler().start(when, grainOffset, grainDuration, | 759 audioBufferSourceHandler().start(when, grainOffset, grainDuration, |
760 exceptionState); | 760 exceptionState); |
761 } | 761 } |
762 | 762 |
763 } // namespace blink | 763 } // namespace blink |
OLD | NEW |