Skip to content

Commit

Permalink
feat(plugins): Move FLAC codec to a dedicated plugin.
Browse files Browse the repository at this point in the history
The Flac Plugin is a shared library backed by the libflac.
  • Loading branch information
na2axl committed Nov 7, 2023
1 parent c1b2813 commit e188059
Show file tree
Hide file tree
Showing 13 changed files with 643 additions and 12,808 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Build and release Amplitude Audio SDK

on:
push:
pull_request:
release:
tags:
- "v*"

jobs:
build-sdk:
uses: ./.github/workflows/cmake.yml
with:
project-path: .
name: Amplitude Audio SDK

build-plugins:
needs: [ build-sdk ]
uses: ./.github/workflows/cmake.yml
with:
project-path: ./plugins/${{ matrix.project.path }}
name: ${{ matrix.project.name }}
strategy:
matrix:
project:
- name: FLAC Codec
path: codec-flac

release:
needs: [ build-plugins ]
runs-on: ${{ matrix.config.os }}
name: "[${{ matrix.build_type }}] ${{ matrix.config.name }}"
strategy:
fail-fast: false
matrix:
build_type: [ "release", "debug" ]
config:
- name: "Windows Latest MSVC"
os: windows-latest
artifact: "amplitude_audio_sdk_windows_msvc_x64.7z"
archiver: "7z a"

- name: "Windows Latest MinGW"
os: windows-latest
artifact: "amplitude_audio_sdk_windows_mingw_x64.7z"
archiver: "7z a"

- name: "Ubuntu_Latest_GCC"
os: ubuntu-latest
artifact: "amplitude_audio_sdk_linux_gcc_x64.7z"
archiver: "7z a"

- name: "Ubuntu_GCC_9"
os: ubuntu-latest
artifact: "amplitude_audio_sdk_linux_gcc9_x64.7z"
archiver: "7z a"

- name: "macOS Latest Clang"
os: macos-latest
artifact: "amplitude_audio_sdk_macos_clang_x64.7z"
archiver: "7za a"

steps:
- name: Setup SDK Cache
uses: actions/cache@v3
with:
path: sdk
key: ${{ matrix.build_type }}-${{ matrix.config.artifact }}-${{ env.GITHUB_SHA }}
restore-keys: |
${{ matrix.build_type }}-${{ matrix.config.artifact }}-
- name: Pack
shell: bash
run: ${{ matrix.config.archiver }} ./${{ matrix.build_type }}_${{ matrix.config.artifact }} LICENSE README.md sdk

- name: Upload
uses: actions/upload-artifact@v1
with:
path: ./${{ matrix.build_type }}_${{ matrix.config.artifact }}
name: ${{ matrix.build_type }}_${{ matrix.config.artifact }}

- name: Upload release asset
if: github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'created')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./${{ matrix.build_type }}_${{ matrix.config.artifact }}
asset_name: ${{ matrix.build_type }}_${{ matrix.config.artifact }}.zip
asset_content_type: application/zip
54 changes: 18 additions & 36 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Build
name: Build CMake Project

on:
push:
pull_request:
release:
tags:
- "v*"
workflow_call:
inputs:
project-path:
required: true
type: string

jobs:
build:
Expand All @@ -21,7 +21,6 @@ jobs:
artifact: "amplitude_audio_sdk_windows_msvc_x64.7z"
cc: "cl"
cxx: "cl"
archiver: "7z a"
generator: "Visual Studio 17 2022"
target_triplet: x64-windows

Expand All @@ -30,7 +29,6 @@ jobs:
artifact: "amplitude_audio_sdk_windows_mingw_x64.7z"
cc: "gcc"
cxx: "g++"
archiver: "7z a"
generator: "Ninja"
target_triplet: x64-windows

Expand All @@ -39,7 +37,6 @@ jobs:
artifact: "amplitude_audio_sdk_linux_gcc_x64.7z"
cc: "gcc"
cxx: "g++"
archiver: "7z a"
generator: "Ninja"
target_triplet: x64-linux

Expand All @@ -48,7 +45,6 @@ jobs:
artifact: "amplitude_audio_sdk_linux_gcc9_x64.7z"
cc: "gcc"
cxx: "g++"
archiver: "7z a"
generator: "Ninja"
target_triplet: x64-linux

Expand All @@ -57,7 +53,6 @@ jobs:
artifact: "amplitude_audio_sdk_macos_clang_x64.7z"
cc: "clang"
cxx: "clang++"
archiver: "7za a"
generator: "Ninja"
target_triplet: x64-osx

Expand All @@ -73,9 +68,8 @@ jobs:
echo github.event_name: ${{ github.event_name }}
- name: Setup vcpkg
uses: lukka/run-vcpkg@v10.0
uses: lukka/run-vcpkg@v11.2
with:
runVcpkgInstall: true
vcpkgGitCommitId: 9f03078bdcbab3ad8c1e3927c40c3fb48e42501f

