summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--example/aao_example.adb9
-rw-r--r--src/libao.adb5
-rw-r--r--src/libao.ads5
3 files changed, 12 insertions, 7 deletions
diff --git a/example/aao_example.adb b/example/aao_example.adb
index 6851f54..51466f8 100644
--- a/example/aao_example.adb
+++ b/example/aao_example.adb
@@ -11,6 +11,7 @@ with
Ada.Command_Line,
Ada.Numerics.Elementary_Functions,
Ada.Text_IO,
+ Interfaces,
Libao;
@@ -74,10 +75,10 @@ begin
Math.Sin (2.0 * Ada.Numerics.Pi * 440.0 * Float (I) / 44100.0)) mod 65536);
-- Put the same stuff in left and right channel
- Buffer (4 * I + 1) := Character'Val (Sample and 16#FF#);
- Buffer (4 * I + 2) := Character'Val ((Sample / 256) and 16#FF#);
- Buffer (4 * I + 3) := Character'Val (Sample and 16#FF#);
- Buffer (4 * I + 4) := Character'Val ((Sample / 256) and 16#FF#);
+ Buffer (4 * I + 1) := Interfaces.Unsigned_8 (Sample and 16#FF#);
+ Buffer (4 * I + 2) := Interfaces.Unsigned_8 ((Sample / 256) and 16#FF#);
+ Buffer (4 * I + 3) := Interfaces.Unsigned_8 (Sample and 16#FF#);
+ Buffer (4 * I + 4) := Interfaces.Unsigned_8 ((Sample / 256) and 16#FF#);
end loop;
My_Device.Play (Buffer);
diff --git a/src/libao.adb b/src/libao.adb
index 0875ba4..48a0ac1 100644
--- a/src/libao.adb
+++ b/src/libao.adb
@@ -119,7 +119,7 @@ package body Libao is
function ao_play
(Output_Device : in System.Address;
- Samples : in Interfaces.C.char_array;
+ Samples : in System.Address;
Num_Bytes : in Interfaces.Unsigned_32)
return Interfaces.C.int;
pragma Import (C, ao_play, "ao_play");
@@ -588,7 +588,8 @@ package body Libao is
is
Result : Interfaces.C.int := ao_play
(Output_Device => Output.Ptr,
- Samples => Interfaces.C.To_C (Item => String (Samples), Append_Nul => False),
+ Samples => Samples'Address,
+ --Samples => Interfaces.C.To_C (Item => String (Samples), Append_Nul => False),
Num_Bytes => Interfaces.Unsigned_32 (Samples'Length));
begin
if Result = 0 then
diff --git a/src/libao.ads b/src/libao.ads
index baea557..db5f7ce 100644
--- a/src/libao.ads
+++ b/src/libao.ads
@@ -29,7 +29,7 @@ package Libao is
type Driver_ID_Number is new Natural;
- type Data_Buffer is new String;
+ type Data_Buffer is array (Positive range <>) of Interfaces.Unsigned_8;
type Device is tagged private;
@@ -214,6 +214,9 @@ private
pragma Linker_Options ("-lao");
+ for Data_Buffer'Component_Size use Interfaces.C.CHAR_BIT;
+
+
procedure Do_Append
(Ptr : in out System.Address;
Key : in Interfaces.C.char_array;