ao: remove trailing NULL element from driver array

This commit is contained in:
Thomas Weißschuh 2023-01-14 18:19:40 +00:00 committed by Dudemanguy
parent 50169e05d8
commit 98c2fa095d
1 changed files with 3 additions and 4 deletions

View File

@ -102,12 +102,11 @@ static const struct ao_driver * const audio_out_drivers[] = {
#endif
&audio_out_pcm,
&audio_out_lavc,
NULL
};
static bool get_desc(struct m_obj_desc *dst, int index)
{
if (index >= MP_ARRAY_SIZE(audio_out_drivers) - 1)
if (index >= MP_ARRAY_SIZE(audio_out_drivers))
return false;
const struct ao_driver *ao = audio_out_drivers[index];
*dst = (struct m_obj_desc) {
@ -313,7 +312,7 @@ struct ao *ao_init_best(struct mpv_global *global,
}
if (autoprobe) {
for (int n = 0; audio_out_drivers[n]; n++) {
for (int n = 0; n < MP_ARRAY_SIZE(audio_out_drivers); n++) {
const struct ao_driver *driver = audio_out_drivers[n];
if (driver == &audio_out_null)
break;
@ -521,7 +520,7 @@ struct ao_device_list *ao_hotplug_get_device_list(struct ao_hotplug *hp,
}
}
for (int n = 0; audio_out_drivers[n]; n++) {
for (int n = 0; n < MP_ARRAY_SIZE(audio_out_drivers); n++) {
const struct ao_driver *d = audio_out_drivers[n];
if (d == &audio_out_null)
break; // don't add unsafe/special entries