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

Re-research right internal OS buffer size for all systems #90

Open
ewjmulder opened this issue Oct 8, 2018 · 1 comment
Open

Re-research right internal OS buffer size for all systems #90

ewjmulder opened this issue Oct 8, 2018 · 1 comment

Comments

@ewjmulder
Copy link
Owner

The change that worked well on the laptop completely screws up playback on SparrenBurcht - Pine64. The code tries to find a very small OS buffer size to optimize performance, but somehow that doesn't play well with Pine64. Code has been removed for now, to be checked later if Pine64 can be optimized as well.

    public void open() {
        // The buffer should be big enough for the sound card buffer millis + some small percentage
        // to account for different sound card streams being out of sync.
        // The underlying implementation will take care of rounding the buffer size to a number of frames.
        int bufferSize = (int) (getTechnicalSettings().getSoundCardBufferMillis() * this.outputFormat.getNumberOfBytesPerMilli() * 1.1);
        boolean openSuccess = false;
        // Max number of retries, should be plenty based on test findings.
        int maxRetries = 10;
        int tries = 0;
        // We have seen LineUnavailableException's happen at certain buffer sizes, so perform retries
        // for slightly larger buffer sizes until either it was a success or the max retries has been reached.
        while (!openSuccess && tries < maxRetries) {
            try {
                this.outputLine.open(this.outputFormat.toJavaAudioFormat(), bufferSize);
                openSuccess = true;
            } catch (LineUnavailableException e) {
                Logger.info("Line unavailable for requested buffer size, will try buffer size with one extra frame");
                bufferSize += this.outputFormat.getNumberOfBytesPerFrame();
                tries++;
            }
        }
        if (!openSuccess) {
            throw new IllegalStateException("Line unavailable after max retries");
        }
    }
@ewjmulder
Copy link
Owner Author

This concerns commit
dd7d6ee

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

No branches or pull requests

1 participant