- name: Find flatc version
Expand Down Expand Up @@ -163,8 +157,17 @@ jobs:
sudo unzip Mac.flatc.binary.zip -d bin
./bin/flatc --version
- name: Setup SDK Cache
uses: actions/cache@v3
with:
path: sdk
key: ${{ matrix.build_type }}-${{ matrix.config.artifact }}-${{ env.GITHUB_SHA }}
restore-keys: |
${{ matrix.build_type }}-${{ matrix.config.artifact }}-
- name: Configure
shell: bash
working-directory: ${{ inputs.project-path }}
run: |
mkdir build
cmake \
Expand All @@ -179,31 +182,10 @@ jobs:
- name: Build
shell: bash
working-directory: build
working-directory: ${{ inputs.project-path }}/build
run: cmake --build . --config ${{ matrix.build_type }}

- name: Install Strip
shell: bash
working-directory: build
working-directory: ${{ inputs.project-path }}/build
run: cmake --install . --strip --config ${{ matrix.build_type }}

- name: Pack
shell: bash
run: ${{ matrix.config.archiver }} ./${{ matrix.build_type }}_${{ matrix.config.artifact }} LICENSE README.md sdk

- name: Upload
uses: actions/upload-artifact@v1
with:
path: ./${{ matrix.build_type }}_${{ matrix.config.artifact }}
name: ${{ matrix.build_type }}_${{ matrix.config.artifact }}

- name: Upload release asset
if: github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'created')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./${{ matrix.build_type }}_${{ matrix.config.artifact }}
asset_name: ${{ matrix.build_type }}_${{ matrix.config.artifact }}.zip
asset_content_type: application/zip
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ set(SA_SOURCE
src/Core/Codecs/AMS/Codec.cpp
src/Core/Codecs/AMS/Codec.h

src/Core/Codecs/FLAC/Codec.cpp
src/Core/Codecs/FLAC/Codec.h
src/Core/Codecs/FLAC/dr_flac.h

src/Core/Codecs/MP3/Codec.cpp
src/Core/Codecs/MP3/Codec.h
src/Core/Codecs/MP3/dr_mp3.h
Expand Down
90 changes: 90 additions & 0 deletions plugins/codec-flac/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Copyright (c) 2021-present Sparky Studios. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.20)

cmake_policy(SET CMP0048 NEW)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../sdk/cmake")

project(AmplitudeFlacCodecPlugin)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_DEBUG_POSTFIX "_d")

set(BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(OBJ_DIR ${CMAKE_CURRENT_BINARY_DIR}/obj)

if(MSVC OR WIN32)
set(RUNTIME_OUTPUT_DIRECTORY "win")
elseif(APPLE)
set(RUNTIME_OUTPUT_DIRECTORY "osx")
set(CMAKE_MACOSX_RPATH 1)
list(APPEND CMAKE_INSTALL_RPATH "@executable_path" "@loader_path/../shared/")
else()
set(RUNTIME_OUTPUT_DIRECTORY "linux")
list(APPEND CMAKE_INSTALL_RPATH "${ORIGIN}" "${ORIGIN}/../shared/")
endif()

find_package(FLAC CONFIG REQUIRED)

# Setup Amplitude
# ------------------------------------------------------------------------------
find_package(AmplitudeAudioSDK REQUIRED)

# Setup project source files.
set(PLUGIN_SOURCE
Plugin.h
Plugin.cpp
Codec.h
Codec.cpp
)

# Includes for this project
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${AM_SDK_PATH}/include
)

add_library(${PROJECT_NAME} SHARED ${PLUGIN_SOURCE})
target_compile_definitions(${PROJECT_NAME} PRIVATE AM_BUILDSYSTEM_BUILDING_PLUGIN)

target_link_libraries(${PROJECT_NAME}
PRIVATE SparkyStudios::Audio::Amplitude::SDK::Shared FLAC::FLAC++
)

# #####################################################
# INSTALL

set(AM_LIB_DESTINATION "lib/${RUNTIME_OUTPUT_DIRECTORY}")
set(AM_INC_DESTINATION "include")

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${AM_LIB_DESTINATION}")

set(CMAKE_INSTALL_PREFIX "${AM_SDK_PATH}")

install(
TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION ${AM_LIB_DESTINATION}/plugins
LIBRARY DESTINATION ${AM_LIB_DESTINATION}/plugins
RUNTIME DESTINATION ${AM_LIB_DESTINATION}/plugins
)

install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${AM_INC_DESTINATION}
FILES_MATCHING PATTERN "*.h*"
)

export(PACKAGE ${PROJECT_NAME})
Loading

0 comments on commit e188059

Please sign in to comment.