static void do_packet(connection_t *cptr, char *buf) { char *ptr, buf2[BUFSIZE * 2]; static char tmp[BUFSIZE * 2 + 1]; while ((ptr = strchr(buf, '\n'))) { snprintf(buf2, (BUFSIZE * 2), "%s%s", tmp, buf); *tmp = '\0'; slog(LG_DEBUG, "-{incoming}-> %s", buf2); sendq_add(cptr, buf2, strlen(buf2)); buf = ptr + 1; } if (*buf) { mowgli_strlcpy(tmp, buf, BUFSIZE * 2); tmp[BUFSIZE * 2] = '\0'; } }
static void event_cb(struct aura_node *node, struct aura_buffer *buf, void *arg) { struct laura_node *lnode = arg; lua_State *L = lnode->L; const struct aura_object *o = aura_get_current_object(node); int nargs; TRACE(); lua_rawgeti(L, LUA_REGISTRYINDEX, lnode->node_container); lua_pushstring(L, o->name); lua_gettable(L, -2); if (!lua_isfunction(L, -1)) { slog(0, SLOG_WARN, "Dropping unhandled event: %s", o->name); return; } lua_rawgeti(L, LUA_REGISTRYINDEX, lnode->node_container); nargs = buffer_to_lua(L, lnode->node, o, buf); lua_call(L, nargs + 1, 0); }
static void susb_handle_event(struct aura_node *node, enum node_event evt, const struct aura_pollfds *fd) { struct aura_buffer *buf; struct usb_dev_info *inf = aura_get_transportdata(node); ncusb_handle_events_nonblock_once(node, inf->ctx, inf->timer); if (inf->cbusy) return; if (evt == NODE_EVENT_STARTED) { aura_etable_activate(inf->etbl); /* Activate our export table * Hack: Since libusb tends to send and receive data in one buffer, * we need to adjust argument buffer to fit in return values as well. * It helps us to avoid needless copying. */ int i; for (i = 0; i < inf->etbl->next; i++) { struct aura_object *tmp; tmp = &inf->etbl->objects[i]; tmp->arglen += tmp->retlen; } inf->etbl = NULL; ncusb_watch_for_device(inf->ctx, &inf->dev_descr); ncusb_start_descriptor_watching(node, inf->ctx); slog(1, SLOG_INFO, "usb: Now looking for a device %x:%x %s/%s/%s", inf->dev_descr.vid, inf->dev_descr.pid, inf->dev_descr.vendor, inf->dev_descr.product, inf->dev_descr.serial); } else if (inf->state == SUSB_DEVICE_RESTART) { susb_offline_transport(inf); } else if (inf->state == SUSB_DEVICE_OPERATIONAL) { buf = aura_peek_buffer(&node->outbound_buffers); if (buf) susb_issue_call(node, buf); } }
static int usb_start_ops(struct libusb_device_handle *hndl, void *arg) { /* FixMe: Reading descriptors is synchronos. This is not needed * often, but leaves a possibility of a flaky usb device to * screw up the event processing. * A proper workaround would be manually reading out string descriptors * from a device in an async fasion in the background. */ int ret; struct usb_dev_info *inf = arg; struct aura_node *node = inf->node; inf->handle = hndl; libusb_fill_interrupt_transfer(inf->itransfer, inf->handle, 0x81, inf->ibuffer, 8, cb_interrupt, node, 10000); libusb_fill_control_setup(inf->ctrlbuf, LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_IN, RQ_GET_DEV_INFO, 0, 0, inf->io_buf_size); libusb_fill_control_transfer(inf->ctransfer, inf->handle, inf->ctrlbuf, cb_got_dev_info, node, 1500); ret = libusb_submit_transfer(inf->ctransfer); if (ret!= 0) { libusb_close(inf->handle); return -1; } inf->state = AUSB_DEVICE_INIT; /* Change our state */ inf->cbusy = true; slog(4, SLOG_DEBUG, "usb: Device opened, info packet requested"); return 0; };
void template_setup (GuTemplate* t) { const gchar *filename; char *filepath = NULL; GError *error = NULL; GtkTreeIter iter; gchar *dirpath = g_build_filename (g_get_user_config_dir (), "gummi", "templates" , NULL); GDir* dir = g_dir_open (dirpath, 0, &error); if (error) { /* print error if directory does not exist */ slog (L_INFO, "unable to read template directory, creating new..\n"); g_mkdir_with_parents (dirpath, DIR_PERMS); g_free (dirpath); return; } while ( (filename = g_dir_read_name (dir))) { filepath = g_build_filename (dirpath, filename, NULL); gtk_list_store_append (t->list_templates, &iter); gtk_list_store_set (t->list_templates, &iter, 0, filename, 1, filepath, -1); g_free (filepath); } g_free (dirpath); // disable the add button when there are no tabs opened (#388) if (!tabmanager_has_tabs()) { gtk_widget_set_sensitive (t->template_add, FALSE); } gtk_widget_set_sensitive (t->template_open, FALSE); }
void actor_empty_list() { int i; Actor *actor = NULL; if(!actorList) { slog("actorList not initialized"); return; } for(i = 0; i < actorMax; ++i) { actor = &actorList[i]; actor_free(&actor); } memset(actorList, 0, sizeof(Actor) * actorMax); for(i = 0; i < actorMax; i++) { if(actorList[i].sprite != NULL) { sprite_free(&actorList[i].sprite); } } actorNum = 0; }
/* * user_delete(user_t *u, const char *comment) * * Destroys a user object and deletes the object from the users DTree. * * Inputs: * - user object to delete * - quit comment * * Outputs: * - nothing * * Side Effects: * - on success, a user is deleted from the users DTree. */ void user_delete(user_t *u, const char *comment) { mowgli_node_t *n, *tn; chanuser_t *cu; mynick_t *mn; char oldnick[NICKLEN]; bool doenforcer = false; return_if_fail(u != NULL); if (u->flags & UF_DOENFORCE) { doenforcer = true; mowgli_strlcpy(oldnick, u->nick, sizeof oldnick); u->flags &= ~UF_DOENFORCE; } if (!comment) comment = ""; slog(LG_DEBUG, "user_delete(): removing user: %s -> %s (%s)", u->nick, u->server->name, comment); hook_call_user_delete_info((&(hook_user_delete_t){ .u = u, .comment = comment}));
int obj_va_search(float *v,float *a,int count,float vtarget[3],float atarget[6]) { int i; if (!v || !a) { slog("error, missing a buffer to search"); return -1;/*not found*/ } for (i = 0; i < count; i++) { if (memcmp(&v[i * 3],vtarget,sizeof(float)*3) != 0) { /*not equal, keep searching*/ continue; } if (memcmp(&a[i * 3],atarget,sizeof(float)*6) != 0) { /*not equal, keep searching*/ continue; } return i; } return -1;/*not found*/ }
void font_draw_text( char * text, int x, int y, Vec3D color, float alpha, Uint32 size ) { if (!font_initialized())return; if (size >= FontSizeMax) { slog("font: passed a font size outside of available range"); return; } font_draw_text_custom( text, x, y, color, alpha, __font_size[size] ); }
void audio_empty_pak_list() { int i; SoundPak *pak = NULL; if(!pakList) { slog("pakList not initialized"); return; } for(i = 0; i < maxPaks; ++i) { pak = &pakList[i]; audio_pak_free(&pak); } memset(pakList, 0, sizeof(SoundPak) * maxPaks); for(i = 0; i < maxPaks; ++i) { pakList[i].moving = NULL; pakList[i].firing1 = NULL; pakList[i].firing2 = NULL; pakList[i].death = NULL; } numPaks = 0; }
static void m_tburst(sourceinfo_t *si, int parc, char *parv[]) { time_t chants = atol(parv[0]); channel_t *c = channel_find(parv[1]); time_t topicts = atol(parv[2]); if (c == NULL) return; /* Our uplink is trying to change the topic during burst, * and we have already set a topic. Assume our change won. * -- jilles */ if (si->s != NULL && si->s->uplink == me.me && !(si->s->flags & SF_EOB) && c->topic != NULL) return; if (c->ts < chants || (c->ts == chants && c->topicts >= topicts)) { slog(LG_DEBUG, "m_tburst(): ignoring topic on %s", c->name); return; } handle_topic_from(si, c, parv[3], topicts, parv[4]); }
/* main routine */ int main(int argc, char **argv) { int listenfd, r; unsigned short port; struct sockaddr_in serv; int mode; int *log_level; signal(SIGPIPE, SIG_IGN); log_level = shmalloc("/log_level", sizeof(int)); if (!log_level) { slog(SLOG_ERROR, "could not allocate shm for slog"); exit(EXIT_FAILURE); } *log_level = SLOG_ALL; slog_level(log_level); if (argc < 2) { fprintf(stderr, "Usage: %s <port number> " "[mode: 0=seq,1=thr,2=proc]\n", argv[0]); exit(EXIT_FAILURE); } else if (argc >= 3) { mode = atoi(argv[2]); if (argc >= 4) { *log_level = atoi(argv[3]); fprintf(stderr, "%s: *log_level = %d\n", argv[0], *log_level); } } else { fprintf(stderr, "%s: no mode specified. " "defaulting to mode=0 (seq)\n", argv[0]); mode = 0; } if ((port = atoi(argv[1])) <= 0) { fprintf(stderr, "%s: bad port\n", argv[0]); exit(EXIT_FAILURE); } listenfd = socket(AF_INET, SOCK_STREAM, 0); if (listenfd == -1) { slog_perror("socket"); exit(EXIT_FAILURE); } memset(&serv, 0, sizeof(serv)); serv.sin_family = AF_INET; serv.sin_addr.s_addr = htonl(INADDR_ANY); serv.sin_port = htons(port); r = bind(listenfd, (struct sockaddr *)&serv, sizeof(serv)); if (r == -1) { slog_perror("bind"); exit(EXIT_FAILURE); } r = listen(listenfd, LISTENQ); if (r == -1) { slog_perror("listen"); exit(EXIT_FAILURE); } if (mode == 0) { proxy_seq(listenfd); } else if (mode == 1) { proxy_thr(listenfd); } else { proxy_proc(listenfd); } r = close(listenfd); if (r == -1) { slog_perror("close"); exit(EXIT_FAILURE); } shfree("/log_level", log_level, sizeof(int)); exit(EXIT_SUCCESS); }
int main(int argc, char *argv[]) { GList* list = NULL; json_t *root; SDL_Surface *optimized_surface = NULL; SDL_Surface *temp = NULL; Sound *bg_music = NULL; Sound *level_music = NULL; int done; const Uint8 *keys; char imagepath[512]; game_initialize_system(); SDL_ShowCursor(SDL_DISABLE); bg_music = sound_load_music("sounds/vanguard_bouncy.mp3"); if(!bg_music) { slog("Could not load music\n"); } level_music = sound_load_music("sounds/chippy_cloud_kid.mp3"); if(!level_music) { slog("Could not load music\n"); } Mix_VolumeMusic(5); if(temp) { optimized_surface = SDL_ConvertSurface( temp, graphics_surface->format, NULL ); SDL_FreeSurface(temp); } SDL_Event e; done = 0; int lock = true; do { if(menu_flag) { menu_draw(); if(lock == false) { Mix_HaltMusic(); lock = true; } if(Mix_PlayingMusic() == 0) { Mix_PlayMusic(bg_music->music, -1); } } else { tilemap_render_tile(); entity_draw_all(); if(lock == true) { Mix_HaltMusic(); lock = false; } if(Mix_PlayingMusic() == 0) { Mix_PlayMusic(level_music->music, -1); } } mouse_draw_self(); graphics_next_frame(); SDL_PumpEvents(); entity_think_all(); while(SDL_PollEvent(&e) != 0) { if(e.type == SDL_QUIT) { done = 1; } bool leftclick = false ; bool rightclick = false; if(e.type == SDL_MOUSEBUTTONDOWN) { if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)) { leftclick = true; } else if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)) { rightclick = true; } } if(leftclick == true) { if(menu_flag) menu_click(); else tilemap_click(); } else if(rightclick == true) { if(menu_flag) menu_click(); else tilemap_remove_tile(); } bool pressed = false; if(e.type == SDL_KEYDOWN) { if(!pressed) { if(make_flag) { keys = SDL_GetKeyboardState(NULL); if(keys[SDL_SCANCODE_W]) { State state = UP; tilemap_m_click(state); } else if(keys[SDL_SCANCODE_A]) { State state = LEFT; tilemap_m_click(state); } else if(keys[SDL_SCANCODE_S]) { State state = DOWN; tilemap_m_click(state); } else if(keys[SDL_SCANCODE_D]) { State state = RIGHT; tilemap_m_click(state); } if(keys[SDL_SCANCODE_T]) { State state = UP; tilemap_c_click(state); } else if(keys[SDL_SCANCODE_F]) { State state = LEFT; tilemap_c_click(state); } else if(keys[SDL_SCANCODE_G]) { State state = DOWN; tilemap_c_click(state); } else if(keys[SDL_SCANCODE_H]) { State state = RIGHT; tilemap_c_click(state); } } } pressed = true; } else if(e.type == SDL_KEYUP) { pressed = false; } } keys = SDL_GetKeyboardState(NULL); if(keys[SDL_SCANCODE_ESCAPE]) { done = 1; } SDL_RenderPresent(graphics_renderer); // update the screen with any rendering performed since previous call } while(!done); exit(0); return 0; }
void D3Drender::render(void) { if (d3ddev == NULL) { #ifdef D3DSLOG slog("D3Drender render-- no device \n"); #endif release(); mHwnd = NULL; return; }//endif d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); d3ddev->BeginScene(); d3ddev->SetTexture(0, mtex.ptex); d3ddev->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); d3ddev->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); d3ddev->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); d3ddev->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); // select which vertex format we are using d3ddev->SetFVF(CUSTOMFVF); // select the vertex buffer to display d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); //draw our quad d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2); d3ddev->EndScene(); d3ddev->Present(NULL, NULL, NULL, NULL); //check if the device was lost (but not every render) //i have yet to encounter any of these log messages //so far device loss seem to be just d3ddev becoming NULL wait += 1; if (wait >= 5) { wait = 0; HRESULT coopResult; coopResult = d3ddev->TestCooperativeLevel(); if (coopResult == D3DERR_DEVICELOST) { slog("D3DRender D3DERR_DEVICELOST \n"); } if (coopResult == D3DERR_DEVICENOTRESET) { slog("D3DRender D3DERR_DEVICENOTRESET \n"); } if (coopResult == D3DERR_DRIVERINTERNALERROR) { slog("D3DRender D3DERR_DRIVERINTERNALERROR \n"); } if ((coopResult == D3DERR_DEVICELOST ) || (coopResult == D3DERR_DEVICENOTRESET) || (coopResult == D3DERR_DRIVERINTERNALERROR) ) { release(); mHwnd = NULL; }//endif }//endif }//update
void sperror(char *message) { slog(LOG_ERROR, "%s: %s\n", message, strerror(errno)); }
int atheme_main(int argc, char *argv[]) { int daemonize_pipe[2]; bool have_conf = false; bool have_log = false; bool have_datadir = false; char buf[32]; int pid, r; FILE *pid_file; const char *pidfilename = RUNDIR "/atheme.pid"; char *log_p = NULL; mowgli_getopt_option_t long_opts[] = { { NULL, 0, NULL, 0, 0 }, }; atheme_bootstrap(); /* do command-line options */ while ((r = mowgli_getopt_long(argc, argv, "c:dhrl:np:D:v", long_opts, NULL)) != -1) { switch (r) { case 'c': config_file = sstrdup(mowgli_optarg); have_conf = true; break; case 'd': log_force = true; break; case 'h': print_help(); exit(EXIT_SUCCESS); break; case 'r': readonly = true; break; case 'l': log_p = sstrdup(mowgli_optarg); have_log = true; break; case 'n': runflags |= RF_LIVE; break; case 'p': pidfilename = mowgli_optarg; break; case 'D': datadir = mowgli_optarg; have_datadir = true; break; case 'v': print_version(); exit(EXIT_SUCCESS); break; default: printf("usage: atheme [-dhnvr] [-c conf] [-l logfile] [-p pidfile]\n"); exit(EXIT_FAILURE); break; } } if (!have_conf) config_file = sstrdup(SYSCONFDIR "/atheme.conf"); if (!have_log) log_p = sstrdup(LOGDIR "/atheme.log"); if (!have_datadir) datadir = sstrdup(DATADIR); cold_start = true; runflags |= RF_STARTING; atheme_init(argv[0], log_p); slog(LG_INFO, "%s is starting up...", PACKAGE_STRING); /* check for pid file */ #ifndef MOWGLI_OS_WIN if ((pid_file = fopen(pidfilename, "r"))) { if (fgets(buf, 32, pid_file)) { pid = atoi(buf); if (!kill(pid, 0)) { fprintf(stderr, "atheme: daemon is already running\n"); exit(EXIT_FAILURE); } } fclose(pid_file); } #endif if (!(runflags & RF_LIVE)) daemonize(daemonize_pipe); atheme_setup(); conf_init(); if (!conf_parse(config_file)) { slog(LG_ERROR, "Error loading config file %s, aborting", config_file); exit(EXIT_FAILURE); } if (config_options.languagefile) { slog(LG_DEBUG, "Using language: %s", config_options.languagefile); if (!conf_parse(config_options.languagefile)) slog(LG_INFO, "Error loading language file %s, continuing", config_options.languagefile); } if (!backend_loaded && authservice_loaded) { slog(LG_ERROR, "atheme: no backend modules loaded, see your configuration file."); exit(EXIT_FAILURE); } /* we've done the critical startup steps now */ cold_start = false; /* load our db */ if (db_load) db_load(NULL); else if (backend_loaded) { slog(LG_ERROR, "atheme: backend module does not provide db_load()!"); exit(EXIT_FAILURE); } db_check(); #ifdef HAVE_GETPID /* write pid */ if ((pid_file = fopen(pidfilename, "w"))) { fprintf(pid_file, "%d\n", getpid()); fclose(pid_file); } else { fprintf(stderr, "atheme: unable to write pid file\n"); exit(EXIT_FAILURE); } #endif /* detach from terminal */ if ((runflags & RF_LIVE) || !detach_console(daemonize_pipe)) { #ifdef HAVE_GETPID slog(LG_INFO, "pid %d", getpid()); #endif slog(LG_INFO, "running in foreground mode from %s", PREFIX); } /* no longer starting */ runflags &= ~RF_STARTING; /* we probably have a few open already... */ me.maxfd = 3; /* DB commit interval is configurable */ if (db_save && !readonly) mowgli_timer_add(base_eventloop, "db_save", db_save, NULL, config_options.commit_interval); /* check expires every hour */ mowgli_timer_add(base_eventloop, "expire_check", expire_check, NULL, 3600); /* check k/x/q line expires every minute */ mowgli_timer_add(base_eventloop, "kline_expire", kline_expire, NULL, 60); mowgli_timer_add(base_eventloop, "xline_expire", xline_expire, NULL, 60); mowgli_timer_add(base_eventloop, "qline_expire", qline_expire, NULL, 60); /* check authcookie expires every ten minutes */ mowgli_timer_add(base_eventloop, "authcookie_expire", authcookie_expire, NULL, 600); /* reseed rng a little every five minutes */ mowgli_timer_add(base_eventloop, "rng_reseed", rng_reseed, NULL, 293); me.connected = false; uplink_connect(); /* main loop */ io_loop(); /* we're shutting down */ hook_call_shutdown(); if (db_save && !readonly) db_save(NULL); remove(pidfilename); errno = 0; if (curr_uplink != NULL && curr_uplink->conn != NULL) sendq_flush(curr_uplink->conn); connection_close_all(); me.connected = false; /* should we restart? */ if (runflags & RF_RESTART) { slog(LG_INFO, "main(): restarting"); #ifdef HAVE_EXECVE execv(BINDIR "/atheme-services", argv); #endif } slog(LG_INFO, "main(): shutting down"); mowgli_eventloop_destroy(base_eventloop); log_shutdown(); return 0; }
/* * Class: sage_DShowCaptureDevice * Method: switchToConnector0 * Signature: (JIILjava/lang/String;II)V */ JNIEXPORT void JNICALL Java_sage_DShowCaptureDevice_switchToConnector0 (JNIEnv *env, jobject jo, jlong capInfo, jint crossType, jint crossIndex, jstring tuningMode, jint countryCode, jint videoFormatCode) { char szTuningMode[16]; if (!capInfo) return; DShowCaptureInfo* pCapInfo = (DShowCaptureInfo*) capInfo; pCapInfo->videoFormatCode = videoFormatCode; const char* pTuningMode = env->GetStringUTFChars(tuningMode, NULL); strncpy( szTuningMode, pTuningMode, sizeof(szTuningMode) ); env->ReleaseStringUTFChars(tuningMode, pTuningMode); slog((env, "switchToConnector0 tuningMode:%s.\r\n", szTuningMode )); if ( String2TVType( szTuningMode ) && BDATypeNum( pCapInfo->captureConfig ) > 0 ) //ZQ REMOVE ME { TV_TYPE newBDAType = String2TVType( szTuningMode ); if ( pCapInfo->dwBDAType != newBDAType && pCapInfo->dwBDAType > 0 ) { int i, CaptureNum = pCapInfo->captureNum; for ( i = 0; i < CaptureNum; i++ ) if ( pCapInfo->captures[i] && pCapInfo->captures[i]->dwBDAType == pCapInfo->dwBDAType ) break; if ( i >= CaptureNum ) { slog((env, "switchToConnector0 ERROR: Orignal BDA Capture :%d is not found\r\n", pCapInfo->dwBDAType )); ASSERT( 0 ); return; } //save back memcpy( pCapInfo->captures[i], pCapInfo, sizeof(DShowCaptureInfo) ); for ( i = 0; i < CaptureNum; i++ ) if ( pCapInfo->captures[i] && pCapInfo->captures[i]->dwBDAType == newBDAType ) break; if ( i >= CaptureNum ) { slog((env, "switchToConnector0 ERROR: BDA Capture :%s is not found\r\n", szTuningMode )); ASSERT( 0 ); return; } memcpy( pCapInfo, pCapInfo->captures[i], sizeof(DShowCaptureInfo) ); setChannelDev( (CHANNEL_DATA*)pCapInfo->channel, (void*)pCapInfo ); slog((env, "switchToConnector0 BDA Capture :%s is switched.\r\n", szTuningMode )); } //strncpy( pCapInfo->tvType, szTuningMode, sizeof(pCapInfo->tvType) ); return; } if (!pCapInfo->pCrossbar) return; slog((env, "switchToConnector0 %d type:%d index:%d country:%d format:%d Mode:%s\r\n", (int)capInfo, crossType, crossIndex, countryCode, videoFormatCode, szTuningMode )); strncpy( pCapInfo->TuningMode, szTuningMode, sizeof(pCapInfo->TuningMode) ); // Setup the tuner first since it's upstream from the crossbar if (crossType == 1 && pCapInfo->pTVTuner) { IAMTVTuner* pTunerProps = NULL; HRESULT hr = pCapInfo->pTVTuner->QueryInterface(IID_IAMTVTuner, (void**)&pTunerProps); if (SUCCEEDED(hr)) { HRESULT ccHr = S_OK; if (countryCode) { long currCountry = 0; hr = pTunerProps->get_CountryCode(&currCountry); if (FAILED(hr) || currCountry != countryCode) { hr = ccHr = pTunerProps->put_CountryCode(countryCode); HTESTPRINT(hr); } hr = pTunerProps->put_TuningSpace(countryCode); HTESTPRINT(hr); } AMTunerModeType currMode; TunerInputType currTuneType; HRESULT currModehr = pTunerProps->get_Mode(&currMode); HTESTPRINT(currModehr); HRESULT currTypehr = pTunerProps->get_InputType(0, &currTuneType); HTESTPRINT(currTypehr); AMTunerModeType newMode; TunerInputType tuneType; slog((env, "Tuning mode:%s; current tuning type:%d current tuning model:%d\r\n", pCapInfo->TuningMode, currTuneType, currMode )); if (!strcmp(pCapInfo->TuningMode, "Air")) { newMode = AMTUNER_MODE_TV; tuneType = TunerInputAntenna; } else if (!strcmp(pCapInfo->TuningMode, "FM Radio")) { newMode = AMTUNER_MODE_FM_RADIO; tuneType = TunerInputAntenna; } else if (!strcmp(pCapInfo->TuningMode, "HRC")) { newMode = AMTUNER_MODE_TV; tuneType = (TunerInputType)2; } else { newMode = AMTUNER_MODE_TV; tuneType = TunerInputCable; } if (FAILED(currModehr) || newMode != currMode) { hr = pTunerProps->put_Mode(newMode); HTESTPRINT(hr); } if (FAILED(currTypehr) || tuneType != currTuneType) { hr = pTunerProps->put_InputType(0, tuneType); HTESTPRINT(hr); } long currConnInput = 0; hr = pTunerProps->get_ConnectInput(&currConnInput); if (FAILED(hr) || currConnInput != 0) { hr = pTunerProps->put_ConnectInput(0); HTESTPRINT(hr); } //long tvFormat; //hr = pTunerProps->get_TVFormat(&tvFormat); //ZQ test /* { IKsPropertySet *pKSProp=NULL; KSPROPERTY_TUNER_STANDARD_S Standard; hr = pCapInfo->pTVTuner->QueryInterface(IID_IKsPropertySet, (PVOID *)&pKSProp); if ( SUCCEEDED(hr) ) { memset(&Standard,0,sizeof(KSPROPERTY_TUNER_STANDARD_S)); Standard.Standard=videoFormatCode; HRESULT hr=pKSProp->Set(PROPSETID_TUNER, KSPROPERTY_TUNER_STANDARD, INSTANCE_DATA_OF_PROPERTY_PTR(&Standard), INSTANCE_DATA_OF_PROPERTY_SIZE(Standard), &Standard, sizeof(Standard)); if(FAILED(hr)) { slog(( env, "Failed set Video Format:%d on TVTuner hr=0x%x \r\n", videoFormatCode, hr )); } else { slog(( env, "Force to set Video Format:%d on TVTuner hr=0x%x \r\n", videoFormatCode, hr )); } SAFE_RELEASE( pKSProp ); } else { slog(( env, "Failed to get IKsPropertySet to set Video Format:%d on TVTuner hr=0x%x \r\n", videoFormatCode, hr )); } }*/ SAFE_RELEASE(pTunerProps); } if (pCapInfo->pTVAudio) { IAMTVAudio* pAudioProps = NULL; hr = pCapInfo->pTVAudio->QueryInterface(IID_IAMTVAudio, (void**)&pAudioProps); if (SUCCEEDED(hr)) { // For Vista+; there's the 'PRESET' flags which we want to use instead for setting the TV audio // selections. OSVERSIONINFOEX osInfo; ZeroMemory(&osInfo, sizeof(OSVERSIONINFOEX)); osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); DWORD vistaPlus = 0; if (GetVersionEx((LPOSVERSIONINFO)&osInfo)) { if (osInfo.dwMajorVersion >= 6) vistaPlus = 1; } if (vistaPlus) hr = pAudioProps->put_TVAudioMode(AMTVAUDIO_PRESET_STEREO | AMTVAUDIO_PRESET_LANG_A); else hr = pAudioProps->put_TVAudioMode(AMTVAUDIO_MODE_STEREO | AMTVAUDIO_MODE_LANG_A); HTESTPRINT(hr); } SAFE_RELEASE(pAudioProps); } } // Setup the crossbar for the graph IAMCrossbar *pXBar1 = NULL; HRESULT hr = pCapInfo->pCrossbar->QueryInterface(IID_IAMCrossbar, (void**)&pXBar1); HTESTPRINT(hr); // Look through the pins on the crossbar and find the correct one for the type of // connector we're routing. Also find the aligned audio pin and set that too. int tempCrossIndex = crossIndex; long i; long videoOutNum = -1; long audioOutNum = -1; long numIn, numOut; hr = pXBar1->get_PinCounts(&numOut, &numIn); HTESTPRINT(hr); long relatedPin, pinType; for (i = 0; i < numOut; i++) { hr = pXBar1->get_CrossbarPinInfo(FALSE, i, &relatedPin, &pinType); HTESTPRINT(hr); if (pinType == PhysConn_Video_VideoDecoder) videoOutNum = i; else if (pinType == PhysConn_Audio_AudioDecoder) audioOutNum = i; } for (i = 0; i < numIn; i++) { hr = pXBar1->get_CrossbarPinInfo(TRUE, i, &relatedPin, &pinType); HTESTPRINT(hr); if (pinType == crossType || (pinType == PhysConn_Video_YRYBY && crossType == 90)) // 90 is Component+SPDIF { if ((crossType != 1 && tempCrossIndex > 0) || tempCrossIndex == 1) { tempCrossIndex--; continue; } // Route the video long currRoute = -1; // hr = pXBar1->get_IsRoutedTo(videoOutNum, &currRoute); // if (FAILED(hr) || currRoute != i) { hr = pXBar1->Route(videoOutNum, i); HTESTPRINT(hr); } if (audioOutNum >= 0) { if (crossType == PhysConn_Video_YRYBY || crossType == 90) { long relatedPinType = 0; long junk = 0; pXBar1->get_CrossbarPinInfo(TRUE, relatedPin, &junk, &relatedPinType); if ((relatedPinType != PhysConn_Audio_SPDIFDigital && crossType == 90) || (relatedPinType == PhysConn_Audio_SPDIFDigital && crossType == PhysConn_Video_YRYBY)) { // Find the other audio input pin that's related to the component input and use that int j; long otherRelatedPin = 0; for (j = 0; j < numIn; j++) { if (j == relatedPin) continue; otherRelatedPin = 0; pXBar1->get_CrossbarPinInfo(TRUE, j, &otherRelatedPin, &junk); if (otherRelatedPin == i) { slog(( env, "Crossbar swapping related audio pins on component video input old:%d new:%d\r\n", relatedPin, j)); relatedPin = j; break; } } } } // Route any related audio // hr = pXBar1->get_IsRoutedTo(audioOutNum, &currRoute); // if (FAILED(hr) || currRoute != relatedPin) { hr = pXBar1->Route(audioOutNum, relatedPin); HTESTPRINT(hr); } } slog(( env, "Crossbar route: video:%d, auido:%d\r\n", i, relatedPin )); break; } } SAFE_RELEASE(pXBar1); if (audioOutNum == -1) { // It may have 2 crossbars, like ATI. Search for the second one. hr = pCapInfo->pBuilder->FindInterface(&LOOK_UPSTREAM_ONLY, NULL, pCapInfo->pCrossbar, IID_IAMCrossbar, (void**)&pXBar1); if (SUCCEEDED(hr)) { slog((env, "Found secondary audio crossbar, routing it\r\n")); tempCrossIndex = crossIndex; hr = pXBar1->get_PinCounts(&numOut, &numIn); HTESTPRINT(hr); for (i = 0; i < numOut; i++) { hr = pXBar1->get_CrossbarPinInfo(FALSE, i, &relatedPin, &pinType); HTESTPRINT(hr); if (pinType == PhysConn_Audio_AudioDecoder) { audioOutNum = i; break; } } for (i = 0; i < numIn && audioOutNum >= 0; i++) { hr = pXBar1->get_CrossbarPinInfo(TRUE, i, &relatedPin, &pinType); HTESTPRINT(hr); if (pinType == crossType) { if ((crossType != 1 && tempCrossIndex > 0) || tempCrossIndex == 1) { tempCrossIndex--; continue; } // Route any related audio hr = pXBar1->Route(audioOutNum, relatedPin); HTESTPRINT(hr); break; } } SAFE_RELEASE(pXBar1); } } IAMAnalogVideoDecoder *vidDec = NULL; hr = pCapInfo->pVideoCaptureFilter->QueryInterface(IID_IAMAnalogVideoDecoder, (void**)&vidDec); if (SUCCEEDED(hr)) { /*if (FAILED(ccHr) && countryCode == 54) { tvFormat = AnalogVideo_PAL_N; }*/ hr = vidDec->put_TVFormat(videoFormatCode); HTESTPRINT(hr); /*if (FAILED(hr) && tvFormat == AnalogVideo_PAL_N) { hr = vidDec->put_TVFormat(AnalogVideo_PAL_B); } */ SAFE_RELEASE(vidDec); } slog((env, "DONE: switchToConnector0 %d type=%d index=%d\r\n", (int)capInfo, crossType, crossIndex)); }
/* * Class: sage_DShowCaptureDevice * Method: autoTuneChannel0 * Signature: (JLjava/lang/String;I)Z */ JNIEXPORT jboolean JNICALL Java_sage_DShowCaptureDevice_autoTuneChannel0 (JNIEnv *env, jobject jo, jlong capInfo, jstring jnum, jint streamType ) { if (!capInfo) return JNI_FALSE; DShowCaptureInfo* pCapInfo = (DShowCaptureInfo*)capInfo; ////ZQ audio leaking //pCapInfo->pMC->Run(); //slog((env, ">>>> Start (capture:%s) \r\n")); //ZQ if (capMask(pCapInfo->captureConfig, sage_DShowCaptureDevice_BDA_VIDEO_CAPTURE_MASK )) { HRESULT hr; const char* cnum = env->GetStringUTFChars(jnum, NULL); if ( cnum == NULL || *cnum == 0x0 ) cnum = "0"; slog((env, "autotune0 digital tuner '%s-%d' num=%s (ver 3.1)\r\n", pCapInfo->videoCaptureFilterName, pCapInfo->videoCaptureFilterNum, cnum )); //setup output format hr = SetupBDAStreamOutFormat( env, pCapInfo, streamType ); hr = TurnBDAChannel( env, pCapInfo, cnum ); env->ReleaseStringUTFChars(jnum, cnum); int locked = SageCheckLocked( pCapInfo ); slog((env, "DONE: autotune0 hr=0x%x locked:%d\r\n", hr, locked )); return hr == S_OK ? JNI_TRUE : JNI_FALSE; }else //ZQ { if (!pCapInfo->pTVTuner) return JNI_FALSE; const char* cnum = env->GetStringUTFChars(jnum, NULL); int numericChannel = atoi(cnum); env->ReleaseStringUTFChars(jnum, cnum); IAMTVTuner* pTunerProps = NULL; long tuneResult = 0; if ( numericChannel == 0 || numericChannel < 0 ) return JNI_FALSE; long lFreq = 0; HRESULT hr = pCapInfo->pTVTuner->QueryInterface(IID_IAMTVTuner, (void**)&pTunerProps); slog((env, "autotune0 analog tuner '%s-%d' hr=0x%x num=%d\r\n", pCapInfo->videoCaptureFilterName, pCapInfo->videoCaptureFilterNum, hr, numericChannel)); if (SUCCEEDED(hr)) { hr = pTunerProps->AutoTune(numericChannel, &tuneResult); HRESULT hr2 = pTunerProps->get_VideoFrequency( &lFreq ); //if ( tuneResult ) // pTunerProps->StoreAutoTune(); pCapInfo->dwTuneState = 0x01; //Fusion Card, FIX: after ATSC tune, fail to tune TV if ( strstr( pCapInfo->videoCaptureFilterName, "Fusion" ) ) pTunerProps->put_Mode( AMTUNER_MODE_FM_RADIO ); pTunerProps->put_Mode( AMTUNER_MODE_TV ); //ZQ. SAFE_RELEASE(pTunerProps); } slog((env, "DONE: autotune0 %d hr=0x%x result=%d freq:%d.\r\n", (int)capInfo, hr, tuneResult, lFreq )); return (SUCCEEDED(hr) && (tuneResult != 0)); } return JNI_FALSE; }
/* Class: sage_DShowCaptureDevice * Method: getDevicesInCategory0 * Signature: (Ljava/lang/String;)[Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_sage_DShowCaptureDevice_scanBDAChannel0 (JNIEnv *env, jobject jo, jlong capInfo, jstring jnum, jstring jcountry, jint streamType ) { static jclass stringClass; DShowCaptureInfo* pCapInfo = (DShowCaptureInfo*) capInfo; if (!pCapInfo ) { slog((env, "ScanDBAChannel0 failed device is not open or not exist.\r\n" )); return env->NewStringUTF(""); } if ( !capMask(pCapInfo->captureConfig, sage_DShowCaptureDevice_BDA_VIDEO_CAPTURE_MASK ) ) { slog((env, "is not BDA capture device\r\n" )); return env->NewStringUTF(""); } TV_TYPE TVType = GetTVType( pCapInfo ); const char* cnum = env->GetStringUTFChars(jnum, NULL); const jchar* country = env->GetStringChars( jcountry, NULL); char countryRegion[256]={0}; char tuningString[64]={0}; if ( country != NULL && country[0] ) wcstombs( countryRegion, (wchar_t*)country, sizeof(countryRegion)-2 ); //trime space int len = strlen(countryRegion); while( len-- > 0 ) { if ( countryRegion[len] == ' ' ) countryRegion[len] = 0x0; else break; } strncpy( pCapInfo->Country, countryRegion, sizeof(pCapInfo->Country) ); //$NEW strncpy( tuningString, cnum, sizeof(tuningString) ); env->ReleaseStringUTFChars( jnum, cnum); env->ReleaseStringChars( jcountry, country); //if ( pCapInfo->filterState <= 1 ) //in case, CaptureFilters is not ready { AddBDAVideoCaptureFilters( env, pCapInfo, pCapInfo->pGraph, 0 ); BDAGraphSetDebugFileSource( env, pCapInfo, pCapInfo->pGraph ); BDAGraphConnectFilter( env, pCapInfo, pCapInfo->pGraph ); SetupCAM( env, pCapInfo ); SetupTunerPlugin( env, pCapInfo, GetTVType( pCapInfo ) ); BDAGraphConnectDebugRawDumpSink( env, pCapInfo, pCapInfo->pGraph ); BDAGraphConnectDumpSink( env, pCapInfo, pCapInfo->pGraph ); ClearUpDebugFileSource( env, pCapInfo, pCapInfo->pGraph ); } TV_TYPE BDATVType = GetTVType( pCapInfo ); if ( BDATVType == ATSC ) { if ( !stricmp( pCapInfo->TuningMode, "Cable" ) ) { if ( QAMTunerType( env, pCapInfo ) == 1 ) { BDATVType = QAM; } else if ( strstr( pCapInfo->videoCaptureFilterName, "Silicondust HDHomeRun" ) ) //ZQ. hardcode HDHR QAM { BDATVType = QAM; slog( (env, "It's a HDHomeRun QAM tuner\r\n") ); } } if ( strcmp( getSourceType( (CHANNEL_DATA*)pCapInfo->channel ), TVTypeString( BDATVType ) ) ) setSourceType( (CHANNEL_DATA*)pCapInfo->channel, TVTypeString( BDATVType ) ); } if ( BDATVType == DVBS ) { if ( atoi( tuningString) == 0 ) SetupSatelliteLNB( pCapInfo, 1 ); } char* deviceName = SageGetTunerDeviceName(pCapInfo); slog(( env, "Scan Channel:%s, country:%s, type:%s...\r\n", tuningString, countryRegion, getSourceType( (CHANNEL_DATA*)pCapInfo->channel ) )); char* scanResult = scanChannel( (CHANNEL_DATA*)pCapInfo->channel, deviceName, tuningString, countryRegion, (int)streamType ); len = strlen( scanResult ); //trim \r\n while ( len > 1 && scanResult[len-1] == '\r' || scanResult[len-1] == '\n' ) { scanResult[len-1] = 0; len--; }; if ( scanResult != NULL && len >= 1024 ) slog(( env, "Scan Channel: scan result too long to log here, check native log\r\n" )); else slog(( env, "Scan Channel:%s, ret='%s'.\r\n", tuningString, scanResult==NULL ? "": scanResult )); jstring jretstr; if ( scanResult != NULL ) { jretstr = env->NewStringUTF(scanResult ); free( scanResult ); } else jretstr = env->NewStringUTF( "" ); return jretstr; //$NEW }
/* this splits apart a message with origin and command picked off already */ int tokenize(char *message, char **parv) { char *pos = NULL; char *next; unsigned int count = 0; if (!message) return -1; /* first we fid out of there's a : in the message, save that string * somewhere so we can set it to the last param in parv * also make sure there's a space before it... if not then we're screwed */ pos = message; while (true) { if ((pos = strchr(pos, ':'))) { pos--; if (*pos != ' ') { pos += 2; continue; } *pos = '\0'; pos++; *pos = '\0'; pos++; break; } else break; } /* now we take the beginning of the message and find all the spaces... * set them to \0 and use 'next' to go through the string */ next = message; parv[0] = message; count = 1; while (*next) { if (count == MAXPARC) { /* we've reached one less than our max limit * to handle the parameter we already ripped off */ slog(LG_DEBUG, "tokenize(): reached para limit"); return count; } if (*next == ' ') { *next = '\0'; next++; /* eat any additional spaces */ while (*next == ' ') next++; /* if it's the end of the string, it's simply * an extra space before the :parameter. break. */ if (*next == '\0') break; parv[count] = next; count++; } else next++; } if (pos) { parv[count] = pos; count++; } return count; }
void iofunctions_start_autosave (void) { sid = g_timeout_add_seconds (atoi(config_get_value ("autosave_timer")) * 60, iofunctions_autosave_cb, NULL); slog (L_DEBUG, "Autosaving function started..\n"); }
void font_draw_text_block_custom( char * thetext, RectFloat block, Vec3D color, float alpha, Font *font ) { Text textline; Text temptextline; Text text; Line word; int whitespace; int drawheight = block.y; int w,h; int i; int space; int lindex = 0; if (!font_initialized())return; if ((thetext == NULL)||(thetext[0] == '\0')) { slog("font: no text provided for draw.\n"); return; } if (font == NULL) { slog("font: no font provided for draw.\n"); return; } if (font->_font == NULL) { slog("font: bad Font provided for draw.\n"); return; } strncpy(text,thetext,TEXTLEN); temptextline[0] = '\0'; do { space = 0; i = 0; do { whitespace = 0; if(sscanf(&text[i],"%c",&word[0]) == EOF)break; if(word[0] == ' ') { space++; whitespace = 1; } if(word[0] == '\t') { space+=2; whitespace = 1; } i++; }while (whitespace); if (sscanf(text,"%s",word) == EOF) { block.y=drawheight+h; font_draw_text_custom(temptextline,block.x,block.y, color, alpha, font); return; } font_crop_string(text,strlen(word) + space,TEXTLEN); strncpy(textline,temptextline,TEXTLEN);/*keep the last line that worked*/ for (i = 0;i < (space - 1);i++) { sprintf(temptextline,"%s%c",temptextline,' '); /*add spaces*/ } sprintf(temptextline,"%s %s",temptextline,word); /*add a word*/ TTF_SizeText(font->_font, temptextline, &w, &h); /*see how big it is now*/ lindex += strlen(word); if(w > block.w) /*see if we have gone over*/ { block.y=drawheight+h; font_draw_text_custom(textline,block.x,block.y, color, alpha, font); /*draw the line and get ready for the next line*/ drawheight += h; if (block.h != 0) { if ((drawheight + h) > block.h) { break; } } sprintf(temptextline,"%s",word); /*add a word*/ } }while(1); }
static void m_nick(sourceinfo_t *si, int parc, char *parv[]) { server_t *s; user_t *u; /* got the right number of args for an introduction? */ if (parc == 8) { s = server_find(parv[6]); if (!s) { slog(LG_DEBUG, "m_nick(): new user on nonexistant server: %s", parv[6]); return; } slog(LG_DEBUG, "m_nick(): new user on `%s': %s", s->name, parv[0]); u = user_add(parv[0], parv[4], parv[5], NULL, NULL, NULL, parv[7], s, atoi(parv[2])); if (u == NULL) return; user_mode(u, parv[3]); /* If server is not yet EOB we will do this later. * This avoids useless "please identify" -- jilles */ if (s->flags & SF_EOB) handle_nickchange(user_find(parv[0])); } /* if it's only 2 then it's a nickname change */ else if (parc == 2) { bool realchange; if (!si->su) { slog(LG_DEBUG, "m_nick(): server trying to change nick: %s", si->s != NULL ? si->s->name : "<none>"); return; } slog(LG_DEBUG, "m_nick(): nickname change from `%s': %s", si->su->nick, parv[0]); realchange = irccasecmp(si->su->nick, parv[0]); if (user_changenick(si->su, parv[0], atoi(parv[1]))) return; /* fix up +e if necessary -- jilles */ if (realchange && should_reg_umode(si->su)) /* changed nick to registered one, reset +e */ sts(":%s ENCAP * IDENTIFIED %s %s", ME, CLIENT_NAME(si->su), si->su->nick); /* It could happen that our PING arrived late and the * server didn't acknowledge EOB yet even though it is * EOB; don't send double notices in that case -- jilles */ if (si->su->server->flags & SF_EOB) handle_nickchange(si->su); } else { int i; slog(LG_DEBUG, "m_nick(): got NICK with wrong number of params"); for (i = 0; i < parc; i++) slog(LG_DEBUG, "m_nick(): parv[%d] = %s", i, parv[i]); } }
RectFloat font_get_block_bounds_custom( char * thetext, Font * font, Uint32 w, Uint32 h ) { RectFloat r = {0,0,0,0}; Text textline; Text temptextline; Text text; Line word; int whitespace; int tw = 0, th = 0; int drawheight = 0; int i = 0; int space = 0; int lindex = 0; if (!font_initialized())return r; if((thetext == NULL)||(thetext[0] == '\0')) { return r; } if (font == NULL) { slog("font: no font provided for draw.\n"); return r; } strncpy(text,thetext,TEXTLEN); temptextline[0] = '\0'; do { space = 0; i = 0; whitespace = 0; do { if(sscanf(&text[i],"%c",&word[0]) == EOF)break; if(word[0] == ' ') { space++; whitespace = 1; } if(word[0] == '\t') { space+=2; whitespace = 1; } i++; }while(whitespace); if(sscanf(text,"%s",word) == EOF) { break; } font_crop_string(text,strlen(word) + 1,TEXTLEN); strncpy(textline,temptextline,TEXTLEN);/*keep the last line that worked*/ for(i = 0;i < (space - 1);i++) { sprintf(temptextline,"%s%c",temptextline,' '); /*add spaces*/ } sprintf(temptextline,"%s %s",temptextline,word); /*add a word*/ TTF_SizeText(font->_font, temptextline, &tw, &th); /*see how big it is now*/ lindex += strlen(word); if(tw > w) /*see if we have gone over*/ { drawheight += th; if (h != 0) { if ((drawheight + th) > h) { break; } } sprintf(temptextline,"%s",word); /*add a word*/ } else if (tw > r.w) { r.w = tw; } }while(1); r.h = drawheight + th; return r; }
/* * Class: sage_DShowCaptureDevice * Method: getChannel0 * Signature: (JI)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_sage_DShowCaptureDevice_getChannel0 (JNIEnv *env, jobject jo, jlong capInfo, jint chanType) { DShowCaptureInfo* pCapInfo = (DShowCaptureInfo*) capInfo; if (!pCapInfo ) return env->NewStringUTF("0"); if (capMask(pCapInfo->captureConfig, sage_DShowCaptureDevice_BDA_VIRTUAL_TUNER_MASK )) return env->NewStringUTF("0"); //ZQ if (capMask(pCapInfo->captureConfig, sage_DShowCaptureDevice_BDA_VIDEO_CAPTURE_MASK )) { HRESULT hr; long lPhysicalChannel, lMinorChannel, lMajorChannel; char rvBuf[32]; hr = RetreveBDAChannel( env, pCapInfo, &lPhysicalChannel, &lMinorChannel, &lMajorChannel ); if ( FAILED( hr ) ) return env->NewStringUTF("0"); if ( lMajorChannel > 0 && lMinorChannel > 0 ) { SPRINTF(rvBuf, sizeof(rvBuf), "%d-%d-%d", lPhysicalChannel, lMajorChannel, lMinorChannel ); return env->NewStringUTF(rvBuf); } else if ( lMinorChannel > 0 ) { SPRINTF(rvBuf, sizeof(rvBuf), "%d-%d", lPhysicalChannel, lMinorChannel ); return env->NewStringUTF(rvBuf); } else { SPRINTF(rvBuf, sizeof(rvBuf), "%d", lPhysicalChannel ); return env->NewStringUTF(rvBuf); } } else try { if ( !pCapInfo->pTVTuner ) return env->NewStringUTF("0"); CComPtr<IAMTVTuner> pTunerProps = NULL; HRESULT hr = pCapInfo->pTVTuner->QueryInterface(IID_IAMTVTuner, (void**)&(pTunerProps.p)); if (FAILED(hr)) return env->NewStringUTF("0"); long currChan, videoSub, audioSub; if (chanType == 0) hr = pTunerProps->get_Channel(&currChan, &videoSub, &audioSub); else if (chanType == 1) hr = pTunerProps->ChannelMinMax(&videoSub, &currChan); else // chanType == -1 hr = pTunerProps->ChannelMinMax(&currChan, &videoSub); if (FAILED(hr)) return env->NewStringUTF("0"); else { char rvBuf[8]; SPRINTF(rvBuf, sizeof(rvBuf), "%d", (int)currChan); return env->NewStringUTF(rvBuf); } } catch (...) { slog((env, "NATIVE EXCEPTION getting current channel capInfo=%d chanType=%d\r\n", (int) capInfo, (int) chanType)); return env->NewStringUTF("0"); } //ZQ }
static void cs_cmd_register(struct sourceinfo *si, int parc, char *parv[]) { struct channel *c; struct chanuser *cu; struct mychan *mc; char *name = parv[0]; char str[21]; hook_channel_register_check_t hdatac; hook_channel_req_t hdata; unsigned int fl; /* This command is not useful on registered channels, ignore it if * it is a fantasy command so users can program bots to react on * it without interference from ChanServ. */ if (si->c != NULL) return; if (!name) { command_fail(si, fault_needmoreparams, STR_INSUFFICIENT_PARAMS, "REGISTER"); command_fail(si, fault_needmoreparams, _("To register a channel: REGISTER <#channel>")); return; } if (*name != '#') { command_fail(si, fault_badparams, STR_INVALID_PARAMS, "REGISTER"); command_fail(si, fault_badparams, _("Syntax: REGISTER <#channel>")); return; } if (si->smu->flags & MU_WAITAUTH) { command_fail(si, fault_notverified, _("You need to verify your email address before you may register channels.")); return; } // make sure it isn't already registered if ((mc = mychan_find(name))) { if (! (mc->flags & MC_PRIVATE)) command_fail(si, fault_alreadyexists, _("\2%s\2 is already registered to \2%s\2."), mc->name, mychan_founder_names(mc)); else command_fail(si, fault_alreadyexists, _("\2%s\2 is already registered."), mc->name); return; } // make sure the channel exists if (!(c = channel_find(name))) { command_fail(si, fault_nosuch_target, _("The channel \2%s\2 must exist in order to register it."), name); return; } // make sure they're in it if (!(cu = chanuser_find(c, si->su))) { command_fail(si, fault_noprivs, _("You must be in \2%s\2 in order to register it."), name); return; } // make sure they're opped (or protected/owner on unreal/inspircd) if (!((CSTATUS_OP | CSTATUS_PROTECT | CSTATUS_OWNER) & cu->modes)) { command_fail(si, fault_noprivs, _("You must be a channel operator in \2%s\2 in order to register it."), name); return; } if (metadata_find(si->smu, "private:restrict:setter")) { command_fail(si, fault_noprivs, _("You have been restricted from registering channels by network staff.")); return; } if ((unsigned int)(CURRTIME - ratelimit_firsttime) > config_options.ratelimit_period) { ratelimit_count = 0; ratelimit_firsttime = CURRTIME; } if (ratelimit_count > config_options.ratelimit_uses && !has_priv(si, PRIV_FLOOD)) { command_fail(si, fault_toomany, _("The system is currently too busy to process your registration, please try again later.")); slog(LG_INFO, "CHANSERV:REGISTER:THROTTLED: \2%s\2 by \2%s\2", name, entity(si->smu)->name); return; } hdatac.si = si; hdatac.name = name; hdatac.chan = c; hdatac.approved = 0; hook_call_channel_can_register(&hdatac); if (hdatac.approved != 0) return; if (!myentity_can_register_channel(entity(si->smu))) { command_fail(si, fault_toomany, _("You have too many channels registered.")); return; } if (config_options.ratelimit_uses && config_options.ratelimit_period) ratelimit_count++; logcommand(si, CMDLOG_REGISTER, "REGISTER: \2%s\2", name); mc = mychan_add(name); mc->registered = CURRTIME; mc->used = CURRTIME; mc->mlock_on |= (CMODE_NOEXT | CMODE_TOPIC); if (c->limit == 0) mc->mlock_off |= CMODE_LIMIT; if (c->key == NULL) mc->mlock_off |= CMODE_KEY; mc->flags |= config_options.defcflags; chanacs_add(mc, entity(si->smu), custom_founder_check(), CURRTIME, entity(si->smu)); if (c->ts > 0) { snprintf(str, sizeof str, "%lu", (unsigned long)c->ts); metadata_add(mc, "private:channelts", str); } if (chansvs.deftemplates != NULL && *chansvs.deftemplates != '\0') metadata_add(mc, "private:templates", chansvs.deftemplates); command_success_nodata(si, _("\2%s\2 is now registered to \2%s\2."), mc->name, entity(si->smu)->name); hdata.si = si; hdata.mc = mc; hook_call_channel_register(&hdata); // Allow the hook to override this. fl = chanacs_source_flags(mc, si); cu = chanuser_find(mc->chan, si->su); if (cu == NULL) ; else if (ircd->uses_owner && fl & CA_USEOWNER && fl & CA_AUTOOP && !(cu->modes & CSTATUS_OWNER)) { modestack_mode_param(si->service->nick, mc->chan, MTYPE_ADD, ircd->owner_mchar[1], CLIENT_NAME(si->su)); cu->modes |= CSTATUS_OWNER; } else if (ircd->uses_protect && fl & CA_USEPROTECT && fl & CA_AUTOOP && !(cu->modes & CSTATUS_PROTECT)) { modestack_mode_param(si->service->nick, mc->chan, MTYPE_ADD, ircd->protect_mchar[1], CLIENT_NAME(si->su)); cu->modes |= CSTATUS_PROTECT; } }
HRESULT SetVboxFrequency( JNIEnv *env, DShowCaptureInfo* pCapInfo, ULONG ulFrequency ) { HRESULT hr; DWORD dwSupported=0; IEnumPins* pEnumPin; IPin* pInputPin; ULONG ulFetched; PIN_INFO infoPin; if ( pCapInfo->pBDATuner == NULL ) return E_FAIL; if( ulFrequency == 0 ) { slog( (env,"VOX tuner skips frequency 0\r\n") ); return S_OK; } IBaseFilter* pTunerDevice = pCapInfo->pBDATuner; pTunerDevice->EnumPins(&pEnumPin); if( SUCCEEDED( hr = pEnumPin->Reset() ) ) { while((hr = pEnumPin->Next( 1, &pInputPin, &ulFetched )) == S_OK) { pInputPin->QueryPinInfo(&infoPin); // Release AddRef'd filter, we don't need it if( infoPin.pFilter != NULL ) infoPin.pFilter->Release(); if(infoPin.dir == PINDIR_INPUT) break; } if(hr != S_OK) { slog( (env,"Vbox tuner input pin query failed \r\n") ); return hr; } } else { slog( (env,"Vbox tuner reset failed \r\n") ); return E_FAIL; } IKsPropertySet *pKsPropertySet; pInputPin->QueryInterface(&pKsPropertySet); if (!pKsPropertySet) { slog( (env,"Vbox tuner input pin's QueryInterface failed \r\n") ); return E_FAIL; } KSPROPERTY_TUNER_MODE_CAPS_S ModeCaps; KSPROPERTY_TUNER_FREQUENCY_S Frequency; memset(&ModeCaps,0,sizeof(KSPROPERTY_TUNER_MODE_CAPS_S)); memset(&Frequency,0,sizeof(KSPROPERTY_TUNER_FREQUENCY_S)); ModeCaps.Mode = AMTUNER_MODE_TV; // Check either the Property is supported or not by the Tuner drivers hr = pKsPropertySet->QuerySupported(PROPSETID_TUNER, KSPROPERTY_TUNER_MODE_CAPS,&dwSupported); if(SUCCEEDED(hr) && dwSupported&KSPROPERTY_SUPPORT_GET) { DWORD cbBytes=0; hr = pKsPropertySet->Get(PROPSETID_TUNER,KSPROPERTY_TUNER_MODE_CAPS, INSTANCEDATA_OF_PROPERTY_PTR(&ModeCaps), INSTANCEDATA_OF_PROPERTY_SIZE(ModeCaps), &ModeCaps, sizeof(ModeCaps), &cbBytes); } else { SAFE_RELEASE(pKsPropertySet); slog( (env,"Vbox tuner input pin's not support GET query \r\n") ); return E_FAIL; } Frequency.Frequency=ulFrequency; // in Hz if(ModeCaps.Strategy==KS_TUNER_STRATEGY_DRIVER_TUNES) Frequency.TuningFlags=KS_TUNER_TUNING_FINE; else Frequency.TuningFlags=KS_TUNER_TUNING_EXACT; // Here the real magic starts //if(ulFrequency>=ModeCaps.MinFrequency && ulFrequency<=ModeCaps.MaxFrequency) { hr = pKsPropertySet->Set(PROPSETID_TUNER, KSPROPERTY_TUNER_FREQUENCY, INSTANCEDATA_OF_PROPERTY_PTR(&Frequency), INSTANCEDATA_OF_PROPERTY_SIZE(Frequency), &Frequency, sizeof(Frequency)); if(FAILED(hr)) { slog( (env,"Vbox tuner input pin's set frequency %d failed hr=0x%x\r\n", Frequency.Frequency, hr ) ); SAFE_RELEASE(pKsPropertySet); return E_FAIL; } } // else // { //slog( (env,"Vbox tuning frequency %d is out of range (%d %d)\r\n", // ulFrequency, ModeCaps.MinFrequency, ModeCaps.MaxFrequency ) ); // return E_FAIL; // } SAFE_RELEASE(pKsPropertySet); slog( (env,"Vbox tuner tuning overider frequency %d successful. \r\n", ulFrequency) ); return S_OK; }
void _modinit() { slog(LG_INFO, "example.so loaded and we did not crash -- sweet."); }
static void process_mowgli_log(const char *line) { slog(LG_ERROR, "%s", line); }
void _moddeinit() { slog(LG_INFO, "example.so unloaded and we did not crash -- kickin'."); }