aboutsummaryrefslogtreecommitdiff
path: root/src/libsndfile.ads
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsndfile.ads')
-rw-r--r--src/libsndfile.ads58
1 files changed, 38 insertions, 20 deletions
diff --git a/src/libsndfile.ads b/src/libsndfile.ads
index d88c06d..f996f9d 100644
--- a/src/libsndfile.ads
+++ b/src/libsndfile.ads
@@ -14,7 +14,7 @@ with
private with
Interfaces.C,
- System;
+ System.Storage_Elements;
package Libsndfile is
@@ -51,7 +51,7 @@ package Libsndfile is
Track_Number_String,
Genre_String);
- type File_Info is private;
+ type File_Info is tagged private;
type Major_Format is
(Format_Unknown,
@@ -222,7 +222,7 @@ package Libsndfile is
(File : in out Sound_File;
Name : in String;
Mode : in File_Mode;
- Info : in out File_Info)
+ Info : in out File_Info'Class)
with Pre => not Is_Open (File),
Post => Is_Open (File);
@@ -343,8 +343,34 @@ package Libsndfile 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 ("-lsndfile");
+
+ 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");
+
+ -- More things that shouldn't fail unless something really weird happens
+ pragma Assert (Short_Integer'Size = Interfaces.C.short'Size);
+ pragma Assert (Integer'Size = Interfaces.C.int'Size);
+ pragma Assert (Float'Size = Interfaces.C.C_float'Size);
+ pragma Assert (Long_Float'Size = Interfaces.C.double'Size);
+ pragma Assert (Character'Size = Interfaces.C.CHAR_BIT);
+
+
pragma Inline (Is_Open);
pragma Inline (Write_Sync);
pragma Inline (Read_Raw);
@@ -352,12 +378,10 @@ private
pragma Inline (Version_String);
-
-
type Sound_File is tagged limited record
- Ptr : System.Address := System.Null_Address;
- FMode : File_Mode := Read_Only;
- Chans : Interfaces.C.int := 0;
+ Ptr : Storage.Integer_Address := Null_Pointer;
+ FMode : File_Mode := Read_Only;
+ Chans : Interfaces.C.int := 0;
end record;
@@ -368,7 +392,7 @@ private
-- This cannot correspond to the C-side SF_INFO since sf_count_t can vary
- type File_Info is record
+ type C_File_Info is record
My_Frames : Interfaces.Integer_64;
My_Sample_Rate : Interfaces.C.int;
My_Channels : Interfaces.C.int;
@@ -379,10 +403,12 @@ private
My_Seekable : Interfaces.C.int;
end record with Convention => C;
-
- Blank_Info : constant File_Info := (My_Frames => 0, others => 0);
+ type File_Info is tagged record
+ Data : C_File_Info;
+ end record;
+ Blank_Info : constant File_Info := (Data => (My_Frames => 0, others => 0));
procedure Raise_Error
@@ -413,8 +439,6 @@ private
return Interfaces.C.int;
-
-
sf_false : constant Interfaces.C.int;
pragma Import (C, sf_false, "sf_false");
@@ -422,8 +446,6 @@ private
pragma Import (C, sf_true, "sf_true");
-
-
sfm_read : constant Interfaces.C.int;
pragma Import (C, sfm_read, "sfm_read");
@@ -434,8 +456,6 @@ private
pragma Import (C, sfm_rdwr, "sfm_rdwr");
-
-
sf_seek_set : constant Interfaces.C.int;
pragma Import (C, sf_seek_set, "sf_seek_set");
@@ -446,10 +466,8 @@ private
pragma Import (C, sf_seek_end, "sf_seek_end");
-
-
function sf_error
- (File : in System.Address)
+ (File : in Storage.Integer_Address)
return Interfaces.C.int;
pragma Import (C, sf_error, "sf_error");