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

cubeb.h: Document device switching policy. #582

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

kinetiknz
Copy link
Collaborator

Following the discussion in mozilla/cubeb-pulse-rs#54
and elsewhere, document the interaction between cubeb_stream_init parameters
and cubeb's intended device switching policy.

Following the discussion in mozilla/cubeb-pulse-rs#54
and elsewhere, document the interaction between cubeb_stream_init parameters
and cubeb's intended device switching policy.
CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING on @ref
cubeb_stream_params.prefs.

@note If @p output_device or @p input_device is a valid non-NULL @ref
Copy link
Member

Choose a reason for hiding this comment

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

The output_device selection isn't supported in audiounit-rust yet. @padenot : Do we have a plan to support that? (however, the test might be ready here)

Copy link
Member

Choose a reason for hiding this comment

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

Ah, it seems we do support output_device selection, but I never tested it.

If the stream needs to be reinitialize to default output device when the specified output_device is no longer available, then we do need to listen kAudioDevicePropertyDeviceIsAlive for output device like what we do for the input side.

On the other hand, if the stream using the specified output_device doesn't need to be reinitialized when the specified output_device is no longer available, it seems audiounit-rust meets the spec here.

Anyway, my problem is: what is the intended behavior when the specified output_device or input_device is unplugged while they are being used by some active streams?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Anyway, my problem is: what is the intended behavior when the specified output_device or input_device is unplugged while they are being used by some active streams?

This is in flux at the minute. The current behaviour we want in gecko:

  • If a output device has been opened with an explicit device or a default device, and is no longer available, switch to the new default device
  • If an input device has been opened, it's always with an explicit ID. It it is not available anymore, turn this stream into a output-only stream

When @achronop finishes setSinkId, we'll reevaluate this (or as part of his effort).

I had a design a long time ago that would allow enough flexibility to implement whatever we need: https://github.com/kinetiknz/cubeb/issues/167. I think it still works

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think in general the behaviour @kinetiknz documents here is simpler and works just as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

If a output device has been opened with an explicit device or a default device, and is no longer available, switch to the new default device

If I am not missing something the output device is always non-explicit at the moment in Gecko so @kinetiknz 's document covers our needs. This will be changed when sinkId is in place but we can re-evaluate then. I have already some thoughts about it.

Copy link
Member

Choose a reason for hiding this comment

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

I think my question is here:

If @p output_device or @p input_device is a valid non-NULL @ref cubeb_devid, cubeb will only ever use the specified device and never follow device changes automatically

We do change the output device if the specified output device is no longer available but the document states: cubeb never follow device changes automatically.

I am ok to reword these once setSinkId is done. Just want to make sure this issue is one someone's radar.


@note If @p output_device or @p input_device is a valid non-NULL @ref
cubeb_devid, cubeb will only ever use the specified device and never
follow device changes automatically. In this case, the application may
Copy link
Member

Choose a reason for hiding this comment

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

audiounit-rust backend will automatically change the input device when the specified input_device is unplugged (cannot be used anymore). So this behavior need to be changed? Should we just return error instead when the specified input_device is gone?

@achronop
Copy link
Contributor

In addition to the above, we need to document what happens when an explicit-defined device is not available anymore. In rust PA this situation results in a state change to CUBEB_STATE_ERROR (due to the general error reporting callback). This is convenient because at Gecko level we react on the state change to error and we want that. If this is a behavior that we would like to keep and propagate the other backends, can we please document it. If not please let us know your thoughts.

Copy link
Member

@ChunMinChang ChunMinChang left a comment

Choose a reason for hiding this comment

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

The current behavior is slightly different from the updated descriptions. I am ok to reword these after setSinkId is done or update our code to meet the descriptions.

CUBEB_STREAM_PREF_DISABLE_DEVICE_SWITCHING on @ref
cubeb_stream_params.prefs.

@note If @p output_device or @p input_device is a valid non-NULL @ref
Copy link
Member

Choose a reason for hiding this comment

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

I think my question is here:

If @p output_device or @p input_device is a valid non-NULL @ref cubeb_devid, cubeb will only ever use the specified device and never follow device changes automatically

We do change the output device if the specified output device is no longer available but the document states: cubeb never follow device changes automatically.

I am ok to reword these once setSinkId is done. Just want to make sure this issue is one someone's radar.

@achronop
Copy link
Contributor

Any thoughts regarding the state change (to error) when the explicit device goes unplug? PA exhibits this behavior, at the moment, and I would like to change it if it is something that we don't want.

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.

4 participants