0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 04:42:18 +02:00

libobs/media-io: Clean surround API

(also modifies obs-ffmpeg, audio-monitoring, win-wasapi, decklink,
obs-outputs)

Removes speaker layouts which are not exposed in UI.  The speaker
layouts selectable by users in the UI are the most common ones.  It is
not necessary to keep other layouts.  (This basically removes
5POINT1_SURROUND, 7POINT1_SURROUND, SURROUND =3.0).
This commit is contained in:
pkviet 2017-12-04 23:32:50 +01:00 committed by jp9000
parent 2c20d42815
commit fb580535c9
10 changed files with 9 additions and 52 deletions

View File

@ -229,14 +229,11 @@ static inline void audio_monitor_free(struct audio_monitor *monitor)
static enum speaker_layout convert_speaker_layout(DWORD layout, WORD channels)
{
switch (layout) {
case KSAUDIO_SPEAKER_QUAD: return SPEAKERS_QUAD;
case KSAUDIO_SPEAKER_2POINT1: return SPEAKERS_2POINT1;
case KSAUDIO_SPEAKER_4POINT1: return SPEAKERS_4POINT1;
case KSAUDIO_SPEAKER_SURROUND: return SPEAKERS_SURROUND;
case KSAUDIO_SPEAKER_QUAD: return SPEAKERS_QUAD;
case KSAUDIO_SPEAKER_5POINT1: return SPEAKERS_5POINT1;
case KSAUDIO_SPEAKER_5POINT1_SURROUND: return SPEAKERS_5POINT1_SURROUND;
case KSAUDIO_SPEAKER_7POINT1: return SPEAKERS_7POINT1;
case KSAUDIO_SPEAKER_7POINT1_SURROUND: return SPEAKERS_7POINT1_SURROUND;
}
return (enum speaker_layout)channels;

View File

@ -59,10 +59,7 @@ enum speaker_layout {
SPEAKERS_QUAD,
SPEAKERS_4POINT1,
SPEAKERS_5POINT1,
SPEAKERS_5POINT1_SURROUND,
SPEAKERS_7POINT1,
SPEAKERS_7POINT1_SURROUND,
SPEAKERS_SURROUND,
SPEAKERS_7POINT1=8,
};
struct audio_data {
@ -101,14 +98,11 @@ static inline uint32_t get_audio_channels(enum speaker_layout speakers)
switch (speakers) {
case SPEAKERS_MONO: return 1;
case SPEAKERS_STEREO: return 2;
case SPEAKERS_2POINT1:
case SPEAKERS_SURROUND: return 3;
case SPEAKERS_2POINT1: return 3;
case SPEAKERS_QUAD: return 4;
case SPEAKERS_4POINT1: return 5;
case SPEAKERS_5POINT1:
case SPEAKERS_5POINT1_SURROUND: return 6;
case SPEAKERS_7POINT1:
case SPEAKERS_7POINT1_SURROUND: return 8;
case SPEAKERS_5POINT1: return 6;
case SPEAKERS_7POINT1: return 8;
case SPEAKERS_UNKNOWN: return 0;
}

View File

@ -67,10 +67,7 @@ static inline uint64_t convert_speaker_layout(enum speaker_layout layout)
case SPEAKERS_QUAD: return AV_CH_LAYOUT_QUAD;
case SPEAKERS_4POINT1: return AV_CH_LAYOUT_4POINT1;
case SPEAKERS_5POINT1: return AV_CH_LAYOUT_5POINT1;
case SPEAKERS_5POINT1_SURROUND: return AV_CH_LAYOUT_5POINT1_BACK;
case SPEAKERS_7POINT1: return AV_CH_LAYOUT_7POINT1;
case SPEAKERS_7POINT1_SURROUND: return AV_CH_LAYOUT_7POINT1_WIDE_BACK;
case SPEAKERS_SURROUND: return AV_CH_LAYOUT_SURROUND;
}
/* shouldn't get here */

View File

@ -12,13 +12,8 @@ ColorRange.Full="Full"
ChannelFormat="Channel"
ChannelFormat.None="None"
ChannelFormat.2_0ch="2ch"
ChannelFormat.2_1ch="2.1"
ChannelFormat.3_1ch="3.1"
ChannelFormat.2_1ch="2.1ch"
ChannelFormat.4_0ch="4ch"
ChannelFormat.4_1ch="4.1ch"
ChannelFormat.5_1ch="5.1ch Side"
ChannelFormat.5_1chBack="5.1ch"
ChannelFormat.7_1ch="7.1ch Side"
ChannelFormat.7_1chBack="7.1ch"
ChannelFormat.8_0ch="8.0ch"
ChannelFormat.16_0ch="16.0ch"
ChannelFormat.5_1ch="5.1ch"
ChannelFormat.7_1ch="7.1ch"

View File

@ -34,9 +34,7 @@ static inline int ConvertChannelFormat(speaker_layout format)
case SPEAKERS_QUAD:
case SPEAKERS_4POINT1:
case SPEAKERS_5POINT1:
case SPEAKERS_5POINT1_SURROUND:
case SPEAKERS_7POINT1:
case SPEAKERS_7POINT1_SURROUND:
return 8;
default:
@ -53,10 +51,8 @@ static inline audio_repack_mode_t ConvertRepackFormat(speaker_layout format)
case SPEAKERS_4POINT1:
return repack_mode_8to5ch_swap23;
case SPEAKERS_5POINT1:
case SPEAKERS_5POINT1_SURROUND:
return repack_mode_8to6ch_swap23;
case SPEAKERS_7POINT1:
case SPEAKERS_7POINT1_SURROUND:
return repack_mode_8ch_swap23_swap46_swap57;
default:
assert(false && "No repack requested");

View File

@ -33,8 +33,6 @@ OBS_MODULE_USE_DEFAULT_LOCALE("decklink", "en-US")
#define TEXT_CHANNEL_FORMAT_4_0CH obs_module_text("ChannelFormat.4_0ch")
#define TEXT_CHANNEL_FORMAT_4_1CH obs_module_text("ChannelFormat.4_1ch")
#define TEXT_CHANNEL_FORMAT_5_1CH obs_module_text("ChannelFormat.5_1ch")
#define TEXT_CHANNEL_FORMAT_5_1CH_BACK \
obs_module_text("ChannelFormat.5_1chBack")
#define TEXT_CHANNEL_FORMAT_7_1CH obs_module_text("ChannelFormat.7_1ch")
#define TEXT_BUFFERING obs_module_text("Buffering")
@ -162,8 +160,6 @@ static bool decklink_device_changed(obs_properties_t *props,
SPEAKERS_QUAD);
obs_property_list_add_int(channelList, TEXT_CHANNEL_FORMAT_5_1CH,
SPEAKERS_5POINT1);
obs_property_list_add_int(channelList,
TEXT_CHANNEL_FORMAT_5_1CH_BACK, SPEAKERS_5POINT1_SURROUND);
obs_property_list_add_int(channelList, TEXT_CHANNEL_FORMAT_7_1CH,
SPEAKERS_7POINT1);
}
@ -267,8 +263,6 @@ static obs_properties_t *decklink_get_properties(void *data)
SPEAKERS_4POINT1);
obs_property_list_add_int(list, TEXT_CHANNEL_FORMAT_5_1CH,
SPEAKERS_5POINT1);
obs_property_list_add_int(list, TEXT_CHANNEL_FORMAT_5_1CH_BACK,
SPEAKERS_5POINT1_SURROUND);
obs_property_list_add_int(list, TEXT_CHANNEL_FORMAT_7_1CH,
SPEAKERS_7POINT1);

