2 Copyright © 2015, The AROS Development Team. All rights reserved.
7 #include "alsa_hostlib.h"
11 return ALSA_HostLib_Init();
16 ALSA_HostLib_Cleanup();
21 snd_pcm_t
* handle
= NULL
;
24 if (ALSACALL(snd_pcm_open
, &handle
, "default",
25 SND_PCM_STREAM_PLAYBACK
, 0) < 0)
31 VOID
ALSA_Close(APTR handle
)
35 ALSACALL(snd_pcm_close
, handle
);
39 BOOL
ALSA_SetHWParams(APTR handle
, ULONG
* rate
)
41 snd_pcm_hw_params_t
*hw_params
;
42 LONG dir
= 0; int r
= 0;
44 ALSACALL(snd_pcm_hw_params_malloc
, &hw_params
);
45 ALSACALL(snd_pcm_hw_params_any
, handle
, hw_params
);
46 ALSACALL(snd_pcm_hw_params_set_access
, handle
, hw_params
,
47 SND_PCM_ACCESS_RW_INTERLEAVED
);
48 ALSACALL(snd_pcm_hw_params_set_format
, handle
, hw_params
,
49 SND_PCM_FORMAT_S16_LE
);
50 ALSACALL(snd_pcm_hw_params_set_channels
, handle
, hw_params
, 2);
51 r
= ALSACALL(snd_pcm_hw_params_set_rate_near
, handle
, hw_params
, rate
, &dir
);
52 ALSACALL(snd_pcm_hw_params_set_buffer_size
, handle
, hw_params
, 4096);
54 ALSACALL(snd_pcm_hw_params
, handle
, hw_params
);
55 ALSACALL(snd_pcm_hw_params_free
, hw_params
);
60 LONG
ALSA_Write(APTR handle
, APTR buffer
, ULONG size
)
62 LONG rc
= ALSACALL(snd_pcm_writei
, handle
, buffer
, (snd_pcm_uframes_t
)size
);
70 VOID
ALSA_Prepare(APTR handle
)
72 ALSACALL(snd_pcm_prepare
, handle
);
75 LONG
ALSA_Avail(APTR handle
)
77 LONG rc
= ALSACALL(snd_pcm_avail_update
, handle
);