early-access version 2835

This commit is contained in:
pineappleEA
2022-07-15 04:00:50 +02:00
parent 5c0ee5eba6
commit 0e7aef7e36
1173 changed files with 55320 additions and 18881 deletions

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -121,7 +121,7 @@ QSA_WaitDevice(_THIS)
/* For example, Vortex 8820 audio driver stucks on second DAC because */
/* it doesn't exist ! */
result = SDL_IOReady(this->hidden->audio_fd,
this->hidden->iscapture ? SDL_IOR_READ : SDL_IOR_WRITE,
this->iscapture ? SDL_IOR_READ : SDL_IOR_WRITE,
2 * 1000);
switch (result) {
case -1:
@@ -180,7 +180,7 @@ QSA_PlayDevice(_THIS)
} else {
if ((errno == EINVAL) || (errno == EIO)) {
SDL_zero(cstatus);
if (!this->hidden->iscapture) {
if (!this->iscapture) {
cstatus.channel = SND_PCM_CHANNEL_PLAYBACK;
} else {
cstatus.channel = SND_PCM_CHANNEL_CAPTURE;
@@ -196,7 +196,7 @@ QSA_PlayDevice(_THIS)
if ((cstatus.status == SND_PCM_STATUS_UNDERRUN) ||
(cstatus.status == SND_PCM_STATUS_READY)) {
if (!this->hidden->iscapture) {
if (!this->iscapture) {
status =
snd_pcm_plugin_prepare(this->hidden->
audio_handle,
@@ -240,7 +240,7 @@ static void
QSA_CloseDevice(_THIS)
{
if (this->hidden->audio_handle != NULL) {
if (!this->hidden->iscapture) {
if (!this->iscapture) {
/* Finish playing available samples */
snd_pcm_plugin_flush(this->hidden->audio_handle,
SND_PCM_CHANNEL_PLAYBACK);
@@ -257,13 +257,13 @@ QSA_CloseDevice(_THIS)
}
static int
QSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
QSA_OpenDevice(_THIS, const char *devname)
{
const QSA_Device *device = (const QSA_Device *) handle;
const QSA_Device *device = (const QSA_Device *) this->handle;
SDL_Bool iscapture = this->iscapture;
int status = 0;
int format = 0;
SDL_AudioFormat test_format = 0;
int found = 0;
SDL_AudioFormat test_format;
snd_pcm_channel_setup_t csetup;
snd_pcm_channel_params_t cparams;
@@ -280,9 +280,6 @@ QSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
/* Initialize channel transfer parameters to default */
QSA_InitAudioParams(&cparams);
/* Initialize channel direction: capture or playback */
this->hidden->iscapture = iscapture ? SDL_TRUE : SDL_FALSE;
if (device != NULL) {
/* Open requested audio device */
this->hidden->deviceno = device->deviceno;
@@ -305,89 +302,49 @@ QSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
}
/* Try for a closest match on audio format */
format = 0;
/* can't use format as SND_PCM_SFMT_U8 = 0 in qsa */
found = 0;
for (test_format = SDL_FirstAudioFormat(this->spec.format); !found;) {
for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
/* if match found set format to equivalent QSA format */
switch (test_format) {
case AUDIO_U8:
{
format = SND_PCM_SFMT_U8;
found = 1;
}
format = SND_PCM_SFMT_U8;
break;
case AUDIO_S8:
{
format = SND_PCM_SFMT_S8;
found = 1;
}
format = SND_PCM_SFMT_S8;
break;
case AUDIO_S16LSB:
{
format = SND_PCM_SFMT_S16_LE;
found = 1;
}
format = SND_PCM_SFMT_S16_LE;
break;
case AUDIO_S16MSB:
{
format = SND_PCM_SFMT_S16_BE;
found = 1;
}
format = SND_PCM_SFMT_S16_BE;
break;
case AUDIO_U16LSB:
{
format = SND_PCM_SFMT_U16_LE;
found = 1;
}
format = SND_PCM_SFMT_U16_LE;
break;
case AUDIO_U16MSB:
{
format = SND_PCM_SFMT_U16_BE;
found = 1;
}
format = SND_PCM_SFMT_U16_BE;
break;
case AUDIO_S32LSB:
{
format = SND_PCM_SFMT_S32_LE;
found = 1;
}
format = SND_PCM_SFMT_S32_LE;
break;
case AUDIO_S32MSB:
{
format = SND_PCM_SFMT_S32_BE;
found = 1;
}
format = SND_PCM_SFMT_S32_BE;
break;
case AUDIO_F32LSB:
{
format = SND_PCM_SFMT_FLOAT_LE;
found = 1;
}
format = SND_PCM_SFMT_FLOAT_LE;
break;
case AUDIO_F32MSB:
{
format = SND_PCM_SFMT_FLOAT_BE;
found = 1;
}
format = SND_PCM_SFMT_FLOAT_BE;
break;
default:
{
break;
}
}
if (!found) {
test_format = SDL_NextAudioFormat();
continue;
}
break;
}
/* assumes test_format not 0 on success */
if (test_format == 0) {
return SDL_SetError("QSA: Couldn't find any hardware audio formats");
/* can't use format as SND_PCM_SFMT_U8 = 0 in qsa */
if (!test_format) {
return SDL_SetError("%s: Unsupported audio format", "qsa");
}
this->spec.format = test_format;
/* Set the audio format */
@@ -407,7 +364,7 @@ QSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
/* Make sure channel is setup right one last time */
SDL_zero(csetup);
if (!this->hidden->iscapture) {
if (!this->iscapture) {
csetup.channel = SND_PCM_CHANNEL_PLAYBACK;
} else {
csetup.channel = SND_PCM_CHANNEL_CAPTURE;
@@ -443,7 +400,7 @@ QSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
this->hidden->pcm_len);
/* get the file descriptor */
if (!this->hidden->iscapture) {
if (!this->iscapture) {
this->hidden->audio_fd =
snd_pcm_file_descriptor(this->hidden->audio_handle,
SND_PCM_CHANNEL_PLAYBACK);
@@ -458,7 +415,7 @@ QSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
}
/* Prepare an audio channel */
if (!this->hidden->iscapture) {
if (!this->iscapture) {
/* Prepare audio playback */
status =
snd_pcm_plugin_prepare(this->hidden->audio_handle,
@@ -635,7 +592,7 @@ QSA_Deinitialize(void)
qsa_capture_devices = 0;
}
static int
static SDL_bool
QSA_Init(SDL_AudioDriverImpl * impl)
{
/* Clear devices array */
@@ -655,20 +612,14 @@ QSA_Init(SDL_AudioDriverImpl * impl)
impl->GetDeviceBuf = QSA_GetDeviceBuf;
impl->CloseDevice = QSA_CloseDevice;
impl->Deinitialize = QSA_Deinitialize;
impl->LockDevice = NULL;
impl->UnlockDevice = NULL;
impl->ProvidesOwnCallbackThread = 0;
impl->SkipMixerLock = 0;
impl->HasCaptureSupport = 1;
impl->OnlyHasDefaultOutputDevice = 0;
impl->OnlyHasDefaultCaptureDevice = 0;
impl->HasCaptureSupport = SDL_TRUE;
return 1; /* this audio target is available. */
return SDL_TRUE; /* this audio target is available. */
}
AudioBootStrap QSAAUDIO_bootstrap = {
"qsa", "QNX QSA Audio", QSA_Init, 0
"qsa", "QNX QSA Audio", QSA_Init, SDL_FALSE
};
#endif /* SDL_AUDIO_DRIVER_QSA */

View File

@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -33,9 +33,6 @@
struct SDL_PrivateAudioData
{
/* SDL capture state */
SDL_bool iscapture;
/* The audio device handle */
int cardno;
int deviceno;