aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-06-15 02:27:29 -0700
committerChris Robinson <[email protected]>2020-06-15 02:27:29 -0700
commit401a9bacd17ef7a08053a4edbc09d93c6f78a291 (patch)
treea58389efcc14cacdf419cbd2724ea2b2c2649a74
parent540315b07c086f4c9af1c632e7464433332de4a8 (diff)
Don't bother with otherwise unused Aux channels
-rw-r--r--alc/backends/base.cpp25
-rw-r--r--alc/backends/pulseaudio.cpp70
-rw-r--r--alc/devformat.h17
-rw-r--r--alc/panning.cpp30
4 files changed, 39 insertions, 103 deletions
diff --git a/alc/backends/base.cpp b/alc/backends/base.cpp
index c0783f86..45a1c25d 100644
--- a/alc/backends/base.cpp
+++ b/alc/backends/base.cpp
@@ -100,31 +100,6 @@ void BackendBase::setDefaultWFXChannelOrder()
mDevice->RealOut.ChannelIndex[SideRight] = 7;
break;
case DevFmtAmbi3D:
- mDevice->RealOut.ChannelIndex[Aux0] = 0;
- if(mDevice->mAmbiOrder > 0)
- {
- mDevice->RealOut.ChannelIndex[Aux1] = 1;
- mDevice->RealOut.ChannelIndex[Aux2] = 2;
- mDevice->RealOut.ChannelIndex[Aux3] = 3;
- }
- if(mDevice->mAmbiOrder > 1)
- {
- mDevice->RealOut.ChannelIndex[Aux4] = 4;
- mDevice->RealOut.ChannelIndex[Aux5] = 5;
- mDevice->RealOut.ChannelIndex[Aux6] = 6;
- mDevice->RealOut.ChannelIndex[Aux7] = 7;
- mDevice->RealOut.ChannelIndex[Aux8] = 8;
- }
- if(mDevice->mAmbiOrder > 2)
- {
- mDevice->RealOut.ChannelIndex[Aux9] = 9;
- mDevice->RealOut.ChannelIndex[Aux10] = 10;
- mDevice->RealOut.ChannelIndex[Aux11] = 11;
- mDevice->RealOut.ChannelIndex[Aux12] = 12;
- mDevice->RealOut.ChannelIndex[Aux13] = 13;
- mDevice->RealOut.ChannelIndex[Aux14] = 14;
- mDevice->RealOut.ChannelIndex[Aux15] = 15;
- }
break;
}
}
diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp
index 8ebea1d9..aa9b0b4a 100644
--- a/alc/backends/pulseaudio.cpp
+++ b/alc/backends/pulseaudio.cpp
@@ -219,39 +219,39 @@ constexpr pa_channel_map MonoChanMap{
}
};
-size_t ChannelFromPulse(pa_channel_position_t chan)
+al::optional<Channel> ChannelFromPulse(pa_channel_position_t chan)
{
switch(chan)
{
case PA_CHANNEL_POSITION_INVALID: break;
- case PA_CHANNEL_POSITION_MONO: return FrontCenter;
- case PA_CHANNEL_POSITION_FRONT_LEFT: return FrontLeft;
- case PA_CHANNEL_POSITION_FRONT_RIGHT: return FrontRight;
- case PA_CHANNEL_POSITION_FRONT_CENTER: return FrontCenter;
- case PA_CHANNEL_POSITION_REAR_CENTER: return BackCenter;
- case PA_CHANNEL_POSITION_REAR_LEFT: return BackLeft;
- case PA_CHANNEL_POSITION_REAR_RIGHT: return BackRight;
- case PA_CHANNEL_POSITION_LFE: return LFE;
+ case PA_CHANNEL_POSITION_MONO: return al::make_optional(FrontCenter);
+ case PA_CHANNEL_POSITION_FRONT_LEFT: return al::make_optional(FrontLeft);
+ case PA_CHANNEL_POSITION_FRONT_RIGHT: return al::make_optional(FrontRight);
+ case PA_CHANNEL_POSITION_FRONT_CENTER: return al::make_optional(FrontCenter);
+ case PA_CHANNEL_POSITION_REAR_CENTER: return al::make_optional(BackCenter);
+ case PA_CHANNEL_POSITION_REAR_LEFT: return al::make_optional(BackLeft);
+ case PA_CHANNEL_POSITION_REAR_RIGHT: return al::make_optional(BackRight);
+ case PA_CHANNEL_POSITION_LFE: return al::make_optional(LFE);
case PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER: break;
case PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER: break;
- case PA_CHANNEL_POSITION_SIDE_LEFT: return SideLeft;
- case PA_CHANNEL_POSITION_SIDE_RIGHT: return SideRight;
- case PA_CHANNEL_POSITION_AUX0: return Aux0;
- case PA_CHANNEL_POSITION_AUX1: return Aux1;
- case PA_CHANNEL_POSITION_AUX2: return Aux2;
- case PA_CHANNEL_POSITION_AUX3: return Aux3;
- case PA_CHANNEL_POSITION_AUX4: return Aux4;
- case PA_CHANNEL_POSITION_AUX5: return Aux5;
- case PA_CHANNEL_POSITION_AUX6: return Aux6;
- case PA_CHANNEL_POSITION_AUX7: return Aux7;
- case PA_CHANNEL_POSITION_AUX8: return Aux8;
- case PA_CHANNEL_POSITION_AUX9: return Aux9;
- case PA_CHANNEL_POSITION_AUX10: return Aux10;
- case PA_CHANNEL_POSITION_AUX11: return Aux11;
- case PA_CHANNEL_POSITION_AUX12: return Aux12;
- case PA_CHANNEL_POSITION_AUX13: return Aux13;
- case PA_CHANNEL_POSITION_AUX14: return Aux14;
- case PA_CHANNEL_POSITION_AUX15: return Aux15;
+ case PA_CHANNEL_POSITION_SIDE_LEFT: return al::make_optional(SideLeft);
+ case PA_CHANNEL_POSITION_SIDE_RIGHT: return al::make_optional(SideRight);
+ case PA_CHANNEL_POSITION_AUX0: break;
+ case PA_CHANNEL_POSITION_AUX1: break;
+ case PA_CHANNEL_POSITION_AUX2: break;
+ case PA_CHANNEL_POSITION_AUX3: break;
+ case PA_CHANNEL_POSITION_AUX4: break;
+ case PA_CHANNEL_POSITION_AUX5: break;
+ case PA_CHANNEL_POSITION_AUX6: break;
+ case PA_CHANNEL_POSITION_AUX7: break;
+ case PA_CHANNEL_POSITION_AUX8: break;
+ case PA_CHANNEL_POSITION_AUX9: break;
+ case PA_CHANNEL_POSITION_AUX10: break;
+ case PA_CHANNEL_POSITION_AUX11: break;
+ case PA_CHANNEL_POSITION_AUX12: break;
+ case PA_CHANNEL_POSITION_AUX13: break;
+ case PA_CHANNEL_POSITION_AUX14: break;
+ case PA_CHANNEL_POSITION_AUX15: break;
case PA_CHANNEL_POSITION_AUX16: break;
case PA_CHANNEL_POSITION_AUX17: break;
case PA_CHANNEL_POSITION_AUX18: break;
@@ -269,22 +269,26 @@ size_t ChannelFromPulse(pa_channel_position_t chan)
case PA_CHANNEL_POSITION_AUX30: break;
case PA_CHANNEL_POSITION_AUX31: break;
case PA_CHANNEL_POSITION_TOP_CENTER: break;
- case PA_CHANNEL_POSITION_TOP_FRONT_LEFT: return UpperFrontLeft;
- case PA_CHANNEL_POSITION_TOP_FRONT_RIGHT: return UpperFrontRight;
+ case PA_CHANNEL_POSITION_TOP_FRONT_LEFT: return al::make_optional(UpperFrontLeft);
+ case PA_CHANNEL_POSITION_TOP_FRONT_RIGHT: return al::make_optional(UpperFrontRight);
case PA_CHANNEL_POSITION_TOP_FRONT_CENTER: break;
- case PA_CHANNEL_POSITION_TOP_REAR_LEFT: return UpperBackLeft;
- case PA_CHANNEL_POSITION_TOP_REAR_RIGHT: return UpperBackRight;
+ case PA_CHANNEL_POSITION_TOP_REAR_LEFT: return al::make_optional(UpperBackLeft);
+ case PA_CHANNEL_POSITION_TOP_REAR_RIGHT: return al::make_optional(UpperBackRight);
case PA_CHANNEL_POSITION_TOP_REAR_CENTER: break;
case PA_CHANNEL_POSITION_MAX: break;
}
- throw al::backend_exception{ALC_INVALID_VALUE, "Unexpected channel enum %d", chan};
+ WARN("Unexpected channel enum %d\n", chan);
+ return al::nullopt;
}
void SetChannelOrderFromMap(ALCdevice *device, const pa_channel_map &chanmap)
{
device->RealOut.ChannelIndex.fill(INVALID_CHANNEL_INDEX);
for(ALuint i{0};i < chanmap.channels;++i)
- device->RealOut.ChannelIndex[ChannelFromPulse(chanmap.map[i])] = i;
+ {
+ if(auto label = ChannelFromPulse(chanmap.map[i]))
+ device->RealOut.ChannelIndex[*label] = i;
+ }
}
diff --git a/alc/devformat.h b/alc/devformat.h
index 402fb8bd..d1624c9c 100644
--- a/alc/devformat.h
+++ b/alc/devformat.h
@@ -29,23 +29,6 @@ enum Channel {
LowerBackLeft,
LowerBackRight,
- Aux0,
- Aux1,
- Aux2,
- Aux3,
- Aux4,
- Aux5,
- Aux6,
- Aux7,
- Aux8,
- Aux9,
- Aux10,
- Aux11,
- Aux12,
- Aux13,
- Aux14,
- Aux15,
-
MaxChannels
};
diff --git a/alc/panning.cpp b/alc/panning.cpp
index e62e2baf..655450b8 100644
--- a/alc/panning.cpp
+++ b/alc/panning.cpp
@@ -99,23 +99,6 @@ inline const char *GetLabelFromChannel(Channel channel)
case LowerBackLeft: return "lower-back-left";
case LowerBackRight: return "lower-back-right";
- case Aux0: return "aux-0";
- case Aux1: return "aux-1";
- case Aux2: return "aux-2";
- case Aux3: return "aux-3";
- case Aux4: return "aux-4";
- case Aux5: return "aux-5";
- case Aux6: return "aux-6";
- case Aux7: return "aux-7";
- case Aux8: return "aux-8";
- case Aux9: return "aux-9";
- case Aux10: return "aux-10";
- case Aux11: return "aux-11";
- case Aux12: return "aux-12";
- case Aux13: return "aux-13";
- case Aux14: return "aux-14";
- case Aux15: return "aux-15";
-
case MaxChannels: break;
}
return "(unknown)";
@@ -228,17 +211,8 @@ bool MakeSpeakerMap(ALCdevice *device, const AmbDecConf *conf, ALuint (&speakerm
ch = BackCenter;
else
{
- const char *name{speaker.Name.c_str()};
- unsigned int n;
- char c;
-
- if(sscanf(name, "AUX%u%c", &n, &c) == 1 && n < 16)
- ch = static_cast<Channel>(Aux0+n);
- else
- {
- ERR("AmbDec speaker label \"%s\" not recognized\n", name);
- return INVALID_CHANNEL_INDEX;
- }
+ ERR("AmbDec speaker label \"%s\" not recognized\n", speaker.Name.c_str());
+ return INVALID_CHANNEL_INDEX;
}
const ALuint chidx{GetChannelIdxByName(device->RealOut, ch)};
if(chidx == INVALID_CHANNEL_INDEX)