Skip to content

Add fn deinitialize() utilizing CoUninitialize #19

Closed

Description

@rosingrind

As stated in docs:

To close the COM library gracefully on a thread, each successful call to CoInitialize or CoInitializeEx, including any call that returns S_FALSE, must be balanced by a corresponding call to CoUninitialize

I'm not really familiar with the wasapi crate development direction, but I think there should be a function such as fn deinitialize() for these safety purposes. What's your opinion?

wasapi-rs/src/api.rs

Lines 61 to 68 in bf15059

pub fn initialize_mta() -> Result<(), windows::core::Error> {
unsafe { CoInitializeEx(std::ptr::null_mut(), COINIT_MULTITHREADED) }
}
/// Initializes COM for use by the calling thread for a single-threaded apartment (STA).
pub fn initialize_sta() -> Result<(), windows::core::Error> {
unsafe { CoInitializeEx(std::ptr::null_mut(), COINIT_APARTMENTTHREADED) }
}

Activity

  1. HEnquist commented on Jun 26, 2023

    @HEnquist
    Owner

    Thanks, this is a good suggestion. I'll include it in the next version.

  2. HEnquist commented on Jul 19, 2023

    @HEnquist
    Owner

    Added in 2613e97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions