Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio: Introduce _connected flag to fix setFilters bug #20093

Merged
merged 1 commit into from
Aug 17, 2020

Conversation

takahirox
Copy link
Collaborator

Problem this PR fixes

Audio.setFilters() resets connection by calling .disconnect() and .connect() if .isPlaying is true.

setFilters( value ) {

	if ( ! value ) value = [];

	if ( this.isPlaying === true ) {

		this.disconnect();
		this.filters = value;
		this.connect();

	} else {

		this.filters = value;

	}

	return this;

}

The problem is Audio status can be "connected but .isPlaying is false". In that case connection won't be reset and then filters won't be applied.

The examples of "connected but .isPlaying is false".

  • Call .setNodeSource(), setMediaElementSource(), or setMediaStreamSource(). And not call .play().
  • Call .play() and then call .pause() or .stop().

How to fix

The root issue would be that .isPlaying is not corresponding to "connected". So I'd like to suggest introducing a new private boolean property ._connected which is updated in .connect/disconnect() and shows exactly whether connected or not. And let setFilters use it to detect whether connected or not.

reset connection if already connected but playing is not started yet
@mrdoob mrdoob added this to the r120 milestone Aug 17, 2020
@mrdoob mrdoob changed the title Introduce _connected flag in Audio to fix setFilters bug Audo: Introduce _connected flag to fix setFilters bug Aug 17, 2020
@mrdoob mrdoob changed the title Audo: Introduce _connected flag to fix setFilters bug Audio: Introduce _connected flag to fix setFilters bug Aug 17, 2020
@mrdoob mrdoob merged commit 3ca2ae0 into mrdoob:dev Aug 17, 2020
@mrdoob
Copy link
Owner

mrdoob commented Aug 17, 2020

Thanks!

@takahirox takahirox deleted the AudioConnected branch August 17, 2020 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants