2013-06-21 16:56:39 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2017-12-12 07:55:31 +00:00
|
|
|
*
|
2013-06-21 16:56:39 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define ALSA_PCM_NEW_HW_PARAMS_API
|
|
|
|
#define ALSA_PCM_NEW_SW_PARAMS_API
|
|
|
|
#include <sys/asoundlib.h>
|
2017-06-28 02:41:38 +00:00
|
|
|
#include <retro_math.h>
|
2013-06-21 16:56:39 +00:00
|
|
|
|
2021-10-11 16:01:37 +00:00
|
|
|
#include "../audio_driver.h"
|
2015-09-14 01:44:06 +00:00
|
|
|
|
2014-05-24 01:48:12 +00:00
|
|
|
#define MAX_FRAG_SIZE 3072
|
|
|
|
#define DEFAULT_RATE 48000
|
|
|
|
|
2014-05-24 02:46:26 +00:00
|
|
|
#define CHANNELS 2
|
|
|
|
|
2013-06-21 16:56:39 +00:00
|
|
|
typedef struct alsa
|
|
|
|
{
|
2014-05-25 18:49:22 +00:00
|
|
|
uint8_t **buffer;
|
2020-08-26 13:24:33 +00:00
|
|
|
snd_pcm_t *pcm;
|
2014-05-25 18:49:22 +00:00
|
|
|
uint8_t *buffer_chunk;
|
|
|
|
unsigned buffer_index;
|
|
|
|
unsigned buffer_ptr;
|
|
|
|
volatile unsigned buffered_blocks;
|
|
|
|
|
2020-08-26 13:24:33 +00:00
|
|
|
unsigned buf_size;
|
|
|
|
unsigned buf_count;
|
2013-06-21 16:56:39 +00:00
|
|
|
bool nonblock;
|
|
|
|
bool has_float;
|
|
|
|
bool can_pause;
|
|
|
|
bool is_paused;
|
2019-05-20 16:44:24 +00:00
|
|
|
} alsa_qsa_t;
|
2013-06-21 16:56:39 +00:00
|
|
|
|
2014-05-24 02:46:26 +00:00
|
|
|
typedef long snd_pcm_sframes_t;
|
|
|
|
|
2014-09-09 20:24:29 +00:00
|
|
|
static void *alsa_qsa_init(const char *device,
|
2017-01-11 06:25:42 +00:00
|
|
|
unsigned rate, unsigned latency, unsigned block_frames,
|
|
|
|
unsigned *new_rate)
|
2013-06-21 16:56:39 +00:00
|
|
|
{
|
2014-05-25 18:49:22 +00:00
|
|
|
int err, card, dev, i;
|
|
|
|
snd_pcm_channel_info_t pi;
|
2016-09-08 09:41:58 +00:00
|
|
|
snd_pcm_channel_params_t params = {0};
|
|
|
|
snd_pcm_channel_setup_t setup = {0};
|
2019-05-20 16:44:24 +00:00
|
|
|
alsa_qsa_t *alsa = (alsa_qsa_t*)calloc(1, sizeof(alsa_qsa_t));
|
2015-03-20 20:31:16 +00:00
|
|
|
if (!alsa)
|
|
|
|
return NULL;
|
2014-05-25 18:49:22 +00:00
|
|
|
|
2013-06-21 16:56:39 +00:00
|
|
|
(void)device;
|
|
|
|
(void)rate;
|
|
|
|
(void)latency;
|
|
|
|
|
|
|
|
if ((err = snd_pcm_open_preferred(&alsa->pcm, &card, &dev,
|
|
|
|
SND_PCM_OPEN_PLAYBACK)) < 0)
|
|
|
|
{
|
2014-09-09 20:24:29 +00:00
|
|
|
RARCH_ERR("[ALSA QSA]: Audio open error: %s\n",
|
|
|
|
snd_strerror(err));
|
2013-06-21 16:56:39 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if((err = snd_pcm_nonblock_mode(alsa->pcm, 1)) < 0)
|
|
|
|
{
|
2014-09-09 20:24:29 +00:00
|
|
|
RARCH_ERR("[ALSA QSA]: Can't set blocking mode: %s\n",
|
|
|
|
snd_strerror(err));
|
2013-06-21 16:56:39 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2014-05-24 04:12:44 +00:00
|
|
|
memset(&pi, 0, sizeof(pi));
|
|
|
|
pi.channel = SND_PCM_CHANNEL_PLAYBACK;
|
2014-05-25 17:02:04 +00:00
|
|
|
if ((err = snd_pcm_channel_info(alsa->pcm, &pi)) < 0)
|
2014-05-24 04:12:44 +00:00
|
|
|
{
|
2014-05-25 17:02:04 +00:00
|
|
|
RARCH_ERR("[ALSA QSA]: snd_pcm_channel_info failed: %s\n",
|
2014-05-24 04:12:44 +00:00
|
|
|
snd_strerror(err));
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2013-06-21 18:01:27 +00:00
|
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
|
2014-05-21 14:29:03 +00:00
|
|
|
params.channel = SND_PCM_CHANNEL_PLAYBACK;
|
2014-05-24 01:48:12 +00:00
|
|
|
params.mode = SND_PCM_MODE_BLOCK;
|
2013-06-21 16:56:39 +00:00
|
|
|
|
|
|
|
params.format.interleave = 1;
|
2014-05-24 01:48:12 +00:00
|
|
|
params.format.format = SND_PCM_SFMT_S16_LE;
|
2014-05-21 14:29:03 +00:00
|
|
|
params.format.rate = DEFAULT_RATE;
|
2013-06-21 16:56:39 +00:00
|
|
|
params.format.voices = 2;
|
|
|
|
|
2014-05-24 03:15:05 +00:00
|
|
|
params.start_mode = SND_PCM_START_FULL;
|
2014-05-24 01:48:12 +00:00
|
|
|
params.stop_mode = SND_PCM_STOP_STOP;
|
2013-07-06 20:45:10 +00:00
|
|
|
|
2014-05-24 04:12:44 +00:00
|
|
|
params.buf.block.frag_size = pi.max_fragment_size;
|
2014-05-25 15:46:31 +00:00
|
|
|
params.buf.block.frags_min = 2;
|
2014-05-24 04:12:44 +00:00
|
|
|
params.buf.block.frags_max = 8;
|
|
|
|
|
|
|
|
RARCH_LOG("Fragment size: %d\n", params.buf.block.frag_size);
|
|
|
|
RARCH_LOG("Min Fragment size: %d\n", params.buf.block.frags_min);
|
|
|
|
RARCH_LOG("Max Fragment size: %d\n", params.buf.block.frags_max);
|
|
|
|
|
2014-05-25 17:02:04 +00:00
|
|
|
if ((err = snd_pcm_channel_params(alsa->pcm, ¶ms)) < 0)
|
2013-06-21 16:56:39 +00:00
|
|
|
{
|
2014-09-09 20:24:29 +00:00
|
|
|
RARCH_ERR("[ALSA QSA]: Channel Parameter Error: %s\n",
|
|
|
|
snd_strerror(err));
|
2013-06-21 16:56:39 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
setup.channel = SND_PCM_CHANNEL_PLAYBACK;
|
|
|
|
|
2014-05-25 17:02:04 +00:00
|
|
|
if ((err = snd_pcm_channel_setup(alsa->pcm, &setup)) < 0)
|
2013-06-21 16:56:39 +00:00
|
|
|
{
|
2014-09-09 20:24:29 +00:00
|
|
|
RARCH_ERR("[ALSA QSA]: Channel Parameter Read Back Error: %s\n",
|
|
|
|
snd_strerror(err));
|
2013-06-21 16:56:39 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2017-01-11 06:25:42 +00:00
|
|
|
if (block_frames)
|
|
|
|
alsa->buf_size = block_frames * 4;
|
2014-05-25 18:49:22 +00:00
|
|
|
else
|
|
|
|
alsa->buf_size = next_pow2(32 * latency);
|
|
|
|
|
2014-09-05 23:43:28 +00:00
|
|
|
RARCH_LOG("[ALSA QSA]: buffer size: %u bytes\n", alsa->buf_size);
|
2014-05-25 18:49:22 +00:00
|
|
|
|
|
|
|
alsa->buf_count = (latency * 4 * rate + 500) / 1000;
|
|
|
|
alsa->buf_count = (alsa->buf_count + alsa->buf_size / 2) / alsa->buf_size;
|
2013-06-21 16:56:39 +00:00
|
|
|
|
2014-09-09 20:24:29 +00:00
|
|
|
if ((err = snd_pcm_channel_prepare(alsa->pcm,
|
|
|
|
SND_PCM_CHANNEL_PLAYBACK)) < 0)
|
2013-06-21 16:56:39 +00:00
|
|
|
{
|
2014-09-09 20:24:29 +00:00
|
|
|
RARCH_ERR("[ALSA QSA]: Channel Prepare Error: %s\n",
|
|
|
|
snd_strerror(err));
|
2013-06-21 16:56:39 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2014-05-25 18:49:22 +00:00
|
|
|
alsa->buffer = (uint8_t**)calloc(sizeof(uint8_t*), alsa->buf_count);
|
|
|
|
if (!alsa->buffer)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
alsa->buffer_chunk = (uint8_t*)calloc(alsa->buf_count, alsa->buf_size);
|
|
|
|
if (!alsa->buffer_chunk)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
for (i = 0; i < alsa->buf_count; i++)
|
|
|
|
alsa->buffer[i] = alsa->buffer_chunk + i * alsa->buf_size;
|
|
|
|
|
2013-06-21 16:56:39 +00:00
|
|
|
alsa->has_float = false;
|
2013-06-21 19:36:19 +00:00
|
|
|
alsa->can_pause = true;
|
2014-09-09 20:24:29 +00:00
|
|
|
RARCH_LOG("[ALSA QSA]: Can pause: %s.\n",
|
|
|
|
alsa->can_pause ? "yes" : "no");
|
2013-06-21 16:56:39 +00:00
|
|
|
|
|
|
|
return alsa;
|
|
|
|
|
|
|
|
error:
|
|
|
|
return (void*)-1;
|
|
|
|
}
|
|
|
|
|
2014-05-25 15:20:45 +00:00
|
|
|
static int check_pcm_status(void *data, int channel_type)
|
|
|
|
{
|
|
|
|
snd_pcm_channel_status_t status;
|
2019-05-20 16:44:24 +00:00
|
|
|
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
|
|
|
|
int ret = EOK;
|
2014-05-25 15:20:45 +00:00
|
|
|
|
|
|
|
memset(&status, 0, sizeof (status));
|
|
|
|
status.channel = channel_type;
|
|
|
|
|
2014-05-25 17:02:04 +00:00
|
|
|
if ((ret = snd_pcm_channel_status(alsa->pcm, &status)) == 0)
|
2014-05-25 15:20:45 +00:00
|
|
|
{
|
|
|
|
if (status.status == SND_PCM_STATUS_UNSECURE)
|
|
|
|
{
|
|
|
|
RARCH_ERR("check_pcm_status got SND_PCM_STATUS_UNSECURE, aborting playback\n");
|
|
|
|
ret = -EPROTO;
|
|
|
|
}
|
|
|
|
else if (status.status == SND_PCM_STATUS_UNDERRUN)
|
|
|
|
{
|
2014-05-25 15:52:41 +00:00
|
|
|
RARCH_LOG("check_pcm_status: SNDP_CM_STATUS_UNDERRUN.\n");
|
2014-05-25 17:02:04 +00:00
|
|
|
if ((ret = snd_pcm_channel_prepare(alsa->pcm, channel_type)) < 0)
|
2014-05-25 15:20:45 +00:00
|
|
|
{
|
2014-09-09 20:24:29 +00:00
|
|
|
RARCH_ERR("Invalid state detected for underrun on snd_pcm_channel_prepare: %s\n",
|
|
|
|
snd_strerror(ret));
|
2014-05-25 15:20:45 +00:00
|
|
|
ret = -EPROTO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (status.status == SND_PCM_STATUS_OVERRUN)
|
|
|
|
{
|
2014-05-25 15:52:41 +00:00
|
|
|
RARCH_LOG("check_pcm_status: SNDP_CM_STATUS_OVERRUN.\n");
|
2014-05-25 17:02:04 +00:00
|
|
|
if ((ret = snd_pcm_channel_prepare(alsa->pcm, channel_type)) < 0)
|
2014-05-25 15:20:45 +00:00
|
|
|
{
|
2014-09-09 20:24:29 +00:00
|
|
|
RARCH_ERR("Invalid state detected for overrun on snd_pcm_channel_prepare: %s\n",
|
|
|
|
snd_strerror(ret));
|
2014-05-25 15:20:45 +00:00
|
|
|
ret = -EPROTO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (status.status == SND_PCM_STATUS_CHANGE)
|
|
|
|
{
|
2014-05-25 15:52:41 +00:00
|
|
|
RARCH_LOG("check_pcm_status: SNDP_CM_STATUS_CHANGE.\n");
|
2014-05-25 17:02:04 +00:00
|
|
|
if ((ret = snd_pcm_channel_prepare(alsa->pcm, channel_type)) < 0)
|
2014-05-25 15:20:45 +00:00
|
|
|
{
|
2014-09-09 20:24:29 +00:00
|
|
|
RARCH_ERR("Invalid state detected for change on snd_pcm_channel_prepare: %s\n",
|
|
|
|
snd_strerror(ret));
|
2014-05-25 15:20:45 +00:00
|
|
|
ret = -EPROTO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RARCH_ERR("check_pcm_status failed: %s\n", snd_strerror(ret));
|
|
|
|
if (ret == -ESRCH)
|
|
|
|
ret = -EBADF;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-04-20 08:15:11 +00:00
|
|
|
static ssize_t alsa_qsa_write(void *data, const void *buf, size_t size)
|
2013-06-21 16:56:39 +00:00
|
|
|
{
|
2019-05-20 16:44:24 +00:00
|
|
|
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
|
2014-05-24 02:46:26 +00:00
|
|
|
snd_pcm_sframes_t written = 0;
|
2013-06-21 18:23:25 +00:00
|
|
|
|
2014-05-24 02:46:26 +00:00
|
|
|
while (size)
|
2013-07-06 20:45:10 +00:00
|
|
|
{
|
2016-03-01 23:07:31 +00:00
|
|
|
size_t avail_write = MIN(alsa->buf_size - alsa->buffer_ptr, size);
|
|
|
|
|
2014-05-25 18:49:22 +00:00
|
|
|
if (avail_write)
|
|
|
|
{
|
2017-12-12 07:55:31 +00:00
|
|
|
memcpy(alsa->buffer[alsa->buffer_index] +
|
2014-09-09 20:24:29 +00:00
|
|
|
alsa->buffer_ptr, buf, avail_write);
|
2015-09-29 16:08:33 +00:00
|
|
|
|
|
|
|
alsa->buffer_ptr += avail_write;
|
|
|
|
buf = (void*)((uint8_t*)buf + avail_write);
|
|
|
|
size -= avail_write;
|
|
|
|
written += avail_write;
|
2014-05-25 18:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (alsa->buffer_ptr >= alsa->buf_size)
|
|
|
|
{
|
2014-09-09 20:24:29 +00:00
|
|
|
snd_pcm_sframes_t frames = snd_pcm_write(alsa->pcm,
|
|
|
|
alsa->buffer[alsa->buffer_index], alsa->buf_size);
|
2014-05-24 02:46:26 +00:00
|
|
|
|
2014-05-25 18:49:22 +00:00
|
|
|
alsa->buffer_index = (alsa->buffer_index + 1) % alsa->buf_count;
|
2015-09-29 16:08:33 +00:00
|
|
|
alsa->buffer_ptr = 0;
|
2014-05-25 16:36:53 +00:00
|
|
|
|
2014-05-25 18:49:22 +00:00
|
|
|
if (frames <= 0)
|
|
|
|
{
|
|
|
|
int ret;
|
2014-05-25 15:20:45 +00:00
|
|
|
|
2014-05-25 18:49:22 +00:00
|
|
|
if (frames == -EAGAIN)
|
|
|
|
continue;
|
2014-05-25 15:20:45 +00:00
|
|
|
|
2014-05-25 18:49:22 +00:00
|
|
|
ret = check_pcm_status(alsa, SND_PCM_CHANNEL_PLAYBACK);
|
2014-05-25 15:20:45 +00:00
|
|
|
|
2014-05-25 18:49:22 +00:00
|
|
|
if (ret == -EPROTO || ret == -EBADF)
|
|
|
|
return -1;
|
|
|
|
}
|
2013-07-06 23:10:05 +00:00
|
|
|
}
|
2014-05-25 18:49:22 +00:00
|
|
|
|
2013-07-06 20:45:10 +00:00
|
|
|
}
|
|
|
|
|
2014-05-24 02:46:26 +00:00
|
|
|
return written;
|
|
|
|
}
|
2013-06-21 16:56:39 +00:00
|
|
|
|
|
|
|
static bool alsa_qsa_stop(void *data)
|
|
|
|
{
|
2019-05-20 16:44:24 +00:00
|
|
|
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
|
2013-06-21 16:56:39 +00:00
|
|
|
|
|
|
|
if (alsa->can_pause && !alsa->is_paused)
|
|
|
|
{
|
2014-10-01 19:42:19 +00:00
|
|
|
int ret = snd_pcm_playback_pause(alsa->pcm);
|
|
|
|
if (ret < 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
alsa->is_paused = true;
|
2013-06-21 16:56:39 +00:00
|
|
|
}
|
2014-08-27 01:11:06 +00:00
|
|
|
|
|
|
|
return true;
|
2013-06-21 16:56:39 +00:00
|
|
|
}
|
|
|
|
|
2014-10-01 19:42:19 +00:00
|
|
|
static bool alsa_qsa_alive(void *data)
|
2013-06-21 16:56:39 +00:00
|
|
|
{
|
2019-05-20 16:44:24 +00:00
|
|
|
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
|
2014-10-01 19:42:19 +00:00
|
|
|
if (alsa)
|
|
|
|
return !alsa->is_paused;
|
|
|
|
return false;
|
2013-06-21 16:56:39 +00:00
|
|
|
}
|
|
|
|
|
2017-01-22 17:05:07 +00:00
|
|
|
static bool alsa_qsa_start(void *data, bool is_shutdown)
|
2013-06-21 19:36:19 +00:00
|
|
|
{
|
2019-05-20 16:44:24 +00:00
|
|
|
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
|
2013-06-21 19:36:19 +00:00
|
|
|
|
|
|
|
if (alsa->can_pause && alsa->is_paused)
|
|
|
|
{
|
|
|
|
int ret = snd_pcm_playback_resume(alsa->pcm);
|
2014-10-01 19:42:19 +00:00
|
|
|
|
2013-06-21 19:36:19 +00:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2014-09-09 20:24:29 +00:00
|
|
|
RARCH_ERR("[ALSA QSA]: Failed to unpause: %s.\n",
|
|
|
|
snd_strerror(ret));
|
2013-06-21 19:36:19 +00:00
|
|
|
return false;
|
|
|
|
}
|
2014-10-01 19:42:19 +00:00
|
|
|
|
|
|
|
alsa->is_paused = false;
|
2013-06-21 19:36:19 +00:00
|
|
|
}
|
|
|
|
|
2014-08-27 01:11:06 +00:00
|
|
|
return true;
|
2013-06-21 19:36:19 +00:00
|
|
|
}
|
|
|
|
|
2014-10-01 19:42:19 +00:00
|
|
|
static void alsa_qsa_set_nonblock_state(void *data, bool state)
|
|
|
|
{
|
2019-05-20 16:44:24 +00:00
|
|
|
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
|
2014-10-01 19:42:19 +00:00
|
|
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if((err = snd_pcm_nonblock_mode(alsa->pcm, state)) < 0)
|
|
|
|
{
|
|
|
|
RARCH_ERR("Can't set blocking mode to %d: %s\n", state,
|
|
|
|
snd_strerror(err));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
alsa->nonblock = state;
|
|
|
|
}
|
|
|
|
|
2013-06-21 16:56:39 +00:00
|
|
|
static bool alsa_qsa_use_float(void *data)
|
|
|
|
{
|
2019-05-20 16:44:24 +00:00
|
|
|
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
|
2013-06-21 16:56:39 +00:00
|
|
|
return alsa->has_float;
|
|
|
|
}
|
|
|
|
|
2013-06-21 19:36:19 +00:00
|
|
|
static void alsa_qsa_free(void *data)
|
|
|
|
{
|
2019-05-20 16:44:24 +00:00
|
|
|
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
|
2013-06-21 19:36:19 +00:00
|
|
|
|
|
|
|
if (alsa)
|
|
|
|
{
|
|
|
|
if (alsa->pcm)
|
|
|
|
{
|
|
|
|
snd_pcm_close(alsa->pcm);
|
|
|
|
alsa->pcm = NULL;
|
|
|
|
}
|
2014-05-25 18:49:22 +00:00
|
|
|
free(alsa->buffer);
|
|
|
|
free(alsa->buffer_chunk);
|
2013-06-21 19:36:19 +00:00
|
|
|
free(alsa);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static size_t alsa_qsa_write_avail(void *data)
|
|
|
|
{
|
2019-05-20 16:44:24 +00:00
|
|
|
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
|
2017-12-12 07:55:31 +00:00
|
|
|
size_t avail = (alsa->buf_count -
|
|
|
|
(int)alsa->buffered_blocks - 1) * alsa->buf_size +
|
2014-09-09 20:24:29 +00:00
|
|
|
(alsa->buf_size - (int)alsa->buffer_ptr);
|
2014-05-25 18:49:22 +00:00
|
|
|
return avail;
|
2013-06-21 19:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static size_t alsa_qsa_buffer_size(void *data)
|
|
|
|
{
|
2019-05-20 16:44:24 +00:00
|
|
|
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
|
2017-12-12 07:55:31 +00:00
|
|
|
return alsa->buf_size * alsa->buf_count;
|
2013-06-21 19:36:19 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 05:06:20 +00:00
|
|
|
audio_driver_t audio_alsa = {
|
2013-06-21 16:56:39 +00:00
|
|
|
alsa_qsa_init,
|
|
|
|
alsa_qsa_write,
|
|
|
|
alsa_qsa_stop,
|
|
|
|
alsa_qsa_start,
|
2014-10-01 19:42:19 +00:00
|
|
|
alsa_qsa_alive,
|
2013-06-21 16:56:39 +00:00
|
|
|
alsa_qsa_set_nonblock_state,
|
|
|
|
alsa_qsa_free,
|
|
|
|
alsa_qsa_use_float,
|
|
|
|
"alsa",
|
2016-04-26 15:55:20 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2013-06-21 19:36:19 +00:00
|
|
|
alsa_qsa_write_avail,
|
|
|
|
alsa_qsa_buffer_size,
|
2013-06-21 16:56:39 +00:00
|
|
|
};
|