Skip to content

Conversation

ReenigneArcher
Copy link
Member

@ReenigneArcher ReenigneArcher commented Jul 18, 2025

Description

This PR fixes audio-info (and maybe dxgi-info) from crashing when special characters exist in the device names or any properties.

Additionally, the formatting was slightly modified for dxgi-info. The output line was previously included even if the device had no output devices attached. The location of the empty line was also changed.

To complete the fix I moved the utf conversion functions out of misc.cpp/h in order to simplify inclusion of these functions in the tool binaries. This is still somewhat more complex than it needs to be due to having to include logging, which requires libdisplaydevice and FFmpeg (libavutil).

Finally, I corrected some IDE and Sonar complaints such as:

  • used c-style cast instead of c++ style
  • added const when possible
  • added a default case for a switch
  • some variables could be initialized inside the if condition

Screenshot

Issues Fixed or Closed

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

@ReenigneArcher ReenigneArcher force-pushed the fix/audio-info/crash-when-device-name-contains-special-characters branch 2 times, most recently from 114b384 to 0b5df33 Compare July 18, 2025 22:00
Copy link

codecov bot commented Jul 18, 2025

Codecov Report

❌ Patch coverage is 30.00000% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 11.37%. Comparing base (8bff4d0) to head (27c9e0b).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/platform/windows/utf_utils.cpp 40.62% 9 Missing and 10 partials ⚠️
src/platform/windows/misc.cpp 7.69% 12 Missing ⚠️
src/platform/windows/audio.cpp 0.00% 6 Missing ⚠️
src/platform/windows/display_base.cpp 60.00% 2 Missing ⚠️
src/platform/windows/publish.cpp 0.00% 2 Missing ⚠️
src/process.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4095      +/-   ##
==========================================
+ Coverage   11.34%   11.37%   +0.02%     
==========================================
  Files          92       93       +1     
  Lines       17623    17623              
  Branches     8109     8109              
==========================================
+ Hits         2000     2005       +5     
+ Misses      14917    14913       -4     
+ Partials      706      705       -1     
Flag Coverage Δ
Linux-AppImage 11.55% <ø> (ø)
Windows-AMD64 12.46% <30.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/platform/windows/display_vram.cpp 8.95% <100.00%> (ø)
src/process.cpp 1.08% <0.00%> (ø)
src/platform/windows/display_base.cpp 35.50% <60.00%> (ø)
src/platform/windows/publish.cpp 0.00% <0.00%> (ø)
src/platform/windows/audio.cpp 25.32% <0.00%> (ø)
src/platform/windows/misc.cpp 2.95% <7.69%> (-0.81%) ⬇️
src/platform/windows/utf_utils.cpp 40.62% <40.62%> (ø)

@ReenigneArcher ReenigneArcher force-pushed the fix/audio-info/crash-when-device-name-contains-special-characters branch 4 times, most recently from d517461 to cf38659 Compare July 18, 2025 23:47
@ReenigneArcher ReenigneArcher requested a review from Copilot July 19, 2025 03:39
Copilot

This comment was marked as outdated.

@ReenigneArcher ReenigneArcher force-pushed the fix/audio-info/crash-when-device-name-contains-special-characters branch 4 times, most recently from 39e03f6 to 29d3bb8 Compare July 19, 2025 14:37
Copy link

codecov bot commented Jul 19, 2025

Bundle Report

Bundle size has no change ✅

@ReenigneArcher ReenigneArcher force-pushed the fix/audio-info/crash-when-device-name-contains-special-characters branch 2 times, most recently from 53b055b to 3e9b451 Compare July 19, 2025 19:50
@ReenigneArcher ReenigneArcher requested a review from Copilot July 19, 2025 22:37
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes crashes in audio-info and dxgi-info tools when device names contain special characters by implementing proper UTF conversion utilities. The changes include creating a new utf_utils namespace for safer UTF conversion, migrating away from the deprecated Boost.Locale library, and improving code quality with modern C++ best practices.

Key changes:

  • Adds new utf_utils namespace with UTF conversion functions to replace the previous platform-specific implementations
  • Migrates audio-info and dxgi-info tools to use standardized UTF-8 output instead of wide character streams
  • Consolidates UTF conversion logic from multiple Windows platform files into a single utility module

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/platform/windows/utf_utils.h New header defining UTF conversion utility functions
src/platform/windows/utf_utils.cpp Implementation of UTF-8/UTF-16 conversion functions with proper error handling
tools/audio.cpp Migrated to use utf_utils and std::cout for consistent UTF-8 output
tools/dxgi.cpp Updated to use utf_utils and improved output formatting
tools/CMakeLists.txt Added dependencies for utf_utils and logging to tool builds
tests/unit/platform/windows/test_utf_utils.cpp Comprehensive tests for UTF conversion functions
src/platform/windows/misc.h Removed UTF conversion functions (moved to utf_utils)
src/platform/windows/misc.cpp Migrated to use utf_utils for UTF conversions

Comment on lines +223 to +225
std::cout << "Device name : " << safe_wstring_output(device_friendly_name.prop.pwszVal) << std::endl;
std::cout << "Adapter name : " << safe_wstring_output(adapter_friendly_name.prop.pwszVal) << std::endl;
std::cout << "Device description : " << safe_wstring_output(device_desc.prop.pwszVal) << std::endl;
Copy link
Preview

Copilot AI Jul 19, 2025

Choose a reason for hiding this comment

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

Incorrect property access. The line uses device_friendly_name.prop.pwszVal but the property should be accessed as device_friendly_name.prop.pszVal based on the PROPVARIANT structure for string values.

Suggested change
std::cout << "Device name : " << safe_wstring_output(device_friendly_name.prop.pwszVal) << std::endl;
std::cout << "Adapter name : " << safe_wstring_output(adapter_friendly_name.prop.pwszVal) << std::endl;
std::cout << "Device description : " << safe_wstring_output(device_desc.prop.pwszVal) << std::endl;
std::cout << "Device name : " << safe_wstring_output(device_friendly_name.prop.pszVal) << std::endl;
std::cout << "Adapter name : " << safe_wstring_output(adapter_friendly_name.prop.pszVal) << std::endl;
std::cout << "Device description : " << safe_wstring_output(device_desc.prop.pszVal) << std::endl;

Copilot uses AI. Check for mistakes.

@ReenigneArcher ReenigneArcher force-pushed the fix/audio-info/crash-when-device-name-contains-special-characters branch from 3e9b451 to 27c9e0b Compare September 1, 2025 20:25
Copy link

sonarqubecloud bot commented Sep 1, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
3 New issues
2 New Code Smells (required ≤ 0)
E Reliability Rating on New Code (required ≥ A)
1 New Bugs (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@LizardByte LizardByte deleted a comment from sonarqubecloud bot Sep 1, 2025
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.

"audio-info.exe" - sanitization of escape characters needed for program output
1 participant