mirror of
https://github.com/love2d/megasource.git
synced 2026-08-17 11:11:35 +02:00
Added missing changes to the OpenAL-Soft update.
This commit is contained in:
@@ -548,6 +548,7 @@ static int audio_thread(void *userdata)
|
||||
MovieState *movState = (MovieState*)userdata;
|
||||
uint8_t *samples = NULL;
|
||||
ALsizei buffer_len;
|
||||
ALenum fmt;
|
||||
|
||||
alGenBuffers(AUDIO_BUFFER_QUEUE_SIZE, movState->audio.buffer);
|
||||
alGenSources(1, &movState->audio.source);
|
||||
@@ -557,56 +558,107 @@ static int audio_thread(void *userdata)
|
||||
|
||||
av_new_packet(&movState->audio.pkt, 0);
|
||||
|
||||
/* Find a suitable format for OpenAL. Currently does not handle surround
|
||||
* sound (everything non-mono becomes stereo). */
|
||||
/* Find a suitable format for OpenAL. */
|
||||
movState->audio.format = AL_NONE;
|
||||
if(movState->audio.st->codec->sample_fmt == AV_SAMPLE_FMT_U8 ||
|
||||
movState->audio.st->codec->sample_fmt == AV_SAMPLE_FMT_U8P)
|
||||
{
|
||||
movState->audio.dst_sample_fmt = AV_SAMPLE_FMT_U8;
|
||||
movState->audio.frame_size = 1;
|
||||
if(movState->audio.st->codec->channel_layout == AV_CH_LAYOUT_7POINT1 &&
|
||||
alIsExtensionPresent("AL_EXT_MCFORMATS") &&
|
||||
(fmt=alGetEnumValue("AL_FORMAT_71CHN8")) != AL_NONE && fmt != -1)
|
||||
{
|
||||
movState->audio.dst_ch_layout = movState->audio.st->codec->channel_layout;
|
||||
movState->audio.frame_size *= 8;
|
||||
movState->audio.format = fmt;
|
||||
}
|
||||
if((movState->audio.st->codec->channel_layout == AV_CH_LAYOUT_5POINT1 ||
|
||||
movState->audio.st->codec->channel_layout == AV_CH_LAYOUT_5POINT1_BACK) &&
|
||||
alIsExtensionPresent("AL_EXT_MCFORMATS") &&
|
||||
(fmt=alGetEnumValue("AL_FORMAT_51CHN8")) != AL_NONE && fmt != -1)
|
||||
{
|
||||
movState->audio.dst_ch_layout = movState->audio.st->codec->channel_layout;
|
||||
movState->audio.frame_size *= 6;
|
||||
movState->audio.format = fmt;
|
||||
}
|
||||
if(movState->audio.st->codec->channel_layout == AV_CH_LAYOUT_MONO)
|
||||
{
|
||||
movState->audio.dst_ch_layout = AV_CH_LAYOUT_MONO;
|
||||
movState->audio.frame_size *= 1;
|
||||
movState->audio.format = AL_FORMAT_MONO8;
|
||||
}
|
||||
else
|
||||
if(movState->audio.format == AL_NONE)
|
||||
{
|
||||
movState->audio.dst_ch_layout = AV_CH_LAYOUT_STEREO;
|
||||
movState->audio.frame_size *= 2;
|
||||
movState->audio.format = AL_FORMAT_STEREO8;
|
||||
}
|
||||
}
|
||||
else if((movState->audio.st->codec->sample_fmt == AV_SAMPLE_FMT_FLT ||
|
||||
movState->audio.st->codec->sample_fmt == AV_SAMPLE_FMT_FLTP) &&
|
||||
alIsExtensionPresent("AL_EXT_FLOAT32"))
|
||||
if((movState->audio.st->codec->sample_fmt == AV_SAMPLE_FMT_FLT ||
|
||||
movState->audio.st->codec->sample_fmt == AV_SAMPLE_FMT_FLTP) &&
|
||||
alIsExtensionPresent("AL_EXT_FLOAT32"))
|
||||
{
|
||||
movState->audio.dst_sample_fmt = AV_SAMPLE_FMT_FLT;
|
||||
movState->audio.frame_size = 4;
|
||||
if(movState->audio.st->codec->channel_layout == AV_CH_LAYOUT_7POINT1 &&
|
||||
alIsExtensionPresent("AL_EXT_MCFORMATS") &&
|
||||
(fmt=alGetEnumValue("AL_FORMAT_71CHN32")) != AL_NONE && fmt != -1)
|
||||
{
|
||||
movState->audio.dst_ch_layout = movState->audio.st->codec->channel_layout;
|
||||
movState->audio.frame_size *= 8;
|
||||
movState->audio.format = fmt;
|
||||
}
|
||||
if((movState->audio.st->codec->channel_layout == AV_CH_LAYOUT_5POINT1 ||
|
||||
movState->audio.st->codec->channel_layout == AV_CH_LAYOUT_5POINT1_BACK) &&
|
||||
alIsExtensionPresent("AL_EXT_MCFORMATS") &&
|
||||
(fmt=alGetEnumValue("AL_FORMAT_51CHN32")) != AL_NONE && fmt != -1)
|
||||
{
|
||||
movState->audio.dst_ch_layout = movState->audio.st->codec->channel_layout;
|
||||
movState->audio.frame_size *= 6;
|
||||
movState->audio.format = fmt;
|
||||
}
|
||||
if(movState->audio.st->codec->channel_layout == AV_CH_LAYOUT_MONO)
|
||||
{
|
||||
movState->audio.dst_ch_layout = AV_CH_LAYOUT_MONO;
|
||||
movState->audio.frame_size *= 1;
|
||||
movState->audio.format = AL_FORMAT_MONO_FLOAT32;
|
||||
}
|
||||
else
|
||||
if(movState->audio.format == AL_NONE)
|
||||
{
|
||||
movState->audio.dst_ch_layout = AV_CH_LAYOUT_STEREO;
|
||||
movState->audio.frame_size *= 2;
|
||||
movState->audio.format = AL_FORMAT_STEREO_FLOAT32;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(movState->audio.format == AL_NONE)
|
||||
{
|
||||
movState->audio.dst_sample_fmt = AV_SAMPLE_FMT_S16;
|
||||
movState->audio.frame_size = 2;
|
||||
if(movState->audio.st->codec->channel_layout == AV_CH_LAYOUT_7POINT1 &&
|
||||
alIsExtensionPresent("AL_EXT_MCFORMATS") &&
|
||||
(fmt=alGetEnumValue("AL_FORMAT_71CHN16")) != AL_NONE && fmt != -1)
|
||||
{
|
||||
movState->audio.dst_ch_layout = movState->audio.st->codec->channel_layout;
|
||||
movState->audio.frame_size *= 8;
|
||||
movState->audio.format = fmt;
|
||||
}
|
||||
if((movState->audio.st->codec->channel_layout == AV_CH_LAYOUT_5POINT1 ||
|
||||
movState->audio.st->codec->channel_layout == AV_CH_LAYOUT_5POINT1_BACK) &&
|
||||
alIsExtensionPresent("AL_EXT_MCFORMATS") &&
|
||||
(fmt=alGetEnumValue("AL_FORMAT_51CHN16")) != AL_NONE && fmt != -1)
|
||||
{
|
||||
movState->audio.dst_ch_layout = movState->audio.st->codec->channel_layout;
|
||||
movState->audio.frame_size *= 6;
|
||||
movState->audio.format = fmt;
|
||||
}
|
||||
if(movState->audio.st->codec->channel_layout == AV_CH_LAYOUT_MONO)
|
||||
{
|
||||
movState->audio.dst_ch_layout = AV_CH_LAYOUT_MONO;
|
||||
movState->audio.frame_size *= 1;
|
||||
movState->audio.format = AL_FORMAT_MONO16;
|
||||
}
|
||||
else
|
||||
if(movState->audio.format == AL_NONE)
|
||||
{
|
||||
movState->audio.dst_ch_layout = AV_CH_LAYOUT_STEREO;
|
||||
movState->audio.frame_size *= 2;
|
||||
@@ -632,7 +684,9 @@ static int audio_thread(void *userdata)
|
||||
movState->audio.dst_ch_layout,
|
||||
movState->audio.dst_sample_fmt,
|
||||
movState->audio.st->codec->sample_rate,
|
||||
movState->audio.st->codec->channel_layout,
|
||||
movState->audio.st->codec->channel_layout ?
|
||||
movState->audio.st->codec->channel_layout :
|
||||
av_get_default_channel_layout(movState->audio.st->codec->channels),
|
||||
movState->audio.st->codec->sample_fmt,
|
||||
movState->audio.st->codec->sample_rate,
|
||||
0, NULL
|
||||
|
||||
Reference in New Issue
Block a user