Skip to content

Commit

Permalink
CDImageDevice: Implement disc reading for Linux
Browse files Browse the repository at this point in the history
And fix it for Windows. SubQ reading should now work.
  • Loading branch information
stenzek committed Feb 29, 2024
1 parent b060edc commit 9e26622
Show file tree
Hide file tree
Showing 6 changed files with 790 additions and 152 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rolling-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ jobs:
extra-cmake-modules libcurl4-openssl-dev libssl-dev libasound2-dev libpulse-dev libx11-xcb-dev build-essential git libclang-dev \
libclang-11-dev libclang-12-dev patchelf libglib2.0-dev libfontconfig1-dev libharfbuzz-dev libjpeg-dev libpng-dev libfreetype-dev \
libinput-dev libxcb-*-dev libxkbcommon-dev libxkbcommon-x11-dev libxrender-dev libwayland-dev libgl1-mesa-dev libegl-dev \
libwebp-dev libzstd-dev libegl1-mesa-dev libgl1-mesa-dev libssl-dev libx11-dev libx11-xcb-dev libfuse2 \
libwebp-dev libzstd-dev libegl1-mesa-dev libgl1-mesa-dev libssl-dev libx11-dev libx11-xcb-dev libfuse2 libudev-dev \
llvm-16 lld-16 clang-16
- name: Cache Dependencies
Expand Down
3 changes: 3 additions & 0 deletions CMakeModules/DuckStationDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ if(NOT WIN32 AND NOT ANDROID)
find_package(WebP REQUIRED)
find_package(ZLIB REQUIRED)
endif()
if(LINUX AND NOT ANDROID)
find_package(UDEV REQUIRED)
endif()
if(UNIX AND NOT APPLE)
find_package(Libbacktrace)
if(NOT LIBBACKTRACE_FOUND)
Expand Down
32 changes: 32 additions & 0 deletions CMakeModules/FindUDEV.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# - Try to find UDEV
# Once done, this will define
#
# UDEV_FOUND - system has UDEV
# UDEV_INCLUDE_DIRS - the UDEV include directories
# UDEV_LIBRARIES - the UDEV library
find_package(PkgConfig)

pkg_check_modules(UDEV_PKGCONF libudev)

find_path(UDEV_INCLUDE_DIRS
NAMES libudev.h
PATHS ${UDEV_PKGCONF_INCLUDE_DIRS}
)

find_library(UDEV_LIBRARIES
NAMES udev
PATHS ${UDEV_PKGCONF_LIBRARY_DIRS}
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(UDEV DEFAULT_MSG UDEV_INCLUDE_DIRS UDEV_LIBRARIES)

mark_as_advanced(UDEV_INCLUDE_DIRS UDEV_LIBRARIES)

if(UDEV_FOUND AND NOT (TARGET UDEV::UDEV))
add_library (UDEV::UDEV UNKNOWN IMPORTED)
set_target_properties(UDEV::UDEV
PROPERTIES
IMPORTED_LOCATION ${UDEV_LIBRARIES}
INTERFACE_INCLUDE_DIRECTORIES ${UDEV_INCLUDE_DIRS})
endif()
4 changes: 4 additions & 0 deletions src/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ elseif(NOT ANDROID)
pkg_check_modules(DBUS REQUIRED dbus-1)
target_include_directories(util PRIVATE ${DBUS_INCLUDE_DIRS})
target_link_libraries(util PRIVATE ${DBUS_LINK_LIBRARIES})

if(LINUX)
target_link_libraries(util PRIVATE UDEV::UDEV)
endif()
endif()

if(NOT WIN32 AND NOT ANDROID)
Expand Down
17 changes: 12 additions & 5 deletions src/util/cd_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,21 @@ std::unique_ptr<CDImage> CDImage::Open(const char* filename, bool allow_patches,
extension = std::strrchr(filename, '.');
#endif

std::unique_ptr<CDImage> image;
if (!extension)
{
Log_ErrorPrintf("Invalid filename: '%s'", filename);
return nullptr;
// Device filenames on Linux don't have extensions.
if (IsDeviceName(filename))
{
image = OpenDeviceImage(filename, error);
}
else
{
Log_ErrorPrintf("Invalid filename: '%s'", filename);
return nullptr;
}
}

std::unique_ptr<CDImage> image;
if (StringUtil::Strcasecmp(extension, ".cue") == 0)
else if (StringUtil::Strcasecmp(extension, ".cue") == 0)
{
image = OpenCueSheetImage(filename, error);
}
Expand Down
Loading

0 comments on commit 9e26622

Please sign in to comment.