* Make utf8_from_cfstringref work with empty CFStringRef
Passing a CFStringRef whose internal string is ""(empty) to
utf8_from_cfstringref will hit an assertion that asserts the passed
CFStringRef cannot be empty. Instead of using the assertion, an empty u8
vec should be returned directly when the passed CFStringRef is empty,
which will yeild an empty String or CString in to_string or to_cstring.
* Move the static strings to their corresponding tests
* Store value instead of reference of property address in device_property_listener
* Remove {INPUT, OUTPUT}_DATA_SOURCE_PROPERTY_ADDRESS
The {INPUT, OUTPUT}_DATA_SOURCE_PROPERTY_ADDRESS values can be generated
by get_property_address so they can be removed.
* Remove DEVICE_IS_ALIVE_PROPERTY_ADDRESS
The value of DEVICE_IS_ALIVE_PROPERTY_ADDRESS can be generated by
get_property_address with propery parameters
* Remove DEVICES_PROPERTY_ADDRESS
The value of DEVICES_PROPERTY_ADDRESS can be generated by
get_property_address with proper parameters
* Remove DEFAULT_{INPUT, OUTPUT}_DEVICE_PROPERTY_ADDRESS
The valus of DEFAULT_{INPUT, OUTPUT}_DEVICE_PROPERTY_ADDRESS can be
generated by get_property_address with proper parameters
* Stop input AudioUnit in input callback
Stopping the input AudioUnit in output callback may cause a deadlock
(see BMO 1574632 for more details). To avoid forming the deadlock, the
input AudioUnit should be stopped in input callback.
Stopping the AudioUnit requires locking the mutex inside AudioUnit
framework for the AudioUnit that we want to stop. When input callback is
called, the mutex for the input AudioUnit (inside the AudioUnit
framework) must be held in the input callback thread, so it's safe to
stop the input AudioUnit in the input callback thread.
* Allow stream draining be set for input-only stream
A side effect comes with this change: For a input-only stream, the
state-changed callback notifying the draining state will be fired in the
next callback after the stream is drained, instead of firing immediately
upon the stream is drained.
* Remove the state callback in the handler
* Notify drained-state upon input-only stream is drained
In the previous changes, for an input-only stream, the notification of
drained-state is fired in the next input callback rather than fired upon
the stream is drained in the current callback. This patch correct the
timing for state-changed callback so the state-changed callback can be
fired upon the stream is drained. Just like what we did before the
previous changes.
* Add a function to check if a device is an input or output
* Update the policy to use aggregate device
* Remove the unnecessary parameters
The parameters, {input, output}_device in should_use_aggregate_device
are same as self.{input, output}_device so there is no need to pass
those data.
* TODO: test case
* Explain why instead of what of the new aggregate device policy
* Update todo: Using ringbuf maybe
* Use official coreaudio-sys
* Remove duplicate tests
`cargo test --verbose` will be called in run_test.sh so there is no need
to call `cargo test --verbose` in the .travis.yml
* Replace io_side by DeviceType
* Revise error message for audiounit_set_channel_layout
* Revise error message for get_buffer_size
* Revise error message for set_buffer_size
* Rephrase the error messages in set_buffer_size_sync
* Replace audiounit_get_default_datasource by get_device_source
* Prevent memory leak in current_device
Memory will leak when the macOS device only has input device. In that
case, the ownership of the CString for the input source will be
transferred and never be retaken. The changes make sure the
current_device call is always successful hence the ownership of the
memory can always be retaken by calling device_destroy.
* Replace audiounit_get_acceptable_latency_range by get_device_buffer_frame_size_range
Most code in audiounit_get_acceptable_latency_range is duplicate of the
get_device_buffer_frame_size_range.
* Create get_device_latency
* Create get_device_streams
* Create get_stream_latency
* Create get_device_sample_rate
With the new introduced API, the nominal sample rate of the device can
be queried wihtout using audiounit_get_available_samplerate, which gives
additional information but it's not often useful.
* Replace audiounit_get_available_samplerate by get_range_of_sample_rates
* Replace audiounit_get_device_presentation_latency by get_presentation_latency
Add logs when the API calls fail before returning the default latency
* Move APIs for AudioDeviceID together
* Create get_device_stream_format
* Simplify preferred_sample_rate
* Simplify get_channel_count
* Shorten the variable name
* Replace audiounit_create_device_from_hwdev by create_cubeb_device_info
* Replace get_device_name by get_device_uid
* Replace audiounit_get_channel_count by get_channel_count
* Set the devid of cubeb_device_info anyway
* Rewrite get_device_uid to get device info by scope
* Create get_device_source to get device info
* Create get_device_source_name to get device info
* Create get_property_address to generate property address
* Create get_device_name to get device info
* Create get_device_label to get device info
* Implement StringRef
* Apply StringRef in device property utils
* Create get_device_manufacturer to get device info
* Move audiounit_strref_to_cstr_utf8 to test-only file
* Make device_type more type-sensible
* Move the position of the max_channels assignment
* Create get_device_buffer_frame_size_range to get device info
* Use DeviceType in audiounit_get_available_samplerate
* Use DeviceType in audiounit_get_device_presentation_latency
* Remove unnecessary code
* Add tests for device property utils
* Return OSStatus when failing to get device info
* update todo list
* Print error directly when failing to get device vendor info
The device change callback triggered by input alive status change will
be tested in the tests that simulate unplugging the alive input devices
on the running streams.
Create bunch of tests that can simulate uplugging the running devices on
the active streams. The device uplugged could be default device or not.
There is a time setting in those test to wait for the stream
reinitialization. If it's 0, then the stream is likely to be destroyed
before being reinitialized.
- Enable the tests based on test_get_stream_with_device_changed_callback
to start playing the stream
- Correct the error that using differnt stream format on input and
output side. They must be same, which is a requirement when using the
resampler.
* Port the output latency fix from the C++ backend to the Rust backend
A direct port of this: c64d242bec
* Port of the minimum latency fix from the C++ backend to the Rust backend.
A port of this: abbdaa2f8e
* Address review comments
* rustfmt