(API Change) Split obs_source_gettype

Changed:
- obs_source_gettype
To:
- enum obs_source_type obs_source_get_type(obs_source_t source);
- const char *obs_source_get_id(obs_source_t source);

This function was inconsistent for a number of reasons.  First, it
returns both the ID and the type of source (input/transition/filter),
which is inconsistent with the name of "get type".  Secondly, the
'squishy' naming convention which has just turned out to be bad
practice and causes inconsistencies.  So it's now replaced with two
functions that just return the type and the ID.
This commit is contained in:
jp9000 2014-08-02 12:42:47 -07:00
parent 0961af6e66
commit e42af67128
5 changed files with 17 additions and 23 deletions

View file

@ -1640,13 +1640,14 @@ void obs_source_setname(obs_source_t source, const char *name)
}
}
void obs_source_gettype(obs_source_t source, enum obs_source_type *type,
const char **id)
enum obs_source_type obs_source_get_type(obs_source_t source)
{
if (!source) return;
return source ? source->info.type : OBS_SOURCE_TYPE_INPUT;
}
if (type) *type = source->info.type;
if (id) *id = source->info.id;
const char *obs_source_get_id(obs_source_t source)
{
return source ? source->info.id : NULL;
}
static inline void render_filter_bypass(obs_source_t target, effect_t effect,

View file

@ -1204,12 +1204,10 @@ obs_data_t obs_save_source(obs_source_t source)
obs_data_t settings = obs_source_getsettings(source);
float volume = obs_source_getvolume(source);
const char *name = obs_source_getname(source);
const char *id;
const char *id = obs_source_get_id(source);
obs_source_save(source);
obs_source_gettype(source, NULL, &id);
obs_data_setstring(source_data, "name", name);
obs_data_setstring(source_data, "id", id);
obs_data_setobj (source_data, "settings", settings);

View file

@ -646,9 +646,11 @@ EXPORT const char *obs_source_getname(obs_source_t source);
/** Sets the name of a source */
EXPORT void obs_source_setname(obs_source_t source, const char *name);
/** Gets the source type and identifier */
EXPORT void obs_source_gettype(obs_source_t source, enum obs_source_type *type,
const char **id);
/** Gets the source type */
EXPORT enum obs_source_type obs_source_get_type(obs_source_t source);
/** Gets the source identifier */
EXPORT const char *obs_source_get_id(obs_source_t source);
/** Returns the signal handler for a source */
EXPORT signal_handler_t obs_source_signalhandler(obs_source_t source);

View file

@ -738,9 +738,6 @@ void OBSBasic::RemoveSceneItem(OBSSceneItem item)
void OBSBasic::UpdateSceneSelection(OBSSource source)
{
if (source) {
obs_source_type type;
obs_source_gettype(source, &type, NULL);
obs_scene_t scene = obs_scene_fromsource(source);
const char *name = obs_source_getname(source);

View file

@ -25,9 +25,7 @@ bool OBSBasicSourceSelect::EnumSources(void *data, obs_source_t source)
{
OBSBasicSourceSelect *window = static_cast<OBSBasicSourceSelect*>(data);
const char *name = obs_source_getname(source);
const char *id;
obs_source_gettype(source, nullptr, &id);
const char *id = obs_source_get_id(source);
if (strcmp(id, window->id) == 0)
window->ui->sourceList->addItem(QT_UTF8(name));
@ -55,10 +53,9 @@ void OBSBasicSourceSelect::OBSSourceRemoved(void *data, calldata_t calldata)
void OBSBasicSourceSelect::SourceAdded(OBSSource source)
{
const char *name = obs_source_getname(source);
const char *sourceId;
const char *name = obs_source_getname(source);
const char *sourceId = obs_source_get_id(source);
obs_source_gettype(source, nullptr, &sourceId);
if (strcmp(sourceId, id) != 0)
return;
@ -67,10 +64,9 @@ void OBSBasicSourceSelect::SourceAdded(OBSSource source)
void OBSBasicSourceSelect::SourceRemoved(OBSSource source)
{
const char *name = obs_source_getname(source);
const char *sourceId;
const char *name = obs_source_getname(source);
const char *sourceId = obs_source_get_id(source);
obs_source_gettype(source, nullptr, &sourceId);
if (strcmp(sourceId, id) != 0)
return;