summaryrefslogtreecommitdiff
path: root/src/libao.ads
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2023-07-18 00:05:43 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2023-07-18 00:05:43 +1200
commitc36d37880986f734a69086b28ac6f0e9df7babab (patch)
tree2c495b569ba11863dc88a615d2faf93cf9c1f7f1 /src/libao.ads
parent74af58587359206ef92249d18e4830c40cac0bc5 (diff)
Removed need for initialize/shutdown, improved documentation slightly
Diffstat (limited to 'src/libao.ads')
-rw-r--r--src/libao.ads103
1 files changed, 33 insertions, 70 deletions
diff --git a/src/libao.ads b/src/libao.ads
index 1bdb142..9e1cde1 100644
--- a/src/libao.ads
+++ b/src/libao.ads
@@ -15,9 +15,9 @@ private with
package Libao is
- -----------------------
- -- Data Structures --
- -----------------------
+ ---------------------------------
+ -- Data Types and Structures --
+ ---------------------------------
type Driver_ID_Number is new Natural;
@@ -35,44 +35,36 @@ package Libao is
function Kind
(Attributes : in Info)
- return Output_Kind
- with Pre => Is_Alive;
+ return Output_Kind;
function Name
(Attributes : in Info)
- return String
- with Pre => Is_Alive;
+ return String;
function Short_Name
(Attributes : in Info)
- return String
- with Pre => Is_Alive;
+ return String;
function Preferred_Byte_Format
(Attributes : in Info)
- return Endianness
- with Pre => Is_Alive;
+ return Endianness;
function Priority_Level
(Attributes : in Info)
- return Positive
- with Pre => Is_Alive;
+ return Positive;
function Comment
(Attributes : in Info)
- return String
- with Pre => Is_Alive;
+ return String;
function Option_Count
(Attributes : in Info)
- return Natural
- with Pre => Is_Alive;
+ return Natural;
function Option_Key
(Attributes : in Info;
Index : in Positive)
- return String
- with Pre => Is_Alive;
+ return String;
type Option_List is tagged private;
@@ -139,24 +131,6 @@ package Libao is
- ------------------------------
- -- Library Setup/Teardown --
- ------------------------------
-
- function Is_Alive
- return Boolean;
-
- procedure Startup
- with Pre => not Is_Alive,
- Post => Is_Alive;
-
- procedure Shutdown
- with Pre => Is_Alive,
- Post => not Is_Alive;
-
-
-
-
--------------------------------------
-- Device Setup/Playback/Teardown --
--------------------------------------
@@ -164,20 +138,17 @@ package Libao is
procedure Append
(This : in out Option_List;
Key : in String;
- Value : in String)
- with Pre => Is_Alive;
+ Value : in String);
procedure Append_Global_Option
(Key : in String;
- Value : in String)
- with Pre => Is_Alive;
+ Value : in String);
function Open_Live
(Driver_ID : in Driver_ID_Number;
Format : in Sample_Format;
Options : in Option_List'Class)
- return Device
- with Pre => Is_Alive;
+ return Device;
function Open_File
(Driver_ID : in Driver_ID_Number;
@@ -185,17 +156,14 @@ package Libao is
Format : in Sample_Format;
Options : in Option_List'Class;
Overwrite : in Boolean := False)
- return Device
- with Pre => Is_Alive;
+ return Device;
procedure Play
(Output_Device : in Device;
- Samples : in Data_Buffer)
- with Pre => Is_Alive;
+ Samples : in Data_Buffer);
procedure Close
- (Output_Device : in out Device)
- with Pre => Is_Alive;
+ (Output_Device : in out Device);
@@ -206,26 +174,21 @@ package Libao is
function Driver_ID
(Short_Name : in String)
- return Driver_ID_Number
- with Pre => Is_Alive;
+ return Driver_ID_Number;
function Default_Driver_ID
- return Driver_ID_Number
- with Pre => Is_Alive;
+ return Driver_ID_Number;
function Driver_Info
(Ident : in Driver_ID_Number)
- return Info
- with Pre => Is_Alive;
+ return Info;
function Driver_Info_List
- return Info_Array
- with Pre => Is_Alive;
+ return Info_Array;
function File_Extension
(Ident : in Driver_ID_Number)
- return String
- with Pre => Is_Alive;
+ return String;
@@ -235,17 +198,13 @@ package Libao is
---------------------
function Is_Big_Endian
- return Boolean
- with Pre => Is_Alive;
+ return Boolean;
private
pragma Linker_Options ("-lao");
- pragma Inline (Is_Alive);
-
-
procedure Do_Append
@@ -257,8 +216,6 @@ private
(Ptr : in System.Address);
-
-
type Device is record
Ptr : System.Address;
end record;
@@ -302,10 +259,7 @@ private
(This : in out Sample_Format);
-
-
- Alive_Status : Boolean := False;
-
+ -- Keep track of
package Address_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive,
Element_Type => System.Address,
@@ -314,6 +268,15 @@ private
Device_List : Address_Vectors.Vector := Address_Vectors.Empty_Vector;
+ -- The clunky way of ensuring that libao is always shut down properly
+ type Final_Controller is new Ada.Finalization.Controlled with null record;
+
+ overriding procedure Finalize
+ (This : in out Final_Controller);
+
+ Cleanup : Final_Controller;
+
+
end Libao;