View File

@ -40,7 +40,6 @@ static enum speaker_layout jack_channels_to_obs_speakers(uint_fast32_t channels)
case 1: return SPEAKERS_MONO;
case 2: return SPEAKERS_STEREO;
case 3: return SPEAKERS_2POINT1;
case 4: return SPEAKERS_SURROUND;
case 5: return SPEAKERS_4POINT1;
case 6: return SPEAKERS_5POINT1;
/* What should we do with 7 channels? */

View File

@ -66,10 +66,7 @@ static inline uint64_t convert_speaker_layout(enum speaker_layout layout)
case SPEAKERS_QUAD: return AV_CH_LAYOUT_QUAD;
case SPEAKERS_4POINT1: return AV_CH_LAYOUT_4POINT1;
case SPEAKERS_5POINT1: return AV_CH_LAYOUT_5POINT1;
case SPEAKERS_5POINT1_SURROUND: return AV_CH_LAYOUT_5POINT1_BACK;
case SPEAKERS_7POINT1: return AV_CH_LAYOUT_7POINT1;
case SPEAKERS_7POINT1_SURROUND: return AV_CH_LAYOUT_7POINT1_WIDE_BACK;
case SPEAKERS_SURROUND: return AV_CH_LAYOUT_SURROUND;
}
/* shouldn't get here */
@ -85,10 +82,7 @@ static inline enum speaker_layout convert_ff_channel_layout(uint64_t channel_la
case AV_CH_LAYOUT_QUAD: return SPEAKERS_QUAD;
case AV_CH_LAYOUT_4POINT1: return SPEAKERS_4POINT1;
case AV_CH_LAYOUT_5POINT1: return SPEAKERS_5POINT1;
case AV_CH_LAYOUT_5POINT1_BACK: return SPEAKERS_5POINT1_SURROUND;
case AV_CH_LAYOUT_7POINT1: return SPEAKERS_7POINT1;
case AV_CH_LAYOUT_7POINT1_WIDE_BACK: return SPEAKERS_7POINT1_SURROUND;
case AV_CH_LAYOUT_SURROUND: return SPEAKERS_SURROUND;
}
/* shouldn't get here */

