/* * Create the plugin object */ static void *pulse_create(obs_data_t settings, obs_source_t source) { struct pulse_data *data = bzalloc(sizeof(struct pulse_data)); data->source = source; data->speakers = SPEAKERS_STEREO; data->device = bstrdup(obs_data_getstring(settings, "device_id")); pulse_init(); if (pulse_start_recording(data) < 0) goto fail; return data; fail: pulse_destroy(data); return NULL; }
/** * Update the input settings */ static void pulse_update(void *vptr, obs_data_t *settings) { PULSE_DATA(vptr); bool restart = false; const char *new_device; new_device = obs_data_get_string(settings, "device_id"); if (!data->device || strcmp(data->device, new_device) != 0) { if (data->device) bfree(data->device); data->device = bstrdup(new_device); restart = true; } if (!restart) return; if (data->stream) pulse_stop_recording(data); pulse_start_recording(data); }