summaryrefslogtreecommitdiff
path: root/portaudio/bindings/java/c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-08-25 14:54:53 -0500
committersanine <sanine.not@pm.me>2022-08-25 14:54:53 -0500
commit37c97e345d12f95dde44e1d1a4c2f2aadd4615bc (patch)
treee1bb25bc855883062bdd7847ff2c04290f71c840 /portaudio/bindings/java/c
parent5634c7b04da619669f2f29f6798c03982be05180 (diff)
add initial structure
Diffstat (limited to 'portaudio/bindings/java/c')
-rw-r--r--portaudio/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.sln26
-rw-r--r--portaudio/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.vcproj198
-rw-r--r--portaudio/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.vcxproj174
-rw-r--r--portaudio/bindings/java/c/src/com_portaudio_BlockingStream.c352
-rw-r--r--portaudio/bindings/java/c/src/com_portaudio_BlockingStream.h130
-rw-r--r--portaudio/bindings/java/c/src/com_portaudio_PortAudio.c279
-rw-r--r--portaudio/bindings/java/c/src/com_portaudio_PortAudio.h183
-rw-r--r--portaudio/bindings/java/c/src/jpa_tools.c208
-rw-r--r--portaudio/bindings/java/c/src/jpa_tools.h62
9 files changed, 1612 insertions, 0 deletions
diff --git a/portaudio/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.sln b/portaudio/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.sln
new file mode 100644
index 0000000..6f8ef5f
--- /dev/null
+++ b/portaudio/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.sln
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PortAudioJNI", "PortAudioJNI.vcxproj", "{4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Debug|Win32.ActiveCfg = Debug|Win32
+ {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Debug|Win32.Build.0 = Debug|Win32
+ {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Debug|x64.ActiveCfg = Debug|x64
+ {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Debug|x64.Build.0 = Debug|x64
+ {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Release|Win32.ActiveCfg = Release|Win32
+ {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Release|Win32.Build.0 = Release|Win32
+ {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Release|x64.ActiveCfg = Release|x64
+ {4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}.Release|x64.Build.0 = Release|x64
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/portaudio/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.vcproj b/portaudio/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.vcproj
new file mode 100644
index 0000000..ce83264
--- /dev/null
+++ b/portaudio/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.vcproj
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="PortAudioJNI"
+ ProjectGUID="{4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}"
+ RootNamespace="PortAudioJNI"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="..\..\..\..\jportaudio"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="C:\glassfish3\jdk\include;C:\glassfish3\jdk\include\win32"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PORTAUDIOJNI_EXPORTS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PORTAUDIOJNI_EXPORTS"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\..\..\src\com_portaudio_PortAudio.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\..\..\src\com_portaudio_PortAudio.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/portaudio/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.vcxproj b/portaudio/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.vcxproj
new file mode 100644
index 0000000..c7e881b
--- /dev/null
+++ b/portaudio/bindings/java/c/build/vs2010/PortAudioJNI/PortAudioJNI.vcxproj
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{4024D885-39B0-4C8A-B3E7-BAB4BA08DFBB}</ProjectGuid>
+ <RootNamespace>PortAudioJNI</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\..\..\jportaudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\..\..\jportaudio\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\..\..\jportaudio\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\..\..\jportaudio\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Configuration)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">jportaudio_x64</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">jportaudio_x86</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">jportaudio_x86</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">jportaudio_x64</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..\..\..\..\include;%JAVA_HOME%\include;%JAVA_HOME%\include\win32</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PORTAUDIOJNI_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\..\..\..\..\include;%JAVA_HOME%\include;%JAVA_HOME%\include\win32</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PORTAUDIOJNI_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PORTAUDIOJNI_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <AdditionalIncludeDirectories>..\..\..\..\..\..\include;%JAVA_HOME%\include;%JAVA_HOME%\include\win32</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PORTAUDIOJNI_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <AdditionalIncludeDirectories>..\..\..\..\..\..\include;%JAVA_HOME%\include;%JAVA_HOME%\include\win32</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\src\com_portaudio_BlockingStream.c" />
+ <ClCompile Include="..\..\..\src\com_portaudio_PortAudio.c" />
+ <ClCompile Include="..\..\..\src\jpa_tools.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\..\src\com_portaudio_BlockingStream.h" />
+ <ClInclude Include="..\..\..\src\com_portaudio_PortAudio.h" />
+ <ClInclude Include="..\..\..\src\jpa_tools.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <Library Include="..\..\..\..\jportaudio\portaudio_x64.lib" />
+ <Library Include="..\..\..\..\jportaudio\portaudio_x86.lib" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/portaudio/bindings/java/c/src/com_portaudio_BlockingStream.c b/portaudio/bindings/java/c/src/com_portaudio_BlockingStream.c
new file mode 100644
index 0000000..64d8213
--- /dev/null
+++ b/portaudio/bindings/java/c/src/com_portaudio_BlockingStream.c
@@ -0,0 +1,352 @@
+/*
+ * Portable Audio I/O Library
+ * Java Binding for PortAudio
+ *
+ * Based on the Open Source API proposed by Ross Bencina
+ * Copyright (c) 2008 Ross Bencina
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * The text above constitutes the entire PortAudio license; however,
+ * the PortAudio community also makes the following non-binding requests:
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
+ * license above.
+ */
+
+#include "com_portaudio_BlockingStream.h"
+#include "portaudio.h"
+#include "jpa_tools.h"
+
+#ifndef FALSE
+#define FALSE (0)
+#endif
+#ifndef TRUE
+#define TRUE (!FALSE)
+#endif
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: getReadAvailable
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_BlockingStream_getReadAvailable
+ (JNIEnv *env, jobject blockingStream)
+{
+ PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+ if( stream == NULL ) return 0;
+ return Pa_GetStreamReadAvailable( stream );
+}
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: getWriteAvailable
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_BlockingStream_getWriteAvailable
+ (JNIEnv *env, jobject blockingStream)
+{
+ PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+ if( stream == NULL ) return 0;
+ return Pa_GetStreamWriteAvailable( stream );
+}
+
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: writeFloats
+ * Signature: ([FI)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_writeFloats
+ (JNIEnv *env, jobject blockingStream, jfloatArray buffer, jint numFrames)
+{
+ jfloat *carr;
+ jint err;
+ PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+ if( buffer == NULL )
+ {
+ (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+ "null stream buffer");
+ return FALSE;
+ }
+ carr = (*env)->GetFloatArrayElements(env, buffer, NULL);
+ if (carr == NULL)
+ {
+ (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+ "invalid stream buffer");
+ return FALSE;
+ }
+ err = Pa_WriteStream( stream, carr, numFrames );
+ (*env)->ReleaseFloatArrayElements(env, buffer, carr, 0);
+ if( err == paOutputUnderflowed )
+ {
+ return TRUE;
+ }
+ else
+ {
+ jpa_CheckError( env, err );
+ return FALSE;
+ }
+}
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: readFloats
+ * Signature: ([FI)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_readFloats
+ (JNIEnv *env, jobject blockingStream, jfloatArray buffer, jint numFrames)
+{
+ jfloat *carr;
+ jint err;
+ PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+ if( buffer == NULL )
+ {
+ (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+ "null stream buffer");
+ return FALSE;
+ }
+ carr = (*env)->GetFloatArrayElements(env, buffer, NULL);
+ if (carr == NULL)
+ {
+ (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+ "invalid stream buffer");
+ return FALSE;
+ }
+ err = Pa_ReadStream( stream, carr, numFrames );
+ (*env)->ReleaseFloatArrayElements(env, buffer, carr, 0);
+ if( err == paInputOverflowed )
+ {
+ return TRUE;
+ }
+ else
+ {
+ jpa_CheckError( env, err );
+ return FALSE;
+ }
+}
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: writeShorts
+ * Signature: ([SI)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_writeShorts
+ (JNIEnv *env, jobject blockingStream, jfloatArray buffer, jint numFrames)
+{
+ jshort *carr;
+ jint err;
+ PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+ if( buffer == NULL )
+ {
+ (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+ "null stream buffer");
+ return FALSE;
+ }
+ carr = (*env)->GetShortArrayElements(env, buffer, NULL);
+ if (carr == NULL)
+ {
+ (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+ "invalid stream buffer");
+ return FALSE;
+ }
+ err = Pa_WriteStream( stream, carr, numFrames );
+ (*env)->ReleaseShortArrayElements(env, buffer, carr, 0);
+ if( err == paOutputUnderflowed )
+ {
+ return TRUE;
+ }
+ else
+ {
+ jpa_CheckError( env, err );
+ return FALSE;
+ }
+}
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: readShorts
+ * Signature: ([SI)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_readShorts
+ (JNIEnv *env, jobject blockingStream, jfloatArray buffer, jint numFrames)
+{
+ jshort *carr;
+ jint err;
+ PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+ if( buffer == NULL )
+ {
+ (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+ "null stream buffer");
+ return FALSE;
+ }
+ carr = (*env)->GetShortArrayElements(env, buffer, NULL);
+ if (carr == NULL)
+ {
+ (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"),
+ "invalid stream buffer");
+ return FALSE;
+ }
+ err = Pa_ReadStream( stream, carr, numFrames );
+ (*env)->ReleaseShortArrayElements(env, buffer, carr, 0);
+ if( err == paInputOverflowed )
+ {
+ return TRUE;
+ }
+ else
+ {
+ jpa_CheckError( env, err );
+ return FALSE;
+ }
+}
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: start
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_start
+ (JNIEnv *env, jobject blockingStream )
+{
+ PaStream *stream = jpa_GetStreamPointer( env, blockingStream );
+ int err = Pa_StartStream( stream );
+ jpa_CheckError( env, err );
+}
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: stop
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_stop
+ (JNIEnv *env, jobject blockingStream )
+{
+ PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+ int err = Pa_StopStream( stream );
+ jpa_CheckError( env, err );
+}
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: abort
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_abort
+ (JNIEnv *env, jobject blockingStream )
+{
+ PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+ int err = Pa_AbortStream( stream );
+ jpa_CheckError( env, err );
+}
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: close
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_close
+ (JNIEnv *env, jobject blockingStream )
+{
+ jclass cls;
+ PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+ if( stream != NULL )
+ {
+ int err = Pa_CloseStream( stream );
+ jpa_CheckError( env, err );
+ cls = (*env)->GetObjectClass(env, blockingStream);
+ jpa_SetLongField( env, cls, blockingStream, "nativeStream", (jlong) 0 );
+ }
+}
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: isStopped
+ * Signature: ()V
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_isStopped
+ (JNIEnv *env, jobject blockingStream )
+{
+ int err;
+ PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+ if( stream == NULL ) return 1;
+ err = Pa_IsStreamStopped( stream );
+ return (jpa_CheckError( env, err ) > 0);
+}
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: isActive
+ * Signature: ()V
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_isActive
+ (JNIEnv *env, jobject blockingStream )
+{
+ int err;
+ PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+ if( stream == NULL ) return 0;
+ err = Pa_IsStreamActive( stream );
+ return (jpa_CheckError( env, err ) > 0);
+}
+
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: getTime
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_portaudio_BlockingStream_getTime
+ (JNIEnv *env, jobject blockingStream )
+{
+ PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+ if( stream == NULL ) return 0.0;
+ return Pa_GetStreamTime( stream );
+}
+
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: getInfo
+ * Signature: ()Lcom/portaudio/StreamInfo;
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_getInfo
+ (JNIEnv *env, jobject blockingStream, jobject streamInfo)
+{
+
+ PaStream *stream =jpa_GetStreamPointer( env, blockingStream );
+ const PaStreamInfo *info = Pa_GetStreamInfo( stream );
+ if( streamInfo == NULL )
+ {
+ jpa_ThrowError( env, "Invalid stream." );
+ }
+ else
+ {
+ /* Get a reference to obj's class */
+ jclass cls = (*env)->GetObjectClass(env, streamInfo);
+
+ jpa_SetIntField( env, cls, streamInfo, "structVersion", info->structVersion );
+ jpa_SetDoubleField( env, cls, streamInfo, "inputLatency", info->inputLatency );
+ jpa_SetDoubleField( env, cls, streamInfo, "outputLatency", info->outputLatency );
+ jpa_SetDoubleField( env, cls, streamInfo, "sampleRate", info->sampleRate );
+ }
+}
+
diff --git a/portaudio/bindings/java/c/src/com_portaudio_BlockingStream.h b/portaudio/bindings/java/c/src/com_portaudio_BlockingStream.h
new file mode 100644
index 0000000..e405fae
--- /dev/null
+++ b/portaudio/bindings/java/c/src/com_portaudio_BlockingStream.h
@@ -0,0 +1,130 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#if defined(__APPLE__)
+#include <JavaVM/jni.h>
+#else
+#include <jni.h>
+#endif
+
+/* Header for class com_portaudio_BlockingStream */
+
+#ifndef _Included_com_portaudio_BlockingStream
+#define _Included_com_portaudio_BlockingStream
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: getReadAvailable
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_BlockingStream_getReadAvailable
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: getWriteAvailable
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_BlockingStream_getWriteAvailable
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: readFloats
+ * Signature: ([FI)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_readFloats
+ (JNIEnv *, jobject, jfloatArray, jint);
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: writeFloats
+ * Signature: ([FI)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_writeFloats
+ (JNIEnv *, jobject, jfloatArray, jint);
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: readShorts
+ * Signature: ([SI)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_readShorts
+ (JNIEnv *, jobject, jshortArray, jint);
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: writeShorts
+ * Signature: ([SI)Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_writeShorts
+ (JNIEnv *, jobject, jshortArray, jint);
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: start
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_start
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: stop
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_stop
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: abort
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_abort
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: close
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_close
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: isStopped
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_isStopped
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: isActive
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_isActive
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: getTime
+ * Signature: ()D
+ */
+JNIEXPORT jdouble JNICALL Java_com_portaudio_BlockingStream_getTime
+ (JNIEnv *, jobject);
+
+/*
+ * Class: com_portaudio_BlockingStream
+ * Method: getInfo
+ * Signature: (Lcom/portaudio/StreamInfo;)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_getInfo
+ (JNIEnv *, jobject, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/portaudio/bindings/java/c/src/com_portaudio_PortAudio.c b/portaudio/bindings/java/c/src/com_portaudio_PortAudio.c
new file mode 100644
index 0000000..77c42eb
--- /dev/null
+++ b/portaudio/bindings/java/c/src/com_portaudio_PortAudio.c
@@ -0,0 +1,279 @@
+/*
+ * Portable Audio I/O Library
+ * Java Binding for PortAudio
+ *
+ * Based on the Open Source API proposed by Ross Bencina
+ * Copyright (c) 2008 Ross Bencina
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * The text above constitutes the entire PortAudio license; however,
+ * the PortAudio community also makes the following non-binding requests:
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
+ * license above.
+ */
+
+#include "com_portaudio_PortAudio.h"
+#include "portaudio.h"
+#include "jpa_tools.h"
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getVersion
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getVersion
+ (JNIEnv *env, jclass clazz)
+{
+ return Pa_GetVersion();
+}
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getVersionText
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_portaudio_PortAudio_getVersionText
+ (JNIEnv *env, jclass clazz)
+{
+ return (*env)->NewStringUTF(env, Pa_GetVersionText() );
+}
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: initialize
+ * Signature: ()I
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_initialize
+ (JNIEnv *env, jclass clazz)
+{
+ PaError err = Pa_Initialize();
+ jpa_CheckError( env, err );
+}
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: terminate
+ * Signature: ()I
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_terminate
+ (JNIEnv *env, jclass clazz)
+{
+ PaError err = Pa_Terminate();
+ jpa_CheckError( env, err );
+}
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getDeviceCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDeviceCount
+ (JNIEnv *env, jclass clazz)
+{
+ jint count = Pa_GetDeviceCount();
+ return jpa_CheckError( env, count );
+}
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getDeviceInfo
+ * Signature: (ILcom/portaudio/DeviceInfo;)I
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_getDeviceInfo
+ (JNIEnv *env, jclass clazz, jint index, jobject deviceInfo)
+{
+ const PaDeviceInfo *info;
+ /* Get a reference to obj's class */
+ jclass cls = (*env)->GetObjectClass(env, deviceInfo);
+
+ info = Pa_GetDeviceInfo( index );
+ if( info == NULL )
+ {
+ jpa_ThrowError( env, "Pa_GetDeviceInfo returned NULL." );
+ }
+ else
+ {
+ jpa_SetStringField( env, cls, deviceInfo, "name", info->name );
+ jpa_SetIntField( env, cls, deviceInfo, "maxInputChannels", info->maxInputChannels );
+ jpa_SetIntField( env, cls, deviceInfo, "maxOutputChannels", info->maxOutputChannels );
+ jpa_SetIntField( env, cls, deviceInfo, "hostApi", info->hostApi );
+ jpa_SetDoubleField( env, cls, deviceInfo, "defaultSampleRate", info->defaultSampleRate );
+ jpa_SetDoubleField( env, cls, deviceInfo, "defaultLowInputLatency", info->defaultLowInputLatency );
+ jpa_SetDoubleField( env, cls, deviceInfo, "defaultLowInputLatency", info->defaultHighInputLatency );
+ jpa_SetDoubleField( env, cls, deviceInfo, "defaultLowOutputLatency", info->defaultLowOutputLatency );
+ jpa_SetDoubleField( env, cls, deviceInfo, "defaultHighOutputLatency", info->defaultHighOutputLatency );
+ }
+}
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: geHostApiCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getHostApiCount
+ (JNIEnv *env, jclass clazz)
+{
+ jint count = Pa_GetHostApiCount();
+ return jpa_CheckError( env, count );
+}
+
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: hostApiTypeIdToHostApiIndex
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_hostApiTypeIdToHostApiIndex
+ (JNIEnv *env, jclass clazz, jint hostApiType)
+{
+ return Pa_HostApiTypeIdToHostApiIndex( (PaHostApiTypeId) hostApiType );
+}
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: hostApiDeviceIndexToDeviceIndex
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_hostApiDeviceIndexToDeviceIndex
+ (JNIEnv *env, jclass clazz, jint hostApiIndex, jint apiDeviceIndex)
+{
+ return Pa_HostApiDeviceIndexToDeviceIndex( hostApiIndex, apiDeviceIndex );
+}
+
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getHostApiInfo
+ * Signature: (ILcom/portaudio/HostApiInfo;)I
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_getHostApiInfo
+ (JNIEnv *env, jclass clazz, jint index, jobject hostApiInfo)
+{
+ const PaHostApiInfo *info;
+ /* Get a reference to obj's class */
+ jclass cls = (*env)->GetObjectClass(env, hostApiInfo);
+
+ info = Pa_GetHostApiInfo( index );
+ if( info == NULL )
+ {
+ jpa_ThrowError( env, "Pa_GetHostApiInfo returned NULL." );
+ }
+ else
+ {
+ jpa_SetIntField( env, cls, hostApiInfo, "version", info->structVersion );
+ jpa_SetIntField( env, cls, hostApiInfo, "type", info->type );
+ jpa_SetStringField( env, cls, hostApiInfo, "name", info->name );
+ jpa_SetIntField( env, cls, hostApiInfo, "deviceCount", info->deviceCount );
+ jpa_SetIntField( env, cls, hostApiInfo, "defaultInputDevice", info->defaultInputDevice );
+ jpa_SetIntField( env, cls, hostApiInfo, "defaultOutputDevice", info->defaultOutputDevice );
+ }
+}
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getDefaultInputDevice
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultInputDevice
+ (JNIEnv *env, jclass clazz)
+{
+ jint deviceId = Pa_GetDefaultInputDevice();
+ return jpa_CheckError( env, deviceId );
+}
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getDefaultOutputDevice
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultOutputDevice
+ (JNIEnv *env, jclass clazz)
+{
+ jint deviceId = Pa_GetDefaultOutputDevice();
+ return jpa_CheckError( env, deviceId );
+}
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getDefaultHostApi
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultHostApi
+ (JNIEnv *env, jclass clazz)
+{
+ jint deviceId = Pa_GetDefaultHostApi();
+ return jpa_CheckError( env, deviceId );
+}
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: isFormatSupported
+ * Signature: (Lcom/portaudio/StreamParameters;Lcom/portaudio/StreamParameters;I)I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_isFormatSupported
+ (JNIEnv *env, jclass clazz, jobject inParams, jobject outParams, jint sampleRate )
+{
+ PaStreamParameters myInParams, *paInParams;
+ PaStreamParameters myOutParams, *paOutParams;
+
+ paInParams = jpa_FillStreamParameters( env, inParams, &myInParams );
+ paOutParams = jpa_FillStreamParameters( env, outParams, &myOutParams );
+
+ return Pa_IsFormatSupported( paInParams, paOutParams, sampleRate );
+
+}
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: openStream
+ * Signature: (Lcom/portaudio/BlockingStream;Lcom/portaudio/StreamParameters;Lcom/portaudio/StreamParameters;III)I
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_openStream
+ (JNIEnv *env, jclass clazz, jobject blockingStream, jobject inParams, jobject outParams, jint sampleRate, jint framesPerBuffer, jint flags )
+{
+ int err;
+ PaStreamParameters myInParams, *paInParams;
+ PaStreamParameters myOutParams, *paOutParams;
+ PaStream *stream;
+
+ paInParams = jpa_FillStreamParameters( env, inParams, &myInParams );
+ paOutParams = jpa_FillStreamParameters( env, outParams, &myOutParams );
+ err = Pa_OpenStream( &stream, paInParams, paOutParams, sampleRate, framesPerBuffer, flags, NULL, NULL );
+ if( jpa_CheckError( env, err ) == 0 )
+ {
+ jclass cls = (*env)->GetObjectClass(env, blockingStream);
+ jpa_SetLongField( env, cls, blockingStream, "nativeStream", (jlong) stream );
+ if( paInParams != NULL )
+ {
+ jpa_SetIntField( env, cls, blockingStream, "inputFormat", paInParams->sampleFormat );
+ }
+ if( paOutParams != NULL )
+ {
+ jpa_SetIntField( env, cls, blockingStream, "outputFormat", paOutParams->sampleFormat );
+ }
+ }
+}
diff --git a/portaudio/bindings/java/c/src/com_portaudio_PortAudio.h b/portaudio/bindings/java/c/src/com_portaudio_PortAudio.h
new file mode 100644
index 0000000..ed806ac
--- /dev/null
+++ b/portaudio/bindings/java/c/src/com_portaudio_PortAudio.h
@@ -0,0 +1,183 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#if defined(__APPLE__)
+#include <JavaVM/jni.h>
+#else
+#include <jni.h>
+#endif
+/* Header for class com_portaudio_PortAudio */
+
+#ifndef _Included_com_portaudio_PortAudio
+#define _Included_com_portaudio_PortAudio
+#ifdef __cplusplus
+extern "C" {
+#endif
+#undef com_portaudio_PortAudio_FLAG_CLIP_OFF
+#define com_portaudio_PortAudio_FLAG_CLIP_OFF 1L
+#undef com_portaudio_PortAudio_FLAG_DITHER_OFF
+#define com_portaudio_PortAudio_FLAG_DITHER_OFF 2L
+#undef com_portaudio_PortAudio_FORMAT_FLOAT_32
+#define com_portaudio_PortAudio_FORMAT_FLOAT_32 1L
+#undef com_portaudio_PortAudio_FORMAT_INT_32
+#define com_portaudio_PortAudio_FORMAT_INT_32 2L
+#undef com_portaudio_PortAudio_FORMAT_INT_24
+#define com_portaudio_PortAudio_FORMAT_INT_24 4L
+#undef com_portaudio_PortAudio_FORMAT_INT_16
+#define com_portaudio_PortAudio_FORMAT_INT_16 8L
+#undef com_portaudio_PortAudio_FORMAT_INT_8
+#define com_portaudio_PortAudio_FORMAT_INT_8 16L
+#undef com_portaudio_PortAudio_FORMAT_UINT_8
+#define com_portaudio_PortAudio_FORMAT_UINT_8 32L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_DEV
+#define com_portaudio_PortAudio_HOST_API_TYPE_DEV 0L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_DIRECTSOUND
+#define com_portaudio_PortAudio_HOST_API_TYPE_DIRECTSOUND 1L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_MME
+#define com_portaudio_PortAudio_HOST_API_TYPE_MME 2L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_ASIO
+#define com_portaudio_PortAudio_HOST_API_TYPE_ASIO 3L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_SOUNDMANAGER
+#define com_portaudio_PortAudio_HOST_API_TYPE_SOUNDMANAGER 4L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_COREAUDIO
+#define com_portaudio_PortAudio_HOST_API_TYPE_COREAUDIO 5L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_OSS
+#define com_portaudio_PortAudio_HOST_API_TYPE_OSS 7L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_ALSA
+#define com_portaudio_PortAudio_HOST_API_TYPE_ALSA 8L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_AL
+#define com_portaudio_PortAudio_HOST_API_TYPE_AL 9L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_BEOS
+#define com_portaudio_PortAudio_HOST_API_TYPE_BEOS 10L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_WDMKS
+#define com_portaudio_PortAudio_HOST_API_TYPE_WDMKS 11L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_JACK
+#define com_portaudio_PortAudio_HOST_API_TYPE_JACK 12L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_WASAPI
+#define com_portaudio_PortAudio_HOST_API_TYPE_WASAPI 13L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_AUDIOSCIENCE
+#define com_portaudio_PortAudio_HOST_API_TYPE_AUDIOSCIENCE 14L
+#undef com_portaudio_PortAudio_HOST_API_TYPE_COUNT
+#define com_portaudio_PortAudio_HOST_API_TYPE_COUNT 15L
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getVersion
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getVersion
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getVersionText
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_com_portaudio_PortAudio_getVersionText
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: initialize
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_initialize
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: terminate
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_terminate
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getDeviceCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDeviceCount
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getDeviceInfo
+ * Signature: (ILcom/portaudio/DeviceInfo;)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_getDeviceInfo
+ (JNIEnv *, jclass, jint, jobject);
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getHostApiCount
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getHostApiCount
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getHostApiInfo
+ * Signature: (ILcom/portaudio/HostApiInfo;)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_getHostApiInfo
+ (JNIEnv *, jclass, jint, jobject);
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: hostApiTypeIdToHostApiIndex
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_hostApiTypeIdToHostApiIndex
+ (JNIEnv *, jclass, jint);
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: hostApiDeviceIndexToDeviceIndex
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_hostApiDeviceIndexToDeviceIndex
+ (JNIEnv *, jclass, jint, jint);
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getDefaultInputDevice
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultInputDevice
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getDefaultOutputDevice
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultOutputDevice
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: getDefaultHostApi
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultHostApi
+ (JNIEnv *, jclass);
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: isFormatSupported
+ * Signature: (Lcom/portaudio/StreamParameters;Lcom/portaudio/StreamParameters;I)I
+ */
+JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_isFormatSupported
+ (JNIEnv *, jclass, jobject, jobject, jint);
+
+/*
+ * Class: com_portaudio_PortAudio
+ * Method: openStream
+ * Signature: (Lcom/portaudio/BlockingStream;Lcom/portaudio/StreamParameters;Lcom/portaudio/StreamParameters;III)V
+ */
+JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_openStream
+ (JNIEnv *, jclass, jobject, jobject, jobject, jint, jint, jint);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/portaudio/bindings/java/c/src/jpa_tools.c b/portaudio/bindings/java/c/src/jpa_tools.c
new file mode 100644
index 0000000..e3f903a
--- /dev/null
+++ b/portaudio/bindings/java/c/src/jpa_tools.c
@@ -0,0 +1,208 @@
+/*
+ * Portable Audio I/O Library
+ * Java Binding for PortAudio
+ *
+ * Based on the Open Source API proposed by Ross Bencina
+ * Copyright (c) 2008 Ross Bencina
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * The text above constitutes the entire PortAudio license; however,
+ * the PortAudio community also makes the following non-binding requests:
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
+ * license above.
+ */
+
+#include "com_portaudio_PortAudio.h"
+#include "portaudio.h"
+#include "jpa_tools.h"
+
+jint jpa_GetIntField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName )
+{
+ /* Look for the instance field maxInputChannels in cls */
+ jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "I");
+ if (fid == NULL)
+ {
+ jpa_ThrowError( env, "Cannot find integer JNI field." );
+ return 0;
+ }
+ else
+ {
+ return (*env)->GetIntField(env, obj, fid );
+ }
+}
+
+void jpa_SetIntField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jint value )
+{
+ /* Look for the instance field maxInputChannels in cls */
+ jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "I");
+ if (fid == NULL)
+ {
+ jpa_ThrowError( env, "Cannot find integer JNI field." );
+ }
+ else
+ {
+ (*env)->SetIntField(env, obj, fid, value );
+ }
+}
+
+jlong jpa_GetLongField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName )
+{
+ /* Look for the instance field maxInputChannels in cls */
+ jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "J");
+ if (fid == NULL)
+ {
+ jpa_ThrowError( env, "Cannot find long JNI field." );
+ return 0L;
+ }
+ else
+ {
+ return (*env)->GetLongField(env, obj, fid );
+ }
+}
+
+void jpa_SetLongField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jlong value )
+{
+ /* Look for the instance field maxInputChannels in cls */
+ jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "J");
+ if (fid == NULL)
+ {
+ jpa_ThrowError( env, "Cannot find long JNI field." );
+ }
+ else
+ {
+ (*env)->SetLongField(env, obj, fid, value );
+ }
+}
+
+
+void jpa_SetDoubleField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jdouble value )
+{
+ /* Look for the instance field maxInputChannels in cls */
+ jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "D");
+ if (fid == NULL)
+ {
+ jpa_ThrowError( env, "Cannot find double JNI field." );
+ }
+ else
+ {
+ (*env)->SetDoubleField(env, obj, fid, value );
+ }
+}
+
+
+jdouble jpa_GetDoubleField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName )
+{
+ /* Look for the instance field maxInputChannels in cls */
+ jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "D");
+ if (fid == NULL)
+ {
+ jpa_ThrowError( env, "Cannot find double JNI field." );
+ return 0;
+ }
+ else
+ {
+ return (*env)->GetDoubleField(env, obj, fid );
+ }
+}
+
+void jpa_SetStringField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, const char *value )
+{
+ /* Look for the instance field maxInputChannels in cls */
+ jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "Ljava/lang/String;");
+ if (fid == NULL)
+ {
+ jpa_ThrowError( env, "Cannot find String JNI field." );
+ }
+ else
+ {
+ jstring jstr = (*env)->NewStringUTF(env, value);
+ if (jstr == NULL)
+ {
+ jpa_ThrowError( env, "Cannot create new String." );
+ }
+ else
+ {
+ (*env)->SetObjectField(env, obj, fid, jstr );
+ }
+ }
+}
+
+PaStreamParameters *jpa_FillStreamParameters( JNIEnv *env, jobject jstreamParam, PaStreamParameters *myParams )
+{
+ jclass cls;
+
+ if( jstreamParam == NULL ) return NULL; // OK, not an error
+
+ cls = (*env)->GetObjectClass(env, jstreamParam);
+
+ myParams->channelCount = jpa_GetIntField( env, cls, jstreamParam, "channelCount" );
+ myParams->device = jpa_GetIntField( env, cls, jstreamParam, "device" );
+ myParams->sampleFormat = jpa_GetIntField( env, cls, jstreamParam, "sampleFormat" );
+ myParams->suggestedLatency = jpa_GetDoubleField( env, cls, jstreamParam, "suggestedLatency" );
+ myParams->hostApiSpecificStreamInfo = NULL;
+
+ return myParams;
+}
+
+// Create an exception that will be thrown when we return from the JNI call.
+jint jpa_ThrowError( JNIEnv *env, const char *message )
+{
+ return (*env)->ThrowNew(env, (*env)->FindClass( env, "java/lang/RuntimeException"),
+ message );
+}
+
+// Throw an exception on error.
+jint jpa_CheckError( JNIEnv *env, PaError err )
+{
+ if( err == -1 )
+ {
+ return jpa_ThrowError( env, "-1, possibly no available default device" );
+ }
+ else if( err < 0 )
+ {
+ if( err == paUnanticipatedHostError )
+ {
+ const PaHostErrorInfo *hostErrorInfo = Pa_GetLastHostErrorInfo();
+ return jpa_ThrowError( env, hostErrorInfo->errorText );
+ }
+ else
+ {
+ return jpa_ThrowError( env, Pa_GetErrorText( err ) );
+ }
+ }
+ else
+ {
+ return err;
+ }
+}
+
+// Get the stream pointer from a BlockingStream long field.
+PaStream *jpa_GetStreamPointer( JNIEnv *env, jobject blockingStream )
+{
+ jclass cls = (*env)->GetObjectClass(env, blockingStream);
+ return (PaStream *) jpa_GetLongField( env, cls, blockingStream, "nativeStream" );
+}
diff --git a/portaudio/bindings/java/c/src/jpa_tools.h b/portaudio/bindings/java/c/src/jpa_tools.h
new file mode 100644
index 0000000..11e724c
--- /dev/null
+++ b/portaudio/bindings/java/c/src/jpa_tools.h
@@ -0,0 +1,62 @@
+/*
+ * Portable Audio I/O Library
+ * Java Binding for PortAudio
+ *
+ * Based on the Open Source API proposed by Ross Bencina
+ * Copyright (c) 2008 Ross Bencina
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * The text above constitutes the entire PortAudio license; however,
+ * the PortAudio community also makes the following non-binding requests:
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
+ * license above.
+ */
+
+#include "com_portaudio_PortAudio.h"
+#include "portaudio.h"
+
+#ifndef JPA_TOOLS_H
+#define JPA_TOOLS_H
+
+jint jpa_GetIntField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName );
+void jpa_SetIntField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jint value );
+
+jlong jpa_GetLongField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName );
+void jpa_SetLongField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jlong value );
+
+jdouble jpa_GetDoubleField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName );
+void jpa_SetDoubleField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jdouble value );
+
+void jpa_SetStringField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, const char *value );
+PaStreamParameters *jpa_FillStreamParameters( JNIEnv *env, jobject jstreamParam, PaStreamParameters *myParams );
+
+jint jpa_CheckError( JNIEnv *env, PaError err );
+jint jpa_ThrowError( JNIEnv *env, const char *message );
+
+PaStream *jpa_GetStreamPointer( JNIEnv *env, jobject blockingStream );
+
+#endif /* JPA_TOOLS_H */