Skip to content

Skip Digital Only Windows devices - #12

Open
Andreas-Froyland wants to merge 1 commit into
mainfrom
return-results
Open

Andreas-Froyland wants to merge 1 commit into
mainfrom
return-results

Conversation

@Andreas-Froyland

@Andreas-Froyland Andreas-Froyland commented Jan 18, 2026

Copy link
Copy Markdown
Member

Skip digital only devices as they are not needed in the context of volume control

It also now skips devices on an error with fetching device sessions instead of crashing

@Andreas-Froyland

Copy link
Copy Markdown
Member Author

@RubenLarsen this should be ready

@Andreas-Froyland

Copy link
Copy Markdown
Member Author

@cubic-dev-ai review this

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown

@cubic-dev-ai review this

@Andreas-Froyland I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

3 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/lib.rs">

<violation number="1" location="src/lib.rs:164">
P2: Each call now leaks the COM-allocated device ID returned by `IMMDevice::GetId`. Convert the ID, call `CoTaskMemFree` on the `PWSTR`, then handle the conversion result.</violation>

<violation number="2" location="src/lib.rs:194">
P2: This filter only affects application-session discovery. `GetDefaultAudioEnpointVolumeControl` and `GetAllAudioDevices` still add digital endpoints, so the public volume-control session list continues exposing the devices this change intends to skip.</violation>

<violation number="3" location="src/lib.rs:195">
P2: Digital-only `DigitalPassthrough` and `HDMI` endpoints are not skipped because this condition recognizes only SPDIF. Match all digital-only form-factor values before enumerating sessions.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread src/lib.rs
Comment on lines +164 to +178
let device_id = match device.GetId() {
Ok(id) => match id.to_string() {
Ok(id_str) => id_str,
Err(_) => {
eprintln!("WARNING: Skipping device {} - couldn't convert device ID to string", device_index);
error!("WARNING: Skipping device {} - couldn't convert device ID to string", device_index);
continue;
}
},
Err(err) => {
eprintln!("WARNING: Skipping device {} - couldn't get device ID: {}", device_index, err);
error!("WARNING: Skipping device {} - couldn't get device ID: {}", device_index, err);
continue;
}
};

@cubic-dev-ai cubic-dev-ai Bot Sep 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Each call now leaks the COM-allocated device ID returned by IMMDevice::GetId. Convert the ID, call CoTaskMemFree on the PWSTR, then handle the conversion result.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib.rs, line 164:

<comment>Each call now leaks the COM-allocated device ID returned by `IMMDevice::GetId`. Convert the ID, call `CoTaskMemFree` on the `PWSTR`, then handle the conversion result.</comment>

<file context>
@@ -136,36 +151,93 @@ impl AudioController {
+            };
+
+            // Get device ID for error reporting
+            let device_id = match device.GetId() {
+                Ok(id) => match id.to_string() {
+                    Ok(id_str) => id_str,
</file context>
Suggested change
let device_id = match device.GetId() {
Ok(id) => match id.to_string() {
Ok(id_str) => id_str,
Err(_) => {
eprintln!("WARNING: Skipping device {} - couldn't convert device ID to string", device_index);
error!("WARNING: Skipping device {} - couldn't convert device ID to string", device_index);
continue;
}
},
Err(err) => {
eprintln!("WARNING: Skipping device {} - couldn't get device ID: {}", device_index, err);
error!("WARNING: Skipping device {} - couldn't get device ID: {}", device_index, err);
continue;
}
};
let device_id = match device.GetId() {
Ok(id) => {
let id_result = id.to_string();
CoTaskMemFree(Some(id.as_ptr().cast()));
match id_result {
Ok(id_str) => id_str,
Err(_) => {
eprintln!("WARNING: Skipping device {} - couldn't convert device ID to string", device_index);
error!("WARNING: Skipping device {} - couldn't convert device ID to string", device_index);
continue;
}
}
},
Err(err) => {
eprintln!("WARNING: Skipping device {} - couldn't get device ID: {}", device_index, err);
error!("WARNING: Skipping device {} - couldn't get device ID: {}", device_index, err);
continue;
}
};
Fix with cubic

Comment thread src/lib.rs
let device_name = get_device_friendly_name(&device, &format!("Device {}", device_index));

// Skip SPDIF/digital outputs if detected by form factor
if let Some(form_factor) = get_device_form_factor(&property_store) {

@cubic-dev-ai cubic-dev-ai Bot Sep 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: This filter only affects application-session discovery. GetDefaultAudioEnpointVolumeControl and GetAllAudioDevices still add digital endpoints, so the public volume-control session list continues exposing the devices this change intends to skip.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib.rs, line 194:

<comment>This filter only affects application-session discovery. `GetDefaultAudioEnpointVolumeControl` and `GetAllAudioDevices` still add digital endpoints, so the public volume-control session list continues exposing the devices this change intends to skip.</comment>

<file context>
@@ -136,36 +151,93 @@ impl AudioController {
+            let device_name = get_device_friendly_name(&device, &format!("Device {}", device_index));
+
+            // Skip SPDIF/digital outputs if detected by form factor
+            if let Some(form_factor) = get_device_form_factor(&property_store) {
+                if form_factor == FORM_FACTOR_SPDIF {
+                    continue;
</file context>
Fix with cubic

Comment thread src/lib.rs

// Skip SPDIF/digital outputs if detected by form factor
if let Some(form_factor) = get_device_form_factor(&property_store) {
if form_factor == FORM_FACTOR_SPDIF {

@cubic-dev-ai cubic-dev-ai Bot Sep 4, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Digital-only DigitalPassthrough and HDMI endpoints are not skipped because this condition recognizes only SPDIF. Match all digital-only form-factor values before enumerating sessions.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib.rs, line 195:

<comment>Digital-only `DigitalPassthrough` and `HDMI` endpoints are not skipped because this condition recognizes only SPDIF. Match all digital-only form-factor values before enumerating sessions.</comment>

<file context>
@@ -136,36 +151,93 @@ impl AudioController {
+
+            // Skip SPDIF/digital outputs if detected by form factor
+            if let Some(form_factor) = get_device_form_factor(&property_store) {
+                if form_factor == FORM_FACTOR_SPDIF {
+                    continue;
+                }
</file context>
Suggested change
if form_factor == FORM_FACTOR_SPDIF {
if form_factor == FORM_FACTOR_SPDIF || matches!(form_factor, 7 | 9 | 10) {
Fix with cubic

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.

1 participant