Skip to content

Conversation

@alexthewilde
Copy link

@alexthewilde alexthewilde commented Jul 6, 2016

Prevents occasional error message upon stopping recording.

Copy link

@no-chris no-chris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is the right way to fix this. Sure it works, but the record() method is still called although it shouldn't, given that finish() have been called before.

I'm not using WebAudioRecorder.js (only the workers) so I cannot check this but cancelling the onaudioprocess callback before sending the finish command to the worker might do the trick.

this.processor.onaudioprocess = null; // <= add this
this.processor.disconnect();
delete this.processor;
this.worker.postMessage({ command: "finish" });

if (encoder)
encoder.encode(buffer);
else
else if (recBuffers)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix is wrong. You need to wrap the top level condition with brackets otherwise you will trigger a timeout with the following else.

    if (bufferCount++ < maxBuffers) {
        if (encoder)
            encoder.encode(buffer);
        else if (recBuffers)
            recBuffers.push(buffer);
    } else
        self.postMessage({ command: "timeout" });

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