Skip to content

Commit 2d08767

Browse files
ChrisCPIkjarosh
authored andcommitted
avm1: Have Sound.getPosition call the same method as position
The only difference between `position` and `get_position` is that `position` only returns it if it has a valid sound handle, which seems to be the correct behavior. In FP, `getPosition` seems to behave the same way as that, but since `get_position` was not reproducing that behavior, it was not entirely correct.
1 parent dd0220b commit 2d08767

4 files changed

Lines changed: 19 additions & 30 deletions

File tree

core/src/avm1/globals/sound.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ const PROTO_DECLS: StaticDeclarations = declare_static_properties! {
337337
"start" => method(start; DONT_ENUM | DONT_DELETE | READ_ONLY);
338338
"getDuration" => method(duration; DONT_ENUM | DONT_DELETE | READ_ONLY | VERSION_6);
339339
"setDuration" => method(set_duration; DONT_ENUM | DONT_DELETE | READ_ONLY | VERSION_6);
340-
"getPosition" => method(get_position; DONT_ENUM | DONT_DELETE | READ_ONLY | VERSION_6);
340+
"getPosition" => method(position; DONT_ENUM | DONT_DELETE | READ_ONLY | VERSION_6);
341341
"setPosition" => method(set_position; DONT_ENUM | DONT_DELETE | READ_ONLY | VERSION_6);
342342
"loadSound" => method(load_sound; DONT_ENUM | DONT_DELETE | READ_ONLY | VERSION_6);
343343
"getBytesLoaded" => method(get_bytes_loaded; DONT_ENUM | DONT_DELETE | READ_ONLY | VERSION_6);
@@ -736,14 +736,3 @@ fn set_position<'gc>(
736736
avm1_stub!(activation, "Sound", "setPosition");
737737
Ok(Value::Undefined)
738738
}
739-
740-
fn get_position<'gc>(
741-
_activation: &mut Activation<'_, 'gc>,
742-
this: Object<'gc>,
743-
_args: &[Value<'gc>],
744-
) -> Result<Value<'gc>, Error<'gc>> {
745-
if let NativeObject::Sound(sound) = this.native() {
746-
return Ok(sound.position().into());
747-
}
748-
Ok(Value::Undefined)
749-
}

tests/tests/swfs/from_gnash/actionscript.all/Sound-v6/output.ruffle.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ PASSED: s1 instanceof Sound [./Sound.as:95]
3333
PASSED: typeof(s1.getDuration()) == 'undefined' [./Sound.as:96]
3434
PASSED: typeof(s1.getPan()) == 'number' [./Sound.as:97]
3535
PASSED: s1.getPan() == 0 [./Sound.as:98]
36-
FAILED: expected: 'undefined' obtained: number [./Sound.as:99]
36+
PASSED: typeof(s1.getPosition()) == 'undefined' [./Sound.as:99]
3737
PASSED: typeof(s1.getTransform()) == 'object' [./Sound.as:100]
3838
PASSED: typeof(s1.getVolume()) == 'number' [./Sound.as:104]
3939
PASSED: s1.getVolume() == 100 [./Sound.as:105]
@@ -49,7 +49,7 @@ PASSED: s2 instanceof Sound [./Sound.as:169]
4949
PASSED: typeof(s2.getDuration()) == 'undefined' [./Sound.as:170]
5050
PASSED: typeof(s2.getPan()) == 'number' [./Sound.as:171]
5151
PASSED: s2.getPan() == 0 [./Sound.as:172]
52-
FAILED: expected: 'undefined' obtained: number [./Sound.as:173]
52+
PASSED: typeof(s2.getPosition()) == 'undefined' [./Sound.as:173]
5353
PASSED: typeof(s2.getTransform()) == 'object' [./Sound.as:174]
5454
PASSED: typeof(s2.getVolume()) == 'number' [./Sound.as:175]
5555
PASSED: s2.getVolume() == 100 [./Sound.as:176]
@@ -98,11 +98,11 @@ PASSED: s3.getVolume() == 80 [./Sound.as:274]
9898
FAILED: expected: "undefined" obtained: number [./Sound.as:336]
9999
FAILED: expected: "undefined" obtained: number [./Sound.as:337]
100100
PASSED: typeof(s.duration) == "undefined" [./Sound.as:338]
101-
FAILED: expected: "undefined" obtained: number [./Sound.as:339]
101+
PASSED: typeof(s.getPosition()) == "undefined" [./Sound.as:339]
102102
PASSED: typeof(s.getDuration()) == "undefined" [./Sound.as:340]
103103
PASSED: typeof(s.getBytesTotal()) == "number" [./Sound.as:345]
104104
PASSED: typeof(s.getBytesLoaded()) == "number" [./Sound.as:346]
105-
PASSED: typeof(s.getPosition()) == "number" [./Sound.as:347]
105+
FAILED: expected: "number" obtained: undefined [./Sound.as:347]
106106
FAILED: expected: "number" obtained: undefined [./Sound.as:348]
107107
FAILED: expected: "number" obtained: undefined [./Sound.as:349]
108108
Waiting 3 seconds for onSoundComplete to be called
@@ -111,6 +111,6 @@ FAILED: expected: 209 obtained: 0 [./Sound.as:328]
111111
PASSED: s.position == 0 [./Sound.as:329]
112112
FAILED: no onSoundComplete arrived after 3 seconds
113113
FAILED: Tests run 107 (expected 112) [ [./Sound.as:31]]
114-
#passed: 71
115-
#failed: 37
114+
#passed: 73
115+
#failed: 35
116116
#total tests run: 108

tests/tests/swfs/from_gnash/actionscript.all/Sound-v7/output.ruffle.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ PASSED: s1 instanceof Sound [./Sound.as:95]
3333
PASSED: typeof(s1.getDuration()) == 'undefined' [./Sound.as:96]
3434
PASSED: typeof(s1.getPan()) == 'number' [./Sound.as:97]
3535
PASSED: s1.getPan() == 0 [./Sound.as:98]
36-
FAILED: expected: 'undefined' obtained: number [./Sound.as:99]
36+
PASSED: typeof(s1.getPosition()) == 'undefined' [./Sound.as:99]
3737
PASSED: typeof(s1.getTransform()) == 'object' [./Sound.as:100]
3838
PASSED: typeof(s1.getVolume()) == 'number' [./Sound.as:104]
3939
PASSED: s1.getVolume() == 100 [./Sound.as:105]
@@ -49,7 +49,7 @@ PASSED: s2 instanceof Sound [./Sound.as:169]
4949
PASSED: typeof(s2.getDuration()) == 'undefined' [./Sound.as:170]
5050
PASSED: typeof(s2.getPan()) == 'number' [./Sound.as:171]
5151
PASSED: s2.getPan() == 0 [./Sound.as:172]
52-
FAILED: expected: 'undefined' obtained: number [./Sound.as:173]
52+
PASSED: typeof(s2.getPosition()) == 'undefined' [./Sound.as:173]
5353
PASSED: typeof(s2.getTransform()) == 'object' [./Sound.as:174]
5454
PASSED: typeof(s2.getVolume()) == 'number' [./Sound.as:175]
5555
PASSED: s2.getVolume() == 100 [./Sound.as:176]
@@ -98,11 +98,11 @@ PASSED: s3.getVolume() == 80 [./Sound.as:274]
9898
FAILED: expected: "undefined" obtained: number [./Sound.as:336]
9999
FAILED: expected: "undefined" obtained: number [./Sound.as:337]
100100
PASSED: typeof(s.duration) == "undefined" [./Sound.as:338]
101-
FAILED: expected: "undefined" obtained: number [./Sound.as:339]
101+
PASSED: typeof(s.getPosition()) == "undefined" [./Sound.as:339]
102102
PASSED: typeof(s.getDuration()) == "undefined" [./Sound.as:340]
103103
PASSED: typeof(s.getBytesTotal()) == "number" [./Sound.as:345]
104104
PASSED: typeof(s.getBytesLoaded()) == "number" [./Sound.as:346]
105-
PASSED: typeof(s.getPosition()) == "number" [./Sound.as:347]
105+
FAILED: expected: "number" obtained: undefined [./Sound.as:347]
106106
FAILED: expected: "number" obtained: undefined [./Sound.as:348]
107107
FAILED: expected: "number" obtained: undefined [./Sound.as:349]
108108
Waiting 3 seconds for onSoundComplete to be called
@@ -111,6 +111,6 @@ FAILED: expected: 209 obtained: 0 [./Sound.as:328]
111111
PASSED: s.position == 0 [./Sound.as:329]
112112
FAILED: no onSoundComplete arrived after 3 seconds
113113
FAILED: Tests run 107 (expected 112) [ [./Sound.as:31]]
114-
#passed: 71
115-
#failed: 37
114+
#passed: 73
115+
#failed: 35
116116
#total tests run: 108

