Skip to content

Commit

Permalink
Add sndio support (#3715)
Browse files Browse the repository at this point in the history
Add sndio support
  • Loading branch information
grayed committed Nov 14, 2020
1 parent 0d222b6 commit 1271981
Show file tree
Hide file tree
Showing 8 changed files with 586 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Expand Up @@ -358,6 +358,7 @@ jobs:
libluajit-5.1-dev \
libpulse-dev \
libqt5x11extras5-dev \
libsndio-dev \
libspeexdsp-dev \
libswresample-dev \
libswscale-dev \
Expand Down
71 changes: 71 additions & 0 deletions cmake/Modules/FindSndio.cmake
@@ -0,0 +1,71 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

#[=======================================================================[.rst:
FindSndio
-------

Finds the Sndio library.

Imported Targets
^^^^^^^^^^^^^^^^

This module provides the following imported targets, if found:

``Sndio::Sndio``
The Sndio library

Result Variables
^^^^^^^^^^^^^^^^

This will define the following variables:

``Sndio_FOUND``
True if the system has the Sndio library.
``Sndio_VERSION``
The version of the Sndio library which was found.
``Sndio_INCLUDE_DIRS``
Include directories needed to use Sndio.
``Sndio_LIBRARIES``
Libraries needed to link to Sndio.

Cache Variables
^^^^^^^^^^^^^^^

The following cache variables may also be set:

``Sndio_INCLUDE_DIR``
The directory containing ``sndio.h``.
``Sndio_LIBRARY``
The path to the Sndio library.

#]=======================================================================]

find_path(Sndio_INCLUDE_DIR sndio.h)
find_library(Sndio_LIBRARY sndio)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Sndio
FOUND_VAR Sndio_FOUND
REQUIRED_VARS
Sndio_LIBRARY
Sndio_INCLUDE_DIR
)

if(Sndio_FOUND)
set(Sndio_LIBRARIES ${Sndio_LIBRARY})
set(Sndio_INCLUDE_DIRS ${Sndio_INCLUDE_DIR})
endif()

if(Sndio_FOUND AND NOT TARGET Sndio::Sndio)
add_library(Sndio::Sndio UNKNOWN IMPORTED)
set_target_properties(Sndio::Sndio PROPERTIES
IMPORTED_LOCATION "${Sndio_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${Sndio_INCLUDE_DIR}"
)
endif()

mark_as_advanced(
Sndio_INCLUDE_DIR
Sndio_LIBRARY
)
5 changes: 5 additions & 0 deletions plugins/CMakeLists.txt
Expand Up @@ -42,6 +42,7 @@ elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
add_subdirectory(linux-alsa)
add_subdirectory(decklink/linux)
add_subdirectory(vlc-video)
add_subdirectory(sndio)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD")
add_subdirectory(linux-capture)
add_subdirectory(linux-pulseaudio)
Expand All @@ -50,6 +51,10 @@ elseif("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD")
add_subdirectory(linux-alsa)
add_subdirectory(vlc-video)
add_subdirectory(oss-audio)
add_subdirectory(sndio)
elseif("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD")
add_subdirectory(linux-capture)
add_subdirectory(sndio)
endif()

option(BUILD_BROWSER "Build browser plugin" OFF)
Expand Down
35 changes: 35 additions & 0 deletions plugins/sndio/CMakeLists.txt
@@ -0,0 +1,35 @@
project(sndio)

if(DISABLE_SNDIO)
message(STATUS "Sndio support disabled")
return()
endif()

find_package(Sndio)
if(NOT Sndio_FOUND AND ENABLE_SNDIO)
message(FATAL_ERROR "Sndio not found but set as enabled")
elseif(NOT Sndio_FOUND)
message(STATUS "Sndio not found, disabling Sndio plugin")
return()
endif()

include_directories(
SYSTEM "${CMAKE_SOURCE_DIR}/libobs" SYSTEM "${CMAKE_SOURCE_DIR}/../../libobs"
${Sndio_INCLUDE_DIRS}
)

set(sndio_SOURCES
sndio.c
sndio-input.c
)

add_library(sndio MODULE
${sndio_SOURCES}
)
target_link_libraries(sndio
libobs
${Sndio_LIBRARIES}
)
set_target_properties(sndio PROPERTIES FOLDER "plugins")

install_obs_plugin_with_data(sndio data)
6 changes: 6 additions & 0 deletions plugins/sndio/data/locale/en-US.ini
@@ -0,0 +1,6 @@
Channels="Number of channels"
Device="Device"
BitsPerSample="Bits per sample"
Rate="Rate"
SndioInput="Sndio input client"

0 comments on commit 1271981

Please sign in to comment.