@@ -5,9 +5,9 @@ extern crate coreaudio;
5
5
6
6
use coreaudio:: audio_unit:: audio_format:: LinearPcmFlags ;
7
7
use coreaudio:: audio_unit:: macos_helpers:: {
8
- audio_unit_from_device_id, find_matching_physical_format, get_default_device_id, get_owner_pid ,
8
+ audio_unit_from_device_id, find_matching_physical_format, get_default_device_id, get_hogging_pid ,
9
9
get_supported_physical_stream_formats, set_device_physical_stream_format,
10
- set_device_sample_rate, switch_ownership , AliveListener , RateListener ,
10
+ set_device_sample_rate, toggle_hog_mode , AliveListener , RateListener ,
11
11
} ;
12
12
use coreaudio:: audio_unit:: render_callback:: { self , data} ;
13
13
use coreaudio:: audio_unit:: { Element , SampleFormat , Scope , StreamFormat } ;
@@ -62,12 +62,12 @@ fn main() -> Result<(), coreaudio::Error> {
62
62
let audio_unit_id = get_default_device_id ( false ) . unwrap ( ) ;
63
63
let mut audio_unit = audio_unit_from_device_id ( audio_unit_id, false ) ?;
64
64
65
- let pid = get_owner_pid ( audio_unit_id) ?;
65
+ let pid = get_hogging_pid ( audio_unit_id) ?;
66
66
if pid != -1 {
67
67
println ! ( "Device is owned by another process with pid {}!" , pid) ;
68
68
} else {
69
69
println ! ( "Device is free, trying to get exclusive access.." ) ;
70
- let new_pid = switch_ownership ( audio_unit_id) ?;
70
+ let new_pid = toggle_hog_mode ( audio_unit_id) ?;
71
71
let process_id = process:: id ( ) ;
72
72
if new_pid == process_id as i32 {
73
73
println ! ( "We have exclusive access." ) ;
@@ -198,12 +198,12 @@ fn main() -> Result<(), coreaudio::Error> {
198
198
println ! ( "alive state: {}" , alive_listener. is_alive( ) ) ;
199
199
}
200
200
201
- // Release exclusive access, not really needed as the process anyway exits after this.
202
- let owner_pid = get_owner_pid ( audio_unit_id) ?;
201
+ // Release exclusive access, not really needed as the process exits anyway after this.
202
+ let owner_pid = get_hogging_pid ( audio_unit_id) ?;
203
203
let process_id = process:: id ( ) ;
204
204
if owner_pid == process_id as i32 {
205
205
println ! ( "Releasing exclusive access" ) ;
206
- let new_pid = switch_ownership ( audio_unit_id) ?;
206
+ let new_pid = toggle_hog_mode ( audio_unit_id) ?;
207
207
if new_pid == -1 {
208
208
println ! ( "Exclusive access released." ) ;
209
209
} else {
0 commit comments