| 208 | } |
| 209 | |
| 210 | void AudioNodeScheduler::start(double when) |
| 211 | { |
| 212 | // irrespective of start state, onStart will be called if possible |
| 213 | // to allow a node to use subsequent starts as a hint |
| 214 | if (_onStart) |
| 215 | _onStart(when); |
| 216 | |
| 217 | // if already scheduled or playing, nothing to do |
| 218 | if (_playbackState == SchedulingState::SCHEDULED || _playbackState == SchedulingState::PLAYING) |
| 219 | return; |
| 220 | |
| 221 | // start cancels stop |
| 222 | _stopWhen = std::numeric_limits<uint64_t>::max(); |
| 223 | |
| 224 | // treat non finite, or max values as a cancellation of stopping or resetting |
| 225 | if (!isfinite(when) || when == std::numeric_limits<double>::max()) |
| 226 | { |
| 227 | if (_playbackState == SchedulingState::STOPPING || _playbackState == SchedulingState::RESETTING) |
| 228 | { |
| 229 | _playbackState = SchedulingState::PLAYING; |
| 230 | } |
| 231 | return; |
| 232 | } |
| 233 | |
| 234 | _startWhen = _epoch + static_cast<uint64_t>(when * _sampleRate); |
| 235 | _playbackState = SchedulingState::SCHEDULED; |
| 236 | } |
| 237 | |
| 238 | void AudioNodeScheduler::stop(double when) |
| 239 | { |
no outgoing calls
no test coverage detected