mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 14:42:30 +00:00
(ALSA QSA) Merge latest patches by CatalystG
This commit is contained in:
parent
73016a2752
commit
7c74542c58
@ -72,12 +72,13 @@ static void *alsa_qsa_init(const char *device, unsigned rate, unsigned latency)
|
|||||||
params.format.rate = rate;
|
params.format.rate = rate;
|
||||||
params.format.voices = 2;
|
params.format.voices = 2;
|
||||||
|
|
||||||
params.start_mode = SND_PCM_START_DATA;
|
params.start_mode = SND_PCM_START_FULL;
|
||||||
params.stop_mode = SND_PCM_STOP_ROLLOVER;
|
params.stop_mode = SND_PCM_STOP_STOP;
|
||||||
|
|
||||||
params.buf.block.frag_size = 4096;
|
params.buf.block.frags_max = (latency * rate * 4) / (1000 * (1 << 10)) - 1;
|
||||||
|
params.buf.block.frag_size = 1024;
|
||||||
params.buf.block.frags_min = 1;
|
params.buf.block.frags_min = 1;
|
||||||
params.buf.block.frags_max = 19;
|
|
||||||
|
|
||||||
if ((err = snd_pcm_plugin_params(alsa->pcm, ¶ms)) < 0)
|
if ((err = snd_pcm_plugin_params(alsa->pcm, ¶ms)) < 0)
|
||||||
{
|
{
|
||||||
@ -93,7 +94,7 @@ static void *alsa_qsa_init(const char *device, unsigned rate, unsigned latency)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
alsa->buffer_size = setup.buf.block.frag_size * 19; /* is this in bytes? */
|
alsa->buffer_size = setup.buf.block.frag_size * (setup.buf.block.frags_max+1); /* is this in bytes? */
|
||||||
RARCH_LOG("[ALSA QSA]: buffer size: %d bytes (?)\n", alsa->buffer_size);
|
RARCH_LOG("[ALSA QSA]: buffer size: %d bytes (?)\n", alsa->buffer_size);
|
||||||
|
|
||||||
if ((err = snd_pcm_plugin_prepare(alsa->pcm, SND_PCM_CHANNEL_PLAYBACK)) < 0)
|
if ((err = snd_pcm_plugin_prepare(alsa->pcm, SND_PCM_CHANNEL_PLAYBACK)) < 0)
|
||||||
@ -114,21 +115,28 @@ error:
|
|||||||
return (void*)-1;
|
return (void*)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ssize_t alsa_qsa_write(void *data, const void *buf, size_t size)
|
static ssize_t alsa_qsa_write(void *data, const void *buf, size_t size)
|
||||||
{
|
{
|
||||||
int err;
|
int written, err;
|
||||||
alsa_t *alsa = (alsa_t*)data;
|
alsa_t *alsa = (alsa_t*)data;
|
||||||
snd_pcm_channel_status_t status = {0};
|
snd_pcm_channel_status_t status = {0};
|
||||||
|
|
||||||
|
written = snd_pcm_plugin_write(alsa->pcm, buf, size);
|
||||||
|
|
||||||
|
if (written < size)
|
||||||
|
{
|
||||||
|
status.channel = SND_PCM_CHANNEL_PLAYBACK;
|
||||||
|
|
||||||
if ((err = snd_pcm_plugin_status(alsa->pcm, &status)) < 0)
|
if ((err = snd_pcm_plugin_status(alsa->pcm, &status)) < 0)
|
||||||
RARCH_ERR("[ALSA QSA]: Error reading status: %s\n", snd_strerror(err));
|
RARCH_ERR("[ALSA QSA]: Error reading status: %s\n", snd_strerror(err));
|
||||||
|
|
||||||
if ((err = snd_pcm_plugin_write(alsa->pcm, buf, size)) < 0)
|
if (status.status == SND_PCM_STATUS_UNDERRUN)
|
||||||
RARCH_ERR("[ALSA QSA]: Error writing PCM: %s\n", snd_strerror(err));
|
if (snd_pcm_plugin_prepare(alsa->pcm, SND_PCM_CHANNEL_PLAYBACK) < 0)
|
||||||
|
RARCH_ERR("[ALSA QSA]: Underrun - playback channel prepare error.\n");
|
||||||
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool alsa_qsa_stop(void *data)
|
static bool alsa_qsa_stop(void *data)
|
||||||
{
|
{
|
||||||
@ -221,6 +229,7 @@ static size_t alsa_qsa_write_avail(void *data)
|
|||||||
alsa_t *alsa = (alsa_t*)data;
|
alsa_t *alsa = (alsa_t*)data;
|
||||||
snd_pcm_channel_status_t status = {0};
|
snd_pcm_channel_status_t status = {0};
|
||||||
|
|
||||||
|
status.channel = SND_PCM_CHANNEL_PLAYBACK;
|
||||||
snd_pcm_plugin_status(alsa->pcm, &status);
|
snd_pcm_plugin_status(alsa->pcm, &status);
|
||||||
|
|
||||||
return status.free;
|
return status.free;
|
||||||
@ -244,3 +253,4 @@ const audio_driver_t audio_alsa = {
|
|||||||
alsa_qsa_write_avail,
|
alsa_qsa_write_avail,
|
||||||
alsa_qsa_buffer_size,
|
alsa_qsa_buffer_size,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user