with Events; use Events;
with Events.Corrals; use Events.Corrals;
with Events.Listeners; use Events.Listeners;
with Objects; use Objects;
with Processes; use Processes;
private with Ada.Real_Time;
private with Ada.Strings.Unbounded;
package Audio_Players is
type Audio_Player is new Limited_Object and Process and Event_Listener with private;
type A_Audio_Player is access all Audio_Player'Class;
function Create_Audio_Player( corral : not null A_Corral ) return A_Audio_Player;
pragma Postcondition( Create_Audio_Player'Result /= null );
procedure Start( this : not null access Audio_Player'Class );
procedure Stop( this : not null access Audio_Player'Class );
procedure Delete( this : in out A_Audio_Player );
pragma Postcondition( this = null );
private
use Ada.Real_Time;
use Ada.Strings.Unbounded;
type Sound_Registry;
type A_Sound_Registry is access all Sound_Registry;
procedure Delete( registry : in out A_Sound_Registry );
pragma Postcondition( registry = null );
type Polling_Task;
type A_Polling_Task is access all Polling_Task;
procedure Delete( pollTask : in out A_Polling_Task );
pragma Postcondition( pollTask = null );
type Audio_Player is new Limited_Object and Process and Event_Listener with
record
started : Boolean := False;
stopped : Boolean := False;
corral : A_Corral := null;
tickDelta : Time_Span := Time_Span_Zero;
registry : A_Sound_Registry := null;
process : A_Polling_Task := null;
music : Unbounded_String;
end record;
procedure Construct( this : access Audio_Player; corral : not null A_Corral );
procedure Delete( this : in out Audio_Player );
function Get_Process_Name( this : access Audio_Player ) return String;
pragma Postcondition( Get_Process_Name'Result'Length > 0 );
procedure Handle_Event( this : access Audio_Player;
evt : in out A_Event;
resp : out Response_Type );
pragma Precondition( evt /= null );
procedure Play_Music( this : not null access Audio_Player'Class; name : String );
pragma Precondition( name'Length > 0 );
procedure Play_Sound( this : not null access Audio_Player'Class; name : String );
pragma Precondition( name'Length > 0 );
procedure Stop_Music( this : not null access Audio_Player'Class );
procedure Tick( this : access Audio_Player; upTime, dt : Time_Span );
end Audio_Players;