8000 review closing of a MidiDevice by MidiPortSelector · Issue #47 · philburk/android-midisuite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

review closing of a MidiDevice by MidiPortSelector #47

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

Open
philburk opened this issue Feb 6, 2018 · 3 comments
Open

review closing of a MidiDevice by MidiPortSelector #47

philburk opened this issue Feb 6, 2018 · 3 comments
Assignees

Comments

@philburk
Copy link
Owner
philburk commented Feb 6, 2018

Mario wrote:

If I have 2 selectors, and they both select (different) ports on the same device, when one of the spinners changes selection, the close() method is called on the device. But this device is being used by the other selector, is it reference counted internally? What does it mean to close it, while a port might be still in use elsewhere?

Good question. This needs to be investigated.

@philburk philburk self-assigned this Feb 6, 2018
@philburk philburk assigned robertwu1 and unassigned philburk May 14, 2022
@robertwu1
Copy link
Collaborator

If the same port is being used for both input and output, we should not open the device twice. We should instead open the device only once and use the same device for both the input and output ports.

@robertwu1
Copy link
Collaborator

Below is what close looks like internally. We should not two separate port selectors call close at the same time. We should expose something like MidiInputOutputPortSelector if developers need to use the same port for both input and output in the same app.

        @Override
        public void close() throws IOException {
            synchronized (mGuard) {
                if (mIsClosed) return;
                mGuard.close();
                try {
                    // close input port
                    mInputPortDeviceServer.closePort(mInputPortToken);
                    // close output port
                    mDeviceServer.closePort(mOutputPortToken);
                } catch (RemoteException e) {
                    Log.e(TAG, "RemoteException in MidiConnection.close");
                }
                mIsClosed = true;
            }
        }

@philburk
Copy link
Owner Author

Or we could cache open devices and not reopen the device if we find it in the cache.

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

2 participants
0