bool ExternalChannel::Open(void) { LOG(VB_CHANNEL, LOG_INFO, LOC + "Open()"); if (m_device.isEmpty()) return false; if (IsOpen()) { if (m_stream_handler->IsAppOpen()) return true; LOG(VB_GENERAL, LOG_ERR, LOC + QString("Valid stream handler, but app is not open! Resetting.")); Close(); } if (!InitializeInput()) return false; if (!m_inputid) return false; m_stream_handler = ExternalStreamHandler::Get(m_device); if (!m_stream_handler || m_stream_handler->HasError()) { LOG(VB_GENERAL, LOG_ERR, LOC + "Open failed"); return false; } LOG(VB_RECORD, LOG_INFO, LOC + "Opened"); return true; }
void ConsumerNode::NodeRegistered() { out("ConsumerNode::NodeRegistered\n"); InitializeInput(); SetPriority(108); Run(); }
/** * Removes a digital input structure from the board's list by specifying its physical input channel. * * @param id uint8_t The physical channel to remove, if present. * @retval none */ static void RemoveDigitalInputByID(uint8_t id) { if (isExternalInput(id)) { InitializeInput(&Ext_DInputs[id]); } else { /* This is out of range */ #ifdef DIGITALINPUT_DEBUG printf("[Digital Input] Cannot find the requested digital input. Input does not exist on the board.\n\r"); #endif } }
void PowerNES(void) { if(!FCEUGameInfo) return; FCEU_CheatResetRAM(); FCEU_CheatAddRAM(2,0,RAM); GeniePower(); #ifndef COPYFAMI FCEU_MemoryRand(RAM,0x800); #endif SetReadHandler(0x0000,0xFFFF,ANull); SetWriteHandler(0x0000,0xFFFF,BNull); #ifdef COPYFAMI SetReadHandler(0,0x3FFF,ARAML); SetWriteHandler(0,0x3FFF,BRAML); #else SetReadHandler(0,0x7FF,ARAML); SetWriteHandler(0,0x7FF,BRAML); SetReadHandler(0x800,0x1FFF,ARAMH); /* Part of a little */ SetWriteHandler(0x800,0x1FFF,BRAMH); /* hack for a small speed boost. */ #endif InitializeInput(); FCEUSND_Power(); FCEUPPU_Power(); /* Have the external game hardware "powered" after the internal NES stuff. Needed for the NSF code and VS System code. */ GameInterface(GI_POWER); if(FCEUGameInfo->type==GIT_VSUNI) FCEU_VSUniPower(); timestampbase=0; X6502_Power(); FCEU_PowerCheats(); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HWND hWnd; if(GenerateWindow(_T("Fire_Balloon"), _T("Fire_Ballon Program"), 600, 700, hWnd) && InitializeInput()) { MSG msg; obj = new Main_Scene(); obj->Initialize(hWnd); obj->Draw(0.0f); while(true) { while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if(msg.message == WM_QUIT) break; else { if(obj->GetSceneNumber() == obj->GAME_SCENE) { obj->Draw(0.0f, *user); } if (obj->GetGameState() && obj->GetSceneNumber() == obj->GAME_SCENE) { delete obj; obj = new GameResultScene(); obj->Initialize(hWnd); obj->Draw(0.0f, *user); } } } return msg.wParam; } UnregisterClass(_T("Fire_Balloon"), wcex.hInstance); delete obj; delete user; return 0; }
bool ASIChannel::Open(void) { LOG(VB_CHANNEL, LOG_INFO, LOC + "Open()"); if (m_device.isEmpty()) return false; if (m_isopen) return true; if (!InitializeInput()) return false; if (!m_inputid) return false; m_isopen = true; return true; }
void ConsumerNode::Disconnected( const media_source & producer, const media_destination & where) { out("ConsumerNode::Disconnected\n"); /* unreserve the connection */ InitializeInput(); #if 0 /* release buffer group */ mBufferGroup = NULL; if (mOwnBufferGroup != NULL) { delete_own_buffer_group(); } #endif return; }
bool CetonChannel::Open(void) { LOG(VB_CHANNEL, LOG_INFO, LOC + "Opening Ceton channel"); if (IsOpen()) return true; _stream_handler = CetonStreamHandler::Get(_device_id, GetInputID()); tunerType = DTVTunerType::kTunerTypeATSC; _tuner_types.push_back(tunerType); if (!InitializeInput()) { Close(); return false; } return _stream_handler->IsConnected(); }
/** * Initializes all requisite sub-modules to properly operate digital inputs. This includes any multiplexing and * default inputs. * * @param none * @retval none */ void DigitalInputsInit(void) { GPIO_InitTypeDef GPIO_InitStructure; /* Enable the GPIO Clock */ RCC_AHB1PeriphClockCmd(GPI_GPIO_CLKS, ENABLE); /* Configure the GPIO pin */ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; /* Configure the Port B Pins */ GPIO_InitStructure.GPIO_Pin = GPI_PORTB_PINS; GPIO_Init(GPIOB, &GPIO_InitStructure); /* Configure the Port E Pins */ GPIO_InitStructure.GPIO_Pin = GPI_PORTE_PINS; GPIO_Init(GPIOE, &GPIO_InitStructure); /* Configure the Port F Pins */ GPIO_InitStructure.GPIO_Pin = GPI_PORTF_PINS; GPIO_Init(GPIOF, &GPIO_InitStructure); /* Configure the Port G Pins */ GPIO_InitStructure.GPIO_Pin = GPI_PORTG_PINS; GPIO_Init(GPIOG, &GPIO_InitStructure); /* Configure the Port H Pins */ GPIO_InitStructure.GPIO_Pin = GPI_PORTH_PINS; GPIO_Init(GPIOH, &GPIO_InitStructure); /* Configure the Port I Pins */ GPIO_InitStructure.GPIO_Pin = GPI_PORTI_PINS; GPIO_Init(GPIOI, &GPIO_InitStructure); for (int i = 0; i < NUM_DIGITAL_INPUTS; ++i) { InitializeInput(&Ext_DInputs[i]); } }
bool DVBChannel::Open(DVBChannel *who) { LOG(VB_CHANNEL, LOG_INFO, LOC + "Opening DVB channel"); if (!m_inputid) { if (!InitializeInput()) return false; } QMutexLocker locker(&hw_lock); if (fd_frontend >= 0) { is_open[who] = true; return true; } DVBChannel *master = GetMasterLock(); if (master != this) { if (!master->Open(who)) { ReturnMasterLock(master); return false; } fd_frontend = master->fd_frontend; frontend_name = master->frontend_name; tunerType = master->tunerType; capabilities = master->capabilities; ext_modulations = master->ext_modulations; frequency_minimum = master->frequency_minimum; frequency_maximum = master->frequency_maximum; symbol_rate_minimum = master->symbol_rate_minimum; symbol_rate_maximum = master->symbol_rate_maximum; is_open[who] = true; if (!InitializeInput()) { Close(); ReturnMasterLock(master); return false; } ReturnMasterLock(master); return true; } ReturnMasterLock(master); // if we're the master we don't need this lock.. QString devname = CardUtil::GetDeviceName(DVB_DEV_FRONTEND, device); QByteArray devn = devname.toLatin1(); for (int tries = 1; ; ++tries) { fd_frontend = open(devn.constData(), O_RDWR | O_NONBLOCK); if (fd_frontend >= 0) break; LOG(VB_GENERAL, LOG_WARNING, LOC + "Opening DVB frontend device failed." + ENO); if (tries >= 20 || (errno != EBUSY && errno != EAGAIN)) { LOG(VB_GENERAL, LOG_ERR, LOC + QString("Failed to open DVB frontend device due to " "fatal error or too many attempts.")); return false; } usleep(50000); } dvb_frontend_info info; memset(&info, 0, sizeof(info)); if (ioctl(fd_frontend, FE_GET_INFO, &info) < 0) { LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to get frontend information." + ENO); close(fd_frontend); fd_frontend = -1; return false; } frontend_name = info.name; tunerType = info.type; #if HAVE_FE_CAN_2G_MODULATION if (info.caps & FE_CAN_2G_MODULATION) { if (tunerType == DTVTunerType::kTunerTypeDVBS1) tunerType = DTVTunerType::kTunerTypeDVBS2; else if (tunerType == DTVTunerType::kTunerTypeDVBT) tunerType = DTVTunerType::kTunerTypeDVBT2; } #endif // HAVE_FE_CAN_2G_MODULATION capabilities = info.caps; frequency_minimum = info.frequency_min; frequency_maximum = info.frequency_max; symbol_rate_minimum = info.symbol_rate_min; symbol_rate_maximum = info.symbol_rate_max; LOG(VB_RECORD, LOG_INFO, LOC + QString("Using DVB card %1, with frontend '%2'.") .arg(device).arg(frontend_name)); // Turn on the power to the LNB if (tunerType.IsDiSEqCSupported()) { diseqc_tree = diseqc_dev.FindTree(m_inputid); if (diseqc_tree) { bool is_SCR = false; DiSEqCDevSCR *scr = diseqc_tree->FindSCR(diseqc_settings); if (scr) { is_SCR = true; LOG(VB_CHANNEL, LOG_INFO, LOC + "Requested DVB channel is on SCR system"); } else LOG(VB_CHANNEL, LOG_INFO, LOC + "Requested DVB channel is on non-SCR system"); diseqc_tree->Open(fd_frontend, is_SCR); } } first_tune = true; if (!InitializeInput()) { Close(); return false; } if (fd_frontend >= 0) is_open[who] = true; return (fd_frontend >= 0); }
int main(int argc, const char* argv[]) { SetSphereDirectory(); // load the configuration settings, then save it for future reference SPHERECONFIG config; LoadSphereConfiguration(&config); for (int i = 0; i < 4; i++) { SetPlayerConfig(i, KeyStringToKeyCode(config.player_configurations[i].key_menu_str.c_str()), KeyStringToKeyCode(config.player_configurations[i].key_up_str.c_str()), KeyStringToKeyCode(config.player_configurations[i].key_down_str.c_str()), KeyStringToKeyCode(config.player_configurations[i].key_left_str.c_str()), KeyStringToKeyCode(config.player_configurations[i].key_right_str.c_str()), KeyStringToKeyCode(config.player_configurations[i].key_a_str.c_str()), KeyStringToKeyCode(config.player_configurations[i].key_b_str.c_str()), KeyStringToKeyCode(config.player_configurations[i].key_x_str.c_str()), KeyStringToKeyCode(config.player_configurations[i].key_y_str.c_str()), config.player_configurations[i].keyboard_input_allowed, config.player_configurations[i].joypad_input_allowed); } SetGlobalConfig(config.language, config.sound, config.allow_networking); SaveSphereConfig(&config, (GetSphereDirectory() + "/engine.ini").c_str()); original_directory = getcwd(NULL, 0); char* env_data_dir = getenv("SPHERE_DATA_DIR"); if (env_data_dir != NULL) strcpy(unix_data_dir, env_data_dir); if (getopt(argc, const_cast<char**>(argv), "d:") == 'd') strcpy(unix_data_dir, optarg); chdir(unix_data_dir); srand((unsigned)GetTime()); // initialize video subsystem if (InitVideo(&config) == false) { printf("Video subsystem could not be initialized...\n"); return 0; } // initialize input InitializeInput(); // initialize audio if (!InitAudio(&config)) { printf("Sound could not be initialized...\n"); } atexit(CloseVideo); atexit(CloseAudio); RunSphere(argc, argv); }
bool DVBChannel::Open(DVBChannel *who) { LOG(VB_CHANNEL, LOG_INFO, LOC + "Opening DVB channel"); if (!m_inputid) { if (!InitializeInput()) return false; } QMutexLocker locker(&m_hw_lock); if (m_fd_frontend >= 0) { m_is_open[who] = true; return true; } DVBChannel *master = GetMasterLock(); if (master != this) { if (!master->Open(who)) { ReturnMasterLock(master); return false; } m_fd_frontend = master->m_fd_frontend; m_frontend_name = master->m_frontend_name; m_tunerType = master->m_tunerType; m_capabilities = master->m_capabilities; m_ext_modulations = master->m_ext_modulations; m_frequency_minimum = master->m_frequency_minimum; m_frequency_maximum = master->m_frequency_maximum; m_symbol_rate_minimum = master->m_symbol_rate_minimum; m_symbol_rate_maximum = master->m_symbol_rate_maximum; m_is_open[who] = true; if (!InitializeInput()) { Close(); ReturnMasterLock(master); return false; } ReturnMasterLock(master); return true; } ReturnMasterLock(master); // if we're the master we don't need this lock.. QString devname = CardUtil::GetDeviceName(DVB_DEV_FRONTEND, m_device); QByteArray devn = devname.toLatin1(); for (int tries = 1; ; ++tries) { m_fd_frontend = open(devn.constData(), O_RDWR | O_NONBLOCK); if (m_fd_frontend >= 0) break; LOG(VB_GENERAL, LOG_WARNING, LOC + "Opening DVB frontend device failed." + ENO); if (tries >= 20 || (errno != EBUSY && errno != EAGAIN)) { LOG(VB_GENERAL, LOG_ERR, LOC + QString("Failed to open DVB frontend device due to " "fatal error or too many attempts.")); return false; } usleep(50000); } dvb_frontend_info info; memset(&info, 0, sizeof(info)); if (ioctl(m_fd_frontend, FE_GET_INFO, &info) < 0) { LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to get frontend information." + ENO); close(m_fd_frontend); m_fd_frontend = -1; return false; } m_frontend_name = info.name; m_tunerType = info.type; #if HAVE_FE_CAN_2G_MODULATION if (info.caps & FE_CAN_2G_MODULATION) { if (m_tunerType == DTVTunerType::kTunerTypeDVBS1) m_tunerType = DTVTunerType::kTunerTypeDVBS2; else if (m_tunerType == DTVTunerType::kTunerTypeDVBT) m_tunerType = DTVTunerType::kTunerTypeDVBT2; } #endif // HAVE_FE_CAN_2G_MODULATION m_capabilities = info.caps; m_frequency_minimum = info.frequency_min; m_frequency_maximum = info.frequency_max; m_symbol_rate_minimum = info.symbol_rate_min; m_symbol_rate_maximum = info.symbol_rate_max; #if DVB_API_VERSION >=5 unsigned int i; struct dtv_property prop; struct dtv_properties cmd; memset(&prop, 0, sizeof(prop)); prop.cmd = DTV_API_VERSION; cmd.num = 1; cmd.props = ∝ if (ioctl(m_fd_frontend, FE_GET_PROPERTY, &cmd) == 0) { LOG(VB_RECORD, LOG_INFO, LOC + QString("dvb api version %1.%2").arg((prop.u.data>>8)&0xff).arg((prop.u.data)&0xff)); }