View File

@ -112,12 +112,8 @@ static bool build_flv_meta_data(obs_output_t *context,
audio_output_get_channels(audio) == 5);
enc_bool_val(&enc, end, "5.1",
audio_output_get_channels(audio) == 6);
enc_bool_val(&enc, end, "5.1surround",
audio_output_get_channels(audio) == 6);
enc_bool_val(&enc, end, "7.1",
audio_output_get_channels(audio) == 8);
enc_bool_val(&enc, end, "7.1surround",
audio_output_get_channels(audio) == 8);
dstr_printf(&encoder_name, "%s (libobs version ",
MODULE_NAME);

View File

@ -17,8 +17,6 @@ static void GetWASAPIDefaults(obs_data_t *settings);
// Fix inconsistent defs of speaker_surround between avutil & wasapi
#define KSAUDIO_SPEAKER_2POINT1 (KSAUDIO_SPEAKER_STEREO|SPEAKER_LOW_FREQUENCY)
#define KSAUDIO_SPEAKER_SURROUND_AVUTIL \
(KSAUDIO_SPEAKER_STEREO|SPEAKER_FRONT_CENTER)
#define KSAUDIO_SPEAKER_4POINT1 (KSAUDIO_SPEAKER_QUAD|SPEAKER_LOW_FREQUENCY)
class WASAPISource {
@ -244,13 +242,10 @@ void WASAPISource::InitRender()
static speaker_layout ConvertSpeakerLayout(DWORD layout, WORD channels)
{
switch (layout) {
case KSAUDIO_SPEAKER_QUAD: return SPEAKERS_QUAD;
case KSAUDIO_SPEAKER_2POINT1: return SPEAKERS_2POINT1;
case KSAUDIO_SPEAKER_QUAD: return SPEAKERS_QUAD;
case KSAUDIO_SPEAKER_4POINT1: return SPEAKERS_4POINT1;
case KSAUDIO_SPEAKER_SURROUND_AVUTIL: return SPEAKERS_SURROUND;
case KSAUDIO_SPEAKER_5POINT1: return SPEAKERS_5POINT1_SURROUND;
case KSAUDIO_SPEAKER_5POINT1_SURROUND: return SPEAKERS_5POINT1;
case KSAUDIO_SPEAKER_7POINT1: return SPEAKERS_7POINT1_SURROUND;
case KSAUDIO_SPEAKER_7POINT1_SURROUND: return SPEAKERS_7POINT1;
}