Compare commits

..

32 commits

Author SHA1 Message Date
orbea
72559114c8
Remove SDL1 support (#45)
* build: remove executable permissions from Makefile

* build: remove SDL1 support

* src: remove SDL1 code path
2024-11-02 21:09:01 -07:00
orbea
7573056761
build: remove -fno-strict-aliasing (#44)
This builds with -Werror=strict-aliasing so it should be not required.
2024-11-02 21:08:14 -07:00
Richard Goedeken
6c2c3f8ae1 update version and release info for v2.6.0 release 2024-07-14 16:01:42 -07:00
Richard Goedeken
32e2f282bb update minimum macos SDK in makefile 2024-07-14 11:59:53 -07:00
Jj0YzL5nvJ
639466bdb0
CI/CD: Update to generic scripts, independent schedule, etc (#43) 2024-05-26 19:57:32 -07:00
Jj0YzL5nvJ
cec70e42b4
CI/CD: Fixes Ubuntu i386 builds, among other changes (#42) 2023-06-11 12:21:09 -07:00
Jj0YzL5nvJ
8d5df662e9
CI/CD: Integrate scheduled builds and other necessary updates (#41) 2023-03-02 22:01:21 -08:00
Jj0YzL5nvJ
8f372a02b0
CI/CD: Update MSVC (#40) 2022-09-30 17:00:14 -07:00
Jj0YzL5nvJ
df0770215f
CI/CD: Update (#39) 2022-07-13 19:31:03 -07:00
Jj0YzL5nvJ
238b119ac9
CI/CD: Implement GitHub Actions and public nightly builds (#38) 2022-04-11 20:54:01 -07:00
bsmiles32
af6af5b1fd
Fix channel swapping logic for BigEndian systems (#37)
* Fix channel swapping logic for BigEndian systems
2021-02-19 20:59:12 -08:00
Richard Goedeken
f352528e43
Merge pull request #35 from bsmiles32/fixes
Fixes
2021-02-19 20:49:48 -08:00
Bobby Smiles
393b1c1f3e Fix warning about maybe uninitialized variable in trivial resampler 2021-01-17 17:09:36 +01:00
Bobby Smiles
1b0b1ecfe7 Fix building for SDL version < 1.3 2021-01-17 17:07:13 +01:00
Bobby Smiles
8182d1d847 Fix audio locking 2021-01-17 16:23:17 +01:00
Bobby Smiles
6c6bb9de24 Simplify sdl_backend API
Audio generated by N64 is always 16-bit stereo. BITRATE is not related
to sample depth at all. So we can simplify set_format and rename it as
set_frequency.
2021-01-17 14:36:19 +01:00
Bobby Smiles
8602b6cec6 Improve debugging when obtained spec differs from desired spec. 2021-01-17 12:11:38 +01:00
orbea
a2472a2788 build: Allow out of tree builds. 2020-12-15 10:16:58 +01:00
Richard Goedeken
1acd163aec Revert "Allow non-default compilers without resorting to symbolic links"
This reverts commit 7155ae6f21, as it conflicts with GNU make which always defines default values for certain variables
2020-09-16 22:40:41 -07:00
Richard Goedeken
39b8cb778c
Merge pull request #32 from Jj0YzL5nvJ/alter_cc_cxx
Allow non-default compilers without resorting to symbolic links
2020-08-30 18:53:18 -07:00
Jj0YzL5nvJ
7155ae6f21 Allow non-default compilers without resorting to symbolic links 2020-08-30 03:57:07 -06:00
Richard Goedeken
671b1b5dc3
Merge pull request #31 from Jj0YzL5nvJ/alter
Allow to set custom platform toolset from commands
2020-08-19 23:36:17 -07:00
Jj0YzL5nvJ
03824450cf Allow to set custom platform toolset from commands 2020-08-13 12:10:16 -06:00
Richard Goedeken
5c431df063 fix mupen64plus-user-issues ticket #712 - set AUDIO_SYNC to true by default 2020-04-21 17:37:19 -07:00
bsmiles32
9e9cd51021
Merge pull request #30 from Gillou68310/SDL2
Add SDL2 compatibility
2020-03-23 12:37:35 +01:00
Gillou68310
e19955bd9e Add SDL2 compatibility 2020-03-02 11:59:23 +01:00
Jj0YzL5nvJ
fb9aa4d65e AppVeyor with artifact packaging 2020-03-02 09:40:43 +01:00
James Donald
a82c12e300 Add standard headers to define uint32_t 2020-03-02 09:40:12 +01:00
Jj0YzL5nvJ
9430858d4c Changes to have more generic project files 2020-02-26 12:40:02 +01:00
Gillou68310
b51ea78013 Migrate to VS2017 2019-11-13 15:43:50 +01:00
Richard Goedeken
4a94ca44b1 add function attributes so GCC can find bugs in calls to string formatting functions with variadic arguments 2019-03-03 09:15:22 -08:00
Richard Goedeken
0176ffb8b1 fix integer size bugs in string format functions with variadic arguments 2019-03-03 09:14:41 -08:00
13 changed files with 550 additions and 130 deletions

160
.github/workflows/build.yml vendored Normal file
View file

@ -0,0 +1,160 @@
name: SDL Audio
on:
push:
paths-ignore:
- '.{gitattributes,gitignore,travis.yml}'
- '*.md,appveyor.yml,README'
pull_request:
paths-ignore:
- '.{gitattributes,gitignore,travis.yml}'
- '*.md,appveyor.yml,README'
workflow_dispatch:
jobs:
Linux:
strategy:
fail-fast: false
matrix:
include:
- cc: GCC
arch: x64
- cc: GCC
arch: x86
- cc: Clang
arch: x64
- cc: Clang
arch: x86
name: Linux / ${{ matrix.cc }} / ${{ matrix.arch }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Get build dependencies and arrange the environment
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ../mupen64plus-core
export C_CLANG_SUFFIX="-15" C_GCC_SUFFIX="-12"
export BUILD_DEPS="libsamplerate0-dev libsdl1.2-dev libsdl2-dev libspeexdsp-dev"
./../mupen64plus-core/.github/workflows/scripts/ci_install_ubuntu_deps.sh ${{ matrix.arch }} ${{ matrix.cc }}
- name: Build and related stuff, backup binaries
run: |
export C_CLANG_SUFFIX="-15" C_GCC_SUFFIX="-12"
export PATH="$(pwd)/../mupen64plus-core/.github/workflows/scripts:${PATH}"
export CONFIG_OVERRIDE="SDL_CONFIG="sdl-config""
ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }}
export CONFIG_OVERRIDE="SDL_CONFIG="sdl2-config""
ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} makepkg
- name: Upload artifact
if: matrix.cc == 'GCC'
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKG_NAME }}
path: pkg/*.tar.gz
MSYS2:
strategy:
fail-fast: false
matrix:
include:
- cc: GCC
arch: x64
cross: x86_64
env: MINGW64
- cc: GCC
arch: x86
cross: i686
env: MINGW32
name: Windows / MSYS2 ${{ matrix.cc }} / ${{ matrix.arch }}
runs-on: windows-2022
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.env }}
update: true
install: >-
git
libtool
make
mingw-w64-${{ matrix.cross }}-gcc
mingw-w64-${{ matrix.cross }}-toolchain
mingw-w64-${{ matrix.cross }}-libsamplerate
mingw-w64-${{ matrix.cross }}-ntldd
mingw-w64-${{ matrix.cross }}-SDL2
mingw-w64-${{ matrix.cross }}-speexdsp
- name: Build and related stuff, backup binaries
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ../mupen64plus-core
./../mupen64plus-core/.github/workflows/scripts/ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }}
- name: Backup dependencies, etc...
run: |
./../mupen64plus-core/.github/workflows/scripts/ci_backup_mingw_deps.sh ${{ matrix.env }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKG_NAME }}
path: pkg/*
MSVC:
strategy:
fail-fast: false
matrix:
include:
- toolset: v143
arch: x64
vs: 2022
- toolset: v141_xp
arch: x86
vs: 2019
name: Windows / MSVC with ${{ matrix.toolset }} / ${{ matrix.arch }}
runs-on: windows-${{ matrix.vs }}
defaults:
run:
shell: cmd
steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-msbuild@v2
- name: Build and related stuff, backup binaries
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ..\mupen64plus-core
set TOOLSET=${{ matrix.toolset }}
.\..\mupen64plus-core\.github\workflows\scripts\ci_msvc_build.cmd ${{ matrix.arch }}
- name: Backup dependencies, etc...
run: |
.\..\mupen64plus-core\.github\workflows\scripts\ci_backup_msvc_deps.cmd ${{ matrix.arch }} SDL2.dll
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKG_NAME }}
path: pkg/*
Nightly-build:
runs-on: ubuntu-latest
if: github.ref_name == 'master'
needs: [Linux, MSYS2, MSVC]
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: binaries
- name: Get some tools
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ../mupen64plus-core
sudo apt-get update
sudo apt-get -y install hashdeep
- name: Creating new artifacts and update nightly-build
run: |
./../mupen64plus-core/.github/workflows/scripts/ci_nightly_artifacts.sh
- name: Nightly-build
uses: ncipollo/release-action@v1
with:
prerelease: true
allowUpdates: true
removeArtifacts: true
replacesArtifacts: false
tag: nightly-build
artifacts: pkg/*

156
.github/workflows/schedule.yml vendored Normal file
View file

@ -0,0 +1,156 @@
name: SDL Audio - Scheduled
on:
schedule:
- cron: '45 14 21 * *'
jobs:
Linux:
strategy:
fail-fast: false
matrix:
include:
- cc: GCC
arch: x64
- cc: GCC
arch: x86
- cc: Clang
arch: x64
- cc: Clang
arch: x86
name: Linux / ${{ matrix.cc }} / ${{ matrix.arch }}
runs-on: ubuntu-22.04
if: github.repository == 'mupen64plus/mupen64plus-audio-sdl'
steps:
- uses: actions/checkout@v4
- name: Get build dependencies and arrange the environment
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ../mupen64plus-core
export C_CLANG_SUFFIX="-15" C_GCC_SUFFIX="-12"
export BUILD_DEPS="libsamplerate0-dev libsdl1.2-dev libsdl2-dev libspeexdsp-dev"
./../mupen64plus-core/.github/workflows/scripts/ci_install_ubuntu_deps.sh ${{ matrix.arch }} ${{ matrix.cc }}
- name: Build and related stuff, backup binaries
run: |
export C_CLANG_SUFFIX="-15" C_GCC_SUFFIX="-12"
export PATH="$(pwd)/../mupen64plus-core/.github/workflows/scripts:${PATH}"
export CONFIG_OVERRIDE="SDL_CONFIG="sdl-config""
ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }}
export CONFIG_OVERRIDE="SDL_CONFIG="sdl2-config""
ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }} makepkg
- name: Upload artifact
if: matrix.cc == 'GCC'
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKG_NAME }}
path: pkg/*.tar.gz
MSYS2:
strategy:
fail-fast: false
matrix:
include:
- cc: GCC
arch: x64
cross: x86_64
env: MINGW64
- cc: GCC
arch: x86
cross: i686
env: MINGW32
name: Windows / MSYS2 ${{ matrix.cc }} / ${{ matrix.arch }}
runs-on: windows-2022
if: github.repository == 'mupen64plus/mupen64plus-audio-sdl'
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.env }}
update: true
install: >-
git
libtool
make
mingw-w64-${{ matrix.cross }}-gcc
mingw-w64-${{ matrix.cross }}-toolchain
mingw-w64-${{ matrix.cross }}-libsamplerate
mingw-w64-${{ matrix.cross }}-ntldd
mingw-w64-${{ matrix.cross }}-SDL2
mingw-w64-${{ matrix.cross }}-speexdsp
- name: Build and related stuff, backup binaries
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ../mupen64plus-core
./../mupen64plus-core/.github/workflows/scripts/ci_build.sh ${{ matrix.arch }} ${{ matrix.cc }}
- name: Backup dependencies, etc...
run: |
./../mupen64plus-core/.github/workflows/scripts/ci_backup_mingw_deps.sh ${{ matrix.env }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKG_NAME }}
path: pkg/*
MSVC:
strategy:
fail-fast: false
matrix:
include:
- toolset: v143
arch: x64
vs: 2022
- toolset: v141_xp
arch: x86
vs: 2019
name: Windows / MSVC with ${{ matrix.toolset }} / ${{ matrix.arch }}
runs-on: windows-${{ matrix.vs }}
if: github.repository == 'mupen64plus/mupen64plus-audio-sdl'
defaults:
run:
shell: cmd
steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-msbuild@v2
- name: Build and related stuff, backup binaries
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ..\mupen64plus-core
set TOOLSET=${{ matrix.toolset }}
.\..\mupen64plus-core\.github\workflows\scripts\ci_msvc_build.cmd ${{ matrix.arch }}
- name: Backup dependencies, etc...
run: |
.\..\mupen64plus-core\.github\workflows\scripts\ci_backup_msvc_deps.cmd ${{ matrix.arch }} SDL2.dll
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKG_NAME }}
path: pkg/*
Nightly-build:
runs-on: ubuntu-latest
if: github.ref_name == 'master'
needs: [Linux, MSYS2, MSVC]
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: binaries
- name: Get some tools
run: |
git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ../mupen64plus-core
sudo apt-get update
sudo apt-get -y install hashdeep
- name: Creating new artifacts and update nightly-build
run: |
./../mupen64plus-core/.github/workflows/scripts/ci_nightly_artifacts.sh
- name: Nightly-build
uses: ncipollo/release-action@v1
with:
prerelease: true
allowUpdates: true
removeArtifacts: true
replacesArtifacts: false
tag: nightly-build
artifacts: pkg/*

54
RELEASE
View file

@ -1,9 +1,57 @@
SDL Audio plugin for Mupen64Plus
---------------------------------
Mupen64Plus-audio-sdl v2.5.9 - February 10, 2019
------------------------------------------------
- *** BETA RELEASE *** For Testing Only ***
----------------------------------------------
# Mupen64Plus-audio-sdl v2.6.0 - July 14, 2024
## Merged PRs
* [43](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/43): CI/CD: Update to generic scripts, independent schedule, etc
* [42](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/42): CI/CD: Fixes Ubuntu i386 builds, among other changes
* [41](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/41): CI/CD: Integrate scheduled builds and other...
* [40](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/40): CI/CD: Update MSVC
* [39](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/39): CI/CD: Update
* [38](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/38): CI/CD: Implement GitHub Actions and public nightly builds
* [37](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/37): Fix channel swapping logic for BigEndian systems
* [35](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/35): Fixes
* [34](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/34): build: Allow out of tree builds.
* [32](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/32): Allow non-default compilers without resorting to symbolic links
* [31](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/31): Allow to set custom platform toolset from commands
* [30](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/30): Add SDL2 compatibility
* [29](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/29): AppVeyor with artifact packaging
* [28](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/28): Changes to have more generic project files
* [27](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/27): Fix gcc 8.3 compile with headers for uint32_t
## Top Contributors (2 or more commits)
1. Jj0YzL5nvJ
2. bsmiles32
3. richard42
4. Gillou68310
--------------------------------------------------
# Mupen64Plus-audio-sdl v2.5.9 - February 10, 2019
## Merged PRs
* [26](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/26): Remove use of ConfigSaveOptions.
* [25](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/25): Update homepage links
* [24](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/24): Fix swap channels path.
* [23](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/23): Remove underrun messages as it spammed too much and is not really needed
* [22](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/22): Build MXE targets as additional tests in travis build matrix
* [21](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/21): Various fixes.
Hopefully this should fix the "audio cracks" reported in https://github.com/mupen64plus/mupen64plus-core/issues/463
* [20](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/20): Disable speex/src when their libraries are not found
* [19](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/19): Refactorings
* [17](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/17): Use faster container based Travis CI
* [16](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/16): Allow audio/video sync to be configured, default to off
* [15](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/15): Use resampler if available
* [14](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/14): bump macosx-version-min to 10.6 for SDL2.0.5.
Allows for compilation on MacOS 10.12 Sierra using packages from Homebrew (samplerate speexdsp nasm and the sdl2 packages).
* [13](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/13): Use Ubuntu Trusty as base system for Travis CI
* [12](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/12): Added x64 configuration to VisualStudio2013 project file
* [11](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/11): Remove unnecessary OpenBSD warning.
* [10](https://github.com/mupen64plus/mupen64plus-audio-sdl/pull/10): bug workaround (volume does not follow system volume on jolla phone)
Mupen64Plus-audio-sdl - v2.5 - April 26, 2015
---------------------------------------------

41
appveyor.yml Normal file
View file

@ -0,0 +1,41 @@
version: 1.0.{build}
image: Visual Studio 2022
skip_tags: true
skip_commits:
files:
- '**/*.md'
- .github/
- data/*
- .gitattributes
- .gitignore
- .travis.yml
- README
configuration:
- Release
platform:
- Win32
- x64
before_build:
- git tag --delete nightly-build
- git clone --depth 1 https://github.com/mupen64plus/mupen64plus-win32-deps.git ..\mupen64plus-win32-deps
- git clone --depth 1 https://github.com/mupen64plus/mupen64plus-core.git ..\mupen64plus-core
build_script:
- msbuild projects\msvc\mupen64plus-audio-sdl.vcxproj /p:Configuration=%configuration%;Platform=%platform%
after_build:
- ps: $env:rev1 = git describe --tags
- set rev2=%platform%
- if "%rev2%"=="Win32" set rev2=x86
- set filepkg=mupen64plus-audio-sdl_v%rev1%_%rev2%
- cd projects\msvc\%platform%\%configuration%
- 7z a -t7z ..\..\..\..\build\%filepkg%.7z *.dll
artifacts:
- path: build\$(filepkg).7z
name: $(filepkg)

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@ -21,30 +21,41 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{96969748-EA54-43FC-8103-A346E9AD98E7}</ProjectGuid>
<RootNamespace>mupen64plusaudiosdl</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<PropertyGroup Condition="'$(WindowsTargetPlatformVersion)'=='' and '$(VisualStudioVersion)' != '14.0'">
<LatestTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</LatestTargetPlatformVersion>
<WindowsTargetPlatformVersion>$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion>
<TargetPlatformVersion>$(WindowsTargetPlatformVersion)</TargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(PlatformToolset)'=='' or '$(PlatformToolset)'=='v100'" Label="Configuration">
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v120_xp</PlatformToolset>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v120</PlatformToolset>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@ -62,102 +73,66 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\src;..\..\..\mupen64plus-core\src\api;..\..\..\mupen64plus-win32-deps\SDL-1.2.15\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\src;..\..\..\mupen64plus-core\src\api;..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>..\..\..\mupen64plus-win32-deps\SDL-1.2.15\lib\x86\SDL.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\lib\x86\SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\src;..\..\..\mupen64plus-core\src\api;..\..\..\mupen64plus-win32-deps\SDL-1.2.15\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\src;..\..\..\mupen64plus-core\src\api;..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>..\..\..\mupen64plus-win32-deps\SDL-1.2.15\lib\x64\SDL.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\lib\x64\SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\src;..\..\..\mupen64plus-core\src\api;..\..\..\mupen64plus-win32-deps\SDL-1.2.15\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\src;..\..\..\mupen64plus-core\src\api;..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<AdditionalDependencies>..\..\..\mupen64plus-win32-deps\SDL-1.2.15\lib\x86\SDL.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\lib\x86\SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\src;..\..\..\mupen64plus-core\src\api;..\..\..\mupen64plus-win32-deps\SDL-1.2.15\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\src;..\..\..\mupen64plus-core\src\api;..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<AdditionalDependencies>..\..\..\mupen64plus-win32-deps\SDL-1.2.15\lib\x64\SDL.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\lib\x64\SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>

52
projects/unix/Makefile Executable file → Normal file
View file

@ -93,10 +93,13 @@ ifeq ("$(CPU)","OTHER")
PIC ?= 1
endif
SRCDIR = ../../src
OBJDIR = _obj$(POSTFIX)
# base CFLAGS, LDLIBS, and LDFLAGS
OPTFLAGS ?= -O3 -flto
WARNFLAGS ?= -Wall
CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src
CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -ffast-math -fvisibility=hidden -I$(SRCDIR)
LDFLAGS += $(SHARED)
# Since we are building a shared library, we must compile with -fPIC on some architectures
@ -112,8 +115,20 @@ ifeq ($(ARCH_DETECTED), 64BITS_32)
ifeq ($(OS), FREEBSD)
$(error Do not use the BITS=32 option with FreeBSD, use -m32 and -m elf_i386)
endif
ifneq ($(OS), OSX)
ifeq ($(OS), MINGW)
LDFLAGS += -Wl,-m,i386pe
else
CFLAGS += -m32
LDFLAGS += -Wl,-m,elf_i386
endif
endif
endif
ifeq ($(ARCH_DETECTED), 64BITS)
ifeq ($(OS), MINGW)
LDFLAGS += -Wl,-m,i386pep
endif
endif
# set special flags per-system
@ -125,32 +140,15 @@ ifeq ($(OS), OSX)
ifeq ($(CPU), X86)
ifeq ($(ARCH_DETECTED), 64BITS)
CFLAGS += -pipe -arch x86_64 -mmacosx-version-min=10.6 -isysroot $(OSX_SDK_PATH)
CFLAGS += -pipe -arch x86_64 -mmacosx-version-min=10.9 -isysroot $(OSX_SDK_PATH)
LDLIBS += -ldl
else
CFLAGS += -pipe -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=10.6 -isysroot $(OSX_SDK_PATH)
CFLAGS += -pipe -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=10.9 -isysroot $(OSX_SDK_PATH)
LDLIBS += -ldl -read_only_relocs suppress
endif
endif
endif
# test for presence of SDL
ifeq ($(origin SDL_CFLAGS) $(origin SDL_LDLIBS), undefined undefined)
SDL_CONFIG = $(CROSS_COMPILE)sdl2-config
ifeq ($(shell which $(SDL_CONFIG) 2>/dev/null),)
SDL_CONFIG = $(CROSS_COMPILE)sdl-config
ifeq ($(shell which $(SDL_CONFIG) 2>/dev/null),)
$(error No SDL development libraries found!)
else
$(warning Using SDL 1.2 libraries)
endif
endif
SDL_CFLAGS += $(shell $(SDL_CONFIG) --cflags)
SDL_LDLIBS += $(shell $(SDL_CONFIG) --libs)
endif
CFLAGS += $(SDL_CFLAGS)
LDLIBS += $(SDL_LDLIBS)
# test for essential build dependencies
ifeq ($(origin PKG_CONFIG), undefined)
PKG_CONFIG = $(CROSS_COMPILE)pkg-config
@ -159,6 +157,17 @@ ifeq ($(origin PKG_CONFIG), undefined)
endif
endif
# test for presence of SDL
ifeq ($(origin SDL_CFLAGS) $(origin SDL_LDLIBS), undefined undefined)
ifeq ($(shell $(PKG_CONFIG) --modversion sdl2 2>/dev/null),)
$(error No SDL2 development libraries found!)
endif
SDL_CFLAGS += $(shell $(PKG_CONFIG) --cflags sdl2)
SDL_LDLIBS += $(shell $(PKG_CONFIG) --libs sdl2)
endif
CFLAGS += $(SDL_CFLAGS)
LDLIBS += $(SDL_LDLIBS)
# test for presence of speexdsp
ifneq ($(NO_SPEEX), 1)
ifeq ($(origin SPEEX_CFLAGS) $(origin SPEEX_LDLIBS), undefined undefined)
@ -291,9 +300,6 @@ ifeq ($(PLUGINDIR),)
PLUGINDIR := $(LIBDIR)/mupen64plus
endif
SRCDIR = ../../src
OBJDIR = _obj$(POSTFIX)
# list of source files to compile
SOURCE = \
$(SRCDIR)/circular_buffer.c \

View file

@ -22,7 +22,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <SDL.h>
#include <SDL_audio.h>
#include <stdio.h>
#include <stdarg.h>
#include "main.h"
@ -43,7 +45,7 @@
#include "m64p_types.h"
/* version info */
#define SDL_AUDIO_PLUGIN_VERSION 0x020509
#define SDL_AUDIO_PLUGIN_VERSION 0x020600
#define AUDIO_PLUGIN_API_VERSION 0x020000
#define CONFIG_API_VERSION 0x020100
#define CONFIG_PARAM_VERSION 1.00
@ -74,6 +76,8 @@
They tend to rely on a default frequency, apparently, never the same one ;)*/
#define DEFAULT_FREQUENCY 33600
#define SDL_MixAudio(A, B, C, D) SDL_MixAudioFormat(A, B, AUDIO_S16SYS, C, D)
/* local variables */
static void (*l_DebugCallback)(void *, int, const char *) = NULL;
static void *l_DebugCallContext = NULL;
@ -230,7 +234,7 @@ EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Con
ConfigSetDefaultInt(l_ConfigAudio, "VOLUME_CONTROL_TYPE", VOLUME_TYPE_SDL, "Volume control type: 1 = SDL (only affects Mupen64Plus output) 2 = OSS mixer (adjusts master PC volume)");
ConfigSetDefaultInt(l_ConfigAudio, "VOLUME_ADJUST", 5, "Percentage change each time the volume is increased or decreased");
ConfigSetDefaultInt(l_ConfigAudio, "VOLUME_DEFAULT", 80, "Default volume when a game is started. Only used if VOLUME_CONTROL_TYPE is 1");
ConfigSetDefaultBool(l_ConfigAudio, "AUDIO_SYNC", 0, "Synchronize Video/Audio");
ConfigSetDefaultBool(l_ConfigAudio, "AUDIO_SYNC", 1, "Synchronize Video/Audio");
#ifdef USE_AUDIORESOURCE
setenv("PULSE_PROP_media.role", "x-maemo", 1);
@ -316,9 +320,8 @@ EXPORT void CALL AiDacrateChanged(int SystemType)
return;
unsigned int frequency = dacrate2freq(vi_clock_from_system_type(SystemType), *AudioInfo.AI_DACRATE_REG);
unsigned int bits = 1 + (*AudioInfo.AI_BITRATE_REG);
sdl_set_format(l_sdl_backend, frequency, bits);
sdl_set_frequency(l_sdl_backend, frequency);
}
EXPORT void CALL AiLenChanged(void)

View file

@ -24,6 +24,12 @@
#include <stddef.h>
#if defined(__GNUC__)
#define ATTR_FMT(fmtpos, attrpos) __attribute__ ((format (printf, fmtpos, attrpos)))
#else
#define ATTR_FMT(fmtpos, attrpos)
#endif
struct resampler_interface;
/* volume mixer types */
@ -56,4 +62,5 @@ extern ptr_ConfigGetParamFloat ConfigGetParamFloat;
extern ptr_ConfigGetParamBool ConfigGetParamBool;
extern ptr_ConfigGetParamString ConfigGetParamString;
void DebugMessage(int level, const char *message, ...);
void DebugMessage(int level, const char *message, ...) ATTR_FMT(2,3);

View file

@ -27,6 +27,7 @@
#include "m64p_types.h"
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#define ARRAY_SIZE(x) sizeof((x)) / sizeof((x)[0])
@ -116,7 +117,7 @@ static size_t speex_resample(void* resampler,
if (dst_size != out_len * BYTES_PER_SAMPLE) {
DebugMessage(M64MSG_WARNING, "dst_size = %u != outlen*4 = %u",
dst_size, out_len * BYTES_PER_SAMPLE);
(uint32_t) dst_size, out_len * BYTES_PER_SAMPLE);
}
memset((char*)dst + out_len * BYTES_PER_SAMPLE, 0, dst_size - out_len * BYTES_PER_SAMPLE);

View file

@ -27,6 +27,7 @@
#include "m64p_types.h"
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@ -181,7 +182,7 @@ static size_t src_resample(void* resampler,
if (dst_size != src_data.output_frames_gen*4) {
DebugMessage(M64MSG_WARNING, "dst_size = %u != output_frames_gen*4 = %u",
dst_size, src_data.output_frames_gen*4);
(uint32_t) dst_size, (uint32_t) src_data.output_frames_gen*4);
}
src_float_to_short_array(src_resampler->fbuffers[1].data, (short*)dst, src_data.output_frames_gen*2);

View file

@ -40,13 +40,13 @@ static size_t trivial_resample(void* resampler,
void* dst, size_t dst_size, unsigned int dst_freq)
{
enum { BYTES_PER_SAMPLE = 4 };
size_t i, j;
size_t i;
size_t j = 0;
if (dst_freq >= src_freq) {
const int dpos = 2*src_freq;
const int dneg = dpos - 2*dst_freq;
j = 0;
int criteria = dpos - dst_freq;
for (i = 0; i < dst_size/BYTES_PER_SAMPLE; ++i) {

View file

@ -37,8 +37,14 @@
#define N64_SAMPLE_BYTES 4
#define SDL_SAMPLE_BYTES 4
#define SDL_LockAudio() SDL_LockAudioDevice(sdl_backend->device)
#define SDL_UnlockAudio() SDL_UnlockAudioDevice(sdl_backend->device)
#define SDL_PauseAudio(A) SDL_PauseAudioDevice(sdl_backend->device, A)
#define SDL_CloseAudio() SDL_CloseAudioDevice(sdl_backend->device)
#define SDL_OpenAudio(A, B) ((sdl_backend->device = SDL_OpenAudioDevice(NULL, 0, A, B, 0)) - 1)
struct sdl_backend
{
SDL_AudioDeviceID device;
m64p_handle config;
struct circular_buffer primary_buffer;
@ -75,6 +81,14 @@ struct sdl_backend
const struct resampler_interface* iresampler;
};
/* SDL_AudioFormat.format format specifier and args builder */
#define AFMT_FMTSPEC "%c%d%s"
#define AFMT_ARGS(x) \
((SDL_AUDIO_ISFLOAT(x)) ? 'F' : (SDL_AUDIO_ISSIGNED(x)) ? 'S' : 'U'), \
SDL_AUDIO_BITSIZE(x), \
SDL_AUDIO_ISBIGENDIAN(x) ? "BE" : "LE"
static void my_audio_callback(void* userdata, unsigned char* stream, int len)
{
struct sdl_backend* sdl_backend = (struct sdl_backend*)userdata;
@ -111,14 +125,14 @@ static size_t new_primary_buffer_size(const struct sdl_backend* sdl_backend)
(sdl_backend->output_frequency * 100);
}
static void resize_primary_buffer(struct circular_buffer* cbuff, size_t new_size)
static void resize_primary_buffer(struct sdl_backend* sdl_backend, size_t new_size)
{
/* only grows the buffer */
if (new_size > cbuff->size) {
if (new_size > sdl_backend->primary_buffer.size) {
SDL_LockAudio();
cbuff->data = realloc(cbuff->data, new_size);
memset((unsigned char*)cbuff->data + cbuff->size, 0, new_size - cbuff->size);
cbuff->size = new_size;
sdl_backend->primary_buffer.data = realloc(sdl_backend->primary_buffer.data, new_size);
memset((unsigned char*)sdl_backend->primary_buffer.data + sdl_backend->primary_buffer.size, 0, new_size - sdl_backend->primary_buffer.size);
sdl_backend->primary_buffer.size = new_size;
SDL_UnlockAudio();
}
}
@ -161,9 +175,9 @@ static void sdl_init_audio_device(struct sdl_backend* sdl_backend)
sdl_backend->secondary_buffer_size = ConfigGetParamInt(sdl_backend->config, "SECONDARY_BUFFER_SIZE");
DebugMessage(M64MSG_INFO, "Initializing SDL audio subsystem...");
DebugMessage(M64MSG_VERBOSE, "Primary buffer: %i output samples.", sdl_backend->primary_buffer_size);
DebugMessage(M64MSG_VERBOSE, "Primary target fullness: %i output samples.", sdl_backend->target);
DebugMessage(M64MSG_VERBOSE, "Secondary buffer: %i output samples.", sdl_backend->secondary_buffer_size);
DebugMessage(M64MSG_VERBOSE, "Primary buffer: %i output samples.", (uint32_t) sdl_backend->primary_buffer_size);
DebugMessage(M64MSG_VERBOSE, "Primary target fullness: %i output samples.", (uint32_t) sdl_backend->target);
DebugMessage(M64MSG_VERBOSE, "Secondary buffer: %i output samples.", (uint32_t) sdl_backend->secondary_buffer_size);
memset(&desired, 0, sizeof(desired));
desired.freq = select_output_frequency(sdl_backend->input_frequency);
@ -174,7 +188,7 @@ static void sdl_init_audio_device(struct sdl_backend* sdl_backend)
desired.userdata = sdl_backend;
DebugMessage(M64MSG_VERBOSE, "Requesting frequency: %iHz.", desired.freq);
DebugMessage(M64MSG_VERBOSE, "Requesting format: %i.", desired.format);
DebugMessage(M64MSG_VERBOSE, "Requesting format: " AFMT_FMTSPEC ".", AFMT_ARGS(desired.format));
/* Open the audio device */
if (SDL_OpenAudio(&desired, &obtained) < 0)
@ -185,11 +199,11 @@ static void sdl_init_audio_device(struct sdl_backend* sdl_backend)
}
if (desired.format != obtained.format)
{
DebugMessage(M64MSG_WARNING, "Obtained audio format differs from requested.");
DebugMessage(M64MSG_WARNING, "Obtained audio format (" AFMT_FMTSPEC ") differs from requested (" AFMT_FMTSPEC ").", AFMT_ARGS(obtained.format), AFMT_ARGS(desired.format));
}
if (desired.freq != obtained.freq)
{
DebugMessage(M64MSG_WARNING, "Obtained frequency differs from requested.");
DebugMessage(M64MSG_WARNING, "Obtained frequency (%i) differs from requested (%i).", obtained.freq, desired.freq);
}
/* adjust some variables given the obtained audio spec */
@ -205,7 +219,7 @@ static void sdl_init_audio_device(struct sdl_backend* sdl_backend)
sdl_backend->primary_buffer_size = sdl_backend->secondary_buffer_size * 2;
/* allocate memory for audio buffers */
resize_primary_buffer(&sdl_backend->primary_buffer, new_primary_buffer_size(sdl_backend));
resize_primary_buffer(sdl_backend, new_primary_buffer_size(sdl_backend));
sdl_backend->mix_buffer = realloc(sdl_backend->mix_buffer, sdl_backend->secondary_buffer_size * SDL_SAMPLE_BYTES);
/* preset the last callback time */
@ -214,7 +228,7 @@ static void sdl_init_audio_device(struct sdl_backend* sdl_backend)
}
DebugMessage(M64MSG_VERBOSE, "Frequency: %i", obtained.freq);
DebugMessage(M64MSG_VERBOSE, "Format: %i", obtained.format);
DebugMessage(M64MSG_VERBOSE, "Format: " AFMT_FMTSPEC, AFMT_ARGS(obtained.format));
DebugMessage(M64MSG_VERBOSE, "Channels: %i", obtained.channels);
DebugMessage(M64MSG_VERBOSE, "Silence: %i", obtained.silence);
DebugMessage(M64MSG_VERBOSE, "Samples: %i", obtained.samples);
@ -313,16 +327,11 @@ void release_sdl_backend(struct sdl_backend* sdl_backend)
free(sdl_backend);
}
void sdl_set_format(struct sdl_backend* sdl_backend, unsigned int frequency, unsigned int bits)
void sdl_set_frequency(struct sdl_backend* sdl_backend, unsigned int frequency)
{
if (sdl_backend->error != 0)
return;
/* XXX: assume 16-bit samples */
if (bits != 16) {
DebugMessage(M64MSG_ERROR, "Incoming samples are not 16 bits (%d)", bits);
}
sdl_backend->input_frequency = frequency;
sdl_init_audio_device(sdl_backend);
}
@ -335,35 +344,47 @@ void sdl_push_samples(struct sdl_backend* sdl_backend, const void* src, size_t s
if (sdl_backend->error != 0)
return;
/* XXX: it looks like that using directly the pointer returned by cbuff_head leads to audio "cracks"
* with better resamplers whereas adding cbuff.head inside each memcpy doesn't... Really strange !
*/
cbuff_head(&sdl_backend->primary_buffer, &available);
unsigned char* dst = (unsigned char*)sdl_backend->primary_buffer.data;
/* truncate to full samples */
if (size & 0x3) {
DebugMessage(M64MSG_WARNING, "sdl_push_samples: pushing non full samples: %zu bytes !", size);
}
size = (size / 4) * 4;
/* We need to lock audio before accessing cbuff */
SDL_LockAudio();
unsigned char* dst = cbuff_head(&sdl_backend->primary_buffer, &available);
if (size <= available)
{
SDL_LockAudio();
if (sdl_backend->swap_channels) {
memcpy(dst + sdl_backend->primary_buffer.head, src, size);
/* Confusing logic but, for LittleEndian host using memcpy will result in swapped channels,
* whereas the other branch will result in non-swapped channels.
* For BigEndian host this logic is inverted, memcpy will result in non swapped channels
* and the other branch will result in swapped channels.
*
* This is due to the fact that the core stores 32bit words in native order in RDRAM.
* For instance N64 bytes "Lh Ll Rh Rl" will be stored as "Rl Rh Ll Lh" on LittleEndian host
* and therefore should the non-memcpy path to get non swapped channels,
* whereas on BigEndian host the bytes will be stored as "Lh Ll Rh Rl" and therefore
* memcpy path results in the non-swapped channels outcome.
*/
if (sdl_backend->swap_channels ^ (SDL_BYTEORDER == SDL_BIG_ENDIAN)) {
memcpy(dst, src, size);
}
else {
size_t i;
for (i = 0 ; i < size ; i += 4 )
{
memcpy(dst + sdl_backend->primary_buffer.head + i + 0, (const unsigned char*)src + i + 2, 2); /* Left */
memcpy(dst + sdl_backend->primary_buffer.head + i + 2, (const unsigned char*)src + i + 0, 2); /* Right */
memcpy(dst + i + 0, (const unsigned char*)src + i + 2, 2); /* Left */
memcpy(dst + i + 2, (const unsigned char*)src + i + 0, 2); /* Right */
}
}
produce_cbuff_data(&sdl_backend->primary_buffer, (size + 3) & ~0x3);
produce_cbuff_data(&sdl_backend->primary_buffer, size);
}
SDL_UnlockAudio();
}
else
if (size > available)
{
DebugMessage(M64MSG_WARNING, "sdl_push_samples: pushing %u samples, but only %u available !", size, available);
DebugMessage(M64MSG_WARNING, "sdl_push_samples: pushing %zu bytes, but only %zu available !", size, available);
}
}
@ -373,6 +394,7 @@ static size_t estimate_level_at_next_audio_cb(struct sdl_backend* sdl_backend)
size_t available;
unsigned int now = SDL_GetTicks();
/* NOTE: given that we only access "available" counter from cbuff, we don't need to protect it's access with LockAudio/UnlockAudio */
cbuff_tail(&sdl_backend->primary_buffer, &available);
/* Start by calculating the current Primary buffer fullness in terms of output samples */
@ -432,5 +454,5 @@ void sdl_set_speed_factor(struct sdl_backend* sdl_backend, unsigned int speed_fa
sdl_backend->speed_factor = speed_factor;
/* we need a different size primary buffer to store the N64 samples when the speed changes */
resize_primary_buffer(&sdl_backend->primary_buffer, new_primary_buffer_size(sdl_backend));
resize_primary_buffer(sdl_backend, new_primary_buffer_size(sdl_backend));
}

View file

@ -30,7 +30,7 @@ struct sdl_backend* init_sdl_backend_from_config(m64p_handle config);
void release_sdl_backend(struct sdl_backend* sdl_backend);
void sdl_set_format(struct sdl_backend* sdl_backend, unsigned int frequency, unsigned int bits);
void sdl_set_frequency(struct sdl_backend* sdl_backend, unsigned int frequency);
void sdl_push_samples(struct sdl_backend* sdl_backend, const void* src, size_t size);