void player::play_id_handler(int id, const std::string& source_name, std::shared_ptr<std::promise<int>> promise) { auto track = db_.find_track(id); std::cerr << "found track" << std::endl; if ( track ) { auto src = track->find_source(source_name); if ( src.uri.length() > 0 ) { promise->set_value(player_status_ok); state_.track = track; state_.source = src.name; open_audio_output(); source_play(src); } else { promise->set_value(player_status_track_not_found); } } else { promise->set_value(player_status_track_not_found); } }
void obs_register_source_s(const struct obs_source_info *info, size_t size) { struct obs_source_info data = {0}; struct darray *array; if (info->type == OBS_SOURCE_TYPE_INPUT) { array = &obs->input_types.da; } else if (info->type == OBS_SOURCE_TYPE_FILTER) { array = &obs->filter_types.da; } else if (info->type == OBS_SOURCE_TYPE_TRANSITION) { array = &obs->transition_types.da; } else { blog(LOG_ERROR, "Tried to register unknown source type: %u", info->type); goto error; } if (find_source(array, info->id)) { blog(LOG_WARNING, "Source d '%s' already exists! " "Duplicate library?", info->id); goto error; } #define CHECK_REQUIRED_VAL_(info, val, func) \ CHECK_REQUIRED_VAL(struct obs_source_info, info, val, func) CHECK_REQUIRED_VAL_(info, get_name, obs_register_source); CHECK_REQUIRED_VAL_(info, create, obs_register_source); CHECK_REQUIRED_VAL_(info, destroy, obs_register_source); if (info->type == OBS_SOURCE_TYPE_INPUT && (info->output_flags & OBS_SOURCE_VIDEO) != 0 && (info->output_flags & OBS_SOURCE_ASYNC) == 0) { CHECK_REQUIRED_VAL_(info, get_width, obs_register_source); CHECK_REQUIRED_VAL_(info, get_height, obs_register_source); } #undef CHECK_REQUIRED_VAL_ if (size > sizeof(data)) { blog(LOG_ERROR, "Tried to register obs_source_info with size " "%llu which is more than libobs currently " "supports (%llu)", (long long unsigned)size, (long long unsigned)sizeof(data)); goto error; } memcpy(&data, info, size); /* mark audio-only filters as an async filter categorically */ if (data.type == OBS_SOURCE_TYPE_FILTER) { if ((data.output_flags & OBS_SOURCE_VIDEO) == 0) data.output_flags |= OBS_SOURCE_ASYNC; } darray_push_back(sizeof(struct obs_source_info), array, &data); return; error: HANDLE_ERROR(size, obs_source_info, info); }
void get_source( char *filename ) { _splitpath( filename, fdisk, fpath, fname, fext ); if ( strchr( filename, '?' ) || strchr( filename, '*' ) ) { /* Check for '*' and '?' */ _makepath( findpath, fdisk, fpath, NULL, NULL ); _makepath( findname, NULL, NULL, fname, fext ); find_source( findpath, findname ); } else get_one_source( filename ); }
static gboolean extract_resolution (GstTcamWhitebalance* self) { GstPad* pad = GST_BASE_TRANSFORM_SINK_PAD(self); GstCaps* caps = gst_pad_get_current_caps(pad); GstStructure *structure = gst_caps_get_structure (caps, 0); g_return_val_if_fail(gst_structure_get_int(structure, "width", &self->image_size.width), FALSE); g_return_val_if_fail(gst_structure_get_int(structure, "height", &self->image_size.height), FALSE); guint fourcc; if (gst_structure_get_field_type(structure, "format") == G_TYPE_STRING) { const char *string; string = gst_structure_get_string (structure, "format"); fourcc = GST_STR_FOURCC (string); } if (fourcc == MAKE_FOURCC ('g','r','b','g')) { self->pattern = GR; } else if (fourcc == MAKE_FOURCC ('r', 'g', 'g', 'b')) { self->pattern = RG; } else if (fourcc == MAKE_FOURCC ('g', 'b', 'r', 'g')) { self->pattern = GB; } else if (fourcc == MAKE_FOURCC ('b', 'g', 'g', 'r')) { self->pattern = BG; } else { GST_ERROR("Unable to determine bayer pattern."); return FALSE; } // we only handle bayer 8 bit -> 1 byte int bytes_per_pixel = 1; self->expected_buffer_size = self->image_size.height * self->image_size.width * bytes_per_pixel; self->res = find_source(GST_ELEMENT(self)); return TRUE; }
static const struct source_info *get_source_info(enum obs_source_type type, const char *id) { struct darray *list = NULL; switch (type) { case SOURCE_INPUT: list = &obs->input_types.da; break; case SOURCE_FILTER: list = &obs->filter_types.da; break; case SOURCE_TRANSITION: list = &obs->transition_types.da; break; case SOURCE_SCENE: default: blog(LOG_WARNING, "get_source_info: invalid source type"); return NULL; } return find_source(list, id); }
void obs_register_source_s(const struct obs_source_info *info, size_t size) { struct obs_source_info data = {0}; struct darray *array; if (info->type == OBS_SOURCE_TYPE_INPUT) { array = &obs->input_types.da; } else if (info->type == OBS_SOURCE_TYPE_FILTER) { array = &obs->filter_types.da; } else if (info->type == OBS_SOURCE_TYPE_TRANSITION) { array = &obs->transition_types.da; } else { blog(LOG_ERROR, "Tried to register unknown source type: %u", info->type); return; } if (find_source(array, info->id)) { blog(LOG_WARNING, "Source d '%s' already exists! " "Duplicate library?", info->id); return; } CHECK_REQUIRED_VAL(info, get_name, obs_register_source); CHECK_REQUIRED_VAL(info, create, obs_register_source); CHECK_REQUIRED_VAL(info, destroy, obs_register_source); if (info->type == OBS_SOURCE_TYPE_INPUT && (info->output_flags & OBS_SOURCE_VIDEO) != 0 && (info->output_flags & OBS_SOURCE_ASYNC) == 0) { CHECK_REQUIRED_VAL(info, get_width, obs_register_source); CHECK_REQUIRED_VAL(info, get_height, obs_register_source); } memcpy(&data, info, size); /* mark audio-only filters as an async filter categorically */ if (data.type == OBS_SOURCE_TYPE_FILTER) { if ((data.output_flags & OBS_SOURCE_VIDEO) == 0) data.output_flags |= OBS_SOURCE_ASYNC; } darray_push_back(sizeof(struct obs_source_info), array, &data); }
// ---------------------------------------------------------------------------- void player::play_from_queue() { if ( play_queue_.size() > 0 ) { auto track = play_queue_.front(); auto src = track.find_source(); if ( !src.is_null() ) { std::cerr << "play_from_queue id=" << track.id() << ", title='" << track.title() << "', source=" << src.name() << std::endl; state_.state = playing; state_.track = std::move(track); state_.source = src.name(); std::cout << "player state=" << state_.state << std::endl; if ( !audio_output_ ) { audio_output_open(); } play_source(src); play_queue_.pop(); } else { std::cerr << "play_from_queue id=" << track.id() << ", title='" << track.title() << "', NO SOURCE!" << std::endl; play_queue_.pop(); play_from_queue(); } } else if ( continuous_playback_ ) { play_queue_.push(ctpb_selector_.next()); play_from_queue(); } else { play_stop(); } }
static const struct obs_source_info *get_source_info(enum obs_source_type type, const char *id) { struct darray *list = NULL; switch (type) { case OBS_SOURCE_TYPE_INPUT: list = &obs->input_types.da; break; case OBS_SOURCE_TYPE_FILTER: list = &obs->filter_types.da; break; case OBS_SOURCE_TYPE_TRANSITION: list = &obs->transition_types.da; break; } return find_source(list, id); }
/* Entry point */ static GstFlowReturn gst_tiswhitebalance_transform_ip (GstBaseTransform* trans, GstBuffer* buf) { GstTisWhiteBalance* self = GST_TISWHITEBALANCE (trans); if (self->res.source_element == NULL) { gst_debug_log (gst_tiswhitebalance_debug_category, GST_LEVEL_INFO, "gst_tiswhitebalance", "gst_tiswhitebalance_fixate_caps", __LINE__, NULL, "Searching for source"); self->res = find_source(GST_ELEMENT(self)); if (self->force_hardware_wb) { self->res.color.has_whitebalance = TRUE; } if (self->res.color.has_whitebalance) { WB_MAX = self->res.color.max; WB_IDENTITY = self->res.color.default_value; init_wb_values(self); } } /* auto is completely disabled */ if (!self->auto_enabled) { return GST_FLOW_OK; } whitebalance_buffer(self, buf); return GST_FLOW_OK; }
int DirectorConference::add_sink(int sid, Sink *s, KVS ¶ms) { // if (sid == -1) { if (s->payload_type() == 100) { ms_filter_call_method(video_publisher_, ZONEKEY_METHOD_PUBLISHER_ADD_REMOTE, s->get_rtp_session()); } else if (s->payload_type() == 102) { ms_filter_call_method(audio_publisher_, ZONEKEY_METHOD_PUBLISHER_ADD_REMOTE, s->get_rtp_session()); } else if (s->payload_type() == 110) { ms_filter_call_method(audio_publisher_, ZONEKEY_METHOD_PUBLISHER_ADD_REMOTE, s->get_rtp_session()); } return 0; } else if (is_source_id(sid)) { assert(find_source(sid) != 0); Graph *g = find_graph(sid); if (!g) { // 没有找到对应的 source return -1; } g->add_sink(s); return 0; } else { // 说明对 Stream 的点播 Stream *stream = find_stream(sid); if (!stream || !stream->support_publisher()) { // 没有找到或者不支持 publisher return -1; } else { stream->add_sink(s); return 0; } } }
obs_source_t obs_source_create(enum obs_source_type type, const char *name, const char *settings) { const struct source_info *info = NULL; struct darray *list = NULL; struct obs_source *source; switch (type) { case SOURCE_INPUT: list = &obs->input_types.da; break; case SOURCE_FILTER: list = &obs->filter_types.da; break; case SOURCE_TRANSITION: list = &obs->transition_types.da; break; case SOURCE_SCENE: default: return NULL; } info = find_source(list, name); if (!info) { blog(LOG_WARNING, "Source '%s' not found", name); return NULL; } source = bmalloc(sizeof(struct obs_source)); memset(source, 0, sizeof(struct obs_source)); source->data = info->create(settings, source); if (!source->data) goto fail; if (!obs_source_init(source, settings, info)) goto fail; return source; fail: blog(LOG_ERROR, "obs_source_create failed"); obs_source_destroy(source); return NULL; }
static inline int set_flags() { struct timex tmx = { .modes = 0 }; if (adjtimex(&tmx) == -1) { fprintf(stderr, "adjtimex get failed: %s\n", strerror(errno)); return -1; } tmx.modes = ADJ_STATUS; tmx.status |= (STA_PPSFREQ | STA_PPSTIME); if (adjtimex(&tmx) == -1) { fprintf(stderr, "adjtimex set failed: %s\n", strerror(errno)); return -1; } return 0; } static inline int unset_flags() { struct timex tmx = { .modes = 0 }; if (adjtimex(&tmx) == -1) { fprintf(stderr, "adjtimex get failed: %s\n", strerror(errno)); return -1; } tmx.modes = ADJ_STATUS; tmx.status &= ~(STA_PPSFREQ | STA_PPSTIME); if (adjtimex(&tmx) == -1) { fprintf(stderr, "adjtimex set failed: %s\n", strerror(errno)); return -1; } return 0; } static inline void usage(char *name) { fprintf(stderr, "Usage: %s [-bBfFac] <ppsdev>\n" "Commands:\n" " -b bind kernel PPS consumer\n" " -B unbind kernel PPS consumer\n" " -f set kernel NTP PPS flags\n" " -F unset kernel NTP PPS flags\n" "Options:\n" " -a use assert edge\n" " -c use clear edge (default)\n", name); } static void parse_args(int argc, char **argv) { while (1) { int c; /* getopt_long stores the option index here. */ int option_index = 0; static struct option long_options[] = { {"bind", no_argument, 0, 'b'}, {"unbind", no_argument, 0, 'B'}, {"set-flags", no_argument, 0, 'f'}, {"unset-flags", no_argument, 0, 'F'}, {"assert", no_argument, 0, 'a'}, {"clear", no_argument, 0, 'c'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "bBfFach", long_options, &option_index); /* detect the end of the options. */ if (c == -1) break; switch (c) { case 'b': { do_bind = 1; break; } case 'B': { do_bind = 2; break; } case 'f': { do_setflags = 1; break; } case 'F': { do_setflags = 2; break; } case 'a': { opt_edge = PPS_CAPTUREASSERT; break; } case 'c': { opt_edge = PPS_CAPTURECLEAR; break; } case 'h': { usage(argv[0]); exit(0); } default: { usage(argv[0]); exit(1); } } } if ((do_bind == 0) && (do_setflags == 0)) { printf("No command specified!\n"); usage(argv[0]); exit(1); } if (optind == argc - 1) { device = argv[optind]; } else { printf("Device name missing!\n"); usage(argv[0]); exit(1); } } int main(int argc, char *argv[]) { pps_handle_t handle; int avail_mode; /* Check the command line */ parse_args(argc, argv); if (find_source(device, &handle, &avail_mode) < 0) exit(EXIT_FAILURE); if (do_setflags == 2) if (unset_flags() < 0) { fprintf(stderr, "Failed to unset flags!\n"); exit(EXIT_FAILURE); } if (do_bind == 2) if (bind(handle, 0) < 0) { fprintf(stderr, "Unbind failed: %s\n", strerror(errno)); exit(EXIT_FAILURE); } if (do_bind == 1) if (bind(handle, opt_edge) < 0) { fprintf(stderr, "Bind failed: %s\n", strerror(errno)); exit(EXIT_FAILURE); } if (do_setflags == 1) if (set_flags() < 0) { fprintf(stderr, "Failed to set flags!\n"); exit(EXIT_FAILURE); } time_pps_destroy(handle); return 0; }
/* ************************************************************************** * lman - Give information on 'local' source code */ nomask varargs int lman(string entry, string docdir) { mixed *argv, *man_arr; int argc, i, num, flag; string *sdirarr, path, *p_parts, man_chapt, str; CHECK_SO_WIZ; if (!entry) { notify_fail("Syntax error, for instructions on usage, " + "do 'help lman'.\n"); return 0; } if (!strlen(docdir)) docdir = this_player()->query_path(); if (!SRCMAN->valid_docdir(docdir)) { notify_fail("The directory: " + docdir + " is not a valid documentation directory\n"); return 0; } argv = explode(entry, " "); argc = sizeof(argv); switch(argv[0]) { case "-k": if (argc == 2) { sdirarr = (string *)SRCMAN->get_subdirs(docdir); if (member_array(argv[1], sdirarr) < 0) { for (i = 0 ; i < sizeof(sdirarr) ; i++) { man_arr = SRCMAN->get_keywords(docdir, sdirarr[i], argv[1])[1]; if (sizeof(man_arr)) { write("--- " + sdirarr[i] + ":\n" + sprintf("%-*#s\n", 76, implode(man_arr, "\n")) + "\n"); flag = 1; } } if (!flag) write("No match.\n"); } else { man_chapt = argv[1]; man_arr = SRCMAN->get_index(docdir, man_chapt)[1]; this_interactive()->add_prop(WIZARD_S_SMAN_SEL_DIR, man_chapt); this_interactive()->add_prop(WIZARD_AM_SMAN_SEL_ARR, man_arr); g_mannum = 2; str = process_string("#1:" + implode(man_arr, "@@man_num@@")); str = "Available functions:\n" + sprintf("%-*#s\n", 76, str); if (strlen(str) > 5000) { this_player()->more(str + "\n"); } else { write(str); } } } if (argc == 3) { if (member_array(argv[1], SRCMAN->get_subdirs(docdir)) < 0) { write("No such subdir '" + argv[1] + "' available.\n"); break; } man_chapt = argv[1]; man_arr = SRCMAN->get_keywords(docdir, man_chapt, argv[2])[1]; this_interactive()->add_prop(WIZARD_S_SMAN_SEL_DIR, man_chapt); this_interactive()->add_prop(WIZARD_AM_SMAN_SEL_ARR, man_arr); g_mannum = 2; str = process_string("#1:" + implode(man_arr, "@@man_num@@")); str = "Available subjects:\n" + sprintf("%-*#s\n", 76, str); if (strlen(str) > 5000) { this_player()->more(str + "\n"); } else { write(str); } } break; case "-?": man_chapt = this_interactive()-> query_prop(WIZARD_S_SMAN_SEL_DIR); if (!man_chapt) { write("You haven't made any selection yet.\n" + "Do 'lman -k <dir>' to select a directory.\n"); break; } man_arr = this_interactive()->query_prop(WIZARD_AM_SMAN_SEL_ARR); g_mannum = 2; str = process_string("#1:" + implode(man_arr, "@@man_num@@")); write("Selected functions (" + man_chapt + "):\n" + sprintf("%-*#s\n", 76, str)); break; case "-c": write("Available subdirs:\n" + sprintf("%-*#s\n", 76, implode(SRCMAN->get_subdirs(docdir), "\n"))); break; case "-u": SRCMAN->update_index(docdir); write("Ok.\n"); break; case "-s": case "-e": if (argc > 1) { sscanf(argv[1], "#%d", num); if (num) { man_chapt = this_interactive()-> query_prop(WIZARD_S_SMAN_SEL_DIR); man_arr = this_interactive()-> query_prop(WIZARD_AM_SMAN_SEL_ARR); if (!man_chapt) { write("You haven't made any selection yet.\n"); break; } if (num < 1 || num > sizeof(man_arr)) { write("The possible interval is 1-" + sizeof(man_arr) + ".\n"); break; } path = docdir + man_chapt + "/" + man_arr[num - 1]; if (!find_source(path, argv[0])) { write("No such source code found.\n"); break; } break; } else if (file_size(docdir + argv[1]) < 0) { sdirarr = SRCMAN->get_subdirs(docdir); if (argc == 3) { if (member_array(argv[1], sdirarr) < 0) { write("No such subdir '" + argv[1] + "' available.\n"); break; } man_chapt = argv[1]; man_arr = SRCMAN->get_keywords(docdir, man_chapt, argv[2])[1]; } else { for (i = 0; i < sizeof(sdirarr); i++) { man_chapt = sdirarr[i]; man_arr = SRCMAN->get_keywords(docdir, man_chapt, argv[1])[1]; if (sizeof(man_arr) > 0) break; } } if (sizeof(man_arr) == 0) write("No command: " + argv[1] + "\n"); else { path = docdir + man_chapt + "/" + man_arr[0]; if (file_size(path) < 0) write("Function not found.\n"); else find_source(path, argv[0]); } break; } else { find_source(docdir + argv[1], argv[0]); } break; } default: sscanf(argv[0], "#%d", num); if (num) { man_chapt = this_interactive()-> query_prop(WIZARD_S_SMAN_SEL_DIR); man_arr = this_interactive()-> query_prop(WIZARD_AM_SMAN_SEL_ARR); if (!man_chapt) { write("You haven't made any selection yet.\n"); break; } if (num < 1 || num > sizeof(man_arr)) { write("The possible interval is 1-" + sizeof(man_arr) + ".\n"); break; } path = docdir + man_chapt + "/" + man_arr[num - 1]; write("File: " + path + "\n"); this_player()->more(path, 1); break; } if (file_size(docdir + argv[0]) < 0) { sdirarr = (string *)SRCMAN->get_subdirs(docdir); if (argc == 2) { if (member_array(argv[0], sdirarr) < 0) { write("No such subdir '" + argv[0] + "' available.\n"); break; } man_chapt = argv[0]; man_arr = (mixed *)SRCMAN->get_keywords(docdir, man_chapt, argv[1])[1]; this_interactive()->add_prop(WIZARD_S_SMAN_SEL_DIR, man_chapt); this_interactive()->add_prop(WIZARD_AM_SMAN_SEL_ARR, man_arr); } else { for (i = 0 ; i < sizeof(sdirarr) ; i++) { man_chapt = sdirarr[i]; man_arr = (mixed *)SRCMAN->get_keywords(docdir, man_chapt, argv[0])[1]; if (sizeof(man_arr) > 0) break; } } if (sizeof(man_arr) == 0) write("No command: " + argv[0] + "\n"); else { path = docdir + man_chapt + "/" + man_arr[0]; if (file_size(path) < 0) write("No command: " + argv[0] + "\n"); else { write("File: " + path + "\n"); this_player()->more(path, 1); } } break; } else { write("File: " + docdir + argv[0] + "\n"); this_player()->more((docdir + argv[0]), 1); } break; } return 1; }
static void on_set_debug(pa_core* c, pa_proplist* p, int debug_sink_id, const char* ext_args) { const char* device_name = pa_proplist_gets(p, PROPLIST_KEY_DEVICE); if (!device_name) { pa_log_error("device not specific!"); return; } int device_id = atoi(device_name); pa_sink* sink = NULL; pa_source* source = NULL; sink = find_sink(c, device_id); if (!sink) { source = find_source(c, device_id); } if (!sink && !source) { pa_log_error("sink/source of device id %s not found!", device_name); return; } pa_sample_spec ss; pa_channel_map map; if (sink) { ss = sink->sample_spec; map = sink->channel_map; } else { ss = source->sample_spec; map = source->channel_map; } if (debug_sink_id == EAUDIO_STREAM_DEVICE_VIRTUALOUPUT_REMOTE) { ss.rate = 8000; ss.format = PA_SAMPLE_U8; ss.channels = 1; map.channels = 1; } char sink_name[64]; GET_PLUGIN_NAME(sink_name, debug_sink_id); pa_module* link_module = NULL; const char* str_func = pa_proplist_gets(p, PROPLIST_VALUE_FUNC); bool func_on = true; if (str_func) { func_on = !strcmp(str_func, PROPLIST_VALUE_TRUE); } if (sink) { link_module = sink->module; } else if (source) { link_module = source->module; } if (func_on) { pa_pre_load_func_t f = pa_get_user_data(PA_USER_SINK_PRELOAD_FUNC); if (f) { f(sink_name, c, &ss, &map, ext_args); } pa_sink* remote_sink = pa_namereg_get(c, sink_name, PA_NAMEREG_SINK); if (!remote_sink) { pa_log_error("remote-sink load failed"); return; } char args[256] = { 0 }; char loopback_name[128] = { 0 }; const char* i_name = NULL; const char* o_name = NULL; if (sink) { i_name = sink->monitor_source->name; o_name = remote_sink->name; } else if (source) { i_name = source->name; o_name = remote_sink->name; } pa_snprintf(loopback_name, sizeof(loopback_name), "Loopback(%s->%s)", i_name, o_name); pa_snprintf(args, sizeof(args), "name=%s source=%s sink=%s token=%u %s", loopback_name, i_name, o_name, MAGIC_TOKEN_ID, ext_args ? ext_args : ""); pa_log_info("load-module module-loopback args: %s", args); pa_module* m = pa_module_load(c, "module-loopback", args); if (!m) { pa_log_error("on_set_debug module load err."); return; } if (link_module) { pa_proplist_sets(link_module->proplist, PA_PROP_LINK_LOOPBACK_ID, loopback_name); } } else { pa_sink* remote_sink = find_sink(c, debug_sink_id); if (remote_sink) { pa_log_info("unloading remote_sink %d", debug_sink_id); pa_module_unload_request(remote_sink->module, true); } } }
void on_set_common(pa_proplist* p, pa_tagstruct* t, pa_core* c) { pa_log_info("on_set_common"); const char* attribute = pa_proplist_gets(p, PROPLIST_KEY_ATTRIBUTE); if (!attribute) { pa_log_error("on_set_common: attribute not found!"); return; } if (!strcmp(attribute, PROPLIST_VALUE_GET_INFO)) { const char* str_device = pa_proplist_gets(p, PROPLIST_KEY_DEVICE); if (!str_device) { pa_log_error("on_set_common device not specific!"); return; } int device_id = atoi(str_device); pa_sink* sink = NULL; pa_source* source = NULL; sink = find_sink(c, device_id); if (!sink) { source = find_source(c, device_id); } if (!sink && !source) { pa_log_error("do not find any sink or source of device %d", device_id); return; } int n_used = 0; if (sink) { n_used = pa_module_get_n_used(sink->module); } else { n_used = pa_module_get_n_used(source->module); } char value[32]; snprintf(value, sizeof(value), "%d", n_used); pa_proplist* replyp = pa_proplist_new(); pa_proplist_sets(replyp, PROPLIST_KEY_VALUE, value); pa_tagstruct_put_proplist(t, replyp); pa_proplist_free(replyp); } else if (!strcmp(attribute, PROPLIST_VALUE_REMOTE_SINK)) { #ifdef HAVE_WEB_SOCKET extern void start_web_socket(); start_web_socket(); #endif on_set_debug(c, p, EAUDIO_STREAM_DEVICE_VIRTUALOUPUT_REMOTE, NULL); } else if (!strcmp(attribute, PROPLIST_VALUE_FILE_SINK)) { const char* str_path = pa_proplist_gets(p, PROPLIST_VALUE_PATH); char args[64] = { 0 }; if (str_path) { snprintf(args, sizeof(args), "path=%s", str_path); } on_set_debug(c, p, EAUDIO_STREAM_DEVICE_VIRTUALOUPUT_FILE, str_path ? args : NULL); } else if (!strcmp(attribute, PROPLIST_VALUE_ALSA_BUFFER)) { const char* str_device = pa_proplist_gets(p, PROPLIST_KEY_DEVICE); if (!str_device) { pa_log_error("on_set_common alsa-buffer device not specific!"); return; } int device = atoi(str_device); pa_sink* s = find_sink(c, device); if (!s) { pa_log_error("sink not found %d", device); return; } pa_usec_t left_to_play = pa_sink_get_left_to_play(s); pa_proplist* replyp = pa_proplist_new(); pa_proplist_set(replyp, PROPLIST_KEY_COMMAND_RESULT, &left_to_play, sizeof(left_to_play)); pa_tagstruct_put_proplist(t, replyp); pa_proplist_free(replyp); } else if (!strcmp(attribute, PROPLIST_VALUE_STOP_TEST)) { pthread_t tid_stop; int err = pthread_create(&tid_stop, NULL, stop_thread, NULL); if (err != 0) { pa_log_error("can't create thread: %s\n", strerror(err)); return; } } #ifdef HAVE_WEB_SOCKET else if (!strcmp(attribute, "web-start")) { extern void start_web_socket(); start_web_socket(); } else if (!strcmp(attribute, "web-stop")) { extern void stop_web_socket(); stop_web_socket(); } #endif }
static int select_source (Marx_Source_Type *st, Param_File_Type *pf, char *name) /*{{{*/ { Source_Object_Type *s; double yoff, zoff; double ra_nom, dec_nom, roll_nom; JDMVector_Type p; s = find_source (name); if (s == NULL) return -1; if (-1 == _marx_init_dither (pf, s->dither_flags, &yoff, &zoff)) return -1; if (-1 == marx_get_nominal_pointing (&ra_nom, &dec_nom, &roll_nom)) return -1; if (-1 == marx_compute_elaz (Source_Ra, Source_Dec, &Source_Azimuth, &Source_Elevation)) return -1; p = JDMv_spherical_to_vector (1.0, 0.5*PI-zoff, yoff); // SIMPUT source gives absolute RA, DEC // MARX sources give relative to source position if (name != "SIMPUT"){ /* Now add offsets via the proper rotations */ p = JDMv_rotate_unit_vector (p, JDMv_vector (0, -1, 0), Source_Elevation); p = JDMv_rotate_unit_vector (p, JDMv_vector (0, 0, 1), Source_Azimuth); /* Finally roll it so that this point will be invariant under roll. That is, * the dither transformation will (on the average) undo this rotation. * See the apply_dither function. */ p = JDMv_rotate_unit_vector (p, JDMv_vector (1, 0, 0), roll_nom); /* This vector must point FROM source TO origin. */ st->p.x = -p.x; st->p.y = -p.y; st->p.z = -p.z; /* Create a vector orthogonal to above. This will save the source * routine the effort required to do this. * * Since st->p is more or less oriented along the negative x direction, * st->p.x will be non-zero. In fact, this will be required. * With this requirement, a normal in the x-y plane is trival to construct. */ if (p.x <= 0.0) { marx_error ("Source rays will not hit the telescope."); return -1; } st->p_normal.z = 0.0; st->p_normal.y = 1.0; st->p_normal.x = -p.y / p.x; JDMv_normalize (&st->p_normal); } else{ st->p = p; } st->distance = Source_Distance; marx_message ("Initializing source type %s...\n", name); if (-1 == (*s->select_source)(st, pf, name, s->source_id)) return -1; return 0; }