VOID GlobalInit() { AddFontResource(_T("res/font/fantiquefour.ttf")); QueryPerformanceFrequency(&global.clockFrequency); GameFolderInit(); MCIOffsetInit(); if (global.songs.empty()) { global.status = global.GS_NOSONG; return; } AudioInit(); Gdiplus::GdiplusStartupInput gdiplusStartupInput; Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL); global.status = global.GS_WELCOME; global.heroWidth = 38; global.heroHeight = 45; settings.foggyMode = FALSE; settings.hideJudgeLine = FALSE; settings.showAccuracyIndicator = FALSE; settings.randomMode = FALSE; settings.universalOffset = 0; }
//------------------------------------------------------- //Function: //Desc : //Input : //Output: //Return: //Others: //Author: //Date : 2011/03/01 //------------------------------------------------------- void system_inital(void) { WaitUs(5); mcu_clk_inital(); mcu_io_inital(); memset(&system, 0, sizeof(SYS_STRUCT)); DISABLE_INTERRUPT; InitSysTimer(); WaitUs(600); // system_read_MTPrecord(); BK2433_RF_Initial(); AudioInit(); if(bUSBMode) usb_ini(); ENABLE_INTERRUPT; #ifdef DEBUG UartOpen(); #endif PowerUp_RF(); }
int SDL_main(int argc, char *argv[]) { int ret = 0; ret = UpgradeInit(); if (ret) goto end; if (SDL_Init(SDL_INIT_VIDEO) < 0) printf("Couldn't initialize SDL: %s\n", SDL_GetError()); logic_init(); WebServerInit(); SceneInit(); SceneLoad(); AudioInit(); ret = SceneRun(); dprintf(" SceneRun exit !!!\n"); FeetDog_Exit(); SceneExit(); if (ret != QUIT_UPGRADE_WEB) WebServerExit(); NetworkExit(); uninit_auTimer(); SDL_Quit(); end: ret = UpgradeProcess(ret); itp_codec_standby(); exit(ret); return ret; }
/*{{{ AudioRelease*/ static int AudioRelease (struct inode* Inode, struct file* File) { struct dvb_device* DvbDevice = (struct dvb_device*)File->private_data; struct DeviceContext_s* Context = (struct DeviceContext_s*)DvbDevice->priv; struct DvbContext_s* DvbContext = Context->DvbContext; DVB_DEBUG("\n"); if ((File->f_flags & O_ACCMODE) != O_RDONLY) { mutex_lock (&(DvbContext->Lock)); if (Context->AudioStream != NULL) { unsigned int MutexIsLocked = true; /* Discard previously injected data to free the lock. */ StreamDrain (Context->AudioStream, true); if (mutex_lock_interruptible (Context->ActiveAudioWriteLock) != 0) MutexIsLocked = false; PlaybackRemoveStream (Context->Playback, Context->AudioStream); Context->AudioStream = NULL; if (MutexIsLocked) mutex_unlock (Context->ActiveAudioWriteLock); } DisplayDelete (BACKEND_AUDIO_ID, Context->Id); /* Check to see if video and demux have also finished so we can release the playback */ if ((Context->VideoStream == NULL) && (Context->DemuxStream == NULL) && (Context->Playback != NULL)) { /* Check to see if our playback has already been deleted by the demux context */ if (Context->DemuxContext->Playback != NULL) { /* Try and delete playback then set our demux to Null if succesful or not. If we fail someone else is still using it but we are done. */ if (PlaybackDelete (Context->Playback) == 0) DVB_DEBUG("Playback deleted successfully\n"); } Context->Playback = NULL; Context->StreamType = STREAM_TYPE_TRANSPORT; Context->PlaySpeed = DVB_SPEED_NORMAL_PLAY; Context->PlayInterval.start = DVB_TIME_NOT_BOUNDED; Context->PlayInterval.end = DVB_TIME_NOT_BOUNDED; Context->SyncContext = Context; } AudioInit (Context); mutex_unlock (&(DvbContext->Lock)); } return dvb_generic_release (Inode, File); }
void sendAudioBlock(int16_t *inRight, int16_t *inLeft, unsigned int length){ unsigned int sample; printf("Sending audio to Line out!\r\n"); AudioInit(); for (sample = 0; sample < length; sample++) { // wait for xmit ready and send a sample to the left channel. while (!CHKBIT(MCASP->SRCTL11, XRDY)) {} MCASP->XBUF11 = inLeft[sample]<<15 | 0x00000000; // MCASP->XBUF11 = (sinetable[sample%48] << 15) | 0x00000000; // wait for xmit ready and send a sample to the left channel. while (!CHKBIT(MCASP->SRCTL11, XRDY)) {} MCASP->XBUF11 = inRight[sample]<<15 | 0x00000000; // MCASP->XBUF11 = (sinetable[sample%48] << 15) | 0x00000000; } }
void getAudioBlock(int16_t *outRight, int16_t *outLeft, unsigned int length){ unsigned int sample; printf("Receiving audio from Line in!\r\n"); AudioInit(); for (sample = 0; sample < length; sample++) { // wait for recv ready and send a sample to the left channel. while (!CHKBIT(MCASP->SRCTL11, XRDY)) {} outLeft[sample] = (int16_t)(MCASP->XBUF12<<1);// >> 16;//TODO: Only shift down by 15 instead of 16? MCASP->XBUF11 = 0; //For some reason this is necessary // wait for recv ready and send a sample to the right channel. while (!CHKBIT(MCASP->SRCTL11, XRDY)) {} outRight[sample] = (int16_t)(MCASP->XBUF12<<1);// >> 16; MCASP->XBUF11 = 0; } }
void mitt_test(void){ int32_t dat; unsigned int sample; AudioInit(); // loop audio while(1) { for (sample = 0; sample < 48; sample++){ // wait for xmit ready and send a sample to the left channel. while (!CHKBIT(MCASP->SRCTL11, XRDY)) {} MCASP->XBUF11 = (sinetable[sample] << 15) | 0x00000000; // wait for xmit ready and send a sample to the left channel. while (!CHKBIT(MCASP->SRCTL11, XRDY)) {} MCASP->XBUF11 = (sinetable[sample] << 15) | 0x00000000; } } }
bool StartScene::init(){ if (!Scene::init()){ return false; } //添加坦克世界的图片 AudioInit(); auto title = Sprite::create("BattleCity.png"); title->setNormalizedPosition(Vec2(0.5, 0.6)); this->addChild(title); //添加开始游戏的按钮 auto item = MenuItemFont::create("StartGame", [](Ref*){ Director::getInstance()->replaceScene(GameScene::create()); }); auto menu = Menu::create(item, nullptr); menu->setPosition(0, 0); item->setNormalizedPosition(Vec2(0.5,0.2)); this->addChild(menu); return true; }
PulseAudioSource(int port, int mic): mPort(port) , mMic(mic) , mBuffering(50) , mPaused(true) , mQuit(false) , mPMainLoop(nullptr) , mPContext(nullptr) , mStream(nullptr) , mServer(nullptr) , mPAready(0) , mResampleRatio(1.0) , mTimeAdjust(1.0) , mOutputSamplesPerSec(48000) , mResampler(nullptr) , mOutSamples(0) { CONFIGVARIANT var(mic ? N_AUDIO_DEVICE1 : N_AUDIO_DEVICE0, CONFIG_TYPE_CHAR); if(LoadSetting(mPort, APINAME, var) && !var.strValue.empty()) { mDevice = var.strValue; //TODO open device etc. } else throw AudioSourceError(APINAME ": failed to load device settings"); { CONFIGVARIANT var(N_BUFFER_LEN, CONFIG_TYPE_INT); if(LoadSetting(mPort, APINAME, var)) mBuffering = var.intValue; } if (!AudioInit()) throw AudioSourceError(APINAME ": failed to bind pulseaudio library"); mSSpec.format = PA_SAMPLE_FLOAT32LE; //PA_SAMPLE_S16LE; mSSpec.channels = 2; mSSpec.rate = 48000; if (!Init()) throw AudioSourceError(APINAME ": failed to init"); }
/*static*/ int __init StmLoadModule(void) { int Result; int i; short int AdapterNumbers[] = { -1 }; DvbContext = kzalloc(sizeof(struct DvbContext_s), GFP_KERNEL); if (DvbContext == NULL) { DVB_ERROR("Unable to allocate device memory\n"); return -ENOMEM; } #ifdef __TDT__ memset(DvbContext, 0, sizeof * DvbContext); #endif #ifdef __TDT__ if (swts) printk("swts ->routing streams from dvr0 to tsm to pti to player\n"); else printk("no swts ->routing streams from dvr0 direct to the player\n"); #endif #if DVB_API_VERSION < 5 Result = dvb_register_adapter(&DvbContext->DvbAdapter, MODULE_NAME, THIS_MODULE, NULL); #else Result = dvb_register_adapter(&DvbContext->DvbAdapter, MODULE_NAME, THIS_MODULE, NULL, AdapterNumbers); #endif if (Result < 0) { DVB_ERROR("Failed to register adapter (%d)\n", Result); kfree(DvbContext); DvbContext = NULL; return -ENOMEM; } mutex_init(&(DvbContext->Lock)); mutex_lock(&(DvbContext->Lock)); /*{{{ Register devices*/ for (i = 0; i < DVB_MAX_DEVICES_PER_ADAPTER; i++) { struct DeviceContext_s* DeviceContext = &DvbContext->DeviceContext[i]; struct dvb_demux* DvbDemux = &DeviceContext->DvbDemux; struct dmxdev* DmxDevice = &DeviceContext->DmxDevice; struct dvb_device* DvrDevice; #ifdef __TDT__ //sylvester: wenn der stream vom user kommt soll WriteToDecoder nix //tun, da das ja hier schon passiert. keine ahnung wie man das ansonsten //verhindern soll;-) DeviceContext->dvr_write = 0; #endif DeviceContext->DvbContext = DvbContext; #if defined (USE_KERNEL_DEMUX) memset(DvbDemux, 0, sizeof(struct dvb_demux)); #ifdef __TDT__ DvbDemux->dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING | DMX_TS_DESCRAMBLING; /* currently only dummy to avoid EINVAL error. Later we need it for second frontend ?! */ DvbDemux->dmx.set_source = SetSource; #else DvbDemux->dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING; #endif DvbDemux->priv = DeviceContext; DvbDemux->filternum = 32; DvbDemux->feednum = 32; DvbDemux->start_feed = StartFeed; DvbDemux->stop_feed = StopFeed; #ifdef __TDT__ DvbDemux->write_to_decoder = WriteToDecoder; #else DvbDemux->write_to_decoder = NULL; #endif Result = dvb_dmx_init(DvbDemux); if (Result < 0) { DVB_ERROR("dvb_dmx_init failed (errno = %d)\n", Result); return Result; } memset(DmxDevice, 0, sizeof(struct dmxdev)); DmxDevice->filternum = DvbDemux->filternum; DmxDevice->demux = &DvbDemux->dmx; DmxDevice->capabilities = 0; Result = dvb_dmxdev_init(DmxDevice, &DvbContext->DvbAdapter); if (Result < 0) { DVB_ERROR("dvb_dmxdev_init failed (errno = %d)\n", Result); dvb_dmx_release(DvbDemux); return Result; } DvrDevice = DvrInit(DmxDevice->dvr_dvbdev->fops); #ifdef __TDT__ printk("%d: DeviceContext %p, DvbDemux %p, DmxDevice %p\n", i, DeviceContext, DvbDemux, DmxDevice); #endif /* Unregister the built-in dvr device and replace it with our own version */ dvb_unregister_device(DmxDevice->dvr_dvbdev); dvb_register_device(&DvbContext->DvbAdapter, &DmxDevice->dvr_dvbdev, DvrDevice, DmxDevice, DVB_DEVICE_DVR); DeviceContext->MemoryFrontend.source = DMX_MEMORY_FE; Result = DvbDemux->dmx.add_frontend(&DvbDemux->dmx, &DeviceContext->MemoryFrontend); if (Result < 0) { DVB_ERROR("add_frontend failed (errno = %d)\n", Result); dvb_dmxdev_release(DmxDevice); dvb_dmx_release(DvbDemux); return Result; } #else dvb_register_device(&DvbContext->DvbAdapter, &DeviceContext->DemuxDevice, DemuxInit(DeviceContext), DeviceContext, DVB_DEVICE_DEMUX); dvb_register_device(&DvbContext->DvbAdapter, &DeviceContext->DvrDevice, DvrInit(DeviceContext), DeviceContext, DVB_DEVICE_DVR); #endif dvb_register_device(&DvbContext->DvbAdapter, &DeviceContext->AudioDevice, AudioInit(DeviceContext), DeviceContext, DVB_DEVICE_AUDIO); #ifdef __TDT__ /* register the CA device (e.g. CIMAX) */ if (i < 3) #ifndef VIP2_V1 dvb_register_device(&DvbContext->DvbAdapter, &DeviceContext->CaDevice, CaInit(DeviceContext), DeviceContext, DVB_DEVICE_CA); #endif #else dvb_register_device(&DvbContext->DvbAdapter, &DeviceContext->CaDevice, CaInit(DeviceContext), DeviceContext, DVB_DEVICE_CA); #endif dvb_register_device(&DvbContext->DvbAdapter, &DeviceContext->VideoDevice, VideoInit(DeviceContext), DeviceContext, DVB_DEVICE_VIDEO); DeviceContext->Id = i; DeviceContext->numRunningFeeds = 0; DeviceContext->DemuxContext = DeviceContext; /* wire directly to own demux by default */ DeviceContext->SyncContext = DeviceContext; /* we are our own sync group by default */ DeviceContext->Playback = NULL; DeviceContext->StreamType = STREAM_TYPE_TRANSPORT; DeviceContext->DvbContext = DvbContext; DeviceContext->DemuxStream = NULL; DeviceContext->VideoStream = NULL; DeviceContext->AudioStream = NULL; DeviceContext->PlaySpeed = DVB_SPEED_NORMAL_PLAY; DeviceContext->dvr_in = kmalloc(65536, GFP_KERNEL); // 128Kbytes is quite a lot per device. DeviceContext->dvr_out = kmalloc(65536, GFP_KERNEL); // However allocating on each write is expensive. DeviceContext->EncryptionOn = 0; #ifdef __TDT__ DeviceContext->VideoPlaySpeed = DVB_SPEED_NORMAL_PLAY; DeviceContext->provideToDecoder = 0; DeviceContext->feedPesType = 0; mutex_init(&DeviceContext->injectMutex); if (i < 4) { ptiInit(DeviceContext); } if (i < 1) { init_e2_proc(DeviceContext); } #endif } mutex_unlock(&(DvbContext->Lock)); DvbBackendInit(); #ifndef __TDT__ #if defined (CONFIG_CPU_SUBTYPE_STX7105) // || defined (CONFIG_CPU_SUBTYPE_STX7200) cap_init(); #endif #endif linuxdvb_v4l2_init(); DVB_DEBUG("STM stream device loaded\n"); return 0; }
//****************************************************************************** // MAIN FUNCTION //****************************************************************************** int main() { long lRetVal = -1; unsigned char RecordPlay; BoardInit(); // // Pinmux Configuration // PinMuxConfig(); // // Initialising the UART terminal // InitTerm(); // // Initialising the I2C Interface // lRetVal = I2C_IF_Open(1); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } RecordPlay = I2S_MODE_RX_TX; g_loopback = 1; // // Create RX and TX Buffer // if(RecordPlay == I2S_MODE_RX_TX) { pRecordBuffer = CreateCircularBuffer(RECORD_BUFFER_SIZE); if(pRecordBuffer == NULL) { UART_PRINT("Unable to Allocate Memory for Tx Buffer\n\r"); LOOP_FOREVER(); } } /* Play */ if(RecordPlay & I2S_MODE_TX) { pPlayBuffer = CreateCircularBuffer(PLAY_BUFFER_SIZE); if(pPlayBuffer == NULL) { UART_PRINT("Unable to Allocate Memory for Rx Buffer\n\r"); LOOP_FOREVER(); } } // // Configure Audio Codec // AudioCodecReset(AUDIO_CODEC_TI_3254, NULL); AudioCodecConfig(AUDIO_CODEC_TI_3254, AUDIO_CODEC_16_BIT, 16000, AUDIO_CODEC_STEREO, AUDIO_CODEC_SPEAKER_ALL, AUDIO_CODEC_MIC_ALL); AudioCodecSpeakerVolCtrl(AUDIO_CODEC_TI_3254, AUDIO_CODEC_SPEAKER_ALL, 50); AudioCodecMicVolCtrl(AUDIO_CODEC_TI_3254, AUDIO_CODEC_SPEAKER_ALL, 50); GPIO_IF_LedConfigure(LED2|LED3); GPIO_IF_LedOff(MCU_RED_LED_GPIO); GPIO_IF_LedOff(MCU_GREEN_LED_GPIO); // // Configure PIN_01 for GPIOOutput // //MAP_PinTypeGPIO(PIN_01, PIN_MODE_0, false); // MAP_GPIODirModeSet(GPIOA1_BASE, 0x4, GPIO_DIR_MODE_OUT); // // Configure PIN_02 for GPIOOutput // //MAP_PinTypeGPIO(PIN_02, PIN_MODE_0, false); // MAP_GPIODirModeSet(GPIOA1_BASE, 0x8, GPIO_DIR_MODE_OUT); //Turning off Green,Orange LED after i2c writes completed - First Time GPIO_IF_LedOff(MCU_GREEN_LED_GPIO); GPIO_IF_LedOff(MCU_ORANGE_LED_GPIO); // // Initialize the Audio(I2S) Module // AudioInit(); // // Initialize the DMA Module // UDMAInit(); if(RecordPlay & I2S_MODE_TX) { UDMAChannelSelect(UDMA_CH5_I2S_TX, NULL); SetupPingPongDMATransferRx(pPlayBuffer); } if(RecordPlay == I2S_MODE_RX_TX) { UDMAChannelSelect(UDMA_CH4_I2S_RX, NULL); SetupPingPongDMATransferTx(pRecordBuffer); } // // Setup the Audio In/Out // lRetVal = AudioSetupDMAMode(DMAPingPongCompleteAppCB_opt, \ CB_EVENT_CONFIG_SZ, RecordPlay); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } AudioCaptureRendererConfigure(AUDIO_CODEC_16_BIT, 16000, AUDIO_CODEC_STEREO, RecordPlay, 1); // // Start Audio Tx/Rx // Audio_Start(RecordPlay); // // Start the simplelink thread // lRetVal = VStartSimpleLinkSpawnTask(9); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the Network Task // lRetVal = osi_TaskCreate( Network, (signed char*)"NetworkTask",\ OSI_STACK_SIZE, NULL, 1, &g_NetworkTask ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the Control Task // lRetVal = ControlTaskCreate(); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the Microphone Task // lRetVal = osi_TaskCreate( Microphone,(signed char*)"MicroPhone", \ OSI_STACK_SIZE, NULL, 1, &g_MicTask ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the Speaker Task // lRetVal = osi_TaskCreate( Speaker, (signed char*)"Speaker",OSI_STACK_SIZE, \ NULL, 1, &g_SpeakerTask ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the task scheduler // osi_start(); }
bool InitAll(const char *vmdir) { // Check ROM version if (!CheckROM()) { ErrorAlert(STR_UNSUPPORTED_ROM_TYPE_ERR); return false; } #if EMULATED_68K // Set CPU and FPU type (UAE emulation) switch (ROMVersion) { case ROM_VERSION_64K: case ROM_VERSION_PLUS: case ROM_VERSION_CLASSIC: CPUType = 0; FPUType = 0; TwentyFourBitAddressing = true; break; case ROM_VERSION_II: CPUType = PrefsFindInt32("cpu"); if (CPUType < 2) CPUType = 2; if (CPUType > 4) CPUType = 4; FPUType = PrefsFindBool("fpu") ? 1 : 0; if (CPUType == 4) FPUType = 1; // 68040 always with FPU TwentyFourBitAddressing = true; break; case ROM_VERSION_32: CPUType = PrefsFindInt32("cpu"); if (CPUType < 2) CPUType = 2; if (CPUType > 4) CPUType = 4; FPUType = PrefsFindBool("fpu") ? 1 : 0; if (CPUType == 4) FPUType = 1; // 68040 always with FPU TwentyFourBitAddressing = false; break; } CPUIs68060 = false; #endif // Load XPRAM XPRAMInit(vmdir); // Load XPRAM default values if signature not found if (XPRAM[0x0c] != 0x4e || XPRAM[0x0d] != 0x75 || XPRAM[0x0e] != 0x4d || XPRAM[0x0f] != 0x63) { D(bug("Loading XPRAM default values\n")); memset(XPRAM, 0, 0x100); XPRAM[0x0c] = 0x4e; // "NuMc" signature XPRAM[0x0d] = 0x75; XPRAM[0x0e] = 0x4d; XPRAM[0x0f] = 0x63; XPRAM[0x01] = 0x80; // InternalWaitFlags = DynWait (don't wait for SCSI devices upon bootup) XPRAM[0x10] = 0xa8; // Standard PRAM values XPRAM[0x11] = 0x00; XPRAM[0x12] = 0x00; XPRAM[0x13] = 0x22; XPRAM[0x14] = 0xcc; XPRAM[0x15] = 0x0a; XPRAM[0x16] = 0xcc; XPRAM[0x17] = 0x0a; XPRAM[0x1c] = 0x00; XPRAM[0x1d] = 0x02; XPRAM[0x1e] = 0x63; XPRAM[0x1f] = 0x00; XPRAM[0x08] = 0x13; XPRAM[0x09] = 0x88; XPRAM[0x0a] = 0x00; XPRAM[0x0b] = 0xcc; XPRAM[0x76] = 0x00; // OSDefault = MacOS XPRAM[0x77] = 0x01; } // Set boot volume int16 i16 = PrefsFindInt32("bootdrive"); XPRAM[0x78] = i16 >> 8; XPRAM[0x79] = i16 & 0xff; i16 = PrefsFindInt32("bootdriver"); XPRAM[0x7a] = i16 >> 8; XPRAM[0x7b] = i16 & 0xff; // Init drivers SonyInit(); DiskInit(); CDROMInit(); SCSIInit(); #if SUPPORTS_EXTFS // Init external file system ExtFSInit(); #endif // Init serial ports SerialInit(); // Init network EtherInit(); // Init Time Manager TimerInit(); // Init clipboard ClipInit(); // Init ADB ADBInit(); // Init audio AudioInit(); // Init video if (!VideoInit(ROMVersion == ROM_VERSION_64K || ROMVersion == ROM_VERSION_PLUS || ROMVersion == ROM_VERSION_CLASSIC)) return false; // Set default video mode in XPRAM XPRAM[0x56] = 0x42; // 'B' XPRAM[0x57] = 0x32; // '2' const monitor_desc &main_monitor = *VideoMonitors[0]; XPRAM[0x58] = uint8(main_monitor.depth_to_apple_mode(main_monitor.get_current_mode().depth)); XPRAM[0x59] = 0; #if EMULATED_68K // Init 680x0 emulation (this also activates the memory system which is needed for PatchROM()) if (!Init680x0()) return false; #endif // Install ROM patches if (!PatchROM()) { ErrorAlert(STR_UNSUPPORTED_ROM_TYPE_ERR); return false; } #if ENABLE_MON // Initialize mon mon_init(); mon_read_byte = mon_read_byte_b2; mon_write_byte = mon_write_byte_b2; #endif return true; }