libobs: Change return type for getting filter index

This changes the return type for getting the filter index from a
size_t to an int. This makes it easier for developers to use,
as an invalid index just returns a -1.
This commit is contained in:
cg2121
2023-06-25 03:29:05 -05:00
committed by Lain
parent ee530c2f49
commit cb8b5ba9cd
3 changed files with 7 additions and 7 deletions

View File

@@ -1281,7 +1281,7 @@ void OBSBasicFilters::FiltersMoved(const QModelIndex &, int srcIdxStart, int,
neighborIdx = 0;
OBSSource neighbor = GetFilter(neighborIdx, isAsync);
size_t idx = obs_source_filter_get_index(source, neighbor);
int idx = obs_source_filter_get_index(source, neighbor);
OBSSource filter = GetFilter(list->currentRow(), isAsync);
obs_source_filter_set_index(source, filter, idx);

View File

@@ -3294,12 +3294,12 @@ void obs_source_filter_set_order(obs_source_t *source, obs_source_t *filter,
obs_source_dosignal(source, NULL, "reorder_filters");
}
size_t obs_source_filter_get_index(obs_source_t *source, obs_source_t *filter)
int obs_source_filter_get_index(obs_source_t *source, obs_source_t *filter)
{
if (!obs_source_valid(source, "obs_source_filter_get_index"))
return DARRAY_INVALID;
return -1;
if (!obs_ptr_valid(filter, "obs_source_filter_get_index"))
return DARRAY_INVALID;
return -1;
size_t idx;
@@ -3307,7 +3307,7 @@ size_t obs_source_filter_get_index(obs_source_t *source, obs_source_t *filter)
idx = da_find(source->filters, &filter, 0);
pthread_mutex_unlock(&source->filter_mutex);
return idx;
return idx != DARRAY_INVALID ? (int)idx : -1;
}
static bool set_filter_index(obs_source_t *source, obs_source_t *filter,

View File

@@ -1134,8 +1134,8 @@ EXPORT void obs_source_filter_set_order(obs_source_t *source,
enum obs_order_movement movement);
/** Gets filter index */
EXPORT size_t obs_source_filter_get_index(obs_source_t *source,
obs_source_t *filter);
EXPORT int obs_source_filter_get_index(obs_source_t *source,
obs_source_t *filter);
/** Sets filter index */
EXPORT void obs_source_filter_set_index(obs_source_t *source,