Split output/input audio capture sources
- Split input and output audio captures so that they're different sources. This allows easier handling and enumeration of audio devices without having to do some sort of string processing. This way the user interface code can handle this a bit more easily, and so that it doesn't confuse users either. This should be done for all audio capture sources for all operating systems. You don't have to duplicate any code, you just need to create input/output wrapper functions to designate the audio as input or output before creation. - Make it detect soundflower and wavtap devices as mac "output" devices (even though they're actually input) for the mac output capture, and make it so that users can select a default output capture and automatically use soundflower or wavtap. I'm not entirely happy about having to do this, but because mac is designed this way, this is really the only way to handle it that makes it easier for users and UI code to deal with. Note that soundflower and wavtap are still also designated as input devices, so will still show up in input device enumeration. - Remove pragma messages because they were kind polluting the other compiler messages and just getting in the way. In the future we can just do a grep for TODO to find them. - Redo list property again, this time using a safer internal array, rather than requiring sketchy array inputs. Having functions handle everything behind the scenes is much safer. - Remove the reference counter debug log code, as it was included unintentionally in a commit.
This commit is contained in:
@@ -560,7 +560,6 @@ void gs_normal3v(const struct vec3 *v)
|
||||
void gs_color4v(const struct vec4 *v)
|
||||
{
|
||||
/* TODO */
|
||||
#pragma message ("TODO: implement gs_color4v")
|
||||
UNUSED_PARAMETER(v);
|
||||
}
|
||||
|
||||
@@ -577,7 +576,6 @@ void gs_texcoord2v(const struct vec2 *v, int unit)
|
||||
input_t gs_getinput(void)
|
||||
{
|
||||
/* TODO */
|
||||
#pragma message ("TODO: implement gs_getinput (hmm, not sure about input yet)")
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -677,7 +675,6 @@ shader_t gs_create_pixelshader_from_file(const char *file, char **error_string)
|
||||
texture_t gs_create_texture_from_file(const char *file, uint32_t flags)
|
||||
{
|
||||
/* TODO */
|
||||
#pragma message ("TODO: implement gs_create_texture_from_file")
|
||||
UNUSED_PARAMETER(file);
|
||||
UNUSED_PARAMETER(flags);
|
||||
return NULL;
|
||||
@@ -686,7 +683,6 @@ texture_t gs_create_texture_from_file(const char *file, uint32_t flags)
|
||||
texture_t gs_create_cubetexture_from_file(const char *file, uint32_t flags)
|
||||
{
|
||||
/* TODO */
|
||||
#pragma message ("TODO: implement gs_create_cubetexture_from_file")
|
||||
UNUSED_PARAMETER(file);
|
||||
UNUSED_PARAMETER(flags);
|
||||
return NULL;
|
||||
@@ -695,7 +691,6 @@ texture_t gs_create_cubetexture_from_file(const char *file, uint32_t flags)
|
||||
texture_t gs_create_volumetexture_from_file(const char *file, uint32_t flags)
|
||||
{
|
||||
/* TODO */
|
||||
#pragma message ("TODO: implement gs_create_volumetexture_from_file")
|
||||
UNUSED_PARAMETER(file);
|
||||
UNUSED_PARAMETER(flags);
|
||||
return NULL;
|
||||
@@ -799,7 +794,6 @@ void gs_draw_cube_backdrop(texture_t cubetex, const struct quat *rot,
|
||||
float left, float right, float top, float bottom, float znear)
|
||||
{
|
||||
/* TODO */
|
||||
#pragma message ("TODO: implement gs_draw_cube_backdrop")
|
||||
UNUSED_PARAMETER(cubetex);
|
||||
UNUSED_PARAMETER(rot);
|
||||
UNUSED_PARAMETER(left);
|
||||
@@ -827,7 +821,6 @@ void gs_set2dmode(void)
|
||||
void gs_set3dmode(double fovy, double znear, double zvar)
|
||||
{
|
||||
/* TODO */
|
||||
#pragma message ("TODO: implement gs_set3dmode")
|
||||
UNUSED_PARAMETER(fovy);
|
||||
UNUSED_PARAMETER(znear);
|
||||
UNUSED_PARAMETER(zvar);
|
||||
@@ -893,7 +886,6 @@ void cubetexture_setimage(texture_t cubetex, uint32_t side, const void *data,
|
||||
uint32_t linesize, bool invert)
|
||||
{
|
||||
/* TODO */
|
||||
#pragma message ("TODO: implement cubetexture_setimage")
|
||||
UNUSED_PARAMETER(cubetex);
|
||||
UNUSED_PARAMETER(side);
|
||||
UNUSED_PARAMETER(data);
|
||||
|
@@ -237,7 +237,6 @@ obs_data_t obs_data_create()
|
||||
obs_data_t obs_data_create_from_json(const char *json_string)
|
||||
{
|
||||
/* TODO */
|
||||
#pragma message ("TODO: implement obs_data_create_from_json")
|
||||
UNUSED_PARAMETER(json_string);
|
||||
return NULL;
|
||||
}
|
||||
@@ -275,7 +274,6 @@ const char *obs_data_getjson(obs_data_t data)
|
||||
if (!data) return NULL;
|
||||
|
||||
/* TODO */
|
||||
#pragma message ("TODO: implement obs_data_getjson")
|
||||
return data->json;
|
||||
}
|
||||
|
||||
|
@@ -91,8 +91,8 @@ void obs_encoder_destroy(obs_encoder_t encoder)
|
||||
obs_properties_t obs_encoder_properties(const char *id, const char *locale)
|
||||
{
|
||||
const struct obs_encoder_info *ei = get_encoder_info(id);
|
||||
if (ei && ei->get_properties)
|
||||
return ei->get_properties(locale);
|
||||
if (ei && ei->properties)
|
||||
return ei->properties(locale);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ bool obs_encoder_start(obs_encoder_t encoder,
|
||||
void (*new_packet)(void *param, struct encoder_packet *packet),
|
||||
void *param)
|
||||
{
|
||||
#pragma message ("TODO: implement obs_encoder_start")
|
||||
/* TODO: implement */
|
||||
UNUSED_PARAMETER(encoder);
|
||||
UNUSED_PARAMETER(new_packet);
|
||||
UNUSED_PARAMETER(param);
|
||||
@@ -155,7 +155,7 @@ void obs_encoder_stop(obs_encoder_t encoder,
|
||||
void (*new_packet)(void *param, struct encoder_packet *packet),
|
||||
void *param)
|
||||
{
|
||||
#pragma message ("TODO: implement obs_encoder_stop")
|
||||
/* TODO: implement */
|
||||
UNUSED_PARAMETER(encoder);
|
||||
UNUSED_PARAMETER(new_packet);
|
||||
UNUSED_PARAMETER(param);
|
||||
|
@@ -140,7 +140,7 @@ struct obs_encoder_info {
|
||||
* @param locale The locale to translate with
|
||||
* @return The properties data
|
||||
*/
|
||||
obs_properties_t (*get_properties)(const char *locale);
|
||||
obs_properties_t (*properties)(const char *locale);
|
||||
|
||||
/**
|
||||
* Updates the settings for this encoder
|
||||
|
@@ -214,7 +214,6 @@ void obs_register_encoder(const struct obs_encoder_info *info)
|
||||
void obs_register_service(const struct obs_service_info *info)
|
||||
{
|
||||
/* TODO */
|
||||
#pragma message ("TODO: implement obs_register_service")
|
||||
UNUSED_PARAMETER(info);
|
||||
}
|
||||
|
||||
|
@@ -16,18 +16,11 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include "util/bmem.h"
|
||||
#include "util/darray.h"
|
||||
#include "obs-properties.h"
|
||||
|
||||
static inline void *get_property_data(struct obs_property *prop);
|
||||
|
||||
static inline void free_str_list(char **str_list)
|
||||
{
|
||||
char **temp_list = str_list;
|
||||
while (*temp_list)
|
||||
bfree(*(temp_list++));
|
||||
bfree(str_list);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
struct float_data {
|
||||
@@ -38,17 +31,25 @@ struct int_data {
|
||||
int min, max, step;
|
||||
};
|
||||
|
||||
struct list_item {
|
||||
char *name;
|
||||
char *value;
|
||||
};
|
||||
|
||||
struct list_data {
|
||||
char **names;
|
||||
char **values;
|
||||
enum obs_combo_type type;
|
||||
enum obs_combo_format format;
|
||||
DARRAY(struct list_item) items;
|
||||
enum obs_combo_type type;
|
||||
enum obs_combo_format format;
|
||||
};
|
||||
|
||||
static inline void list_data_free(struct list_data *data)
|
||||
{
|
||||
free_str_list(data->names);
|
||||
free_str_list(data->values);
|
||||
for (size_t i = 0; i < data->items.num; i++) {
|
||||
bfree(data->items.array[i].name);
|
||||
bfree(data->items.array[i].value);
|
||||
}
|
||||
|
||||
da_free(data->items);
|
||||
}
|
||||
|
||||
struct obs_property {
|
||||
@@ -136,7 +137,7 @@ static inline size_t get_property_size(enum obs_property_type type)
|
||||
case OBS_PROPERTY_FLOAT: return sizeof(struct float_data);
|
||||
case OBS_PROPERTY_TEXT: return 0;
|
||||
case OBS_PROPERTY_PATH: return 0;
|
||||
case OBS_PROPERTY_LIST: return sizeof(struct list_data);
|
||||
case OBS_PROPERTY_LIST: return sizeof(struct list_data);
|
||||
case OBS_PROPERTY_COLOR: return 0;
|
||||
}
|
||||
|
||||
@@ -228,47 +229,26 @@ void obs_properties_add_path(obs_properties_t props, const char *name,
|
||||
new_prop(props, name, desc, OBS_PROPERTY_PATH);
|
||||
}
|
||||
|
||||
static char **dup_str_list(const char **str_list)
|
||||
{
|
||||
int count = 0;
|
||||
char **new_list;
|
||||
const char **temp_list = str_list;
|
||||
|
||||
if (!str_list)
|
||||
return NULL;
|
||||
|
||||
while (*(temp_list++) != NULL)
|
||||
count++;
|
||||
|
||||
new_list = bmalloc((count+1) * sizeof(char*));
|
||||
new_list[count] = NULL;
|
||||
for (int i = 0; i < count; i++)
|
||||
new_list[i] = bstrdup(str_list[i]);
|
||||
|
||||
return new_list;
|
||||
}
|
||||
|
||||
void obs_properties_add_list(obs_properties_t props,
|
||||
obs_property_t obs_properties_add_list(obs_properties_t props,
|
||||
const char *name, const char *desc,
|
||||
const char **value_names, const char **values,
|
||||
enum obs_combo_type type,
|
||||
enum obs_combo_format format)
|
||||
{
|
||||
if (!props || has_prop(props, name)) return;
|
||||
if (!props || has_prop(props, name)) return NULL;
|
||||
|
||||
if (type == OBS_COMBO_TYPE_EDITABLE &&
|
||||
format != OBS_COMBO_FORMAT_STRING) {
|
||||
blog(LOG_WARNING, "List '%s', error: Editable combo boxes "
|
||||
"must be of the 'string' type", name);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct obs_property *p = new_prop(props, name, desc, OBS_PROPERTY_LIST);
|
||||
struct list_data *data = get_property_data(p);
|
||||
data->names = dup_str_list(value_names);
|
||||
data->values = dup_str_list(values);
|
||||
data->format = format;
|
||||
data->type = type;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void obs_properties_add_color(obs_properties_t props, const char *name,
|
||||
@@ -278,6 +258,34 @@ void obs_properties_add_color(obs_properties_t props, const char *name,
|
||||
new_prop(props, name, desc, OBS_PROPERTY_COLOR);
|
||||
}
|
||||
|
||||
|
||||
static inline bool is_combo(struct obs_property *p)
|
||||
{
|
||||
return p->type == OBS_PROPERTY_LIST;
|
||||
}
|
||||
|
||||
static inline struct list_data *get_list_data(struct obs_property *p)
|
||||
{
|
||||
if (!p || !is_combo(p))
|
||||
return NULL;
|
||||
|
||||
return get_property_data(p);
|
||||
}
|
||||
|
||||
void obs_property_list_add_item(obs_property_t p,
|
||||
const char *name, const char *value)
|
||||
{
|
||||
struct list_data *data = get_list_data(p);
|
||||
if (data) {
|
||||
struct list_item item = {
|
||||
.name = bstrdup(name),
|
||||
.value = bstrdup(value)
|
||||
};
|
||||
|
||||
da_insert(data->items, data->items.num-1, &item);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
bool obs_property_next(obs_property_t *p)
|
||||
@@ -340,43 +348,34 @@ double obs_property_float_step(obs_property_t p)
|
||||
return data ? data->step : 0;
|
||||
}
|
||||
|
||||
static inline bool is_combo(struct obs_property *p)
|
||||
{
|
||||
return p->type == OBS_PROPERTY_LIST;
|
||||
}
|
||||
|
||||
const char **obs_property_list_names(obs_property_t p)
|
||||
{
|
||||
if (!p || !is_combo(p))
|
||||
return NULL;
|
||||
|
||||
struct list_data *data = get_property_data(p);
|
||||
return (const char **)data->names;
|
||||
}
|
||||
|
||||
const char **obs_property_list_values(obs_property_t p)
|
||||
{
|
||||
if (!p || !is_combo(p))
|
||||
return NULL;
|
||||
|
||||
struct list_data *data = get_property_data(p);
|
||||
return (const char **)data->values;
|
||||
}
|
||||
|
||||
enum obs_combo_type obs_property_list_type(obs_property_t p)
|
||||
{
|
||||
if (!p || !is_combo(p))
|
||||
return OBS_COMBO_TYPE_INVALID;
|
||||
|
||||
struct list_data *data = get_property_data(p);
|
||||
return data->type;
|
||||
struct list_data *data = get_list_data(p);
|
||||
return data ? data->type : OBS_COMBO_TYPE_INVALID;
|
||||
}
|
||||
|
||||
enum obs_combo_format obs_property_list_format(obs_property_t p)
|
||||
{
|
||||
if (!p || !is_combo(p))
|
||||
return OBS_COMBO_FORMAT_INVALID;
|
||||
|
||||
struct list_data *data = get_property_data(p);
|
||||
return data->format;
|
||||
struct list_data *data = get_list_data(p);
|
||||
return data ? data->format : OBS_COMBO_FORMAT_INVALID;
|
||||
}
|
||||
|
||||
size_t obs_property_list_item_count(obs_property_t p)
|
||||
{
|
||||
struct list_data *data = get_list_data(p);
|
||||
return data ? data->items.num : 0;
|
||||
}
|
||||
|
||||
const char *obs_property_list_item_name(obs_property_t p, size_t idx)
|
||||
{
|
||||
struct list_data *data = get_list_data(p);
|
||||
return (data && idx < data->items.num) ?
|
||||
data->items.array[idx].name : NULL;
|
||||
}
|
||||
|
||||
const char *obs_property_list_item_value(obs_property_t p, size_t idx)
|
||||
{
|
||||
struct list_data *data = get_list_data(p);
|
||||
return (data && idx < data->items.num) ?
|
||||
data->items.array[idx].value : NULL;
|
||||
}
|
||||
|
@@ -71,16 +71,14 @@ EXPORT void obs_properties_add_text(obs_properties_t props, const char *name,
|
||||
const char *description);
|
||||
EXPORT void obs_properties_add_path(obs_properties_t props, const char *name,
|
||||
const char *description);
|
||||
EXPORT void obs_properties_add_list(obs_properties_t props,
|
||||
EXPORT obs_property_t obs_properties_add_list(obs_properties_t props,
|
||||
const char *name, const char *description,
|
||||
const char **value_names, const char **values,
|
||||
enum obs_combo_type type,
|
||||
enum obs_combo_format format);
|
||||
enum obs_combo_type type, enum obs_combo_format format);
|
||||
EXPORT void obs_properties_add_color(obs_properties_t props, const char *name,
|
||||
const char *description);
|
||||
|
||||
EXPORT bool obs_properties_next(obs_properties_t *props);
|
||||
EXPORT obs_property_t obs_properties_first_property(obs_properties_t props);
|
||||
EXPORT void obs_property_list_add_item(obs_property_t p,
|
||||
const char *name, const char *value);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@@ -96,11 +94,13 @@ EXPORT int obs_property_int_step(obs_property_t p);
|
||||
EXPORT double obs_property_float_min(obs_property_t p);
|
||||
EXPORT double obs_property_float_max(obs_property_t p);
|
||||
EXPORT double obs_property_float_step(obs_property_t p);
|
||||
EXPORT const char ** obs_property_list_names(obs_property_t p);
|
||||
EXPORT const char ** obs_property_list_values(obs_property_t p);
|
||||
EXPORT enum obs_combo_type obs_property_list_type(obs_property_t p);
|
||||
EXPORT enum obs_combo_format obs_property_list_format(obs_property_t p);
|
||||
|
||||
EXPORT size_t obs_property_list_item_count(obs_property_t p);
|
||||
EXPORT const char *obs_property_list_item_name(obs_property_t p, size_t idx);
|
||||
EXPORT const char *obs_property_list_item_value(obs_property_t p, size_t idx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -374,8 +374,6 @@ void obs_sceneitem_addref(obs_sceneitem_t item)
|
||||
{
|
||||
if (item)
|
||||
++item->ref;
|
||||
|
||||
blog(LOG_DEBUG, "addref %s, ref: %d", item->source->name, item->ref);
|
||||
}
|
||||
|
||||
void obs_sceneitem_release(obs_sceneitem_t item)
|
||||
@@ -383,8 +381,6 @@ void obs_sceneitem_release(obs_sceneitem_t item)
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
blog(LOG_DEBUG, "release %s, ref: %d", item->source->name, item->ref);
|
||||
|
||||
if (--item->ref == 0)
|
||||
obs_sceneitem_destroy(item);
|
||||
}
|
||||
|
@@ -302,8 +302,8 @@ obs_properties_t obs_source_properties(enum obs_source_type type,
|
||||
const char *id, const char *locale)
|
||||
{
|
||||
const struct obs_source_info *info = get_source_info(type, id);
|
||||
if (info && info->get_properties)
|
||||
return info->get_properties(locale);
|
||||
if (info && info->properties)
|
||||
return info->properties(locale);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@@ -141,7 +141,7 @@ struct obs_source_info {
|
||||
* @param locale The locale to translate with
|
||||
* @return The properties data
|
||||
*/
|
||||
obs_properties_t (*get_properties)(const char *locale);
|
||||
obs_properties_t (*properties)(const char *locale);
|
||||
|
||||
/**
|
||||
* Updates the settings for this source
|
||||
|
@@ -160,6 +160,23 @@ int wstrcmpi_n(const wchar_t *str1, const wchar_t *str2, size_t n)
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *astrstri(char *str, const char *find)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if (!str || !find)
|
||||
return NULL;
|
||||
|
||||
len = strlen(find);
|
||||
|
||||
do {
|
||||
if (astrcmpi_n(str, find, len) == 0)
|
||||
return str;
|
||||
} while (*str++);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *strdepad(char *str)
|
||||
{
|
||||
char *temp;
|
||||
|
@@ -46,6 +46,8 @@ EXPORT int wstrcmp_n(const wchar_t *str1, const wchar_t *str2, size_t n);
|
||||
EXPORT int astrcmpi_n(const char *str1, const char *str2, size_t n);
|
||||
EXPORT int wstrcmpi_n(const wchar_t *str1, const wchar_t *str2, size_t n);
|
||||
|
||||
EXPORT char *astrstri(char *str, const char *find);
|
||||
|
||||
EXPORT char *strdepad(char *str);
|
||||
EXPORT wchar_t *wcsdepad(wchar_t *str);
|
||||
|
||||
@@ -108,6 +110,8 @@ EXPORT void dstr_safe_printf(struct dstr *dst, const char *format,
|
||||
const char *val1, const char *val2, const char *val3,
|
||||
const char *val4);
|
||||
|
||||
static inline const char *dstr_find_i(const struct dstr *str,
|
||||
const char *find);
|
||||
static inline const char *dstr_find(const struct dstr *str,
|
||||
const char *find);
|
||||
|
||||
@@ -269,8 +273,12 @@ static inline void dstr_cat_ch(struct dstr *dst, char ch)
|
||||
dst->array[dst->len] = 0;
|
||||
}
|
||||
|
||||
static inline const char *dstr_find(const struct dstr *str,
|
||||
const char *find)
|
||||
static inline const char *dstr_find_i(const struct dstr *str, const char *find)
|
||||
{
|
||||
return astrstri(str->array, find);
|
||||
}
|
||||
|
||||
static inline const char *dstr_find(const struct dstr *str, const char *find)
|
||||
{
|
||||
return strstr(str->array, find);
|
||||
}
|
||||
|
Reference in New Issue
Block a user