From baac81253b3cc2e3addbbe6e90ec2a7abb5d56fd Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Tue, 18 Jul 2023 01:47:26 +1200 Subject: Code cleanup, slight API improvement --- src/libao.ads | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'src/libao.ads') diff --git a/src/libao.ads b/src/libao.ads index 9e1cde1..33ec49c 100644 --- a/src/libao.ads +++ b/src/libao.ads @@ -4,6 +4,10 @@ -- Released into the public domain +with + + Interfaces; + private with Ada.Finalization, @@ -25,7 +29,7 @@ package Libao is type Data_Buffer is new String; - type Device is private; + type Device is tagged private; type Info is tagged private; @@ -72,7 +76,7 @@ package Libao is Empty_Options : constant Option_List; - type Sample_Format is private; + type Sample_Format is tagged private; type Channel_Mnemonic is (L, R, C, M, CL, CR, BL, BR, BC, SL, SR, LFE, A1, A2, A3, A4, X); type Mnemonic_Array is array (Positive range <>) of Channel_Mnemonic; @@ -144,26 +148,26 @@ package Libao is (Key : in String; Value : in String); - function Open_Live - (Driver_ID : in Driver_ID_Number; - Format : in Sample_Format; - Options : in Option_List'Class) - return Device; + procedure Open_Live + (Output : in out Device; + Driver_ID : in Driver_ID_Number; + Format : in Sample_Format'Class; + Options : in Option_List'Class); - function Open_File - (Driver_ID : in Driver_ID_Number; - Filename : in String; - Format : in Sample_Format; - Options : in Option_List'Class; - Overwrite : in Boolean := False) - return Device; + procedure Open_File + (Output : in out Device; + Driver_ID : in Driver_ID_Number; + Filename : in String; + Format : in Sample_Format'Class; + Options : in Option_List'Class; + Overwrite : in Boolean := False); procedure Play - (Output_Device : in Device; - Samples : in Data_Buffer); + (Output : in Device; + Samples : in Data_Buffer); procedure Close - (Output_Device : in out Device); + (Output : in out Device); @@ -216,13 +220,13 @@ private (Ptr : in System.Address); - type Device is record - Ptr : System.Address; + type Device is tagged record + Ptr : System.Address := System.Null_Address; end record; type Info is tagged record - Ptr : System.Address; + Ptr : System.Address := System.Null_Address; end record; @@ -259,7 +263,7 @@ private (This : in out Sample_Format); - -- Keep track of + -- Keep track of open devices package Address_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => System.Address, -- cgit