mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 07:04:36 +00:00
update sdl2 to 2.32.10
This commit is contained in:
parent
a181f488b2
commit
4823dee76e
44 changed files with 439 additions and 182 deletions
|
|
@ -83,6 +83,12 @@ static int (*ALSA_snd_device_name_hint)(int, const char *, void ***);
|
|||
static char *(*ALSA_snd_device_name_get_hint)(const void *, const char *);
|
||||
static int (*ALSA_snd_device_name_free_hint)(void **);
|
||||
static snd_pcm_sframes_t (*ALSA_snd_pcm_avail)(snd_pcm_t *);
|
||||
static int (*ALSA_snd_pcm_info)(snd_pcm_t *, snd_pcm_info_t *);
|
||||
static const char *(*ALSA_snd_pcm_info_get_name)(const snd_pcm_info_t *);
|
||||
static int (*ALSA_snd_pcm_info_get_card)(const snd_pcm_info_t *);
|
||||
static int (*ALSA_snd_card_get_name)(int, char **);
|
||||
static int (*ALSA_snd_pcm_info_malloc)(snd_pcm_info_t **);
|
||||
static int (*ALSA_snd_pcm_info_free)(snd_pcm_info_t *);
|
||||
#ifdef SND_CHMAP_API_VERSION
|
||||
static snd_pcm_chmap_t *(*ALSA_snd_pcm_get_chmap)(snd_pcm_t *);
|
||||
static int (*ALSA_snd_pcm_chmap_print)(const snd_pcm_chmap_t *map, size_t maxlen, char *buf);
|
||||
|
|
@ -152,6 +158,12 @@ static int load_alsa_syms(void)
|
|||
SDL_ALSA_SYM(snd_device_name_get_hint);
|
||||
SDL_ALSA_SYM(snd_device_name_free_hint);
|
||||
SDL_ALSA_SYM(snd_pcm_avail);
|
||||
SDL_ALSA_SYM(snd_pcm_info);
|
||||
SDL_ALSA_SYM(snd_pcm_info_get_card);
|
||||
SDL_ALSA_SYM(snd_pcm_info_get_name);
|
||||
SDL_ALSA_SYM(snd_card_get_name);
|
||||
SDL_ALSA_SYM(snd_pcm_info_malloc);
|
||||
SDL_ALSA_SYM(snd_pcm_info_free);
|
||||
#ifdef SND_CHMAP_API_VERSION
|
||||
SDL_ALSA_SYM(snd_pcm_get_chmap);
|
||||
SDL_ALSA_SYM(snd_pcm_chmap_print);
|
||||
|
|
@ -466,6 +478,58 @@ static void ALSA_CloseDevice(_THIS)
|
|||
SDL_free(this->hidden);
|
||||
}
|
||||
|
||||
static int ALSA_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
|
||||
{
|
||||
const char *device = "default";
|
||||
snd_pcm_t *pcm_handle;
|
||||
snd_pcm_info_t *pcm_info;
|
||||
snd_pcm_stream_t stream;
|
||||
int card_index;
|
||||
const char *dev_name;
|
||||
char *card_name = NULL;
|
||||
char final_name[256];
|
||||
|
||||
SDL_zero(final_name);
|
||||
stream = iscapture ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK;
|
||||
|
||||
if (ALSA_snd_pcm_open(&pcm_handle, device, stream, SND_PCM_NONBLOCK) < 0) {
|
||||
return SDL_SetError("ALSA: Couldn't open default device");
|
||||
}
|
||||
|
||||
if (ALSA_snd_pcm_info_malloc(&pcm_info) < 0) {
|
||||
ALSA_snd_pcm_close(pcm_handle);
|
||||
return SDL_SetError("ALSA: Couldn't allocate pcm_info");
|
||||
}
|
||||
|
||||
if (ALSA_snd_pcm_info(pcm_handle, pcm_info) < 0) {
|
||||
ALSA_snd_pcm_info_free(pcm_info);
|
||||
ALSA_snd_pcm_close(pcm_handle);
|
||||
return SDL_SetError("ALSA: Couldn't get PCM info");
|
||||
}
|
||||
|
||||
card_index = ALSA_snd_pcm_info_get_card(pcm_info);
|
||||
dev_name = ALSA_snd_pcm_info_get_name(pcm_info);
|
||||
|
||||
if (card_index >= 0 && ALSA_snd_card_get_name(card_index, &card_name) >= 0) {
|
||||
SDL_snprintf(final_name, sizeof(final_name), "%s, %s", card_name, dev_name);
|
||||
*name = SDL_strdup(final_name);
|
||||
} else {
|
||||
*name = SDL_strdup(dev_name ? dev_name : "Unknown ALSA Device");
|
||||
}
|
||||
|
||||
if (spec) {
|
||||
SDL_zero(*spec);
|
||||
spec->freq = 48000;
|
||||
spec->format = AUDIO_S16SYS;
|
||||
spec->channels = 2;
|
||||
spec->samples = 512;
|
||||
}
|
||||
|
||||
ALSA_snd_pcm_info_free(pcm_info);
|
||||
ALSA_snd_pcm_close(pcm_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params)
|
||||
{
|
||||
int status;
|
||||
|
|
@ -975,6 +1039,7 @@ static SDL_bool ALSA_Init(SDL_AudioDriverImpl *impl)
|
|||
impl->Deinitialize = ALSA_Deinitialize;
|
||||
impl->CaptureFromDevice = ALSA_CaptureFromDevice;
|
||||
impl->FlushCapture = ALSA_FlushCapture;
|
||||
impl->GetDefaultAudioInfo = ALSA_GetDefaultAudioInfo;
|
||||
|
||||
impl->HasCaptureSupport = SDL_TRUE;
|
||||
impl->SupportsNonPow2Samples = SDL_TRUE;
|
||||
|
|
|
|||
|
|
@ -383,7 +383,8 @@ static BOOL update_audio_session(_THIS, SDL_bool open, SDL_bool allow_playandrec
|
|||
|
||||
hint = SDL_GetHint(SDL_HINT_AUDIO_CATEGORY);
|
||||
if (hint) {
|
||||
if (SDL_strcasecmp(hint, "AVAudioSessionCategoryAmbient") == 0) {
|
||||
if (SDL_strcasecmp(hint, "AVAudioSessionCategoryAmbient") == 0 ||
|
||||
SDL_strcasecmp(hint, "ambient") == 0) {
|
||||
category = AVAudioSessionCategoryAmbient;
|
||||
} else if (SDL_strcasecmp(hint, "AVAudioSessionCategorySoloAmbient") == 0) {
|
||||
category = AVAudioSessionCategorySoloAmbient;
|
||||
|
|
|
|||
|
|
@ -413,27 +413,32 @@ static int openslES_CreatePCMPlayer(_THIS)
|
|||
SLresult result;
|
||||
int i;
|
||||
|
||||
/* If we want to add floating point audio support (requires API level 21)
|
||||
it can be done as described here:
|
||||
https://developer.android.com/ndk/guides/audio/opensl/android-extensions.html#floating-point
|
||||
*/
|
||||
/* according to https://developer.android.com/ndk/guides/audio/opensl/opensl-for-android,
|
||||
Android's OpenSL ES only supports Uint8 and _littleendian_ Sint16.
|
||||
(and float32, with an extension we use, below.) */
|
||||
if (SDL_GetAndroidSDKVersion() >= 21) {
|
||||
SDL_AudioFormat test_format;
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
|
||||
if (SDL_AUDIO_ISSIGNED(test_format)) {
|
||||
switch (test_format) {
|
||||
case AUDIO_U8:
|
||||
case AUDIO_S16LSB:
|
||||
case AUDIO_F32LSB:
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!test_format) {
|
||||
/* Didn't find a compatible format : */
|
||||
LOGI("No compatible audio format, using signed 16-bit audio");
|
||||
test_format = AUDIO_S16SYS;
|
||||
LOGI("No compatible audio format, using signed 16-bit LE audio");
|
||||
test_format = AUDIO_S16LSB;
|
||||
}
|
||||
this->spec.format = test_format;
|
||||
} else {
|
||||
/* Just go with signed 16-bit audio as it's the most compatible */
|
||||
this->spec.format = AUDIO_S16SYS;
|
||||
this->spec.format = AUDIO_S16LSB;
|
||||
}
|
||||
|
||||
/* Update the fragment size as size in bytes */
|
||||
|
|
|
|||
|
|
@ -574,6 +574,25 @@ static SDL_bool get_int_param(const struct spa_pod *param, Uint32 key, int *val)
|
|||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static SDL_AudioFormat SPAFormatToSDL(enum spa_audio_format spafmt)
|
||||
{
|
||||
switch (spafmt) {
|
||||
#define CHECKFMT(spa,sdl) case SPA_AUDIO_FORMAT_##spa: return AUDIO_##sdl
|
||||
CHECKFMT(U8, U8);
|
||||
CHECKFMT(S8, S8);
|
||||
CHECKFMT(S16_LE, S16LSB);
|
||||
CHECKFMT(S16_BE, S16MSB);
|
||||
CHECKFMT(S32_LE, S32LSB);
|
||||
CHECKFMT(S32_BE, S32MSB);
|
||||
CHECKFMT(F32_LE, F32LSB);
|
||||
CHECKFMT(F32_BE, F32MSB);
|
||||
#undef CHECKFMT
|
||||
default: break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Interface node callbacks */
|
||||
static void node_event_info(void *object, const struct pw_node_info *info)
|
||||
{
|
||||
|
|
@ -602,6 +621,15 @@ static void node_event_param(void *object, int seq, uint32_t id, uint32_t index,
|
|||
struct node_object *node = object;
|
||||
struct io_node *io = node->userdata;
|
||||
|
||||
if ((id == SPA_PARAM_Format) && (io->spec.format == 0)) {
|
||||
struct spa_audio_info_raw info;
|
||||
SDL_zero(info);
|
||||
if (spa_format_audio_raw_parse(param, &info) == 0) {
|
||||
/*SDL_Log("Sink Format: %d, Rate: %d Hz, Channels: %d", info.format, info.rate, info.channels);*/
|
||||
io->spec.format = SPAFormatToSDL(info.format);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the default frequency */
|
||||
if (io->spec.freq == 0) {
|
||||
get_range_param(param, SPA_FORMAT_AUDIO_rate, &io->spec.freq, NULL, NULL);
|
||||
|
|
@ -719,7 +747,9 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p
|
|||
/* Begin setting the node properties */
|
||||
io->id = id;
|
||||
io->is_capture = is_capture;
|
||||
io->spec.format = AUDIO_F32; /* Pipewire uses floats internally, other formats require conversion. */
|
||||
if (io->spec.format == 0) {
|
||||
io->spec.format = AUDIO_S16; /* we'll go conservative here if for some reason the format isn't known. */
|
||||
}
|
||||
io->name = io->buf;
|
||||
io->path = io->buf + desc_buffer_len;
|
||||
SDL_strlcpy(io->buf, node_desc, desc_buffer_len);
|
||||
|
|
|
|||
|
|
@ -24,18 +24,12 @@
|
|||
|
||||
/* Allow access to a raw mixing buffer */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#ifdef __NETBSD__
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/audioio.h>
|
||||
#endif
|
||||
#ifdef __SVR4
|
||||
#include <sys/audioio.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
#include "SDL_timer.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue