Skip to content

Commit

Permalink
libobs/media-io: Replace quad with 4.0
Browse files Browse the repository at this point in the history
(also obs, deps/media-playback, libobs/audio-monitoring, decklink,
linux-alsa, linux-pulseaudio, mac-capture, obs-ffmpeg, win-dshow,
win-wasapi)

Default channel layout for 4 channels is 4.0 in FFmpeg.
Replacing quad with 4.0 will improve compatibility since FFmpeg has
better support of its default channel layouts.
  • Loading branch information
pkviet authored and jp9000 committed Jan 5, 2018
1 parent fb58053 commit 67e48ec
Show file tree
Hide file tree
Showing 19 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion UI/forms/OBSBasicSettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -3229,7 +3229,7 @@
</item>
<item>
<property name="text">
<string>4.0 Quad</string>
<string>4.0</string>
</property>
</item>
<item>
Expand Down
4 changes: 2 additions & 2 deletions UI/window-basic-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3185,8 +3185,8 @@ bool OBSBasic::ResetAudio()
ai.speakers = SPEAKERS_MONO;
else if (strcmp(channelSetupStr, "2.1") == 0)
ai.speakers = SPEAKERS_2POINT1;
else if (strcmp(channelSetupStr, "4.0 Quad") == 0)
ai.speakers = SPEAKERS_QUAD;
else if (strcmp(channelSetupStr, "4.0") == 0)
ai.speakers = SPEAKERS_4POINT0;
else if (strcmp(channelSetupStr, "4.1") == 0)
ai.speakers = SPEAKERS_4POINT1;
else if (strcmp(channelSetupStr, "5.1") == 0)
Expand Down
6 changes: 3 additions & 3 deletions UI/window-basic-settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ static inline bool IsSurround(const char *speakers)
{
static const char *surroundLayouts[] = {
"2.1",
"4.0 Quad",
"4.0",
"4.1",
"5.1",
"7.1",
Expand Down Expand Up @@ -2109,7 +2109,7 @@ void OBSBasicSettings::LoadAudioSettings()
ui->channelSetup->setCurrentIndex(0);
else if (strcmp(speakers, "2.1") == 0)
ui->channelSetup->setCurrentIndex(2);
else if (strcmp(speakers, "4.0 Quad") == 0)
else if (strcmp(speakers, "4.0") == 0)
ui->channelSetup->setCurrentIndex(3);
else if (strcmp(speakers, "4.1") == 0)
ui->channelSetup->setCurrentIndex(4);
Expand Down Expand Up @@ -3015,7 +3015,7 @@ void OBSBasicSettings::SaveAudioSettings()
channelSetup = "2.1";
break;
case 3:
channelSetup = "4.0 Quad";
channelSetup = "4.0";
break;
case 4:
channelSetup = "4.1";
Expand Down
2 changes: 1 addition & 1 deletion deps/media-playback/media-playback/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static inline enum speaker_layout convert_speaker_layout(uint8_t channels)
case 1: return SPEAKERS_MONO;
case 2: return SPEAKERS_STEREO;
case 3: return SPEAKERS_2POINT1;
case 4: return SPEAKERS_QUAD;
case 4: return SPEAKERS_4POINT0;
case 5: return SPEAKERS_4POINT1;
case 6: return SPEAKERS_5POINT1;
case 8: return SPEAKERS_7POINT1;
Expand Down
2 changes: 1 addition & 1 deletion libobs/audio-monitoring/pulse/pulseaudio-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static enum speaker_layout pulseaudio_channels_to_obs_speakers(
case 1: return SPEAKERS_MONO;
case 2: return SPEAKERS_STEREO;
case 3: return SPEAKERS_2POINT1;
case 4: return SPEAKERS_QUAD;
case 4: return SPEAKERS_4POINT0;
case 5: return SPEAKERS_4POINT1;
case 6: return SPEAKERS_5POINT1;
case 8: return SPEAKERS_7POINT1;
Expand Down
2 changes: 1 addition & 1 deletion libobs/audio-monitoring/win32/wasapi-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ static enum speaker_layout convert_speaker_layout(DWORD layout, WORD channels)
{
switch (layout) {
case KSAUDIO_SPEAKER_2POINT1: return SPEAKERS_2POINT1;
case KSAUDIO_SPEAKER_SURROUND: return SPEAKERS_4POINT0;
case KSAUDIO_SPEAKER_4POINT1: return SPEAKERS_4POINT1;
case KSAUDIO_SPEAKER_QUAD: return SPEAKERS_QUAD;
case KSAUDIO_SPEAKER_5POINT1: return SPEAKERS_5POINT1;
case KSAUDIO_SPEAKER_7POINT1: return SPEAKERS_7POINT1;
}
Expand Down
4 changes: 2 additions & 2 deletions libobs/media-io/audio-io.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ enum speaker_layout {
SPEAKERS_MONO,
SPEAKERS_STEREO,
SPEAKERS_2POINT1,
SPEAKERS_QUAD,
SPEAKERS_4POINT0,
SPEAKERS_4POINT1,
SPEAKERS_5POINT1,
SPEAKERS_7POINT1=8,
Expand Down Expand Up @@ -99,7 +99,7 @@ static inline uint32_t get_audio_channels(enum speaker_layout speakers)
case SPEAKERS_MONO: return 1;
case SPEAKERS_STEREO: return 2;
case SPEAKERS_2POINT1: return 3;
case SPEAKERS_QUAD: return 4;
case SPEAKERS_4POINT0: return 4;
case SPEAKERS_4POINT1: return 5;
case SPEAKERS_5POINT1: return 6;
case SPEAKERS_7POINT1: return 8;
Expand Down
2 changes: 1 addition & 1 deletion libobs/media-io/audio-resampler-ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static inline uint64_t convert_speaker_layout(enum speaker_layout layout)
case SPEAKERS_MONO: return AV_CH_LAYOUT_MONO;
case SPEAKERS_STEREO: return AV_CH_LAYOUT_STEREO;
case SPEAKERS_2POINT1: return AV_CH_LAYOUT_2_1;
case SPEAKERS_QUAD: return AV_CH_LAYOUT_QUAD;
case SPEAKERS_4POINT0: return AV_CH_LAYOUT_4POINT0;
case SPEAKERS_4POINT1: return AV_CH_LAYOUT_4POINT1;
case SPEAKERS_5POINT1: return AV_CH_LAYOUT_5POINT1;
case SPEAKERS_7POINT1: return AV_CH_LAYOUT_7POINT1;
Expand Down
4 changes: 2 additions & 2 deletions plugins/decklink/decklink-device-instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static inline int ConvertChannelFormat(speaker_layout format)
{
switch (format) {
case SPEAKERS_2POINT1:
case SPEAKERS_QUAD:
case SPEAKERS_4POINT0:
case SPEAKERS_4POINT1:
case SPEAKERS_5POINT1:
case SPEAKERS_7POINT1:
Expand All @@ -46,7 +46,7 @@ static inline int ConvertChannelFormat(speaker_layout format)
static inline audio_repack_mode_t ConvertRepackFormat(speaker_layout format)
{
switch (format) {
case SPEAKERS_QUAD:
case SPEAKERS_4POINT0:
return repack_mode_8to4ch_swap23;
case SPEAKERS_4POINT1:
return repack_mode_8to5ch_swap23;
Expand Down
4 changes: 2 additions & 2 deletions plugins/decklink/plugin-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static bool decklink_device_changed(obs_properties_t *props,

if (device->GetMaxChannel() >= 8) {
obs_property_list_add_int(channelList, TEXT_CHANNEL_FORMAT_4_0CH,
SPEAKERS_QUAD);
SPEAKERS_4POINT0);
obs_property_list_add_int(channelList, TEXT_CHANNEL_FORMAT_5_1CH,
SPEAKERS_5POINT1);
obs_property_list_add_int(channelList, TEXT_CHANNEL_FORMAT_7_1CH,
Expand Down Expand Up @@ -258,7 +258,7 @@ static obs_properties_t *decklink_get_properties(void *data)
obs_property_list_add_int(list, TEXT_CHANNEL_FORMAT_2_1CH,
SPEAKERS_2POINT1);
obs_property_list_add_int(list, TEXT_CHANNEL_FORMAT_4_0CH,
SPEAKERS_QUAD);
SPEAKERS_4POINT0);
obs_property_list_add_int(list, TEXT_CHANNEL_FORMAT_4_1CH,
SPEAKERS_4POINT1);
obs_property_list_add_int(list, TEXT_CHANNEL_FORMAT_5_1CH,
Expand Down
2 changes: 1 addition & 1 deletion plugins/linux-alsa/alsa-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ enum speaker_layout _alsa_channels_to_obs_speakers(unsigned int channels)
case 1: return SPEAKERS_MONO;
case 2: return SPEAKERS_STEREO;
case 3: return SPEAKERS_2POINT1;
case 4: return SPEAKERS_QUAD;
case 4: return SPEAKERS_4POINT0;
case 5: return SPEAKERS_4POINT1;
case 6: return SPEAKERS_5POINT1;
case 8: return SPEAKERS_7POINT1;
Expand Down
2 changes: 1 addition & 1 deletion plugins/linux-pulseaudio/pulse-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static enum speaker_layout pulse_channels_to_obs_speakers(
case 1: return SPEAKERS_MONO;
case 2: return SPEAKERS_STEREO;
case 3: return SPEAKERS_2POINT1;
case 4: return SPEAKERS_QUAD;
case 4: return SPEAKERS_4POINT0;
case 5: return SPEAKERS_4POINT1;
case 6: return SPEAKERS_5POINT1;
case 8: return SPEAKERS_7POINT1;
Expand Down
2 changes: 1 addition & 1 deletion plugins/mac-capture/mac-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static inline enum speaker_layout convert_ca_speaker_layout(UInt32 channels)
case 1: return SPEAKERS_MONO;
case 2: return SPEAKERS_STEREO;
case 3: return SPEAKERS_2POINT1;
case 4: return SPEAKERS_QUAD;
case 4: return SPEAKERS_4POINT0;
case 5: return SPEAKERS_4POINT1;
case 6: return SPEAKERS_5POINT1;
case 8: return SPEAKERS_7POINT1;
Expand Down
4 changes: 2 additions & 2 deletions plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static inline uint64_t convert_speaker_layout(enum speaker_layout layout)
case SPEAKERS_MONO: return AV_CH_LAYOUT_MONO;
case SPEAKERS_STEREO: return AV_CH_LAYOUT_STEREO;
case SPEAKERS_2POINT1: return AV_CH_LAYOUT_2_1;
case SPEAKERS_QUAD: return AV_CH_LAYOUT_QUAD;
case SPEAKERS_4POINT0: return AV_CH_LAYOUT_4POINT0;
case SPEAKERS_4POINT1: return AV_CH_LAYOUT_4POINT1;
case SPEAKERS_5POINT1: return AV_CH_LAYOUT_5POINT1;
case SPEAKERS_7POINT1: return AV_CH_LAYOUT_7POINT1;
Expand All @@ -79,7 +79,7 @@ static inline enum speaker_layout convert_ff_channel_layout(uint64_t channel_la
case AV_CH_LAYOUT_MONO: return SPEAKERS_MONO;
case AV_CH_LAYOUT_STEREO: return SPEAKERS_STEREO;
case AV_CH_LAYOUT_2_1: return SPEAKERS_2POINT1;
case AV_CH_LAYOUT_QUAD: return SPEAKERS_QUAD;
case AV_CH_LAYOUT_4POINT0: return SPEAKERS_4POINT0;
case AV_CH_LAYOUT_4POINT1: return SPEAKERS_4POINT1;
case AV_CH_LAYOUT_5POINT1: return SPEAKERS_5POINT1;
case AV_CH_LAYOUT_7POINT1: return SPEAKERS_7POINT1;
Expand Down
4 changes: 0 additions & 4 deletions plugins/obs-ffmpeg/obs-ffmpeg-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,6 @@ static bool create_audio_stream(struct ffmpeg_data *data)
context->channel_layout =
av_get_default_channel_layout(context->channels);

//AVlib default channel layout for 4 channels is 4.0 ; fix for quad
if (aoi.speakers == SPEAKERS_QUAD)
context->channel_layout = av_get_channel_layout("quad");

//AVlib default channel layout for 5 channels is 5.0 ; fix for 4.1
if (aoi.speakers == SPEAKERS_4POINT1)
context->channel_layout = av_get_channel_layout("4.1");
Expand Down
2 changes: 1 addition & 1 deletion plugins/obs-outputs/flv-mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static bool build_flv_meta_data(obs_output_t *context,
audio_output_get_channels(audio) == 3);
enc_bool_val(&enc, end, "3.1",
audio_output_get_channels(audio) == 4);
enc_bool_val(&enc, end, "4.0 Quad",
enc_bool_val(&enc, end, "4.0",
audio_output_get_channels(audio) == 4);
enc_bool_val(&enc, end, "4.1",
audio_output_get_channels(audio) == 5);
Expand Down
2 changes: 1 addition & 1 deletion plugins/win-dshow/ffmpeg-decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static inline enum speaker_layout convert_speaker_layout(uint8_t channels)
case 1: return SPEAKERS_MONO;
case 2: return SPEAKERS_STEREO;
case 3: return SPEAKERS_2POINT1;
case 4: return SPEAKERS_QUAD;
case 4: return SPEAKERS_4POINT0;
case 5: return SPEAKERS_4POINT1;
case 6: return SPEAKERS_5POINT1;
case 8: return SPEAKERS_7POINT1;
Expand Down
2 changes: 1 addition & 1 deletion plugins/win-dshow/win-dshow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ static inline enum speaker_layout convert_speaker_layout(uint8_t channels)
case 1: return SPEAKERS_MONO;
case 2: return SPEAKERS_STEREO;
case 3: return SPEAKERS_2POINT1;
case 4: return SPEAKERS_QUAD;
case 4: return SPEAKERS_4POINT0;
case 5: return SPEAKERS_4POINT1;
case 6: return SPEAKERS_5POINT1;
case 8: return SPEAKERS_7POINT1;
Expand Down
2 changes: 1 addition & 1 deletion plugins/win-wasapi/win-wasapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static speaker_layout ConvertSpeakerLayout(DWORD layout, WORD channels)
{
switch (layout) {
case KSAUDIO_SPEAKER_2POINT1: return SPEAKERS_2POINT1;
case KSAUDIO_SPEAKER_QUAD: return SPEAKERS_QUAD;
case KSAUDIO_SPEAKER_SURROUND: return SPEAKERS_4POINT0;
case KSAUDIO_SPEAKER_4POINT1: return SPEAKERS_4POINT1;
case KSAUDIO_SPEAKER_5POINT1_SURROUND: return SPEAKERS_5POINT1;
case KSAUDIO_SPEAKER_7POINT1_SURROUND: return SPEAKERS_7POINT1;
Expand Down

0 comments on commit 67e48ec

Please sign in to comment.