mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 13:20:30 +00:00
(ALSA QSA) Merge latest patches by CatalystG
This commit is contained in:
parent
73016a2752
commit
7c74542c58
@ -69,15 +69,16 @@ static void *alsa_qsa_init(const char *device, unsigned rate, unsigned latency)
|
||||
|
||||
params.format.interleave = 1;
|
||||
params.format.format = SND_PCM_SFMT_S16_LE;
|
||||
params.format.rate = rate;
|
||||
params.format.rate = rate;
|
||||
params.format.voices = 2;
|
||||
|
||||
params.start_mode = SND_PCM_START_DATA;
|
||||
params.stop_mode = SND_PCM_STOP_ROLLOVER;
|
||||
params.start_mode = SND_PCM_START_FULL;
|
||||
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_max = 19;
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if ((err = snd_pcm_plugin_prepare(alsa->pcm, SND_PCM_CHANNEL_PLAYBACK)) < 0)
|
||||
@ -114,21 +115,28 @@ error:
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
snd_pcm_channel_status_t status = {0};
|
||||
|
||||
if ((err = snd_pcm_plugin_status(alsa->pcm, &status)) < 0)
|
||||
RARCH_ERR("[ALSA QSA]: Error reading status: %s\n", snd_strerror(err));
|
||||
written = snd_pcm_plugin_write(alsa->pcm, buf, size);
|
||||
|
||||
if ((err = snd_pcm_plugin_write(alsa->pcm, buf, size)) < 0)
|
||||
RARCH_ERR("[ALSA QSA]: Error writing PCM: %s\n", snd_strerror(err));
|
||||
if (written < size)
|
||||
{
|
||||
status.channel = SND_PCM_CHANNEL_PLAYBACK;
|
||||
|
||||
return size;
|
||||
}
|
||||
if ((err = snd_pcm_plugin_status(alsa->pcm, &status)) < 0)
|
||||
RARCH_ERR("[ALSA QSA]: Error reading status: %s\n", snd_strerror(err));
|
||||
|
||||
if (status.status == SND_PCM_STATUS_UNDERRUN)
|
||||
if (snd_pcm_plugin_prepare(alsa->pcm, SND_PCM_CHANNEL_PLAYBACK) < 0)
|
||||
RARCH_ERR("[ALSA QSA]: Underrun - playback channel prepare error.\n");
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
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;
|
||||
snd_pcm_channel_status_t status = {0};
|
||||
|
||||
status.channel = SND_PCM_CHANNEL_PLAYBACK;
|
||||
snd_pcm_plugin_status(alsa->pcm, &status);
|
||||
|
||||
return status.free;
|
||||
@ -244,3 +253,4 @@ const audio_driver_t audio_alsa = {
|
||||
alsa_qsa_write_avail,
|
||||
alsa_qsa_buffer_size,
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user