Граф коммитов

38 Коммитов

Автор SHA1 Сообщение Дата
Dzmitry Malyshau b4f91ef3a7
Update core-foundation-sys (#80)
* Update core-foundation-sys

* Revert the version change
2020-04-08 15:12:23 -07:00
Paul Adenot c9f0499f27
Revert `derive(Debug)` removal (#75)
* Revert "Merge pull request #72 from ChunMinChang/rm-debug-trait"

This reverts commit 828efbcf50, reversing
changes made to 20daa86ae2.

* Implement empty Debug for BufferManager to unbreak the build
2020-04-01 11:40:16 -07:00
Chun-Min Chang 4b343ab1fe Remove Debug trait in coreaudio-sys-utils 2020-03-30 10:04:32 -07:00
Chun-Min Chang 799518a033
Rework threading model (#55)
* Create a friendly wrapper around dispatch_queue_t

Instead of using low-level dispatch APIs directly, we should create a
wrapper around `dispatch_queue_t` that can retain or release the
reference count automatically.

* Hide low-level dispatch APIs

With the new `Queue` struct is introduced, there is no need to expose
the low-level dispatch APIs. Those low-level dispatch APIs should be
prevented from being used directly.

* Make the task queue stream-local

The stream start, stop, destroy, reinit tasks, from different streams,
will be dispatched to the same task queue and then be executed one by
one. In fact, those tasks dispatched from different streams can be run
separately in parallel since those tasks don't share data in common. We
can create a task queue per stream and dispatch the stream's own task to
its own task queue so those tasks fired from different streams can be
run in parallel. This should boost the speed of creating, staring,
stopping, or reinitializing multiple streams at the same time.

* Implement a sync task runner that runs the final task

Any task appended after the stream-destroy task should be cancelled.
After moving the task queue from being owned by the cubeb context to the
cubeb stream, we can easily cancel the stream X's job in the task queue
after stream X is destroyed, without interfering other stream's tasks.

* Give task queue an unique label

The task queue in the cubeb stream should have a unique lable so it
would be easier to identify the task queue's owner when debugging
issues.

* Merge create_dispatch_queue to Queue::new

* Merge release_dispatch_queue to Queue::drop

* Merge retain_dispatch_queue to Queue::clone

* Merge get_dispatch_context to Queue::get_context

* Merge set_dispatch_context to Queue::set_context

* Init should_cancel to false in new instead of run_final

* Replace generic type by AtomicBool type in {get, set}_context

* Rename {get,set}_context to {get,set}_should_cancel

* Merge async_dispatch to run_async

* Merge sync_dispatch to Queue::run_{sync, final}

* Move create_closure_and_executor into Queue

* Destroy AudioUnitContext properly

* Revise comments
2020-03-19 11:04:15 -07:00
Chun-Min Chang 132d2093f7
Clean up clippy warnings and errors (#49)
* Set RUST_BACKTRACE in the environment

* Add Rust format check in Travis CI

* Add Rust clippy check in Travis CI

* Fix warning: array_into_iter

Replace `.into_iter()` by `.iter()` used in the Rust array

* Fix warning: private_in_public

Allow private struct AudioUnitStream in public interface when running tests

* Fix clippy errors in audio_unit_get_property_info

* Fix clippy errors in audio_unit_render

* Align interface of audio_unit_get_property with audio_unit_get_property_info

- Change `data` and `size` of audio_unit_get_property from raw pointers
to references
- Make the variable `size` used when calling audio_unit_get_property in
test_audiounit_scope_is_enabled live when the calling explicitly

* Align interface of audio_unit_set_property with audio_unit_get_property's one

* Fix clippy warning: redundant_field_names in create_device_info

* Fix clippy warning: let_and_return in create_blank_device

* Fix clippy warning: let_and_return in audiounit_input_callback

* Fix clippy warning: needless_return in host_time_to_ns

* Fix clippy warning: or_fun_call in get_device_label

The function within `or(...)` will always be called and potentially
allocate an object acting as the default. We don't need to call
get_device_name if get_device_source_name works

* Fix clippy warning: len_zero in Mixer::new

* Fix clippy warning: option_map_unit_fn in Finalizer::drop

* Fix clippy error: float_cmp in minimum_resampling_input_frames

* Fix clippy warning: needless_range_loop in audiounit_output_callback

* Allow clippy::mutex_atomic on set_buffer_size_sync

* Fix clippy warning: redundant_clone in get_range_of_sample_rates

* Fix clippy warning: cmp_null in DevicesData::is_empty

* Fix clippy warning: unnecessary_unwrap in reinit

* Fix clippy warning: or_fun_call in current_device

* Allow clippy::cognitive_complexity on CoreStreamData::setup

* Allow clippy::cast_ptr_alignment on get_device_stream_configuration

* Fix clippy warning: needless_range_loop in get_default_channel_order

* Fix clippy warning: missing_safety_doc for audiounit_rust_init

* Avoid using set_len in allocate_array

`set_len` is unsafe function that should be avoided if possible. On the
other hand, we should initialize the item value when allocating the
array by expected size or the number of the items.

* Fix warning: unused_parens in stream_init

* Fix warning: unused_parens in CoreStreamData::setup

* Skip test changing the default device if no device is available

* Automatically install latest clippy and rustfmt

- Download and install the latest available rustfmt if rustfmt isn't
available in the nightly
- Install latest available clippy if clippy in nightly isn't available
2020-02-18 14:09:56 -08:00
Chun-Min Chang 80978b6c02
Implement Display trait for StringRef (#36)
StringRef should implement `Display` trait to get the `to_string` method
rather than implementing `to_string` by itself. Implementing `Display`
is preferred and will make printing StringRef instance easier. Read more
in:
https://rust-lang.github.io/rust-clippy/master/index.html#inherent_to_string
2020-01-06 09:08:55 -08:00
Mike Hommey 5fcbd99e1b Add the license to Cargo.toml (#29) 2019-12-05 11:38:50 -08:00
Chun-Min Chang dba0344754
Add manual tests (#24)
* Move STREAM_FORMAT to the function using it

* Add a test template with default callbacks

* Revise comments

* Add manual tests: Loop in input/output/duplex streams

* Remove unnecessary type declarations

* Set RUST_BACKTRACE in test script

* Move common test code to tests/utils.rs

* Fix type

* Terminate stream by pressing q

* Create a stream tester with common testing operations

* Add a choice to quit early

* Revise stream tester

To add the command to create or destroy the stream, the cubeb context
need to be passed to the test function. Instead of using the test
template that will pass the cubeb stream, using the test template that
will give te cubeb context is the right way to create the test.

* Revise command line interface
2019-11-22 10:41:26 -08:00
Chun-Min Chang 92e2e116cf minor style fix 2019-10-21 15:51:54 -07:00
Chun-Min Chang fdb0b1d54c
Make utf8_from_cfstringref work with empty CFStringRef (#20)
* 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
2019-10-21 14:08:57 -07:00
Chun-Min Chang 3f2512bf49
Update dependencies (#17)
* 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
2019-10-02 14:26:04 -07:00
Chun-Min Chang b132620728
Simplify the APIs to get the device info from hardware (#6)
* 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
2019-08-12 11:17:32 -07:00
Chun-Min Chang 611c3decc5 Run rustfmt 2019-07-24 14:43:32 -07:00
Chun-Min Chang 98d218f502 Remove the unnecessary slash 2019-07-18 10:12:25 -07:00
Chun-Min Chang 1ed0f7cc56 Use generic for audio_object_{add, remove}_property_listener 2019-06-21 13:57:51 -07:00
Chun-Min Chang dabbc77703 Use generic in audio_unit_{add, remove}_property_listener 2019-06-21 13:51:55 -07:00
Chun-Min Chang 73763e1494 Remove unnecessary comments 2019-06-06 10:21:15 -07:00
Chun-Min Chang 8a71b99acb Implement CFMutableDictRef 2019-05-29 11:11:21 -07:00
Chun-Min Chang 945ea239a2 Implement audio_object_get_property_data(_size)_with_qualifier 2019-05-29 11:11:21 -07:00
Chun-Min Chang fe5e278e66 Run cargo fmt for coreaudio-sys-utils 2019-05-29 11:11:21 -07:00
Chun-Min Chang 1899f784ec Add debug trait for structs in coreaudio-sys-utils 2019-05-29 11:11:21 -07:00
Chun-Min Chang 7223f64728 Add a struct PropertySelector to wrap AudioObjectPropertySelector 2019-05-01 13:52:37 -07:00
Chun-Min Chang 9992ff7acc Remove unnecessary comments 2019-05-01 13:24:40 -07:00
Chun-Min Chang 00020e9db7 Use a safer type for DISPATCH_QUEUE_SERIAL 2019-04-25 10:41:54 -07:00
Chun-Min Chang b42ea92a36 Fix use-after-free problem 2019-04-25 10:41:54 -07:00
Chun-Min Chang f7ddf506dc Fix style 2019-04-23 10:36:38 -07:00
Chun-Min Chang 803004d1ec Create a simulator to fake plugging and unplugging device 2019-04-15 16:59:27 -07:00
Chun-Min Chang 7e4edbe4ca Rename AGGREGATE_DEVICE_UID to AGGREGATE_DEVICE_UID_KEY 2019-04-15 15:37:10 -07:00
Chun-Min Chang 5acd23b412 A safer way to pass AudioUnitStream across threads 2019-04-11 11:23:49 -07:00
Chun-Min Chang 3edd8765c7 A workaround to pass AudioUnitStream across threads 2019-04-08 14:44:34 -07:00
Chun-Min Chang f1e94172fd Fix tests in coreaudio-sys-utils 2019-03-29 16:00:31 -07:00
Chun-Min Chang 7ee958545d Move dispatch to coreaudio-sys-utils 2019-03-29 13:32:47 -07:00
Chun-Min Chang 3d4d665563 Expose utils with module name as the prefix 2019-03-29 13:26:53 -07:00
Chun-Min Chang e80e8eadcf Move constants for aggregate device to coreaudio-sys-utils 2019-03-29 13:14:44 -07:00
Chun-Min Chang b91bde4446 Move AudioUnit related APIs from utils to coreaudio-sys-utils 2019-03-29 10:48:56 -07:00
Chun-Min Chang a35a3b3881 Move AudioObject related APIs from utils to coreaudio-sys-utils 2019-03-29 10:43:29 -07:00
Chun-Min Chang 93d06f8edc Move cfstringref_from_(static_)string from utils to coreaudio-sys-utils 2019-03-28 16:27:22 -07:00
Chun-Min Chang 12da6aa3a6 Replace coreaudio-sys by coreaudio-sys-utils 2019-03-28 16:06:33 -07:00