pax_global_header00006660000000000000000000000064146450543260014523gustar00rootroot0000000000000052 comment=6c2c3f8ae10b7f0f6dfe06f45ca7ca598a6b659a mupen64plus-audio-sdl-src-2.6.0/000077500000000000000000000000001464505432600163765ustar00rootroot00000000000000mupen64plus-audio-sdl-src-2.6.0/.gitattributes000066400000000000000000000007661464505432600213020ustar00rootroot00000000000000* text=auto # normal text files *.6 text AUTHORS text *.c text *.cfg text *.cht text *.conf text COPYING text *.cpp text *.def text *-license text *.h text *.html text *.ini text INSTALL text LICENSES text Makefile text *.py text README text RELEASE text *.S text *.sh text *.txt text *.ver text # windows specific text files *.sln text eol=crlf *.vcproj text eol=crlf *.vcxproj text eol=crlf *.vcxproj.filters text eol=crlf # binary files *.gz binary *.ttf binary cursor.tex binary font.tex binary mupen64plus-audio-sdl-src-2.6.0/.github/000077500000000000000000000000001464505432600177365ustar00rootroot00000000000000mupen64plus-audio-sdl-src-2.6.0/.github/workflows/000077500000000000000000000000001464505432600217735ustar00rootroot00000000000000mupen64plus-audio-sdl-src-2.6.0/.github/workflows/build.yml000066400000000000000000000121701464505432600236160ustar00rootroot00000000000000name: 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/* mupen64plus-audio-sdl-src-2.6.0/.github/workflows/schedule.yml000066400000000000000000000121671464505432600243210ustar00rootroot00000000000000name: 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/* mupen64plus-audio-sdl-src-2.6.0/.gitignore000066400000000000000000000000771464505432600203720ustar00rootroot00000000000000/projects/unix/_obj*/ /projects/unix/mupen64plus-audio-sdl*.so mupen64plus-audio-sdl-src-2.6.0/.travis.yml000066400000000000000000000102141464505432600205050ustar00rootroot00000000000000sudo: required dist: xenial language: cpp compiler: - gcc - clang addons: apt: packages: - git - libsdl1.2-dev - libsdl2-dev - libsamplerate0-dev - libspeexdsp-dev - pkg-config before_install: - git clone --depth=1 --branch=master git://github.com/mupen64plus/mupen64plus-core.git deps/mupen64plus-core env: - NO_SRC=0 NO_SPEEX=0 - NO_SRC=0 NO_SPEEX=0 - NO_SRC=0 NO_SPEEX=1 - NO_SRC=0 NO_SPEEX=1 - NO_SRC=1 NO_SPEEX=0 - NO_SRC=1 NO_SPEEX=0 - NO_SRC=1 NO_SPEEX=1 - NO_SRC=1 NO_SPEEX=1 script: - make -C projects/unix APIDIR="$(pwd)/deps/mupen64plus-core/src/api/" V=1 clean && LDFLAGS="-Wl,--no-add-needed -Wl,--no-undefined" OPTFLAGS="-O2" make SDL_CONFIG=sdl-config CC="${CC}" CXX="${CXX}" -j$(nproc) -C projects/unix APIDIR="$(pwd)/deps/mupen64plus-core/src/api/" V=1 all - make -C projects/unix APIDIR="$(pwd)/deps/mupen64plus-core/src/api/" V=1 clean && LDFLAGS="-Wl,--no-add-needed -Wl,--no-undefined" OPTFLAGS="-O2" make SDL_CONFIG=sdl2-config CC="${CC}" CXX="${CXX}" -j$(nproc) -C projects/unix APIDIR="$(pwd)/deps/mupen64plus-core/src/api/" V=1 all # extra mxe build entries matrix: include: - env: - MXE_CPU=i686 - PATH="/usr/lib/mxe/usr/bin/:$PATH" before_install: - curl -sSL "https://mirror.mxe.cc/repos/apt/client-conf/mxeapt.gpg" | sudo -E apt-key add - - echo "deb https://mirror.mxe.cc/repos/apt xenial main" | sudo tee -a /etc/apt/sources.list - sudo apt-get update -qq - sudo apt-get -y --allow-unauthenticated install mxe-i686-w64-mingw32.shared-gcc - sudo apt-get -y --allow-unauthenticated install mxe-i686-w64-mingw32.shared-sdl2 - sudo apt-get -y --allow-unauthenticated install mxe-i686-w64-mingw32.shared-speexdsp - sudo apt-get -y --allow-unauthenticated install mxe-i686-w64-mingw32.shared-libsamplerate - sudo apt-get -y --allow-unauthenticated install mxe-i686-w64-mingw32.shared-pkgconf - git clone --depth=1 --branch=master git://github.com/mupen64plus/mupen64plus-core.git deps/mupen64plus-core script: - make UNAME=MINGW CROSS_COMPILE="${MXE_CPU}-w64-mingw32.shared-" CC="${MXE_CPU}-w64-mingw32.shared-gcc" CXX="${MXE_CPU}-w64-mingw32.shared-g++" HOST_CPU="${MXE_CPU}" SDL_CONFIG="${MXE_CPU}-w64-mingw32.shared-sdl2-config" -C projects/unix APIDIR="$(pwd)/deps/mupen64plus-core/src/api/" V=1 clean && make UNAME=MINGW CROSS_COMPILE="${MXE_CPU}-w64-mingw32.shared-" CC="${MXE_CPU}-w64-mingw32.shared-gcc" CXX="${MXE_CPU}-w64-mingw32.shared-g++" HOST_CPU="${MXE_CPU}" SDL_CONFIG="${MXE_CPU}-w64-mingw32.shared-sdl2-config" -C projects/unix APIDIR="$(pwd)/deps/mupen64plus-core/src/api/" V=1 -j$(nproc) all - env: - MXE_CPU=x86_64 - PATH="/usr/lib/mxe/usr/bin/:$PATH" before_install: - curl -sSL "https://mirror.mxe.cc/repos/apt/client-conf/mxeapt.gpg" | sudo -E apt-key add - - echo "deb https://mirror.mxe.cc/repos/apt xenial main" | sudo tee -a /etc/apt/sources.list - sudo apt-get update -qq - sudo apt-get -y --allow-unauthenticated install mxe-x86-64-w64-mingw32.shared-gcc - sudo apt-get -y --allow-unauthenticated install mxe-x86-64-w64-mingw32.shared-sdl2 - sudo apt-get -y --allow-unauthenticated install mxe-x86-64-w64-mingw32.shared-speexdsp - sudo apt-get -y --allow-unauthenticated install mxe-x86-64-w64-mingw32.shared-libsamplerate - sudo apt-get -y --allow-unauthenticated install mxe-x86-64-w64-mingw32.shared-pkgconf - git clone --depth=1 --branch=master git://github.com/mupen64plus/mupen64plus-core.git deps/mupen64plus-core script: - make UNAME=MINGW CROSS_COMPILE="${MXE_CPU}-w64-mingw32.shared-" CC="${MXE_CPU}-w64-mingw32.shared-gcc" CXX="${MXE_CPU}-w64-mingw32.shared-g++" HOST_CPU="${MXE_CPU}" SDL_CONFIG="${MXE_CPU}-w64-mingw32.shared-sdl2-config" -C projects/unix APIDIR="$(pwd)/deps/mupen64plus-core/src/api/" V=1 clean && make UNAME=MINGW CROSS_COMPILE="${MXE_CPU}-w64-mingw32.shared-" CC="${MXE_CPU}-w64-mingw32.shared-gcc" CXX="${MXE_CPU}-w64-mingw32.shared-g++" HOST_CPU="${MXE_CPU}" SDL_CONFIG="${MXE_CPU}-w64-mingw32.shared-sdl2-config" -C projects/unix APIDIR="$(pwd)/deps/mupen64plus-core/src/api/" V=1 -j$(nproc) all mupen64plus-audio-sdl-src-2.6.0/INSTALL000066400000000000000000000014671464505432600174370ustar00rootroot00000000000000Mupen64Plus-Audio-SDL INSTALL ----------------------------- This text file was written to explain the installation process of the Mupen64Plus-Audio-SDL module. If this module is part of a Mupen64Plus source code bundle, the user should run the "m64p_install.sh" script in the root of the unzipped bundle to install all of the included modules in the bundle. If this module is a standalone source code release, you should build the library from source code and install it via the makefile, like this: $ cd projects/unix $ make all $ sudo make install If you want to build the Mupen64Plus-Audio-SDL module for installation in a home folder for a single user, you may build it like this (replacing with your desired local installation path): $ cd projects/unix $ make all $ make install LIBDIR= mupen64plus-audio-sdl-src-2.6.0/LICENSES000066400000000000000000000456111464505432600175350ustar00rootroot00000000000000Mupen64Plus-audio-sdl LICENSE ----------------------------- Mupen64Plus-audio-sdl is licensed under the GNU General Public License version 2. The authors of Mupen64Plus are: * Richard Goedeken (Richard42) * John Chadwick (NMN) * James Hood (Ebenblues) * Scott Gorman (okaygo) * Scott Knauert (Tillin9) * Jesse Dean (DarkJezter) * Louai Al-Khanji (slougi) * Bob Forder (orbitaldecay) * Jason Espinosa (hasone) * Nebuleon * krnlyng * Casualjames * HyperHacker * and others. Mupen64Plus is based on GPL-licensed source code from Mupen64 v0.5, originally written by: * Hacktarux * Dave2001 * Zilmar * Gregor Anich (Blight) * Juha Luotio (JttL) * and others. GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. mupen64plus-audio-sdl-src-2.6.0/RELEASE000066400000000000000000000212421464505432600174020ustar00rootroot00000000000000SDL Audio plugin for Mupen64Plus --------------------------------- ---------------------------------------------- # 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 --------------------------------------------- - MS Visual Studio 2013 project files - audioresource support for integration with Linux-based Nemo Mobile OS - Makefile: use SDL2 by default if present, disable OSS support on OpenBSD Mupen64Plus-audio-sdl - v2.0 - July 4, 2013 ------------------------------------------- - Add support for resampling with speexdsp library - Add more resampling quality options - Bugfix: Don't assume OSS is installed in all linux systems. - Bugfix: Some combinations of VolumeSetLevel and VolumeMute caused VolumeGetString to return "Mute" when not muted - Make SDL volume handling the default, since OSS is no longer included in the kernel. - Minor refactoring of volume handling code. - MS Visual Studio 2012 project files - Makefile improvements - support for ARM and MINGW architectures - support for cross-compiling (MXE win32 builds under Unix) Mupen64Plus-audio-sdl v1.99.5 - March 10, 2012 -------------------------------------------------- - added version number to SDL-audio plugin config parameters, to support future changes - updated audio plugin for new Mupen64plus 2.0 API versioning scheme - makefile fixes and improvements Mupen64Plus-audio-sdl v1.99.4 - November 22, 2010 -------------------------------------------------- - Bugfix: Plugin should write default config values at startup time - Bugfix: fixed fast-forward for banjo-kazooie and other games which was broken due to limitation in basic resampling algorithm - many makefile fixes and improvements Mupen64Plus-audio-sdl v1.99.3 - February 13, 2010 -------------------------------------------------- - sync with core<-->plugin API change for RomOpen() - bugfix: logical error in previous audio refactoring causing slowdown/lockup on loading savestate or re-initializing audio - Makefile improvements: - 'sdl-config --libs' can give "-Wl,-rpath", so plugin must be linked with CC instead of LD - issue #257: added to makefile OS type GNU/kFreeBSD Mupen64Plus-audio-sdl v1.99.2 - January 6, 2010 ------------------------------------------------- - new feature: Completely re-wrote buffering/synchronization code: - Buffer parameters now work as advertised and all use the same units - Bugfix: previous defaults and algorithm behavior caused audio choppiness on slower PCs - Bugfix: maximum speed was previously limited to low value by constraints from primary buffer size - bugfix: SDL volume control will always be used on systems without OSS support - new feature: added MSVC8 project file, minor code refactoring to build in Windows - Makefile improvements: - throw error if OS/CPU not supported - use DESTDIR in install/uninstall paths - Allow user-specified CC/CXX/LD paths Mupen64Plus-audio-sdl v1.99.1 - December 14, 2009 ------------------------------------------------- - Converted to new Mupen64Plus 2.0 API - Code cleanup to remove non-standard data types - Refactored build system to separate source and object files - bugfix #269: jttl_audio segfaults on exit due to incorrectly ordered shutdown code Mupen64plus 1.5: +Additional SDL modulation option for volume control. +New Gtk GUI for plugin configuration. +Improved no GUI support. Mupen64plus 1.4: +Extended plugin API to allow all for runtime volume changes via OSS. 1.4: +Use only standard frequency for higher compatibility +Fast resample algorithm (use only integers) +Slight improvements in buffer management : pausing audio when buffer underrun occur 1.2: +Added possibility to swap channels +Some more optimizations +Calling RomOpen() is not required anymore. Plugin should now follow Zilmar's specs. +Added test functions. +Added support for config file 1.1.1: +Fixed the bug that was causing terrible noise (thanks Law) +Much more debugging data appears now if DEBUG is defined +Few more error checks 1.1: +Audio device is opened now with native byte ordering of the machine. Just for compatibility (thanks Flea). +Fixed possible double freeing bug (thanks Flea) +Optimizations in AiLenChanged +Fixed segmentation fault when changing rom. +Syncronization redone 1.0.1.3: +Smarter versioning. No more betas. +More cleaning up done. +Buffer underrun and overflow messages appear now at stderr (if DEBUG is defined) +Many things are now precalculated (this should bring a small performance boost) +Buffer underrun bug fixed. +Segmentation fault when closing rom fixed (at least I think so) 1.0 beta 2: +Makefile fixed to get rid of annoying warning messages +Cleaned up some old code +Default frequency set to 33600Hz (for Master Quest compatibility) +Better syncronization (needs some work still though) 1.0 beta 1: +First public release mupen64plus-audio-sdl-src-2.6.0/appveyor.yml000066400000000000000000000017071464505432600207730ustar00rootroot00000000000000version: 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) mupen64plus-audio-sdl-src-2.6.0/projects/000077500000000000000000000000001464505432600202275ustar00rootroot00000000000000mupen64plus-audio-sdl-src-2.6.0/projects/msvc/000077500000000000000000000000001464505432600211775ustar00rootroot00000000000000mupen64plus-audio-sdl-src-2.6.0/projects/msvc/mupen64plus-audio-sdl.vcxproj000066400000000000000000000225521464505432600267030ustar00rootroot00000000000000 Debug Win32 Debug x64 Release Win32 Release x64 {96969748-EA54-43FC-8103-A346E9AD98E7} mupen64plusaudiosdl $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) $(LatestTargetPlatformVersion) $(WindowsTargetPlatformVersion) $(DefaultPlatformToolset) DynamicLibrary MultiByte true $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ DynamicLibrary MultiByte true $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ DynamicLibrary MultiByte $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ DynamicLibrary MultiByte $(SolutionDir)$(Platform)\$(Configuration)\ $(Platform)\$(Configuration)\ Disabled ..\..\src;..\..\..\mupen64plus-core\src\api;..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level3 ..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\lib\x86\SDL2.lib;%(AdditionalDependencies) true Windows Disabled ..\..\src;..\..\..\mupen64plus-core\src\api;..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level3 ..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\lib\x64\SDL2.lib;%(AdditionalDependencies) true Windows ..\..\src;..\..\..\mupen64plus-core\src\api;..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) MultiThreadedDLL Level3 MaxSpeed true true ..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\lib\x86\SDL2.lib;%(AdditionalDependencies) true Windows true true ..\..\src;..\..\..\mupen64plus-core\src\api;..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) MultiThreadedDLL Level3 MaxSpeed true true ..\..\..\mupen64plus-win32-deps\SDL2-2.26.3\lib\x64\SDL2.lib;%(AdditionalDependencies) true Windows true true mupen64plus-audio-sdl-src-2.6.0/projects/unix/000077500000000000000000000000001464505432600212125ustar00rootroot00000000000000mupen64plus-audio-sdl-src-2.6.0/projects/unix/Makefile000077500000000000000000000302721464505432600226610ustar00rootroot00000000000000#/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # * Mupen64plus-audio-sdl - Makefile * # * Mupen64Plus homepage: https://mupen64plus.org/ * # * Copyright (C) 2007-2009 Richard Goedeken * # * Copyright (C) 2007-2008 Tillin9 * # * * # * This program is free software; you can redistribute it and/or modify * # * it under the terms of the GNU General Public License as published by * # * the Free Software Foundation; either version 2 of the License, or * # * (at your option) any later version. * # * * # * This program is distributed in the hope that it will be useful, * # * but WITHOUT ANY WARRANTY; without even the implied warranty of * # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * # * GNU General Public License for more details. * # * * # * You should have received a copy of the GNU General Public License * # * along with this program; if not, write to the * # * Free Software Foundation, Inc., * # * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ # Makefile for SDL Audio plugin in Mupen64plus # detect operation system UNAME ?= $(shell uname -s) OS := NONE ifeq ("$(UNAME)","Linux") OS = LINUX SHARED = -shared SO_EXTENSION = so endif ifeq ("$(UNAME)","linux") OS = LINUX SHARED = -shared SO_EXTENSION = so endif ifneq ("$(filter GNU hurd,$(UNAME))","") OS = LINUX SHARED = -shared SO_EXTENSION = so endif ifeq ("$(UNAME)","Darwin") OS = OSX SHARED = -bundle SO_EXTENSION = dylib endif ifeq ("$(UNAME)","FreeBSD") OS = FREEBSD SHARED = -shared SO_EXTENSION = so endif ifeq ("$(UNAME)","OpenBSD") OS = FREEBSD SHARED = -shared SO_EXTENSION = so NO_OSS = 1 endif ifneq ("$(filter GNU/kFreeBSD kfreebsd,$(UNAME))","") OS = LINUX SHARED = -shared SO_EXTENSION = so endif ifeq ("$(patsubst MINGW%,MINGW,$(UNAME))","MINGW") OS = MINGW SHARED = -shared SO_EXTENSION = dll PIC = 0 NO_OSS = 1 endif ifeq ("$(OS)","NONE") $(error OS type "$(UNAME)" not supported. Please file bug report at 'https://github.com/mupen64plus/mupen64plus-core/issues') endif # detect system architecture, only if it matters for build flags HOST_CPU ?= $(shell uname -m) CPU := OTHER ifneq ("$(filter x86_64 amd64,$(HOST_CPU))","") CPU := X86 ifeq ("$(BITS)", "32") ARCH_DETECTED := 64BITS_32 PIC ?= 0 else ARCH_DETECTED := 64BITS PIC ?= 1 endif endif ifneq ("$(filter pentium i%86,$(HOST_CPU))","") CPU := X86 ARCH_DETECTED := 32BITS PIC ?= 0 endif 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$(SRCDIR) LDFLAGS += $(SHARED) # Since we are building a shared library, we must compile with -fPIC on some architectures # On 32-bit x86 systems we do not want to use -fPIC because we don't have to and it has a big performance penalty on this arch ifeq ($(PIC), 1) CFLAGS += -fPIC else CFLAGS += -fno-PIC endif # tweak flags for 32-bit build on 64-bit system 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 ifeq ($(OS), LINUX) LDLIBS += -ldl endif ifeq ($(OS), OSX) OSX_SDK_PATH = $(shell xcrun --sdk macosx --show-sdk-path) ifeq ($(CPU), X86) ifeq ($(ARCH_DETECTED), 64BITS) 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.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 ifeq ($(shell which $(PKG_CONFIG) 2>/dev/null),) $(error $(PKG_CONFIG) not found) endif endif # test for presence of speexdsp ifneq ($(NO_SPEEX), 1) ifeq ($(origin SPEEX_CFLAGS) $(origin SPEEX_LDLIBS), undefined undefined) ifneq ($(strip $(shell $(PKG_CONFIG) speexdsp --modversion 2> /dev/null)),) # set speexdsp flags and libraries SPEEX_CFLAGS += $(shell $(PKG_CONFIG) speexdsp --cflags) -DUSE_SPEEX SPEEX_LDLIBS += $(shell $(PKG_CONFIG) speexdsp --libs) else # warn user $(warning No libspeexdsp development libraries found. Mupen64plus-sdl-audio will be built without speex-* resampler.) NO_SPEEX = 1 endif else SPEEX_CFLAGS += -DUSE_SPEEX endif CFLAGS += $(SPEEX_CFLAGS) LDLIBS += $(SPEEX_LDLIBS) endif # test for presence of libsamplerate ifneq ($(NO_SRC), 1) ifeq ($(origin SRC_CFLAGS) $(origin SRC_LDLIBS), undefined undefined) ifneq ($(strip $(shell $(PKG_CONFIG) samplerate --modversion 2> /dev/null)),) # set libsamplerate flags and libraries SRC_CFLAGS += $(shell $(PKG_CONFIG) samplerate --cflags) -DUSE_SRC SRC_LDLIBS += $(shell $(PKG_CONFIG) samplerate --libs) else $(warning No libsamplerate development libraries found. Mupen64plus-sdl-audio will be built without src-* resampler.) NO_SRC = 1 endif else SRC_CFLAGS += -DUSE_SRC endif CFLAGS += $(SRC_CFLAGS) LDLIBS += $(SRC_LDLIBS) endif USE_AUDIORESOURCE = 0 ifeq ($(origin AUDIORESOURCE_CFLAGS) $(origin AUDIORESOURCE_LDLIBS), undefined undefined) ifneq ($(strip $(shell $(PKG_CONFIG) audioresource --modversion 2> /dev/null)),) # set audioresourceflags and libraries USE_AUDIORESOURCE = 1 AUDIORESOURCE_CFLAGS += $(shell $(PKG_CONFIG) audioresource --cflags) -DUSE_AUDIORESOURCE AUDIORESOURCE_LDLIBS += $(shell $(PKG_CONFIG) audioresource --libs) endif else USE_AUDIORESOURCE = 1 AUDIORESOURCE_CFLAGS += -DUSE_AUDIORESOURCE endif ifeq ($(USE_AUDIORESOURCE),1) ifeq ($(origin GLIB_CFLAGS) $(origin GLIB_LDLIBS), undefined undefined) ifneq ($(strip $(shell $(PKG_CONFIG) glib-2.0 --modversion 2> /dev/null)),) # set glib-2.0 flags and libraries GLIB_CFLAGS += $(shell $(PKG_CONFIG) glib-2.0 --cflags) GLIB_LDLIBS += $(shell $(PKG_CONFIG) glib-2.0 --libs) else $(warning audioresource available but glib-2.0 not found, disabling audioresource support. Mupen64plus-sdl-audio will be built without the Nemo Mobile Audio Resource API.) AUDIORESOURCE_CFLAGS = AUDIORESOURCE_LDLIBS = endif endif CFLAGS += $(GLIB_CFLAGS) $(AUDIORESOURCE_CFLAGS) LDLIBS += $(GLIB_LDLIBS) $(AUDIORESOURCE_LDLIBS) endif # test for the presence of OSS ifneq ($(wildcard /dev/mixer),) ifneq ($(NO_OSS), 1) CFLAGS += -DHAS_OSS_SUPPORT endif endif # set mupen64plus core API header path ifneq ("$(APIDIR)","") CFLAGS += "-I$(APIDIR)" else TRYDIR = ../../../mupen64plus-core/src/api ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","") CFLAGS += -I$(TRYDIR) else TRYDIR = /usr/local/include/mupen64plus ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","") CFLAGS += -I$(TRYDIR) else TRYDIR = /usr/include/mupen64plus ifneq ("$(wildcard $(TRYDIR)/m64p_types.h)","") CFLAGS += -I$(TRYDIR) else $(error Mupen64Plus API header files not found! Use makefile parameter APIDIR to force a location.) endif endif endif endif # reduced compile output when running make without V=1 ifneq ($(findstring $(MAKEFLAGS),s),s) ifndef V Q_CC = @echo ' CC '$@; Q_LD = @echo ' LD '$@; endif endif # set base program pointers and flags CC = $(CROSS_COMPILE)gcc RM ?= rm -f INSTALL ?= install MKDIR ?= mkdir -p COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c LINK.o = $(Q_LD)$(CC) $(CFLAGS) $(LDFLAGS) $(TARGET_ARCH) # set special flags for given Makefile parameters ifeq ($(DEBUG),1) CFLAGS += -g INSTALL_STRIP_FLAG ?= else ifneq ($(OS),OSX) INSTALL_STRIP_FLAG ?= -s endif endif # set installation options ifeq ($(PREFIX),) PREFIX := /usr/local endif ifeq ($(LIBDIR),) LIBDIR := $(PREFIX)/lib endif ifeq ($(PLUGINDIR),) PLUGINDIR := $(LIBDIR)/mupen64plus endif # list of source files to compile SOURCE = \ $(SRCDIR)/circular_buffer.c \ $(SRCDIR)/main.c \ $(SRCDIR)/sdl_backend.c \ $(SRCDIR)/volume.c \ $(SRCDIR)/resamplers/resamplers.c \ $(SRCDIR)/resamplers/trivial.c ifeq ($(OS),MINGW) SOURCE += $(SRCDIR)/osal_dynamiclib_win32.c else SOURCE += $(SRCDIR)/osal_dynamiclib_unix.c endif ifneq ($(NO_SPEEX), 1) SOURCE += $(SRCDIR)/resamplers/speex.c endif ifneq ($(NO_SRC), 1) SOURCE += $(SRCDIR)/resamplers/src.c endif # generate a list of object files build, make a temporary directory for them OBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(filter %.c, $(SOURCE))) OBJDIRS = $(dir $(OBJECTS)) $(shell $(MKDIR) $(OBJDIRS)) # build targets TARGET = mupen64plus-audio-sdl$(POSTFIX).$(SO_EXTENSION) targets: @echo "Mupen64Plus-audio-sdl makefile. " @echo " Targets:" @echo " all == Build Mupen64Plus SDL audio plugin" @echo " clean == remove object files" @echo " rebuild == clean and re-build all" @echo " install == Install Mupen64Plus SDL audio plugin" @echo " uninstall == Uninstall Mupen64Plus SDL audio plugin" @echo " Options:" @echo " BITS=32 == build 32-bit binaries on 64-bit machine" @echo " APIDIR=path == path to find Mupen64Plus Core headers" @echo " OPTFLAGS=flag == compiler optimization (default: -O3 -flto)" @echo " WARNFLAGS=flag == compiler warning levels (default: -Wall)" @echo " PIC=(1|0) == Force enable/disable of position independent code" @echo " NO_SRC=1 == build without libsamplerate; disables src-* high-quality audio resampling" @echo " NO_SPEEX=1 == build without libspeexdsp; disables speex-* high-quality audio resampling" @echo " NO_OSS=1 == build without OSS; disables Open Sound System support" @echo " POSTFIX=name == String added to the name of the the build (default: '')" @echo " Install Options:" @echo " PREFIX=path == install/uninstall prefix (default: /usr/local)" @echo " LIBDIR=path == library prefix (default: PREFIX/lib)" @echo " PLUGINDIR=path == path to install plugin libraries (default: LIBDIR/mupen64plus)" @echo " DESTDIR=path == path to prepend to all installation paths (only for packagers)" @echo " Debugging Options:" @echo " DEBUG=1 == add debugging symbols" @echo " V=1 == show verbose compiler output" all: $(TARGET) install: $(TARGET) $(INSTALL) -d "$(DESTDIR)$(PLUGINDIR)" $(INSTALL) -m 0644 $(INSTALL_STRIP_FLAG) $(TARGET) "$(DESTDIR)$(PLUGINDIR)" uninstall: $(RM) "$(DESTDIR)$(PLUGINDIR)/$(TARGET)" clean: $(RM) -r $(OBJDIR) $(TARGET) rebuild: clean all # build dependency files CFLAGS += -MD -MP -include $(OBJECTS:.o=.d) # standard build rules $(OBJDIR)/%.o: $(SRCDIR)/%.c $(COMPILE.c) -o $@ $< $(TARGET): $(OBJECTS) $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ .PHONY: all clean install uninstall targets mupen64plus-audio-sdl-src-2.6.0/src/000077500000000000000000000000001464505432600171655ustar00rootroot00000000000000mupen64plus-audio-sdl-src-2.6.0/src/circular_buffer.c000066400000000000000000000052451464505432600224740ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus-ui-console - circular_buffer.c * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2015 Bobby Smiles * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include #include #include "circular_buffer.h" int init_cbuff(struct circular_buffer* cbuff, size_t capacity) { void* data = malloc(capacity); if (data == NULL) { return -1; } cbuff->data = data; cbuff->size = capacity; cbuff->head = 0; return 0; } void release_cbuff(struct circular_buffer* cbuff) { free(cbuff->data); memset(cbuff, 0, sizeof(*cbuff)); } void* cbuff_head(const struct circular_buffer* cbuff, size_t* available) { assert(cbuff->head <= cbuff->size); *available = cbuff->size - cbuff->head; return (unsigned char*)cbuff->data + cbuff->head; } void* cbuff_tail(const struct circular_buffer* cbuff, size_t* available) { *available = cbuff->head; return cbuff->data; } void produce_cbuff_data(struct circular_buffer* cbuff, size_t amount) { assert(cbuff->head + amount <= cbuff->size); cbuff->head += amount; } void consume_cbuff_data(struct circular_buffer* cbuff, size_t amount) { assert(cbuff->head >= amount); memmove(cbuff->data, (unsigned char*)cbuff->data + amount, cbuff->head - amount); cbuff->head -= amount; } mupen64plus-audio-sdl-src-2.6.0/src/circular_buffer.h000066400000000000000000000041131464505432600224720ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus-ui-console - circular_buffer.h * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2015 Bobby Smiles * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef M64P_CIRCULAR_BUFFER_H #define M64P_CIRCULAR_BUFFER_H #include struct circular_buffer { void* data; size_t size; size_t head; }; int init_cbuff(struct circular_buffer* cbuff, size_t capacity); void release_cbuff(struct circular_buffer* cbuff); void* cbuff_head(const struct circular_buffer* cbuff, size_t* available); void* cbuff_tail(const struct circular_buffer* cbuff, size_t* available); void produce_cbuff_data(struct circular_buffer* cbuff, size_t amount); void consume_cbuff_data(struct circular_buffer* cbuff, size_t amount); #endif mupen64plus-audio-sdl-src-2.6.0/src/main.c000066400000000000000000000453041464505432600202630ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus-sdl-audio - main.c * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2007-2009 Richard Goedeken * * Copyright (C) 2007-2008 Ebenblues * * Copyright (C) 2003 JttL * * Copyright (C) 2002 Hacktarux * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include #include #include #include "main.h" #include "osal_dynamiclib.h" #include "sdl_backend.h" #include "volume.h" #include "resamplers/resamplers.h" #ifdef USE_AUDIORESOURCE #include #include #endif #define M64P_PLUGIN_PROTOTYPES 1 #include "m64p_common.h" #include "m64p_config.h" #include "m64p_plugin.h" #include "m64p_types.h" /* version info */ #define SDL_AUDIO_PLUGIN_VERSION 0x020600 #define AUDIO_PLUGIN_API_VERSION 0x020000 #define CONFIG_API_VERSION 0x020100 #define CONFIG_PARAM_VERSION 1.00 #define VERSION_PRINTF_SPLIT(x) (((x) >> 16) & 0xffff), (((x) >> 8) & 0xff), ((x) & 0xff) /* Default start-time size of primary buffer (in equivalent output samples). This is the buffer where audio is loaded after it's extracted from n64's memory. This value must be larger than PRIMARY_BUFFER_TARGET */ #define PRIMARY_BUFFER_SIZE 16384 /* this is the buffer fullness level (in equivalent output samples) which is targeted for the primary audio buffer (by inserting delays) each time data is received from the running N64 program. This value must be larger than the SECONDARY_BUFFER_SIZE. Decreasing this value will reduce audio latency but requires a faster PC to avoid choppiness. Increasing this will increase audio latency but reduce the chance of drop-outs. The default value 2048 gives a 46ms maximum A/V delay at 44.1khz */ #define PRIMARY_BUFFER_TARGET 2048 /* Size of secondary buffer, in output samples. This is the requested size of SDL's hardware buffer, and the size of the mix buffer for doing SDL volume control. The SDL documentation states that this should be a power of two between 512 and 8192. */ #define SECONDARY_BUFFER_SIZE 1024 /* This sets default frequency what is used if rom doesn't want to change it. Probably only game that needs this is Zelda: Ocarina Of Time Master Quest *NOTICE* We should try to find out why Demos' frequencies are always wrong They tend to rely on a default frequency, apparently, never the same one ;)*/ #define DEFAULT_FREQUENCY 33600 #if SDL_VERSION_ATLEAST(2,0,0) #define SDL_MixAudio(A, B, C, D) SDL_MixAudioFormat(A, B, AUDIO_S16SYS, C, D) #endif /* local variables */ static void (*l_DebugCallback)(void *, int, const char *) = NULL; static void *l_DebugCallContext = NULL; static int l_PluginInit = 0; static m64p_handle l_ConfigAudio; #ifdef USE_AUDIORESOURCE static audioresource_t *l_audioresource = NULL; static int l_audioresource_acquired = 0; #endif static struct sdl_backend* l_sdl_backend = NULL; /* Read header for type definition */ static AUDIO_INFO AudioInfo; // volume to scale the audio by, range of 0..100 // if muted, this holds the volume when not muted static int VolPercent = 80; // how much percent to increment/decrement volume by static int VolDelta = 5; // the actual volume passed into SDL, range of 0..SDL_MIX_MAXVOLUME static int VolSDL = SDL_MIX_MAXVOLUME; // Muted or not static int VolIsMuted = 0; //which type of volume control to use static int VolumeControlType = VOLUME_TYPE_SDL; /* definitions of pointers to Core config functions */ ptr_ConfigOpenSection ConfigOpenSection = NULL; ptr_ConfigDeleteSection ConfigDeleteSection = NULL; ptr_ConfigSetParameter ConfigSetParameter = NULL; ptr_ConfigGetParameter ConfigGetParameter = NULL; ptr_ConfigGetParameterHelp ConfigGetParameterHelp = NULL; ptr_ConfigSetDefaultInt ConfigSetDefaultInt = NULL; ptr_ConfigSetDefaultFloat ConfigSetDefaultFloat = NULL; ptr_ConfigSetDefaultBool ConfigSetDefaultBool = NULL; ptr_ConfigSetDefaultString ConfigSetDefaultString = NULL; ptr_ConfigGetParamInt ConfigGetParamInt = NULL; ptr_ConfigGetParamFloat ConfigGetParamFloat = NULL; ptr_ConfigGetParamBool ConfigGetParamBool = NULL; ptr_ConfigGetParamString ConfigGetParamString = NULL; /* Global functions */ void DebugMessage(int level, const char *message, ...) { char msgbuf[1024]; va_list args; if (l_DebugCallback == NULL) return; va_start(args, message); vsprintf(msgbuf, message, args); (*l_DebugCallback)(l_DebugCallContext, level, msgbuf); va_end(args); } #ifdef USE_AUDIORESOURCE void on_audioresource_acquired(audioresource_t *audioresource, bool acquired, void *user_data) { DebugMessage(M64MSG_VERBOSE, "audioresource acquired: %d", acquired); l_audioresource_acquired = acquired; } #endif /* Mupen64Plus plugin functions */ EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Context, void (*DebugCallback)(void *, int, const char *)) { ptr_CoreGetAPIVersions CoreAPIVersionFunc; int ConfigAPIVersion, DebugAPIVersion, VidextAPIVersion; float fConfigParamsVersion = 0.0f; if (l_PluginInit) return M64ERR_ALREADY_INIT; /* first thing is to set the callback function for debug info */ l_DebugCallback = DebugCallback; l_DebugCallContext = Context; /* attach and call the CoreGetAPIVersions function, check Config API version for compatibility */ CoreAPIVersionFunc = (ptr_CoreGetAPIVersions) osal_dynlib_getproc(CoreLibHandle, "CoreGetAPIVersions"); if (CoreAPIVersionFunc == NULL) { DebugMessage(M64MSG_ERROR, "Core emulator broken; no CoreAPIVersionFunc() function found."); return M64ERR_INCOMPATIBLE; } (*CoreAPIVersionFunc)(&ConfigAPIVersion, &DebugAPIVersion, &VidextAPIVersion, NULL); if ((ConfigAPIVersion & 0xffff0000) != (CONFIG_API_VERSION & 0xffff0000)) { DebugMessage(M64MSG_ERROR, "Emulator core Config API (v%i.%i.%i) incompatible with plugin (v%i.%i.%i)", VERSION_PRINTF_SPLIT(ConfigAPIVersion), VERSION_PRINTF_SPLIT(CONFIG_API_VERSION)); return M64ERR_INCOMPATIBLE; } /* Get the core config function pointers from the library handle */ ConfigOpenSection = (ptr_ConfigOpenSection) osal_dynlib_getproc(CoreLibHandle, "ConfigOpenSection"); ConfigDeleteSection = (ptr_ConfigDeleteSection) osal_dynlib_getproc(CoreLibHandle, "ConfigDeleteSection"); ConfigSetParameter = (ptr_ConfigSetParameter) osal_dynlib_getproc(CoreLibHandle, "ConfigSetParameter"); ConfigGetParameter = (ptr_ConfigGetParameter) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParameter"); ConfigSetDefaultInt = (ptr_ConfigSetDefaultInt) osal_dynlib_getproc(CoreLibHandle, "ConfigSetDefaultInt"); ConfigSetDefaultFloat = (ptr_ConfigSetDefaultFloat) osal_dynlib_getproc(CoreLibHandle, "ConfigSetDefaultFloat"); ConfigSetDefaultBool = (ptr_ConfigSetDefaultBool) osal_dynlib_getproc(CoreLibHandle, "ConfigSetDefaultBool"); ConfigSetDefaultString = (ptr_ConfigSetDefaultString) osal_dynlib_getproc(CoreLibHandle, "ConfigSetDefaultString"); ConfigGetParamInt = (ptr_ConfigGetParamInt) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParamInt"); ConfigGetParamFloat = (ptr_ConfigGetParamFloat) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParamFloat"); ConfigGetParamBool = (ptr_ConfigGetParamBool) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParamBool"); ConfigGetParamString = (ptr_ConfigGetParamString) osal_dynlib_getproc(CoreLibHandle, "ConfigGetParamString"); if (!ConfigOpenSection || !ConfigDeleteSection || !ConfigSetParameter || !ConfigGetParameter || !ConfigSetDefaultInt || !ConfigSetDefaultFloat || !ConfigSetDefaultBool || !ConfigSetDefaultString || !ConfigGetParamInt || !ConfigGetParamFloat || !ConfigGetParamBool || !ConfigGetParamString) return M64ERR_INCOMPATIBLE; /* get a configuration section handle */ if (ConfigOpenSection("Audio-SDL", &l_ConfigAudio) != M64ERR_SUCCESS) { DebugMessage(M64MSG_ERROR, "Couldn't open config section 'Audio-SDL'"); return M64ERR_INPUT_NOT_FOUND; } /* check the section version number */ if (ConfigGetParameter(l_ConfigAudio, "Version", M64TYPE_FLOAT, &fConfigParamsVersion, sizeof(float)) != M64ERR_SUCCESS) { DebugMessage(M64MSG_WARNING, "No version number in 'Audio-SDL' config section. Setting defaults."); ConfigDeleteSection("Audio-SDL"); ConfigOpenSection("Audio-SDL", &l_ConfigAudio); } else if (((int) fConfigParamsVersion) != ((int) CONFIG_PARAM_VERSION)) { DebugMessage(M64MSG_WARNING, "Incompatible version %.2f in 'Audio-SDL' config section: current is %.2f. Setting defaults.", fConfigParamsVersion, (float) CONFIG_PARAM_VERSION); ConfigDeleteSection("Audio-SDL"); ConfigOpenSection("Audio-SDL", &l_ConfigAudio); } else if ((CONFIG_PARAM_VERSION - fConfigParamsVersion) >= 0.0001f) { /* handle upgrades */ float fVersion = CONFIG_PARAM_VERSION; ConfigSetParameter(l_ConfigAudio, "Version", M64TYPE_FLOAT, &fVersion); DebugMessage(M64MSG_INFO, "Updating parameter set version in 'Audio-SDL' config section to %.2f", fVersion); } /* set the default values for this plugin */ ConfigSetDefaultFloat(l_ConfigAudio, "Version", CONFIG_PARAM_VERSION, "Mupen64Plus SDL Audio Plugin config parameter version number"); ConfigSetDefaultInt(l_ConfigAudio, "DEFAULT_FREQUENCY", DEFAULT_FREQUENCY, "Frequency which is used if rom doesn't want to change it"); ConfigSetDefaultBool(l_ConfigAudio, "SWAP_CHANNELS", 0, "Swaps left and right channels"); ConfigSetDefaultInt(l_ConfigAudio, "PRIMARY_BUFFER_SIZE", PRIMARY_BUFFER_SIZE, "Size of primary buffer in output samples. This is where audio is loaded after it's extracted from n64's memory."); ConfigSetDefaultInt(l_ConfigAudio, "PRIMARY_BUFFER_TARGET", PRIMARY_BUFFER_TARGET, "Fullness level target for Primary audio buffer, in equivalent output samples. This value must be larger than the SECONDARY_BUFFER_SIZE. Decreasing this value will reduce audio latency but requires a faster PC to avoid choppiness. Increasing this will increase audio latency but reduce the chance of drop-outs."); ConfigSetDefaultInt(l_ConfigAudio, "SECONDARY_BUFFER_SIZE", SECONDARY_BUFFER_SIZE, "Size of secondary buffer in output samples. This is SDL's hardware buffer. The SDL documentation states that this should be a power of two between 512 and 8192."); ConfigSetDefaultString(l_ConfigAudio, "RESAMPLE", DEFAULT_RESAMPLER, "Audio resampling algorithm. src-sinc-best-quality, src-sinc-medium-quality, src-sinc-fastest, src-zero-order-hold, src-linear, speex-fixed-{10-0}, trivial"); 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", 1, "Synchronize Video/Audio"); #ifdef USE_AUDIORESOURCE setenv("PULSE_PROP_media.role", "x-maemo", 1); l_audioresource = audioresource_init(AUDIO_RESOURCE_GAME, on_audioresource_acquired, NULL); audioresource_acquire(l_audioresource); while(!l_audioresource_acquired) { DebugMessage(M64MSG_INFO, "Waiting for audioresource..."); g_main_context_iteration(NULL, false); } #endif l_PluginInit = 1; return M64ERR_SUCCESS; } EXPORT m64p_error CALL PluginShutdown(void) { if (!l_PluginInit) return M64ERR_NOT_INIT; /* reset some local variables */ l_DebugCallback = NULL; l_DebugCallContext = NULL; #ifdef USE_AUDIORESOURCE audioresource_release(l_audioresource); audioresource_free(l_audioresource); #endif l_PluginInit = 0; return M64ERR_SUCCESS; } EXPORT m64p_error CALL PluginGetVersion(m64p_plugin_type *PluginType, int *PluginVersion, int *APIVersion, const char **PluginNamePtr, int *Capabilities) { /* set version info */ if (PluginType != NULL) *PluginType = M64PLUGIN_AUDIO; if (PluginVersion != NULL) *PluginVersion = SDL_AUDIO_PLUGIN_VERSION; if (APIVersion != NULL) *APIVersion = AUDIO_PLUGIN_API_VERSION; if (PluginNamePtr != NULL) *PluginNamePtr = "Mupen64Plus SDL Audio Plugin"; if (Capabilities != NULL) { *Capabilities = 0; } return M64ERR_SUCCESS; } /* ----------- Audio Functions ------------- */ static unsigned int vi_clock_from_system_type(int system_type) { switch (system_type) { default: DebugMessage(M64MSG_WARNING, "Invalid system_type %d. Assuming NTSC", system_type); /* fallback */ case SYSTEM_NTSC: return 48681812; case SYSTEM_PAL: return 49656530; case SYSTEM_MPAL: return 48628316; } } static unsigned int dacrate2freq(unsigned int vi_clock, uint32_t dacrate) { return vi_clock / (dacrate + 1); } EXPORT void CALL AiDacrateChanged(int SystemType) { if (!l_PluginInit || l_sdl_backend == NULL) return; unsigned int frequency = dacrate2freq(vi_clock_from_system_type(SystemType), *AudioInfo.AI_DACRATE_REG); sdl_set_frequency(l_sdl_backend, frequency); } EXPORT void CALL AiLenChanged(void) { if (!l_PluginInit || l_sdl_backend == NULL) return; sdl_push_samples(l_sdl_backend, AudioInfo.RDRAM + (*AudioInfo.AI_DRAM_ADDR_REG & 0xffffff), *AudioInfo.AI_LEN_REG); sdl_synchronize_audio(l_sdl_backend); } EXPORT int CALL InitiateAudio(AUDIO_INFO Audio_Info) { if (!l_PluginInit) return 0; AudioInfo = Audio_Info; return 1; } EXPORT int CALL RomOpen(void) { if (!l_PluginInit || l_sdl_backend != NULL) return 0; VolDelta = ConfigGetParamInt(l_ConfigAudio, "VOLUME_ADJUST"); VolumeControlType = ConfigGetParamInt(l_ConfigAudio, "VOLUME_CONTROL_TYPE"); VolPercent = ConfigGetParamInt(l_ConfigAudio, "VOLUME_DEFAULT"); l_sdl_backend = init_sdl_backend_from_config(l_ConfigAudio); return 1; } EXPORT void CALL RomClosed(void) { if (!l_PluginInit) return; release_sdl_backend(l_sdl_backend); l_sdl_backend = NULL; } EXPORT void CALL ProcessAList(void) { } EXPORT void CALL SetSpeedFactor(int percentage) { if (!l_PluginInit || l_sdl_backend == NULL) return; sdl_set_speed_factor(l_sdl_backend, percentage); } size_t ResampleAndMix(void* resampler, const struct resampler_interface* iresampler, void* mix_buffer, const void* src, size_t src_size, unsigned int src_freq, void* dst, size_t dst_size, unsigned int dst_freq) { size_t consumed; #if defined(HAS_OSS_SUPPORT) if (VolumeControlType == VOLUME_TYPE_OSS) { consumed = iresampler->resample(resampler, src, src_size, src_freq, dst, dst_size, dst_freq); } else #endif { consumed = iresampler->resample(resampler, src, src_size, src_freq, mix_buffer, dst_size, dst_freq); memset(dst, 0, dst_size); SDL_MixAudio(dst, mix_buffer, dst_size, VolSDL); } return consumed; } void SetPlaybackVolume(void) { #if defined(HAS_OSS_SUPPORT) if (VolumeControlType == VOLUME_TYPE_OSS) { VolPercent = volGet(); } else #endif { VolSDL = SDL_MIX_MAXVOLUME * VolPercent / 100; } } // Returns the most recent ummuted volume level. static int VolumeGetUnmutedLevel(void) { #if defined(HAS_OSS_SUPPORT) // reload volume if we're using OSS if (!VolIsMuted && VolumeControlType == VOLUME_TYPE_OSS) { return volGet(); } #endif return VolPercent; } // Sets the volume level based on the contents of VolPercent and VolIsMuted static void VolumeCommit(void) { int levelToCommit = VolIsMuted ? 0 : VolPercent; #if defined(HAS_OSS_SUPPORT) if (VolumeControlType == VOLUME_TYPE_OSS) { //OSS mixer volume volSet(levelToCommit); } else #endif { VolSDL = SDL_MIX_MAXVOLUME * levelToCommit / 100; } } EXPORT void CALL VolumeMute(void) { if (!l_PluginInit) return; // Store the volume level in order to restore it later if (!VolIsMuted) VolPercent = VolumeGetUnmutedLevel(); // Toogle mute VolIsMuted = !VolIsMuted; VolumeCommit(); } EXPORT void CALL VolumeUp(void) { if (!l_PluginInit) return; VolumeSetLevel(VolumeGetUnmutedLevel() + VolDelta); } EXPORT void CALL VolumeDown(void) { if (!l_PluginInit) return; VolumeSetLevel(VolumeGetUnmutedLevel() - VolDelta); } EXPORT int CALL VolumeGetLevel(void) { return VolIsMuted ? 0 : VolumeGetUnmutedLevel(); } EXPORT void CALL VolumeSetLevel(int level) { if (!l_PluginInit) return; //if muted, unmute first VolIsMuted = 0; // adjust volume VolPercent = level; if (VolPercent < 0) VolPercent = 0; else if (VolPercent > 100) VolPercent = 100; VolumeCommit(); } EXPORT const char * CALL VolumeGetString(void) { static char VolumeString[32]; if (VolIsMuted) { strcpy(VolumeString, "Mute"); } else { sprintf(VolumeString, "%i%%", VolPercent); } return VolumeString; } mupen64plus-audio-sdl-src-2.6.0/src/main.h000066400000000000000000000060361464505432600202670ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus - main.h * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2008-2012 Tillin9, Richard42 * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* version info */ #include "m64p_config.h" #include #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 */ enum { VOLUME_TYPE_SDL = 1, VOLUME_TYPE_OSS = 2, }; void SetPlaybackVolume(void); size_t ResampleAndMix(void* resampler, const struct resampler_interface* iresampler, void* mix_buffer, const void* src, size_t src_size, unsigned int src_freq, void* dst, size_t dst_size, unsigned int dst_freq); /* declarations of pointers to Core config functions */ extern ptr_ConfigListSections ConfigListSections; extern ptr_ConfigOpenSection ConfigOpenSection; extern ptr_ConfigDeleteSection ConfigDeleteSection; extern ptr_ConfigListParameters ConfigListParameters; extern ptr_ConfigSetParameter ConfigSetParameter; extern ptr_ConfigGetParameter ConfigGetParameter; extern ptr_ConfigGetParameterHelp ConfigGetParameterHelp; extern ptr_ConfigSetDefaultInt ConfigSetDefaultInt; extern ptr_ConfigSetDefaultFloat ConfigSetDefaultFloat; extern ptr_ConfigSetDefaultBool ConfigSetDefaultBool; extern ptr_ConfigSetDefaultString ConfigSetDefaultString; extern ptr_ConfigGetParamInt ConfigGetParamInt; extern ptr_ConfigGetParamFloat ConfigGetParamFloat; extern ptr_ConfigGetParamBool ConfigGetParamBool; extern ptr_ConfigGetParamString ConfigGetParamString; void DebugMessage(int level, const char *message, ...) ATTR_FMT(2,3); mupen64plus-audio-sdl-src-2.6.0/src/osal_dynamiclib.h000066400000000000000000000033371464505432600224750ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus-core - osal/dynamiclib.h * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2009 Richard Goedeken * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #if !defined(OSAL_DYNAMICLIB_H) #define OSAL_DYNAMICLIB_H #include "m64p_types.h" void * osal_dynlib_getproc(m64p_dynlib_handle LibHandle, const char *pccProcedureName); #endif /* #define OSAL_DYNAMICLIB_H */ mupen64plus-audio-sdl-src-2.6.0/src/osal_dynamiclib_unix.c000066400000000000000000000034731464505432600235340ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus-core - osal/dynamiclib_unix.c * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2009 Richard Goedeken * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include #include #include "m64p_types.h" #include "osal_dynamiclib.h" void * osal_dynlib_getproc(m64p_dynlib_handle LibHandle, const char *pccProcedureName) { if (pccProcedureName == NULL) return NULL; return dlsym(LibHandle, pccProcedureName); } mupen64plus-audio-sdl-src-2.6.0/src/osal_dynamiclib_win32.c000066400000000000000000000060551464505432600235120ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus-ui-console - osal_dynamiclib_win32.c * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2009 Richard Goedeken * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include #include #include "m64p_types.h" #include "osal_dynamiclib.h" m64p_error osal_dynlib_open(m64p_dynlib_handle *pLibHandle, const char *pccLibraryPath) { if (pLibHandle == NULL || pccLibraryPath == NULL) return M64ERR_INPUT_ASSERT; *pLibHandle = LoadLibrary(pccLibraryPath); if (*pLibHandle == NULL) { char *pchErrMsg; DWORD dwErr = GetLastError(); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &pchErrMsg, 0, NULL); fprintf(stderr, "LoadLibrary('%s') error: %s\n", pccLibraryPath, pchErrMsg); LocalFree(pchErrMsg); return M64ERR_INPUT_NOT_FOUND; } return M64ERR_SUCCESS; } void * osal_dynlib_getproc(m64p_dynlib_handle LibHandle, const char *pccProcedureName) { if (pccProcedureName == NULL) return NULL; return GetProcAddress(LibHandle, pccProcedureName); } m64p_error osal_dynlib_close(m64p_dynlib_handle LibHandle) { int rval = FreeLibrary(LibHandle); if (rval == 0) { char *pchErrMsg; DWORD dwErr = GetLastError(); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &pchErrMsg, 0, NULL); fprintf(stderr, "FreeLibrary() error: %s\n", pchErrMsg); LocalFree(pchErrMsg); return M64ERR_INTERNAL; } return M64ERR_SUCCESS; } mupen64plus-audio-sdl-src-2.6.0/src/resamplers/000077500000000000000000000000001464505432600213425ustar00rootroot00000000000000mupen64plus-audio-sdl-src-2.6.0/src/resamplers/resamplers.c000066400000000000000000000057411464505432600236720ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus-audio-sdl - resamplers.c * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2017 Bobby Smiles * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "resamplers.h" #include "main.h" #include "m64p_types.h" #include extern const struct resampler_interface g_trivial_iresampler; #ifdef USE_SPEEX extern const struct resampler_interface g_speex_iresampler; #endif #ifdef USE_SRC extern const struct resampler_interface g_src_iresampler; #endif #define ARRAY_SIZE(x) sizeof((x)) / sizeof((x)[0]) const struct resampler_interface* get_iresampler(const char* resampler_id, void** resampler) { size_t i; static const struct { const struct resampler_interface* iresampler; const char* cmp_str; } resamplers[] = { { &g_trivial_iresampler, "trivial" }, #ifdef USE_SPEEX { &g_speex_iresampler, "speex-" }, #endif #ifdef USE_SRC { &g_src_iresampler, "src-" } #endif }; /* search matching resampler */ for(i = 0; i < ARRAY_SIZE(resamplers); ++i) { if (strncmp(resampler_id, resamplers[i].cmp_str, strlen(resamplers[i].cmp_str)) == 0) { DebugMessage(M64MSG_INFO, "Using resampler %s", resamplers[i].iresampler->name); break; } } /* handle not found case */ if (i >= ARRAY_SIZE(resamplers)) { i = 0; DebugMessage(M64MSG_WARNING, "Could not find RESAMPLE configuration %s; use %s resampler", resampler_id, resamplers[i].iresampler->name); } /* instanciate resampler */ *resampler = resamplers[i].iresampler->init_from_id(resampler_id); return resamplers[i].iresampler; } mupen64plus-audio-sdl-src-2.6.0/src/resamplers/resamplers.h000066400000000000000000000044061464505432600236740ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus-audio-sdl - resamplers.h * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2017 Bobby Smiles * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef M64P_RESAMPLERS_RESAMPLERS_H #define M64P_RESAMPLERS_RESAMPLERS_H #include struct resampler_interface { const char* name; void* (*init_from_id)(const char* resampler_id); void (*release)(void* resampler); size_t (*resample)(void* resampler, const void* src, size_t src_size, unsigned int src_freq, void* dst, size_t dst_size, unsigned int dst_freq); }; const struct resampler_interface* get_iresampler(const char* resampler_id, void** resampler); /* default resampler */ #if defined(USE_SPEEX) #define DEFAULT_RESAMPLER "speex-fixed-4" #elif defined(USE_SRC) #define DEFAULT_RESAMPLER "src-sinc-medium-quality" #else #define DEFAULT_RESAMPLER "trivial" #endif #endif mupen64plus-audio-sdl-src-2.6.0/src/resamplers/speex.c000066400000000000000000000110071464505432600226310ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus-sdl-audio - speex.c * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2017 Bobby Smiles * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "resamplers/resamplers.h" #include "main.h" #include #include "m64p_types.h" #include #include #include #define ARRAY_SIZE(x) sizeof((x)) / sizeof((x)[0]) /* assume 2x16bit interleaved channels */ enum { BYTES_PER_SAMPLE = 4 }; static void* speex_init_from_id(const char* resampler_id) { size_t i; int error; static const char *types[] = { "speex-fixed-0", "speex-fixed-1", "speex-fixed-2", "speex-fixed-3", "speex-fixed-4", "speex-fixed-5", "speex-fixed-6", "speex-fixed-7", "speex-fixed-8", "speex-fixed-9", "speex-fixed-10", }; /* select resampler configuration */ for (i = 0; i < ARRAY_SIZE(types); ++i) { if (strcmp(types[i], resampler_id) == 0) { break; } } /* handle unknown configuration */ if (i >= ARRAY_SIZE(types)) { i = 4; DebugMessage(M64MSG_WARNING, "Unknown RESAMPLE configuration %s; use %s resampler", resampler_id, types[i]); } /* init speex object with dummy frequencies (will be set later) */ SpeexResamplerState* spx_state = speex_resampler_init(2, 44100, 44100, (int)i, &error); if (error != RESAMPLER_ERR_SUCCESS) { DebugMessage(M64MSG_ERROR, "Speex error: %s", speex_resampler_strerror(error)); } return spx_state; } static void speex_release(void* resampler) { SpeexResamplerState* spx_state = (SpeexResamplerState*)resampler; if (spx_state == NULL) { return; } speex_resampler_destroy(spx_state); } static size_t speex_resample(void* resampler, const void* src, size_t src_size, unsigned int src_freq, void* dst, size_t dst_size, unsigned int dst_freq) { SpeexResamplerState* spx_state = (SpeexResamplerState*)resampler; /* update resampling rates */ speex_resampler_set_rate(spx_state, src_freq, dst_freq); /* perform resampling */ spx_uint32_t in_len = src_size / BYTES_PER_SAMPLE; spx_uint32_t out_len = dst_size / BYTES_PER_SAMPLE; int error = speex_resampler_process_interleaved_int(spx_state, (const spx_int16_t *)src, &in_len, (spx_int16_t *)dst, &out_len); /* in case of error, display error, zero output buffer and discard input buffer */ if (error != RESAMPLER_ERR_SUCCESS) { DebugMessage(M64MSG_ERROR, "Speex error: %s", speex_resampler_strerror(error)); memset(dst, 0, dst_size); return src_size; } if (dst_size != out_len * BYTES_PER_SAMPLE) { DebugMessage(M64MSG_WARNING, "dst_size = %u != outlen*4 = %u", (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); return in_len * BYTES_PER_SAMPLE; } const struct resampler_interface g_speex_iresampler = { "speex", speex_init_from_id, speex_release, speex_resample }; mupen64plus-audio-sdl-src-2.6.0/src/resamplers/src.c000066400000000000000000000142041464505432600222760ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus-sdl-audio - src.c * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2017 Bobby Smiles * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "resamplers/resamplers.h" #include "main.h" #include #include "m64p_types.h" #include #include #include #include #define ARRAY_SIZE(x) sizeof((x)) / sizeof((x)[0]) struct fbuffer { float* data; size_t size; }; static void grow_fbuffer(struct fbuffer* fbuffer, size_t new_size) { if (fbuffer->size < new_size) { fbuffer->data = realloc(fbuffer->data, new_size); fbuffer->size = new_size; } } static void free_fbuffer(struct fbuffer* fbuffer) { free(fbuffer->data); fbuffer->data = NULL; fbuffer->size = 0; } struct src_resampler { SRC_STATE* state; /* 2 intermediate buffers are needed for float/int conversion */ struct fbuffer fbuffers[2]; }; static void* src_init_from_id(const char* resampler_id) { size_t i; int error = 0; static const struct { const char* name; int converter_type; } types[] = { { "src-sinc-best-quality", SRC_SINC_BEST_QUALITY }, { "src-sinc-medium-quality", SRC_SINC_MEDIUM_QUALITY }, { "src-sinc-fastest", SRC_SINC_FASTEST }, { "src-zero-order-hold", SRC_ZERO_ORDER_HOLD }, { "src-linear", SRC_LINEAR } }; /* select resampler configuration */ for (i = 0; i < ARRAY_SIZE(types); ++i) { if (strcmp(types[i].name, resampler_id) == 0) { break; } } /* handle unknown configuration */ if (i >= ARRAY_SIZE(types)) { i = 1; DebugMessage(M64MSG_WARNING, "Unknown RESAMPLE configuration %s; use %s resampler", resampler_id, types[i].name); } /* init src resampler */ struct src_resampler* src_resampler = malloc(sizeof(*src_resampler)); if (src_resampler == NULL) { DebugMessage(M64MSG_ERROR, "Failed to allocate memory for SRC resampler"); return NULL; } /* lazy-alloc of fbuffers */ memset(src_resampler, 0, sizeof(*src_resampler)); src_resampler->state = src_new(types[i].converter_type, 2, &error); if (error != 0) { DebugMessage(M64MSG_ERROR, "SRC error: %s", src_strerror(error)); free(src_resampler); return NULL; } return src_resampler; } static void src_release(void* resampler) { size_t i; struct src_resampler* src_resampler = (struct src_resampler*)resampler; if (src_resampler == NULL) return; src_delete(src_resampler->state); for(i = 0; i < 2; ++i) { free_fbuffer(&src_resampler->fbuffers[i]); } } static size_t src_resample(void* resampler, const void* src, size_t src_size, unsigned int src_freq, void* dst, size_t dst_size, unsigned int dst_freq) { struct src_resampler* src_resampler = (struct src_resampler*)resampler; /* High quality resamplers needs more input than what * the sample rate ratio would indicate to work properly, hence the src/dst>1 ratio * * Limit src_size to avoid too much short-float-short conversion time */ if (src_size > dst_size * 5 / 2) { src_size = dst_size * 5 / 2; } /* grow float buffers if necessary */ if (src_size > 0) { grow_fbuffer(&src_resampler->fbuffers[0], src_size*2); } if (dst_size > 0) { grow_fbuffer(&src_resampler->fbuffers[1], dst_size*2); } src_short_to_float_array((short*)src, src_resampler->fbuffers[0].data, src_size/2); /* perform resampling */ SRC_DATA src_data; src_data.data_in = src_resampler->fbuffers[0].data; src_data.input_frames = src_size/4; src_data.data_out = src_resampler->fbuffers[1].data; src_data.output_frames = dst_size/4; src_data.src_ratio = (float)dst_freq / src_freq; src_data.end_of_input = 0; int error = src_process(src_resampler->state, &src_data); /* in case of error, display error, zero output buffer and discard input buffer */ if (error) { DebugMessage(M64MSG_ERROR, "SRC error: %s", src_strerror(error)); memset(dst, 0, dst_size); return src_size; } if (dst_size != src_data.output_frames_gen*4) { DebugMessage(M64MSG_WARNING, "dst_size = %u != output_frames_gen*4 = %u", (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); memset((char*)dst + src_data.output_frames_gen*4, 0, dst_size - src_data.output_frames_gen*4); return src_data.input_frames_used * 4; } const struct resampler_interface g_src_iresampler = { "src", src_init_from_id, src_release, src_resample }; mupen64plus-audio-sdl-src-2.6.0/src/resamplers/trivial.c000066400000000000000000000056061464505432600231670ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus-sdl-audio - trivial.c * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2017 Bobby Smiles * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "resamplers/resamplers.h" #include #include static void* trivial_init_from_id(const char* resampler_id) { /* nothing to do */ return NULL; } static void trivial_release(void* resampler) { /* nothing to do */ } static size_t trivial_resample(void* resampler, const void* src, size_t src_size, unsigned int src_freq, void* dst, size_t dst_size, unsigned int dst_freq) { enum { BYTES_PER_SAMPLE = 4 }; 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; int criteria = dpos - dst_freq; for (i = 0; i < dst_size/BYTES_PER_SAMPLE; ++i) { ((uint32_t*)dst)[i] = ((const uint32_t*)src)[j]; if (criteria >= 0) { ++j; criteria += dneg; } else { criteria += dpos; } } } else { /* Can happen when speed_factor > 1 */ for (i = 0; i < dst_size/BYTES_PER_SAMPLE; ++i) { j = i * src_freq / dst_freq; ((uint32_t*)dst)[i] = ((const uint32_t*)src)[j]; } } return j * 4; } const struct resampler_interface g_trivial_iresampler = { "trivial", trivial_init_from_id, trivial_release, trivial_resample }; mupen64plus-audio-sdl-src-2.6.0/src/sdl_backend.c000066400000000000000000000431621464505432600215700ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus-sdl-audio - sdl_backend.c * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2017 Bobby Smiles * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include #include #include #include #include "circular_buffer.h" #include "main.h" #include "resamplers/resamplers.h" #define M64P_PLUGIN_PROTOTYPES 1 #include "m64p_common.h" #include "m64p_config.h" #include "m64p_types.h" /* number of bytes per sample */ #define N64_SAMPLE_BYTES 4 #define SDL_SAMPLE_BYTES 4 /* For SDL < 1.3 */ #if !SDL_VERSION_ATLEAST(1,3,0) #define SDL_AUDIO_MASK_BITSIZE (0xFF) #define SDL_AUDIO_MASK_DATATYPE (1<<8) #define SDL_AUDIO_MASK_ENDIAN (1<<12) #define SDL_AUDIO_MASK_SIGNED (1<<15) #define SDL_AUDIO_BITSIZE(x) (x & SDL_AUDIO_MASK_BITSIZE) #define SDL_AUDIO_ISFLOAT(x) (x & SDL_AUDIO_MASK_DATATYPE) #define SDL_AUDIO_ISBIGENDIAN(x) (x & SDL_AUDIO_MASK_ENDIAN) #define SDL_AUDIO_ISSIGNED(x) (x & SDL_AUDIO_MASK_SIGNED) #define SDL_AUDIO_ISINT(x) (!SDL_AUDIO_ISFLOAT(x)) #define SDL_AUDIO_ISLITTLEENDIAN(x) (!SDL_AUDIO_ISBIGENDIAN(x)) #define SDL_AUDIO_ISUNSIGNED(x) (!SDL_AUDIO_ISSIGNED(x)) #endif #if SDL_VERSION_ATLEAST(2,0,0) #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; #else struct sdl_backend { #endif m64p_handle config; struct circular_buffer primary_buffer; /* Primary buffer size (in output samples) */ size_t primary_buffer_size; /* Primary buffer fullness target (in output samples) */ size_t target; /* Secondary buffer size (in output samples) */ size_t secondary_buffer_size; /* Mixing buffer used for volume control */ unsigned char* mix_buffer; unsigned int last_cb_time; unsigned int input_frequency; unsigned int output_frequency; unsigned int speed_factor; unsigned int swap_channels; unsigned int audio_sync; unsigned int paused_for_sync; unsigned int underrun_count; unsigned int error; /* Resampler */ void* resampler; 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; /* mark the time, for synchronization on the input side */ sdl_backend->last_cb_time = SDL_GetTicks(); unsigned int newsamplerate = sdl_backend->output_frequency * 100 / sdl_backend->speed_factor; unsigned int oldsamplerate = sdl_backend->input_frequency; size_t needed = (len * oldsamplerate) / newsamplerate; size_t available; size_t consumed; const void* src = cbuff_tail(&sdl_backend->primary_buffer, &available); if ((available > 0) && (available >= needed)) { consumed = ResampleAndMix(sdl_backend->resampler, sdl_backend->iresampler, sdl_backend->mix_buffer, src, available, oldsamplerate, stream, len, newsamplerate); consume_cbuff_data(&sdl_backend->primary_buffer, consumed); } else { ++sdl_backend->underrun_count; memset(stream, 0, len); } } static size_t new_primary_buffer_size(const struct sdl_backend* sdl_backend) { return N64_SAMPLE_BYTES * ((uint64_t)sdl_backend->primary_buffer_size * sdl_backend->input_frequency * sdl_backend->speed_factor) / (sdl_backend->output_frequency * 100); } static void resize_primary_buffer(struct sdl_backend* sdl_backend, size_t new_size) { /* only grows the buffer */ if (new_size > sdl_backend->primary_buffer.size) { SDL_LockAudio(); 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(); } } static unsigned int select_output_frequency(unsigned int input_frequency) { if (input_frequency <= 11025) { return 11025; } else if (input_frequency <= 22050) { return 22050; } else { return 44100; } } static void sdl_init_audio_device(struct sdl_backend* sdl_backend) { SDL_AudioSpec desired, obtained; sdl_backend->error = 0; if (SDL_WasInit(SDL_INIT_AUDIO|SDL_INIT_TIMER) == (SDL_INIT_AUDIO|SDL_INIT_TIMER) ) { DebugMessage(M64MSG_VERBOSE, "sdl_init_audio_device(): SDL Audio sub-system already initialized."); SDL_PauseAudio(1); SDL_CloseAudio(); } else { if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_TIMER) < 0) { DebugMessage(M64MSG_ERROR, "Failed to initialize SDL audio subsystem."); sdl_backend->error = 1; return; } } sdl_backend->paused_for_sync = 1; /* reload these because they gets re-assigned from SDL data below, and sdl_init_audio_device can be called more than once */ sdl_backend->primary_buffer_size = ConfigGetParamInt(sdl_backend->config, "PRIMARY_BUFFER_SIZE"); sdl_backend->target = ConfigGetParamInt(sdl_backend->config, "PRIMARY_BUFFER_TARGET"); 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.", (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); desired.format = AUDIO_S16SYS; desired.channels = 2; desired.samples = sdl_backend->secondary_buffer_size; desired.callback = my_audio_callback; desired.userdata = sdl_backend; DebugMessage(M64MSG_VERBOSE, "Requesting frequency: %iHz.", desired.freq); DebugMessage(M64MSG_VERBOSE, "Requesting format: " AFMT_FMTSPEC ".", AFMT_ARGS(desired.format)); /* Open the audio device */ if (SDL_OpenAudio(&desired, &obtained) < 0) { DebugMessage(M64MSG_ERROR, "Couldn't open audio: %s", SDL_GetError()); sdl_backend->error = 1; return; } if (desired.format != obtained.format) { 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 (%i) differs from requested (%i).", obtained.freq, desired.freq); } /* adjust some variables given the obtained audio spec */ sdl_backend->output_frequency = obtained.freq; sdl_backend->secondary_buffer_size = obtained.samples; if (sdl_backend->target < sdl_backend->secondary_buffer_size) sdl_backend->target = sdl_backend->secondary_buffer_size; if (sdl_backend->primary_buffer_size < sdl_backend->target) sdl_backend->primary_buffer_size = sdl_backend->target; if (sdl_backend->primary_buffer_size < sdl_backend->secondary_buffer_size * 2) sdl_backend->primary_buffer_size = sdl_backend->secondary_buffer_size * 2; /* allocate memory for audio buffers */ 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 */ if (sdl_backend->last_cb_time == 0) { sdl_backend->last_cb_time = SDL_GetTicks(); } DebugMessage(M64MSG_VERBOSE, "Frequency: %i", obtained.freq); 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); DebugMessage(M64MSG_VERBOSE, "Size: %i", obtained.size); /* set playback volume */ SetPlaybackVolume(); } static void release_audio_device(struct sdl_backend* sdl_backend) { if (SDL_WasInit(SDL_INIT_AUDIO) != 0) { SDL_PauseAudio(1); SDL_CloseAudio(); SDL_QuitSubSystem(SDL_INIT_AUDIO); } if (SDL_WasInit(SDL_INIT_TIMER) != 0) { SDL_QuitSubSystem(SDL_INIT_TIMER); } } static struct sdl_backend* init_sdl_backend(m64p_handle config, unsigned int default_frequency, unsigned int swap_channels, unsigned int audio_sync, const char* resampler_id) { /* allocate memory for sdl_backend */ struct sdl_backend* sdl_backend = malloc(sizeof(*sdl_backend)); if (sdl_backend == NULL) { return NULL; } /* reset sdl_backend */ memset(sdl_backend, 0, sizeof(*sdl_backend)); /* instanciate resampler */ void* resampler = NULL; const struct resampler_interface* iresampler = get_iresampler(resampler_id, &resampler); if (iresampler == NULL) { free(sdl_backend); return NULL; } sdl_backend->config = config; sdl_backend->input_frequency = default_frequency; sdl_backend->swap_channels = swap_channels; sdl_backend->audio_sync = audio_sync; sdl_backend->paused_for_sync = 1; sdl_backend->speed_factor = 100; sdl_backend->resampler = resampler; sdl_backend->iresampler = iresampler; sdl_init_audio_device(sdl_backend); return sdl_backend; } struct sdl_backend* init_sdl_backend_from_config(m64p_handle config) { unsigned int default_frequency = ConfigGetParamInt(config, "DEFAULT_FREQUENCY"); unsigned int swap_channels = ConfigGetParamBool(config, "SWAP_CHANNELS"); unsigned int audio_sync = ConfigGetParamBool(config, "AUDIO_SYNC"); const char* resampler_id = ConfigGetParamString(config, "RESAMPLE"); return init_sdl_backend(config, default_frequency, swap_channels, audio_sync, resampler_id); } void release_sdl_backend(struct sdl_backend* sdl_backend) { if (sdl_backend == NULL) { return; } if (sdl_backend->error == 0) { release_audio_device(sdl_backend); } /* release primary buffer */ release_cbuff(&sdl_backend->primary_buffer); /* release mix buffer */ free(sdl_backend->mix_buffer); /* release resampler */ sdl_backend->iresampler->release(sdl_backend->resampler); /* release sdl backend */ free(sdl_backend); } void sdl_set_frequency(struct sdl_backend* sdl_backend, unsigned int frequency) { if (sdl_backend->error != 0) return; sdl_backend->input_frequency = frequency; sdl_init_audio_device(sdl_backend); } void sdl_push_samples(struct sdl_backend* sdl_backend, const void* src, size_t size) { size_t available; if (sdl_backend->error != 0) return; /* 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) { /* 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 + 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); } SDL_UnlockAudio(); if (size > available) { DebugMessage(M64MSG_WARNING, "sdl_push_samples: pushing %zu bytes, but only %zu available !", size, available); } } 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 */ size_t expected_level = (size_t)(((int64_t)(available/N64_SAMPLE_BYTES) * sdl_backend->output_frequency * 100) / (sdl_backend->input_frequency * sdl_backend->speed_factor)); /* Next, extrapolate to the buffer level at the expected time of the next audio callback, assuming that the buffer is filled at the same rate as the output frequency */ unsigned int expected_next_cb_time = sdl_backend->last_cb_time + ((1000 * sdl_backend->secondary_buffer_size) / sdl_backend->output_frequency); if (now < expected_next_cb_time) { expected_level += (expected_next_cb_time - now) * sdl_backend->output_frequency / 1000; } return expected_level; } void sdl_synchronize_audio(struct sdl_backend* sdl_backend) { enum { TOLERANCE_MS = 10 }; size_t expected_level = estimate_level_at_next_audio_cb(sdl_backend); /* If the expected value of the Primary Buffer Fullness at the time of the next audio callback is more than 10 milliseconds ahead of our target buffer fullness level, then insert a delay now */ if (sdl_backend->audio_sync && expected_level >= sdl_backend->target + sdl_backend->output_frequency * TOLERANCE_MS / 1000) { /* Core is ahead of SDL audio thread, * delay emulation to allow the SDL audio thread to catch up */ unsigned int wait_time = (expected_level - sdl_backend->target) * 1000 / sdl_backend->output_frequency; if (sdl_backend->paused_for_sync) { SDL_PauseAudio(0); } sdl_backend->paused_for_sync = 0; SDL_Delay(wait_time); } else if (expected_level < sdl_backend->secondary_buffer_size) { /* Core is behind SDL audio thread (predicting an underflow), * pause the audio to let the Core catch up */ if (!sdl_backend->paused_for_sync) { SDL_PauseAudio(1); } sdl_backend->paused_for_sync = 1; } else { /* Expected fullness is within tolerance, * audio thread is running */ if (sdl_backend->paused_for_sync) { SDL_PauseAudio(0); } sdl_backend->paused_for_sync = 0; } } void sdl_set_speed_factor(struct sdl_backend* sdl_backend, unsigned int speed_factor) { if (speed_factor < 10 || speed_factor > 300) return; 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, new_primary_buffer_size(sdl_backend)); } mupen64plus-audio-sdl-src-2.6.0/src/sdl_backend.h000066400000000000000000000040601464505432600215670ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus-sdl-audio - sdl_backend.h * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2017 Bobby Smiles * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef M64P_SDL_BACKEND_H #define M64P_SDL_BACKEND_H #include struct sdl_backend; struct sdl_backend* init_sdl_backend_from_config(m64p_handle config); void release_sdl_backend(struct sdl_backend* sdl_backend); 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); void sdl_synchronize_audio(struct sdl_backend* sdl_backend); void sdl_set_speed_factor(struct sdl_backend* sdl_backend, unsigned int speed_factor); #endif mupen64plus-audio-sdl-src-2.6.0/src/volume.c000066400000000000000000000056251464505432600206500ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus-sdl-audio - volume.c * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2007-2008 Richard42 Ebenblues * * Copyright (C) 2002 Hacktarux * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #if defined(HAS_OSS_SUPPORT) #include #include #include #include /* Sound volume functions. */ #include #include #include #include /* close() */ #include "volume.h" /* volSet * Sets volume of left and right PCM channels to given percentage (0-100) value. */ void volSet(int percent) { int ret, vol; int mixerfd = open("/dev/mixer", O_RDONLY); if(mixerfd < 0) { perror("/dev/mixer"); return; } if(percent > 100) percent = 100; else if(percent < 0) percent = 0; vol = (percent << 8) + percent; // set both left/right channels to same vol ret = ioctl(mixerfd, MIXER_WRITE(SOUND_MIXER_PCM), &vol); if(ret < 0) perror("Setting PCM volume"); close(mixerfd); } /* volGet * Returns volume of PCM channel as a percentage (0-100). * Returns 0 on error. */ int volGet(void) { int vol, ret; int mixerfd = open("/dev/mixer", O_RDONLY); if(mixerfd < 0) { perror("/dev/mixer"); return 0; } ret = ioctl(mixerfd, MIXER_READ(SOUND_MIXER_PCM), &vol); if(ret < 0) perror("Reading PCM volume"); close(mixerfd); return vol & 0xff; // just return the left channel } #endif /* defined(HAS_OSS_SUPPORT) */ mupen64plus-audio-sdl-src-2.6.0/src/volume.h000066400000000000000000000033331464505432600206470ustar00rootroot00000000000000/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Mupen64plus - nogui.h * * Mupen64Plus homepage: https://mupen64plus.org/ * * Copyright (C) 2007-2008 Richard42 Ebenblues * * Copyright (C) 2002 Hacktarux * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Sound volume functions. */ #ifndef __VOLUME_H__ #define __VOLUME_H__ void volSet(int); int volGet(void); #endif // __VOLUME_H__