summaryrefslogtreecommitdiff
path: root/src/portaudio-streams.ads
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2023-10-12 17:39:45 +1300
committerJedidiah Barber <contact@jedbarber.id.au>2023-10-12 17:39:45 +1300
commit87b89d768d367a475bb553de295ac867909c28c9 (patch)
tree4369e966ed4668a2fe7a1cbc65faed7206bd8106 /src/portaudio-streams.ads
parented02634895209b9a937297838c1ae04f072f9c79 (diff)
Added callbacks for streams finishing
Diffstat (limited to 'src/portaudio-streams.ads')
-rw-r--r--src/portaudio-streams.ads78
1 files changed, 45 insertions, 33 deletions
diff --git a/src/portaudio-streams.ads b/src/portaudio-streams.ads
index c8d3e92..0f3d2ba 100644
--- a/src/portaudio-streams.ads
+++ b/src/portaudio-streams.ads
@@ -272,6 +272,8 @@ package Portaudio.Streams is
Bunting : in Callback_Flags)
return Callback_Result;
+ type Stream_Finished_Function is access procedure;
+
@@ -297,33 +299,33 @@ package Portaudio.Streams is
return Boolean;
procedure Open_Input
- (Stream : in out Audio_Stream;
- Input_Params : in Parameters;
- Sample_Rate : in Hertz;
- Buffer_Frames : in Frame_Amount;
- Bunting : in Stream_Flags;
- Callback : in Callback_Function)
+ (Stream : in out Audio_Stream;
+ Input_Params : in Parameters;
+ Sample_Rate : in Hertz;
+ Buffer_Frames : in Frame_Amount;
+ Bunting : in Stream_Flags;
+ Callback : in not null Callback_Function)
with Pre => not Stream.Is_Open,
Post => Stream.Is_Open;
procedure Open_Output
- (Stream : in out Audio_Stream;
- Output_Params : in Parameters;
- Sample_Rate : in Hertz;
- Buffer_Frames : in Frame_Amount;
- Bunting : in Stream_Flags;
- Callback : in Callback_Function)
+ (Stream : in out Audio_Stream;
+ Output_Params : in Parameters;
+ Sample_Rate : in Hertz;
+ Buffer_Frames : in Frame_Amount;
+ Bunting : in Stream_Flags;
+ Callback : in not null Callback_Function)
with Pre => not Stream.Is_Open,
Post => Stream.Is_Open;
procedure Open_Full
- (Stream : in out Audio_Stream;
- Input_Params : in Parameters;
- Output_Params : in Parameters;
- Sample_Rate : in Hertz;
- Buffer_Frames : in Frame_Amount;
- Bunting : in Stream_Flags;
- Callback : in Callback_Function)
+ (Stream : in out Audio_Stream;
+ Input_Params : in Parameters;
+ Output_Params : in Parameters;
+ Sample_Rate : in Hertz;
+ Buffer_Frames : in Frame_Amount;
+ Bunting : in Stream_Flags;
+ Callback : in not null Callback_Function)
with Pre => not Stream.Is_Open,
Post => Stream.Is_Open;
@@ -356,13 +358,13 @@ package Portaudio.Streams is
Post => Stream.Is_Open;
procedure Open_Default
- (Stream : in out Audio_Stream;
- Input_Channels : in Natural;
- Output_Channels : in Natural;
- Format : in Sample_Format;
- Sample_Rate : in Hertz;
- Buffer_Frames : in Frame_Amount;
- Callback : in Callback_Function)
+ (Stream : in out Audio_Stream;
+ Input_Channels : in Natural;
+ Output_Channels : in Natural;
+ Format : in Sample_Format;
+ Sample_Rate : in Hertz;
+ Buffer_Frames : in Frame_Amount;
+ Callback : in not null Callback_Function)
with Pre => not Stream.Is_Open and
(Input_Channels > 0 or Output_Channels > 0),
Post => Stream.Is_Open;
@@ -383,6 +385,15 @@ package Portaudio.Streams is
with Pre => Stream.Is_Open,
Post => not Stream.Is_Open;
+ procedure Set_Finished_Callback
+ (Stream : in out Audio_Stream;
+ Callback : in not null Stream_Finished_Function)
+ with Pre => Stream.Is_Open and then Stream.Is_Stopped;
+
+ procedure Clear_Finished_Callback
+ (Stream : in out Audio_Stream)
+ with Pre => Stream.Is_Open and then Stream.Is_Stopped;
+
procedure Start
(Stream : in Audio_Stream)
with Pre => Stream.Is_Open;
@@ -495,13 +506,14 @@ private
type Audio_Stream is tagged limited record
- Ptr : System.Address;
- Open : Boolean := False;
- Func : Callback_Function;
- Chin : Interfaces.C.int := 0;
- Chout : Interfaces.C.int := 0;
- Sin : Interfaces.C.unsigned_long := 0;
- Sout : Interfaces.C.unsigned_long := 0;
+ Ptr : System.Address;
+ Open : Boolean := False;
+ Callfun : Callback_Function;
+ Finfun : Stream_Finished_Function;
+ Chin : Interfaces.C.int := 0;
+ Chout : Interfaces.C.int := 0;
+ Sin : Interfaces.C.unsigned_long := 0;
+ Sout : Interfaces.C.unsigned_long := 0;
end record;