mirror of
https://github.com/rive-app/rive-flutter
synced 2025-06-22 01:55:59 +00:00
Fix audio overlap
Also fixes some warnings from the flutter runtime. Diffs= 5d10f615b Fix audio overlap (#6979) Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
This commit is contained in:
@ -1 +1 @@
|
||||
6837ee0f71109d0eee0f35ceb2326cf50325432b
|
||||
5d10f615b6501e8cff88e0b2aca49c99ae22e5bb
|
||||
|
@ -8,7 +8,6 @@ analyzer:
|
||||
linter:
|
||||
rules:
|
||||
- always_put_required_named_parameters_first
|
||||
- always_require_non_null_named_parameters
|
||||
- annotate_overrides
|
||||
# - avoid_annotating_with_dynamic
|
||||
- avoid_bool_literals_in_conditional_expressions
|
||||
@ -24,8 +23,6 @@ linter:
|
||||
- avoid_null_checks_in_equality_operators
|
||||
- avoid_relative_lib_imports
|
||||
- avoid_return_types_on_setters
|
||||
- avoid_returning_null
|
||||
- avoid_returning_null_for_future
|
||||
- avoid_returning_null_for_void
|
||||
- avoid_returning_this
|
||||
- avoid_setters_without_getters
|
||||
|
@ -52,14 +52,23 @@ class AudioPlayer {
|
||||
|
||||
isPlaying.value = true;
|
||||
|
||||
var sound = engine.play(source, engineTime, 0,
|
||||
var sound = engine.play(
|
||||
source,
|
||||
engineTime,
|
||||
endTime == null
|
||||
? 0
|
||||
: (engineTime +
|
||||
(endTime - startTime).inMicroseconds *
|
||||
1e-6 *
|
||||
engine.sampleRate)
|
||||
.round(),
|
||||
(startTime.inMicroseconds * 1e-6 * engine.sampleRate).round());
|
||||
_sounds.add(sound);
|
||||
_soundDuration = source.duration;
|
||||
_soundStartTime = engineTime -
|
||||
(startTime.inMicroseconds * 1e-6 * engine.sampleRate).round();
|
||||
_soundEndTime = endTime;
|
||||
_timer = Timer.periodic(const Duration(milliseconds: 0), _frameCallback);
|
||||
_timer ??= Timer.periodic(const Duration(milliseconds: 0), _frameCallback);
|
||||
}
|
||||
|
||||
bool playSource(AudioAsset? audio) {
|
||||
|
@ -40,9 +40,6 @@ abstract class Drawable extends DrawableBase {
|
||||
@override
|
||||
void blendModeValueChanged(int from, int to) {}
|
||||
|
||||
@override
|
||||
void isTargetOpaqueChanged(bool from, bool to) {}
|
||||
|
||||
List<ClippingShape> _clippingShapes = [];
|
||||
|
||||
bool clip(Canvas canvas) {
|
||||
|
@ -326,7 +326,4 @@ class LayoutComponentStyle extends LayoutComponentStyleBase {
|
||||
|
||||
@override
|
||||
void update(int dirt) {}
|
||||
|
||||
@override
|
||||
String get defaultName => 'Layout Style';
|
||||
}
|
||||
|
@ -308,70 +308,4 @@ class LayoutComponent extends LayoutComponentBase {
|
||||
super.buildDependencies();
|
||||
parent?.addDependent(this);
|
||||
}
|
||||
|
||||
@override
|
||||
String get defaultName => 'Layout Component';
|
||||
}
|
||||
|
||||
Mat2D _computeAlignment(
|
||||
BoxFit fit, Alignment alignment, AABB frame, AABB content) {
|
||||
double contentWidth = content[2] - content[0];
|
||||
double contentHeight = content[3] - content[1];
|
||||
|
||||
if (contentWidth == 0 || contentHeight == 0) {
|
||||
return Mat2D();
|
||||
}
|
||||
|
||||
double x =
|
||||
-1 * content[0] - contentWidth / 2.0 - (alignment.x * contentWidth / 2.0);
|
||||
double y = -1 * content[1] -
|
||||
contentHeight / 2.0 -
|
||||
(alignment.y * contentHeight / 2.0);
|
||||
|
||||
double scaleX = 1.0, scaleY = 1.0;
|
||||
|
||||
switch (fit) {
|
||||
case BoxFit.fill:
|
||||
scaleX = frame.width / contentWidth;
|
||||
scaleY = frame.height / contentHeight;
|
||||
break;
|
||||
case BoxFit.contain:
|
||||
double minScale =
|
||||
min(frame.width / contentWidth, frame.height / contentHeight);
|
||||
scaleX = scaleY = minScale;
|
||||
break;
|
||||
case BoxFit.cover:
|
||||
double maxScale =
|
||||
max(frame.width / contentWidth, frame.height / contentHeight);
|
||||
scaleX = scaleY = maxScale;
|
||||
break;
|
||||
case BoxFit.fitHeight:
|
||||
double minScale = frame.height / contentHeight;
|
||||
scaleX = scaleY = minScale;
|
||||
break;
|
||||
case BoxFit.fitWidth:
|
||||
double minScale = frame.width / contentWidth;
|
||||
scaleX = scaleY = minScale;
|
||||
break;
|
||||
case BoxFit.none:
|
||||
scaleX = scaleY = 1.0;
|
||||
break;
|
||||
case BoxFit.scaleDown:
|
||||
double minScale =
|
||||
min(frame.width / contentWidth, frame.height / contentHeight);
|
||||
scaleX = scaleY = minScale < 1.0 ? minScale : 1.0;
|
||||
break;
|
||||
}
|
||||
|
||||
Mat2D translation = Mat2D();
|
||||
|
||||
translation[4] =
|
||||
frame[0] + frame.width / 2.0 + (alignment.x * frame.width / 2.0);
|
||||
translation[5] =
|
||||
frame[1] + frame.height / 2.0 + (alignment.y * frame.height / 2.0);
|
||||
|
||||
return Mat2D.multiply(
|
||||
Mat2D(),
|
||||
Mat2D.multiply(Mat2D(), translation, Mat2D.fromScale(scaleX, scaleY)),
|
||||
Mat2D.fromTranslate(x, y));
|
||||
}
|
||||
|
@ -100,14 +100,14 @@ class PathComposer extends Component {
|
||||
artboard?.onComponentDirty(this);
|
||||
}
|
||||
|
||||
// Instead of adding dirt and rely on the recursive behavior of the addDirt method,
|
||||
// we need to explicitly add dirt to the dependents. The reason is that a collapsed
|
||||
// shape will not clear its dirty path flag in the current frame since it is collapsed.
|
||||
// So in a future frame if it is uncollapsed, we mark its path flag as dirty again,
|
||||
// but since it was already dirty, the recursive part will not kick in and the dependents
|
||||
// won't update.
|
||||
// This scenario is not common, but it can happen when a solo toggles between an empty
|
||||
// group and a path for example.
|
||||
// Instead of adding dirt and rely on the recursive behavior of the addDirt
|
||||
// method, we need to explicitly add dirt to the dependents. The reason is
|
||||
// that a collapsed shape will not clear its dirty path flag in the current
|
||||
// frame since it is collapsed. So in a future frame if it is uncollapsed, we
|
||||
// mark its path flag as dirty again, but since it was already dirty, the
|
||||
// recursive part will not kick in and the dependents won't update. This
|
||||
// scenario is not common, but it can happen when a solo toggles between an
|
||||
// empty group and a path for example.
|
||||
void pathCollapseChanged() {
|
||||
addDirt(ComponentDirt.path);
|
||||
for (final d in dependents) {
|
||||
|
Reference in New Issue
Block a user