| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 float sampleRate) | 43 float sampleRate) |
| 44 : AudioHandler(nodeType, node, sampleRate), | 44 : AudioHandler(nodeType, node, sampleRate), |
| 45 m_startTime(0), | 45 m_startTime(0), |
| 46 m_endTime(UnknownTime), | 46 m_endTime(UnknownTime), |
| 47 m_playbackState(UNSCHEDULED_STATE) {} | 47 m_playbackState(UNSCHEDULED_STATE) {} |
| 48 | 48 |
| 49 void AudioScheduledSourceHandler::updateSchedulingInfo( | 49 void AudioScheduledSourceHandler::updateSchedulingInfo( |
| 50 size_t quantumFrameSize, | 50 size_t quantumFrameSize, |
| 51 AudioBus* outputBus, | 51 AudioBus* outputBus, |
| 52 size_t& quantumFrameOffset, | 52 size_t& quantumFrameOffset, |
| 53 size_t& nonSilentFramesToProcess, | 53 size_t& nonSilentFramesToProcess) { |
| 54 double& startFrameOffset) { | |
| 55 DCHECK(outputBus); | 54 DCHECK(outputBus); |
| 56 if (!outputBus) | 55 if (!outputBus) |
| 57 return; | 56 return; |
| 58 | 57 |
| 59 DCHECK_EQ(quantumFrameSize, | 58 DCHECK_EQ(quantumFrameSize, |
| 60 static_cast<size_t>(AudioUtilities::kRenderQuantumFrames)); | 59 static_cast<size_t>(AudioUtilities::kRenderQuantumFrames)); |
| 61 if (quantumFrameSize != AudioUtilities::kRenderQuantumFrames) | 60 if (quantumFrameSize != AudioUtilities::kRenderQuantumFrames) |
| 62 return; | 61 return; |
| 63 | 62 |
| 64 double sampleRate = this->sampleRate(); | 63 double sampleRate = this->sampleRate(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 88 outputBus->zero(); | 87 outputBus->zero(); |
| 89 nonSilentFramesToProcess = 0; | 88 nonSilentFramesToProcess = 0; |
| 90 return; | 89 return; |
| 91 } | 90 } |
| 92 | 91 |
| 93 // Check if it's time to start playing. | 92 // Check if it's time to start playing. |
| 94 if (state == SCHEDULED_STATE) { | 93 if (state == SCHEDULED_STATE) { |
| 95 // Increment the active source count only if we're transitioning from | 94 // Increment the active source count only if we're transitioning from |
| 96 // SCHEDULED_STATE to PLAYING_STATE. | 95 // SCHEDULED_STATE to PLAYING_STATE. |
| 97 setPlaybackState(PLAYING_STATE); | 96 setPlaybackState(PLAYING_STATE); |
| 98 // Determine the offset of the true start time from the starting frame. | |
| 99 startFrameOffset = m_startTime * sampleRate - startFrame; | |
| 100 } else { | |
| 101 startFrameOffset = 0; | |
| 102 } | 97 } |
| 103 | 98 |
| 104 quantumFrameOffset = | 99 quantumFrameOffset = |
| 105 startFrame > quantumStartFrame ? startFrame - quantumStartFrame : 0; | 100 startFrame > quantumStartFrame ? startFrame - quantumStartFrame : 0; |
| 106 quantumFrameOffset = | 101 quantumFrameOffset = |
| 107 std::min(quantumFrameOffset, quantumFrameSize); // clamp to valid range | 102 std::min(quantumFrameOffset, quantumFrameSize); // clamp to valid range |
| 108 nonSilentFramesToProcess = quantumFrameSize - quantumFrameOffset; | 103 nonSilentFramesToProcess = quantumFrameSize - quantumFrameOffset; |
| 109 | 104 |
| 110 if (!nonSilentFramesToProcess) { | 105 if (!nonSilentFramesToProcess) { |
| 111 // Output silence. | 106 // Output silence. |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // playback state if the context is closed. | 275 // playback state if the context is closed. |
| 281 if (context()->isContextClosed()) | 276 if (context()->isContextClosed()) |
| 282 return false; | 277 return false; |
| 283 | 278 |
| 284 // If a node is scheduled or playing, do not collect the node prematurely | 279 // If a node is scheduled or playing, do not collect the node prematurely |
| 285 // even its reference is out of scope. Then fire onended event if assigned. | 280 // even its reference is out of scope. Then fire onended event if assigned. |
| 286 return audioScheduledSourceHandler().isPlayingOrScheduled(); | 281 return audioScheduledSourceHandler().isPlayingOrScheduled(); |
| 287 } | 282 } |
| 288 | 283 |
| 289 } // namespace blink | 284 } // namespace blink |
| OLD | NEW |