tests/tests/swfs/from_gnash/actionscript.all/Sound-v8/output.ruffle.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ PASSED: s1 instanceof Sound [./Sound.as:95]
3333
PASSED: typeof(s1.getDuration()) == 'undefined' [./Sound.as:96]
3434
PASSED: typeof(s1.getPan()) == 'number' [./Sound.as:97]
3535
PASSED: s1.getPan() == 0 [./Sound.as:98]
36-
FAILED: expected: 'undefined' obtained: number [./Sound.as:99]
36+
PASSED: typeof(s1.getPosition()) == 'undefined' [./Sound.as:99]
3737
PASSED: typeof(s1.getTransform()) == 'object' [./Sound.as:100]
3838
PASSED: typeof(s1.getVolume()) == 'number' [./Sound.as:104]
3939
PASSED: s1.getVolume() == 100 [./Sound.as:105]
@@ -49,7 +49,7 @@ PASSED: s2 instanceof Sound [./Sound.as:169]
4949
PASSED: typeof(s2.getDuration()) == 'undefined' [./Sound.as:170]
5050
PASSED: typeof(s2.getPan()) == 'number' [./Sound.as:171]
5151
PASSED: s2.getPan() == 0 [./Sound.as:172]
52-
FAILED: expected: 'undefined' obtained: number [./Sound.as:173]
52+
PASSED: typeof(s2.getPosition()) == 'undefined' [./Sound.as:173]
5353
PASSED: typeof(s2.getTransform()) == 'object' [./Sound.as:174]
5454
PASSED: typeof(s2.getVolume()) == 'number' [./Sound.as:175]
5555
PASSED: s2.getVolume() == 100 [./Sound.as:176]
@@ -98,11 +98,11 @@ PASSED: s3.getVolume() == 80 [./Sound.as:274]
9898
FAILED: expected: "undefined" obtained: number [./Sound.as:336]
9999
FAILED: expected: "undefined" obtained: number [./Sound.as:337]
100100
PASSED: typeof(s.duration) == "undefined" [./Sound.as:338]
101-
FAILED: expected: "undefined" obtained: number [./Sound.as:339]
101+
PASSED: typeof(s.getPosition()) == "undefined" [./Sound.as:339]
102102
PASSED: typeof(s.getDuration()) == "undefined" [./Sound.as:340]
103103
PASSED: typeof(s.getBytesTotal()) == "number" [./Sound.as:345]
104104
PASSED: typeof(s.getBytesLoaded()) == "number" [./Sound.as:346]
105-
PASSED: typeof(s.getPosition()) == "number" [./Sound.as:347]
105+
FAILED: expected: "number" obtained: undefined [./Sound.as:347]
106106
FAILED: expected: "number" obtained: undefined [./Sound.as:348]
107107
FAILED: expected: "number" obtained: undefined [./Sound.as:349]
108108
Waiting 3 seconds for onSoundComplete to be called
@@ -111,6 +111,6 @@ FAILED: expected: 209 obtained: 0 [./Sound.as:328]
111111
PASSED: s.position == 0 [./Sound.as:329]
112112
FAILED: no onSoundComplete arrived after 3 seconds
113113
FAILED: Tests run 107 (expected 112) [ [./Sound.as:31]]
114-
#passed: 71
115-
#failed: 37
114+
#passed: 73
115+
#failed: 35
116116
#total tests run: 108

0 commit comments

Comments
 (0)