int MeterSML::open() { if (_device != "") { _fd = _openDevice(&_old_tio, _baudrate); } else if (_host != "") { char *addr = strdup(host()); const char *node = strsep(&addr, ":"); const char *service = strsep(&addr, ":"); if(node == NULL && service == NULL) return -1; _fd = _openSocket(node, service); free(addr); } return _fd; }
void AppleRemote::startListening() { if (queue != NULL) // already listening return; io_object_t hidDevice = _findAppleRemoteDevice("AppleIRController"); if (!hidDevice) hidDevice = _findAppleRemoteDevice("AppleTVIRReceiver"); if (!hidDevice || !_createDeviceInterface(hidDevice) || !_initCookies() || !_openDevice()) { LOG(VB_GENERAL, LOG_ERR, LOC + "startListening() failed"); stopListening(); return; } IOObjectRelease(hidDevice); }
/*============================================================================= FUNCTION: createVideoSurface DESCRIPTION: This function create a video surface. ==============================================================================*/ void * createVideoSurface (int devid, int mode_idx, SourceFmt * src, DestinationFmt * des) { VS_FLOW ("Fun %s in\n", __FUNCTION__); VideoSurfacesControl *vc; VideoSurface *vs = NULL; VideoDevice *vd; int i; if (_checkSource (src)) { VS_ERROR ("source fmt error\n"); goto err; } if ((des == NULL) || (src == NULL)) { VS_ERROR ("%s: parameters error!\n", __FUNCTION__); goto err; } if (gVSctl == NULL) { gVSlock = _getAndLockVSLock (VS_IPC_CREATE); if (gVSlock == NULL) { VS_ERROR ("Can not create/open ipc semphone!\n"); goto err; } gVSctl = _getVSControl (VS_IPC_CREATE); if (gVSctl == NULL) { VS_ERROR ("Can not create/open ipc sharememory!\n"); VS_UNLOCK (gVSlock); goto err; } } else { VS_LOCK (gVSlock); } vc = gVSctl; if ((vd = _getDevicebyDevID (devid)) == NULL) { VS_ERROR ("Can not find dev id %d!\n", devid); VS_UNLOCK (gVSlock); goto err; } if (vd->cnt >= vd->vsmax) { VS_UNLOCK (gVSlock); VS_ERROR ("%s: max surfaces on device support on device%d exceeded!\n", __FUNCTION__, devid); goto err; } for (i = 0; i < VS_MAX; i++) { if (vc->surfaces[i].status == VS_STATUS_IDLE) { break; } } if (i == VS_MAX) { VS_UNLOCK (gVSlock); VS_ERROR ("%s: max surface support exceeded!\n", __FUNCTION__); goto err; } vs = &vc->surfaces[i]; vs->status = VS_STATUS_VISIBLE; vs->vd_id = vd->id; vs->srcfmt = *src; vs->desfmt = *des; vs->itask.mode = 0; vs->mainframeupdate = 1; memset (&vs->itask, 0, sizeof (IPUTaskOne)); if (vd->init == 0) { if (_initVideoDevice (vd, mode_idx)) { VS_UNLOCK (gVSlock); VS_ERROR ("%s: error config!\n", __FUNCTION__); goto err; } } vs->outside = _adjustDestRect (&des->rect, vd); vs->adjustdesrect = des->rect; VS_MESSAGE ("VS%d created. in fmt[" FOURCC_FMT "] win" WIN_FMT " out win" WIN_FMT "\n", vs->id - 1, FOURCC_ARGS (src->fmt), WIN_ARGS (&src->croprect.win), WIN_ARGS (&vs->desfmt.rect)); vs->next = gvslocal; gvslocal = vs; vd->cnt++; if (vd->cnt == 1) { _openDevice (vd); } _addVideoSurface2Device (vd, vs); if (_checkOnDevice (vd)) { _reconfigAllVideoSurfaces (vd); _setDeviceConfig (vd); } vd->init = 1; _initVSIPUTask (vs); if (vd->setalpha) _setAlpha (vd); VS_UNLOCK (gVSlock); VS_FLOW ("Fun %s out\n", __FUNCTION__); return (void *) vs; err: if (vs) { vs->status = VS_STATUS_IDLE; } return NULL; }