Flutter Engine
The Flutter Engine
SkAudioPlayer.cpp
Go to the documentation of this file.
1/*
2* Copyright 2020 Google Inc.
3*
4* Use of this source code is governed by a BSD-style license that can be
5* found in the LICENSE file.
6*/
7
9#include <algorithm>
10#include <cmath>
11
13
14double SkAudioPlayer::setTime(double t) {
15 t = std::min(std::max(t, 0.0), this->duration());
16 if (!std::isfinite(t)) {
17 t = this->time();
18 }
19 if (t != this->time()) {
20 t = this->onSetTime(t);
21 }
22 return t;
23}
24
26 this->setTime(t * this->duration());
27 return this->normalizedTime();
28}
29
31 if (s != fState) {
32 fState = this->onSetState(s);
33 }
34 return fState;
35}
36
37float SkAudioPlayer::setRate(float r) {
38 r = std::min(std::max(r, 0.f), 1.f);
39 if (!std::isfinite(r)) {
40 r = fRate;
41 }
42 if (r != fRate) {
43 fRate = this->onSetRate(r);
44 }
45 return fRate;
46}
47
49 v = std::min(std::max(v, 0.f), 1.f);
50 if (!std::isfinite(v)) {
51 v = fVolume;
52 }
53 if (v != fVolume) {
54 fVolume = this->onSetVolume(v);
55 }
56 return fVolume;
57}
virtual double onSetTime(double)=0
float setVolume(float)
float setRate(float)
virtual ~SkAudioPlayer()
double time() const
Definition: SkAudioPlayer.h:21
double setTime(double)
double normalizedTime() const
Definition: SkAudioPlayer.h:24
double duration() const
Definition: SkAudioPlayer.h:20
virtual float onSetVolume(float)=0
State setState(State)
virtual State onSetState(State)=0
virtual float onSetRate(float)=0
double setNormalizedTime(double t)
struct MyStruct s
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48
SINT bool isfinite(const Vec< N, T > &v)
Definition: SkVx.h:1003