Skip to content

Commit e748cc0

Browse files
committed
Implement SteamAudio based on rbfx/rbfx#659
1 parent c06ef3d commit e748cc0

15 files changed

+1762
-64
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616
env:
1717
# Common settings.
1818
CMAKE_VERSION: 3.21.x
19+
ci_steam_audio_version: 4.7.0
1920
# Common paths.
2021
ci_source_dir: ${{ github.workspace }}/source-code
2122
ci_build_script: ./source-code/ci_build.sh
@@ -74,6 +75,18 @@ jobs:
7475
unzip ${{ env.ci_target_sdk_name }}
7576
mv ./SDK ./SDK-target
7677
78+
- name: Download Steam Audio SDK
79+
uses: robinraju/release-downloader@v1.8
80+
with:
81+
repository: ValveSoftware/steam-audio
82+
tag: v${{ env.ci_steam_audio_version }}
83+
fileName: steamaudio_${{ env.ci_steam_audio_version }}.zip
84+
85+
- name: Unzip Steam Audio SDK
86+
run: |
87+
cd ${{ github.workspace }}
88+
unzip steamaudio_${{ env.ci_steam_audio_version }}.zip
89+
7790
- name: Setup cmake
7891
uses: jwlawson/actions-setup-cmake@v1
7992
with:

CMake/Modules/FindSteamAudio.cmake

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
# Copyright (c) 2024-2024 the rbfx project.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
# THE SOFTWARE.
21+
#
22+
23+
if (NOT DEFINED STEAMAUDIO_ROOT)
24+
set (STEAMAUDIO_ROOT "${CMAKE_SOURCE_DIR}/../steamaudio" CACHE PATH "Steam Audio SDK")
25+
endif ()
26+
27+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
28+
set(ARCH x64)
29+
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
30+
set(ARCH x86)
31+
endif()
32+
33+
set(STEAMAUDIO_FOUND TRUE)
34+
set(STEAMAUDIO_INCLUDE_DIRS "${STEAMAUDIO_ROOT}/include")
35+
if (WIN32)
36+
set(STEAMAUDIO_LIBRARIES "${STEAMAUDIO_ROOT}/lib/windows-${ARCH}/phonon.lib")
37+
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
38+
set(STEAMAUDIO_LIBRARIES "${STEAMAUDIO_ROOT}/lib/linux-${ARCH}/phonon.so")
39+
elseif (ANDROID)
40+
set(ANDROID_ABI ${ANDROID_NDK_ABI_NAME})
41+
string(REPLACE "v(7|8)a" "v\\1" ANDROID_ABI "${ANDROID_ABI}")
42+
set(STEAMAUDIO_LIBRARIES "${STEAMAUDIO_ROOT}/lib/android-${ANDROID_ABI}/libphonon.so")
43+
elseif (IOS)
44+
set(STEAMAUDIO_LIBRARIES "${STEAMAUDIO_ROOT}/lib/ios/libphonon.a")
45+
elseif (APPLE)
46+
set(STEAMAUDIO_LIBRARIES "${STEAMAUDIO_ROOT}/lib/osx/libphonon.dylib")
47+
else ()
48+
set(STEAMAUDIO_FOUND FALSE)
49+
endif ()

CMakeLists.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
cmake_minimum_required(VERSION 3.21)
22
project (Plugin.Core.SteamAudio)
33

4-
# Top-level plugin build is not supported yet.
5-
# If the plugin is only built as subdirectory, this snippet is not needed and may be discarded.
64
if (PROJECT_IS_TOP_LEVEL)
75
set (CMAKE_CXX_STANDARD 17)
86
find_package (Urho3D REQUIRED)
@@ -11,6 +9,20 @@ endif ()
119
file (GLOB SOURCE_FILES *.h *.cpp)
1210
add_plugin (${PROJECT_NAME} "${SOURCE_FILES}")
1311

12+
# Link to SteamAudio
13+
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake/Modules")
14+
find_package (SteamAudio REQUIRED)
15+
target_include_directories (${PROJECT_NAME} PRIVATE ${STEAMAUDIO_INCLUDE_DIRS})
16+
target_link_libraries (${PROJECT_NAME} PRIVATE ${STEAMAUDIO_LIBRARIES})
17+
18+
# Copy .so and .dll files to the binary directory
19+
foreach (lib ${STEAMAUDIO_LIBRARIES})
20+
string (REGEX REPLACE ".lib$" ".dll" lib "${lib}")
21+
if ("${lib}" MATCHES ".*\\.(so|dll)" AND EXISTS "${lib}")
22+
add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${lib} $<TARGET_FILE_DIR:${PROJECT_NAME}>)
23+
endif ()
24+
endforeach ()
25+
1426
if (URHO3D_CSHARP)
1527
set (DEST_BIN_DIR_CONFIG bin)
1628
set (DEST_LIBRARY_DIR_CONFIG bin)

SampleComponent.cpp

Lines changed: 0 additions & 27 deletions
This file was deleted.

SampleComponent.h

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)