summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c_portadao.c6
-rw-r--r--src/c_portadao.h3
-rw-r--r--src/portaudio-devices.adb8
-rw-r--r--src/portaudio-streams.adb132
-rw-r--r--src/portaudio-streams.ads4
-rw-r--r--src/portaudio.adb11
-rw-r--r--src/portaudio.ads20
7 files changed, 105 insertions, 79 deletions
diff --git a/src/c_portadao.c b/src/c_portadao.c
index d664b69..53b22a3 100644
--- a/src/c_portadao.c
+++ b/src/c_portadao.c
@@ -88,6 +88,12 @@ const unsigned long pa_priming_output = paPrimingOutput;
+size_t c_pointer_size() {
+ return sizeof(void*);
+}
+
+
+
int fd_backup;
int suppressed = 0;
diff --git a/src/c_portadao.h b/src/c_portadao.h
index 9bcd3be..bee7a5c 100644
--- a/src/c_portadao.h
+++ b/src/c_portadao.h
@@ -85,6 +85,9 @@ extern const unsigned long pa_output_overflow;
extern const unsigned long pa_priming_output;
+size_t c_pointer_size();
+
+
int apa_init(int msg);
int apa_term();
diff --git a/src/portaudio-devices.adb b/src/portaudio-devices.adb
index 7e0e5e6..aa697ad 100644
--- a/src/portaudio-devices.adb
+++ b/src/portaudio-devices.adb
@@ -45,7 +45,7 @@ package body Portaudio.Devices is
function pa_get_host_api_info
(Index : in Interfaces.C.int)
- return System.Address;
+ return Storage.Integer_Address;
pragma Import (C, pa_get_host_api_info, "Pa_GetHostApiInfo");
function pa_host_api_type_id_to_host_api_index
@@ -74,7 +74,7 @@ package body Portaudio.Devices is
function pa_get_device_info
(Index : in Interfaces.C.int)
- return System.Address;
+ return Storage.Integer_Address;
pragma Import (C, pa_get_device_info, "Pa_GetDeviceInfo");
@@ -288,7 +288,7 @@ package body Portaudio.Devices is
is
Result : System.Address;
begin
- Result := pa_get_host_api_info (Interfaces.C.int (Index) - 1);
+ Result := Storage.To_Address (pa_get_host_api_info (Interfaces.C.int (Index) - 1));
if Result = System.Null_Address then
raise General_Failure;
else
@@ -375,7 +375,7 @@ package body Portaudio.Devices is
is
Result : System.Address;
begin
- Result := pa_get_device_info (Interfaces.C.int (Index) - 1);
+ Result := Storage.To_Address (pa_get_device_info (Interfaces.C.int (Index) - 1));
if Result = System.Null_Address then
raise General_Failure;
else
diff --git a/src/portaudio-streams.adb b/src/portaudio-streams.adb
index ed837b9..070da8b 100644
--- a/src/portaudio-streams.adb
+++ b/src/portaudio-streams.adb
@@ -84,108 +84,108 @@ package body Portaudio.Streams is
------------------------
function pa_is_format_supported
- (Input : in System.Address;
- Output : in System.Address;
+ (Input : in Storage.Integer_Address;
+ Output : in Storage.Integer_Address;
Rate : in Interfaces.C.double)
return Interfaces.C.int;
pragma Import (C, pa_is_format_supported, "Pa_IsFormatSupported");
function pa_open_stream
- (Stream : in out System.Address;
- In_Params : in System.Address;
- Out_Params : in System.Address;
+ (Stream : in out Storage.Integer_Address;
+ In_Params : in Storage.Integer_Address;
+ Out_Params : in Storage.Integer_Address;
Rate : in Interfaces.C.double;
Frames : in Interfaces.C.unsigned_long;
Flags : in Interfaces.C.unsigned_long;
- Callback : in System.Address;
- Userdata : in System.Address)
+ Callback : in Storage.Integer_Address;
+ Userdata : in Storage.Integer_Address)
return Interfaces.C.int;
pragma Import (C, pa_open_stream, "Pa_OpenStream");
function pa_open_default_stream
- (Stream : in out System.Address;
+ (Stream : in out Storage.Integer_Address;
In_Chans : in Interfaces.C.int;
Out_Chans : in Interfaces.C.int;
Format : in Interfaces.C.unsigned_long;
Rate : in Interfaces.C.double;
Frames : in Interfaces.C.unsigned_long;
- Callback : in System.Address;
- Userdata : in System.Address)
+ Callback : in Storage.Integer_Address;
+ Userdata : in Storage.Integer_Address)
return Interfaces.C.int;
pragma Import (C, pa_open_default_stream, "Pa_OpenDefaultStream");
function pa_close_stream
- (Stream : in System.Address)
+ (Stream : in Storage.Integer_Address)
return Interfaces.C.int;
pragma Import (C, pa_close_stream, "Pa_CloseStream");
function pa_set_stream_finished_callback
- (Stream : in System.Address;
- Callback : in System.Address)
+ (Stream : in Storage.Integer_Address;
+ Callback : in Storage.Integer_Address)
return Interfaces.C.int;
pragma Import (C, pa_set_stream_finished_callback, "Pa_SetStreamFinishedCallback");
function pa_start_stream
- (Stream : in System.Address)
+ (Stream : in Storage.Integer_Address)
return Interfaces.C.int;
pragma Import (C, pa_start_stream, "Pa_StartStream");
function pa_stop_stream
- (Stream : in System.Address)
+ (Stream : in Storage.Integer_Address)
return Interfaces.C.int;
pragma Import (C, pa_stop_stream, "Pa_StopStream");
function pa_abort_stream
- (Stream : in System.Address)
+ (Stream : in Storage.Integer_Address)
return Interfaces.C.int;
pragma Import (C, pa_abort_stream, "Pa_AbortStream");
function pa_is_stream_stopped
- (Stream : in System.Address)
+ (Stream : in Storage.Integer_Address)
return Interfaces.C.int;
pragma Import (C, pa_is_stream_stopped, "Pa_IsStreamStopped");
function pa_is_stream_active
- (Stream : in System.Address)
+ (Stream : in Storage.Integer_Address)
return Interfaces.C.int;
pragma Import (C, pa_is_stream_active, "Pa_IsStreamActive");
function pa_get_stream_info
- (Stream : in System.Address)
- return System.Address;
+ (Stream : in Storage.Integer_Address)
+ return Storage.Integer_Address;
pragma Import (C, pa_get_stream_info, "Pa_GetStreamInfo");
function pa_get_stream_time
- (Stream : in System.Address)
+ (Stream : in Storage.Integer_Address)
return Interfaces.C.double;
pragma Import (C, pa_get_stream_time, "Pa_GetStreamTime");
function pa_get_stream_cpu_load
- (Stream : in System.Address)
+ (Stream : in Storage.Integer_Address)
return Interfaces.C.double;
pragma Import (C, pa_get_stream_cpu_load, "Pa_GetStreamCpuLoad");
function pa_read_stream
- (Stream : in System.Address;
- Buffer : in System.Address;
+ (Stream : in Storage.Integer_Address;
+ Buffer : in Storage.Integer_Address;
Frames : in Interfaces.C.unsigned_long)
return Interfaces.C.int;
pragma Import (C, pa_read_stream, "Pa_ReadStream");
function pa_write_stream
- (Stream : in System.Address;
- Buffer : in System.Address;
+ (Stream : in Storage.Integer_Address;
+ Buffer : in Storage.Integer_Address;
Frames : in Interfaces.C.unsigned_long)
return Interfaces.C.int;
pragma Import (C, pa_write_stream, "Pa_WriteStream");
function pa_get_stream_read_available
- (Stream : in System.Address)
+ (Stream : in Storage.Integer_Address)
return Interfaces.C.long;
pragma Import (C, pa_get_stream_read_available, "Pa_GetStreamReadAvailable");
function pa_get_stream_write_available
- (Stream : in System.Address)
+ (Stream : in Storage.Integer_Address)
return Interfaces.C.long;
pragma Import (C, pa_get_stream_write_available, "Pa_GetStreamWriteAvailable");
@@ -584,7 +584,7 @@ package body Portaudio.Streams is
My_Channels => Interfaces.C.int (Channels),
My_Samples => To_Cnum (Format),
My_Latency => Interfaces.C.double (Latency),
- My_Specific => System.Null_Address);
+ My_Specific => Null_Pointer);
end Create;
@@ -630,8 +630,8 @@ package body Portaudio.Streams is
Param_Conversions.To_Address (Param_Conversions.Object_Pointer (Output));
begin
Code := pa_is_format_supported
- (Input_Address,
- Output_Address,
+ (Storage.To_Integer (Input_Address),
+ Storage.To_Integer (Output_Address),
Interfaces.C.double (Rate));
return Code = pa_format_is_supported;
end Is_Format_Supported;
@@ -648,13 +648,13 @@ package body Portaudio.Streams is
begin
Code := pa_open_stream
(Stream.Ptr,
- Input_Params'Address,
- System.Null_Address,
+ Storage.To_Integer (Input_Params'Address),
+ Null_Pointer,
Interfaces.C.double (Sample_Rate),
Interfaces.C.unsigned_long (Buffer_Frames),
Interfaces.C.unsigned_long (Bunting),
- Stream_Callback_Hook'Address,
- Stream'Address);
+ Storage.To_Integer (Stream_Callback_Hook'Address),
+ Storage.To_Integer (Stream'Address));
if Code /= pa_no_error then
Raise_Error (Code);
raise Program_Error;
@@ -678,13 +678,13 @@ package body Portaudio.Streams is
begin
Code := pa_open_stream
(Stream.Ptr,
- System.Null_Address,
- Output_Params'Address,
+ Null_Pointer,
+ Storage.To_Integer (Output_Params'Address),
Interfaces.C.double (Sample_Rate),
Interfaces.C.unsigned_long (Buffer_Frames),
Interfaces.C.unsigned_long (Bunting),
- Stream_Callback_Hook'Address,
- Stream'Address);
+ Storage.To_Integer (Stream_Callback_Hook'Address),
+ Storage.To_Integer (Stream'Address));
if Code /= pa_no_error then
Raise_Error (Code);
raise Program_Error;
@@ -709,13 +709,13 @@ package body Portaudio.Streams is
begin
Code := pa_open_stream
(Stream.Ptr,
- Input_Params'Address,
- Output_Params'Address,
+ Storage.To_Integer (Input_Params'Address),
+ Storage.To_Integer (Output_Params'Address),
Interfaces.C.double (Sample_Rate),
Interfaces.C.unsigned_long (Buffer_Frames),
Interfaces.C.unsigned_long (Bunting),
- Stream_Callback_Hook'Address,
- Stream'Address);
+ Storage.To_Integer (Stream_Callback_Hook'Address),
+ Storage.To_Integer (Stream'Address));
if Code /= pa_no_error then
Raise_Error (Code);
raise Program_Error;
@@ -740,13 +740,13 @@ package body Portaudio.Streams is
begin
Code := pa_open_stream
(Stream.Ptr,
- Input_Params'Address,
- System.Null_Address,
+ Storage.To_Integer (Input_Params'Address),
+ Null_Pointer,
Interfaces.C.double (Sample_Rate),
Interfaces.C.unsigned_long (Buffer_Frames),
Interfaces.C.unsigned_long (Bunting),
- System.Null_Address,
- System.Null_Address);
+ Null_Pointer,
+ Null_Pointer);
if Code /= pa_no_error then
Raise_Error (Code);
raise Program_Error;
@@ -766,13 +766,13 @@ package body Portaudio.Streams is
begin
Code := pa_open_stream
(Stream.Ptr,
- System.Null_Address,
- Output_Params'Address,
+ Null_Pointer,
+ Storage.To_Integer (Output_Params'Address),
Interfaces.C.double (Sample_Rate),
Interfaces.C.unsigned_long (Buffer_Frames),
Interfaces.C.unsigned_long (Bunting),
- System.Null_Address,
- System.Null_Address);
+ Null_Pointer,
+ Null_Pointer);
if Code /= pa_no_error then
Raise_Error (Code);
raise Program_Error;
@@ -793,13 +793,13 @@ package body Portaudio.Streams is
begin
Code := pa_open_stream
(Stream.Ptr,
- Input_Params'Address,
- Output_Params'Address,
+ Storage.To_Integer (Input_Params'Address),
+ Storage.To_Integer (Output_Params'Address),
Interfaces.C.double (Sample_Rate),
Interfaces.C.unsigned_long (Buffer_Frames),
Interfaces.C.unsigned_long (Bunting),
- System.Null_Address,
- System.Null_Address);
+ Null_Pointer,
+ Null_Pointer);
if Code /= pa_no_error then
Raise_Error (Code);
raise Program_Error;
@@ -826,8 +826,8 @@ package body Portaudio.Streams is
To_Cnum (Format),
Interfaces.C.double (Sample_Rate),
Interfaces.C.unsigned_long (Buffer_Frames),
- Stream_Callback_Hook'Address,
- Stream'Address);
+ Storage.To_Integer (Stream_Callback_Hook'Address),
+ Storage.To_Integer (Stream'Address));
if Code /= pa_no_error then
Raise_Error (Code);
raise Program_Error;
@@ -858,8 +858,8 @@ package body Portaudio.Streams is
To_Cnum (Format),
Interfaces.C.double (Sample_Rate),
Interfaces.C.unsigned_long (Buffer_Frames),
- System.Null_Address,
- System.Null_Address);
+ Null_Pointer,
+ Null_Pointer);
if Code /= pa_no_error then
Raise_Error (Code);
raise Program_Error;
@@ -895,7 +895,7 @@ package body Portaudio.Streams is
Stream.Finfun := Callback;
Code := pa_set_stream_finished_callback
(Stream.Ptr,
- Stream_Finished_Callback_Hook'Address);
+ Storage.To_Integer (Stream_Finished_Callback_Hook'Address));
if Code /= pa_no_error then
Raise_Error (Code);
raise Program_Error;
@@ -909,7 +909,7 @@ package body Portaudio.Streams is
begin
Code := pa_set_stream_finished_callback
(Stream.Ptr,
- System.Null_Address);
+ Null_Pointer);
if Code /= pa_no_error then
Raise_Error (Code);
raise Program_Error;
@@ -990,15 +990,15 @@ package body Portaudio.Streams is
(Stream : in Audio_Stream)
return Stream_Info
is
- Result : System.Address;
+ Result : Storage.Integer_Address;
begin
Result := pa_get_stream_info (Stream.Ptr);
- if Result = System.Null_Address then
+ if Result = Null_Pointer then
raise General_Failure;
else
declare
C_Data : C_Stream_Info;
- for C_Data'Address use Result;
+ for C_Data'Address use Storage.To_Address (Result);
pragma Import (Ada, C_Data);
begin
return
@@ -1039,7 +1039,7 @@ package body Portaudio.Streams is
begin
Code := pa_read_stream
(Stream.Ptr,
- Store.My_Array,
+ Storage.To_Integer (Store.My_Array),
Interfaces.C.unsigned_long (Frames));
if Code /= pa_no_error then
Raise_Error (Code);
@@ -1056,7 +1056,7 @@ package body Portaudio.Streams is
begin
Code := pa_write_stream
(Stream.Ptr,
- Store.My_Array,
+ Storage.To_Integer (Store.My_Array),
Interfaces.C.unsigned_long (Frames));
if Code /= pa_no_error then
Raise_Error (Code);
diff --git a/src/portaudio-streams.ads b/src/portaudio-streams.ads
index 0f3d2ba..4a431b8 100644
--- a/src/portaudio-streams.ads
+++ b/src/portaudio-streams.ads
@@ -482,7 +482,7 @@ private
My_Channels : Interfaces.C.int;
My_Samples : Interfaces.C.unsigned_long;
My_Latency : Interfaces.C.double;
- My_Specific : System.Address;
+ My_Specific : Storage.Integer_Address;
end record with Convention => C;
@@ -506,7 +506,7 @@ private
type Audio_Stream is tagged limited record
- Ptr : System.Address;
+ Ptr : Storage.Integer_Address;
Open : Boolean := False;
Callfun : Callback_Function;
Finfun : Stream_Finished_Function;
diff --git a/src/portaudio.adb b/src/portaudio.adb
index 2ed90ea..1b23daa 100644
--- a/src/portaudio.adb
+++ b/src/portaudio.adb
@@ -10,8 +10,7 @@ pragma Ada_2012;
with
Ada.Strings.Fixed,
- Interfaces.C.Strings,
- System.Address_To_Access_Conversions;
+ Interfaces.C.Strings;
use type
@@ -176,7 +175,7 @@ package body Portaudio is
pragma Import (C, pa_get_version, "Pa_GetVersion");
function pa_get_version_info
- return System.Address;
+ return Storage.Integer_Address;
pragma Import (C, pa_get_version_info, "Pa_GetVersionInfo");
function pa_get_error_text
@@ -194,7 +193,7 @@ package body Portaudio is
pragma Import (C, pa_terminate, "apa_term");
function pa_get_last_host_error_info
- return System.Address;
+ return Storage.Integer_Address;
pragma Import (C, pa_get_last_host_error_info, "Pa_GetLastHostErrorInfo");
@@ -213,7 +212,7 @@ package body Portaudio is
elsif Num = pa_unanticipated_host_error then
declare
Info : C_Host_Error_Info;
- for Info'Address use pa_get_last_host_error_info;
+ for Info'Address use Storage.To_Address (pa_get_last_host_error_info);
pragma Import (Ada, Info);
begin
raise Unanticipated_Host_Error with
@@ -559,7 +558,7 @@ package body Portaudio is
function Get_Version_Info
return Version_Info is
begin
- return (Ptr => pa_get_version_info);
+ return (Ptr => Storage.To_Address (pa_get_version_info));
end Get_Version_Info;
diff --git a/src/portaudio.ads b/src/portaudio.ads
index 2744047..282f994 100644
--- a/src/portaudio.ads
+++ b/src/portaudio.ads
@@ -11,7 +11,7 @@ private with
Ada.Finalization,
Interfaces.C.Strings,
- System;
+ System.Storage_Elements;
package Portaudio is
@@ -190,9 +190,27 @@ package Portaudio is
private
+ package Storage renames System.Storage_Elements;
+ use type Interfaces.C.size_t, Storage.Integer_Address;
+
+
+ Null_Pointer : constant Storage.Integer_Address := Storage.To_Integer (System.Null_Address);
+
+
pragma Linker_Options ("-lportaudio");
+ function c_pointer_size
+ return Interfaces.C.size_t;
+ pragma Import (C, c_pointer_size, "c_pointer_size");
+
+ -- If this fails then we are on an architecture that for whatever reason
+ -- has significant problems interfacing between C and Ada
+ pragma Assert
+ (c_pointer_size * Interfaces.C.CHAR_BIT = Storage.Integer_Address'Size,
+ "Size of C void pointers and size of Ada address values do not match");
+
+
type C_Version_Info is record
My_Major : Interfaces.C.int;
My_Minor : Interfaces.C.int;