u16 DSPLLE::DSP_WriteControlRegister(u16 _uFlag) { UDSPControl Temp(_uFlag); if (!m_InitMixer) { if (!Temp.DSPHalt) { InitMixer(); } } DSPInterpreter::WriteCR(_uFlag); // Check if the CPU has set an external interrupt (CR_EXTERNAL_INT) // and immediately process it, if it has. if (_uFlag & 2) { if (!m_bDSPThread) { DSPCore_CheckExternalInterrupt(); DSPCore_CheckExceptions(); } else { DSPCore_SetExternalInterrupt(true); } } return DSPInterpreter::ReadCR(); }
void InitScreen(void) { GtkWidget *notebook; GtkWidget *playbacklabel; GtkWidget *capturelabel; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW(window), "Lightweight Alsa Mixer"); //gtk_container_set_border_width (GTK_CONTAINER (window), 1); gtk_signal_connect (GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(gtk_main_quit), NULL); windowbox = gtk_vbox_new(FALSE,1); InitMenu(); gtk_box_pack_start(GTK_BOX(windowbox), menu_bar, FALSE, TRUE, 0); lamixer_enum_cards(); lamixer_mixer_init(card_id); mixerbox = gtk_table_new(mRows, 1, FALSE); capturebox = gtk_table_new(mRows, 1, FALSE); InitMixer(card_id); playbackscrollwin = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (playbackscrollwin),GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW (playbackscrollwin), mixerbox); capturescrollwin = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (capturescrollwin),GTK_POLICY_AUTOMATIC, GTK_POLICY_NEVER); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW (capturescrollwin), capturebox); playbacklabel = gtk_label_new("Playback"); capturelabel = gtk_label_new("Capture"); notebook = gtk_notebook_new (); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), playbackscrollwin, playbacklabel); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), capturescrollwin, capturelabel); switchmixer = gtk_combo_box_new_text(); GList *card_name = g_list_first(SoundCards); while(card_name) { gtk_combo_box_append_text (GTK_COMBO_BOX (switchmixer), card_name->data); card_name = g_list_next(card_name); } gtk_combo_box_set_active(GTK_COMBO_BOX (switchmixer), 0); g_signal_connect(G_OBJECT(switchmixer), "changed", G_CALLBACK(lamixer_mixer_switch), NULL); gtk_notebook_set_action_widget (GTK_NOTEBOOK (notebook), switchmixer, GTK_PACK_END); gtk_widget_show(switchmixer); gtk_box_pack_start(GTK_BOX(windowbox), notebook, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER(window), windowbox); lamixer_window_resize(); gtk_widget_show_all (window); }
void DSPLLE::DoState(PointerWrap &p) { bool isHLE = false; p.Do(isHLE); if (isHLE != false && p.GetMode() == PointerWrap::MODE_READ) { Core::DisplayMessage("State is incompatible with current DSP engine. Aborting load state.", 3000); p.SetMode(PointerWrap::MODE_VERIFY); return; } p.Do(g_dsp.r); p.Do(g_dsp.pc); #if PROFILE p.Do(g_dsp.err_pc); #endif p.Do(g_dsp.cr); p.Do(g_dsp.reg_stack_ptr); p.Do(g_dsp.exceptions); p.Do(g_dsp.external_interrupt_waiting); for (int i = 0; i < 4; i++) { p.Do(g_dsp.reg_stack[i]); } p.Do(g_dsp.step_counter); p.Do(g_dsp.ifx_regs); p.Do(g_dsp.mbox[0]); p.Do(g_dsp.mbox[1]); UnWriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false); p.DoArray(g_dsp.iram, DSP_IRAM_SIZE); WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false); if (p.GetMode() == PointerWrap::MODE_READ) DSPHost::CodeLoaded((const u8*)g_dsp.iram, DSP_IRAM_BYTE_SIZE); p.DoArray(g_dsp.dram, DSP_DRAM_SIZE); p.Do(cyclesLeft); p.Do(init_hax); p.Do(m_cycle_count); bool prevInitMixer = m_InitMixer; p.Do(m_InitMixer); if (prevInitMixer != m_InitMixer && p.GetMode() == PointerWrap::MODE_READ) { if (m_InitMixer) { InitMixer(); AudioCommon::PauseAndLock(true); } else { AudioCommon::PauseAndLock(false); soundStream->Stop(); delete soundStream; soundStream = nullptr; } } }
void lamixer_mixer_switch() { char card[64]; sprintf(card,"hw:%i",gtk_combo_box_get_active (GTK_COMBO_BOX(switchmixer))); lamixer_mixer_destroy(); lamixer_mixer_init(card); InitMixer(card); lamixer_window_resize(); }
void DSPHLE::DoState(PointerWrap &p) { bool prevInitMixer = m_InitMixer; p.Do(m_InitMixer); if (prevInitMixer != m_InitMixer && p.GetMode() == PointerWrap::MODE_READ) { if (m_InitMixer) { InitMixer(); AudioCommon::PauseAndLock(true); } else { AudioCommon::PauseAndLock(false); soundStream->Stop(); delete soundStream; soundStream = NULL; } } p.Do(m_DSPControl); p.Do(m_dspState); int ucode_crc = IUCode::GetCRC(m_pUCode); int ucode_crc_beforeLoad = ucode_crc; int lastucode_crc = IUCode::GetCRC(m_lastUCode); int lastucode_crc_beforeLoad = lastucode_crc; p.Do(ucode_crc); p.Do(lastucode_crc); // if a different type of ucode was being used when the savestate was created, // we have to reconstruct the old type of ucode so that we have a valid thing to call DoState on. IUCode* ucode = (ucode_crc == ucode_crc_beforeLoad) ? m_pUCode : UCodeFactory( ucode_crc, this, m_bWii); IUCode* lastucode = (lastucode_crc != lastucode_crc_beforeLoad) ? m_lastUCode : UCodeFactory(lastucode_crc, this, m_bWii); if (ucode) ucode->DoState(p); if (lastucode) lastucode->DoState(p); // if a different type of ucode was being used when the savestate was created, // discard it if we're not loading, otherwise discard the old one and keep the new one. if (ucode != m_pUCode) { if (p.GetMode() != PointerWrap::MODE_READ) delete ucode; else { delete m_pUCode; m_pUCode = ucode; } } if (lastucode != m_lastUCode) { if (p.GetMode() != PointerWrap::MODE_READ) delete lastucode; else { delete m_lastUCode; m_lastUCode = lastucode; } } m_MailHandler.DoState(p); }
/*------------------------------------------------ initialize the clock --------------------------------------------------*/ void InitClock(HWND hwnd) { RECT rc; if(g_bInitClock) return; g_bInitClock = TRUE; g_hInst = GetModuleHandle(DLLFILENAME); g_winver = CheckWinVersion(); // common/utl.c g_bVisualStyle = IsXPVisualStyle(); // common/utl.c #if 0 if(!(g_winver&WIN10RS1)) { // check subclassification if(IsSubclassed(hwnd)) { SendMessage(g_hwndTClockMain, TCM_CLOCKERROR, 0, 6); return; } } #endif GetModuleFileName(g_hInst, g_mydir, MAX_PATH); del_title(g_mydir); strcpy(g_inifile, g_mydir); add_title(g_inifile, "tclock.ini"); g_bIniSetting = TRUE; /* g_bIniSetting = FALSE; if(IsFile(g_inifile)) g_bIniSetting = TRUE; */ // Save the original window size GetWindowRect(hwnd, &rc); g_OrigClockWidth = rc.right - rc.left; g_OrigClockHeight = rc.bottom - rc.top; // Save taskbar direction g_bVertTaskbar = IsVertTaskbar(GetParent(GetParent(hwnd))); g_bTaskbarPosChanging = FALSE; // tell tclock.exe clock's HWND PostMessage(g_hwndTClockMain, TCM_HWNDCLOCK, 0, (LPARAM)hwnd); // read settings LoadSetting(hwnd); InitTooltip(hwnd); // tooltip.c InitUserStr(); // userstr.c // subclassfy the clock window !! if(g_winver&WIN10RS1) { SetWindowSubclass(GetParent(hwnd), SubclassTrayProc, SUBCLASSTRAY_ID, (DWORD_PTR)hwnd); } SetWindowSubclass(hwnd, SubclassProc, SUBCLASS_ID, 0); // don't accept double clicks SetClassLong(hwnd, GCL_STYLE, GetClassLong(hwnd, GCL_STYLE) & ~CS_DBLCLKS); #if TC_ENABLE_STARTBUTTON InitStartButton(hwnd); // startbtn.c #endif #if TC_ENABLE_STARTMENU InitStartMenu(hwnd); // startmenu.c #endif #if TC_ENABLE_TASKBAR InitTaskbar(hwnd); // taskbar.c #endif #if TC_ENABLE_TASKSWITCH InitTaskSwitch(hwnd); // taskswitch.c #endif #if TC_ENABLE_TRAYNOTIFY InitTrayNotify(hwnd); // traynotify.c #endif #if TC_ENABLE_VOLUME InitMixer(); // mixer.c #endif #if TC_ENABLE_SYSINFO InitSysInfo(hwnd); // sysinfo.c #endif #if TC_ENABLE_TASKBAR RefreshTaskbar(hwnd); // taskbar.c #else PostMessage(GetParent(GetParent(hwnd)), WM_SIZE, SIZE_RESTORED, 0); InvalidateRect(GetParent(GetParent(hwnd)), NULL, TRUE); #endif SetTimer(hwnd, IDTIMER_MAIN, 1000, NULL); #if TC_ENABLE_DESKTOPICON SetDesktopIcons(); // desktop.c #endif }
void DSPHLE::DoState(PointerWrap &p) { bool isHLE = true; p.Do(isHLE); if (isHLE != true && p.GetMode() == PointerWrap::MODE_READ) { Core::DisplayMessage("State is incompatible with current DSP engine. Aborting load state.", 3000); p.SetMode(PointerWrap::MODE_VERIFY); return; } bool prevInitMixer = m_InitMixer; p.Do(m_InitMixer); if (prevInitMixer != m_InitMixer && p.GetMode() == PointerWrap::MODE_READ) { if (m_InitMixer) { InitMixer(); AudioCommon::PauseAndLock(true); } else { AudioCommon::PauseAndLock(false); soundStream->Stop(); delete soundStream; soundStream = nullptr; } } p.DoPOD(m_DSPControl); p.DoPOD(m_dspState); int ucode_crc = IUCode::GetCRC(m_pUCode); int ucode_crc_beforeLoad = ucode_crc; int lastucode_crc = IUCode::GetCRC(m_lastUCode); int lastucode_crc_beforeLoad = lastucode_crc; p.Do(ucode_crc); p.Do(lastucode_crc); // if a different type of ucode was being used when the savestate was created, // we have to reconstruct the old type of ucode so that we have a valid thing to call DoState on. IUCode* ucode = (ucode_crc == ucode_crc_beforeLoad) ? m_pUCode : UCodeFactory( ucode_crc, this, m_bWii); IUCode* lastucode = (lastucode_crc != lastucode_crc_beforeLoad) ? m_lastUCode : UCodeFactory(lastucode_crc, this, m_bWii); if (ucode) ucode->DoState(p); if (lastucode) lastucode->DoState(p); // if a different type of ucode was being used when the savestate was created, // discard it if we're not loading, otherwise discard the old one and keep the new one. if (ucode != m_pUCode) { if (p.GetMode() != PointerWrap::MODE_READ) { delete ucode; } else { delete m_pUCode; m_pUCode = ucode; } } if (lastucode != m_lastUCode) { if (p.GetMode() != PointerWrap::MODE_READ) { delete lastucode; } else { delete m_lastUCode; m_lastUCode = lastucode; } } m_MailHandler.DoState(p); }
RTC::ReturnCode_t PortAudioInput::onActivated(RTC::UniqueId ec_id) { RTC_DEBUG(("onActivated start")); PaStreamParameters inputParameters; // PaWasapiStreamInfo wasapiinfo; try { //m_pa_mutex.lock(); //by Irie Seisho m_format = getFormat(m_formatstr); m_totalframes = FRAMES_PER_BUFFER * m_channels; m_err = Pa_GetSampleSize(m_format); if( m_err > 0 ) { m_totalframes *= m_err; } #if 0 /* Find all WASAPI devices */ const PaDeviceInfo *device; for ( int i = 0; i < Pa_GetDeviceCount(); ++i ) { device = Pa_GetDeviceInfo(i); if ( Pa_GetDeviceInfo(i)->hostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI) ) { std::cout << "Device Index " << i << " : " << device->name << ", inch " << device->maxInputChannels << ", outch " << device->maxOutputChannels << std::endl; } } //#if 0 PaDeviceIndex dnum = Pa_GetDeviceCount(); for (int i = 0; i < (int)dnum; i++) { std::cout << "Device Index " << i << " : " << Pa_GetDeviceInfo(i)->name << ", inch " << Pa_GetDeviceInfo(i)->maxInputChannels << ", outch " << Pa_GetDeviceInfo(i)->maxOutputChannels << std::endl; } //#endif void *pFormat; unsigned int nFormatSize; PaDeviceIndex nDevice; int r = PaWasapi_GetDeviceDefaultFormat(pFormat, nFormatSize, nDevice); #endif inputParameters.device = Pa_GetDefaultInputDevice(); //!< default input device if ( inputParameters.device < 0 ) { throw (paNotInitialized); } if ( m_channels > Pa_GetDeviceInfo(inputParameters.device)->maxInputChannels ) m_channels = Pa_GetDeviceInfo(inputParameters.device)->maxInputChannels; inputParameters.channelCount = m_channels; inputParameters.sampleFormat = m_format; inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultLowInputLatency; /* wasapiinfo.size = sizeof(PaWasapiStreamInfo); wasapiinfo.hostApiType = paWASAPI; wasapiinfo.version = 1; wasapiinfo.flags = paWasapiUseChannelSelectors; wasapiinfo.hostProcessorInput wasapiinfo.threadPriority wasapiinfo.channelMask = outputChannelSelectors; inputParameters.hostApiSpecificStreamInfo = wasapiinfo; */ inputParameters.hostApiSpecificStreamInfo = NULL; m_err = Pa_OpenStream( &m_stream, //!< PortAudioStream &inputParameters, //!< InputParameters NULL, //!< outputParameters m_samplerate, //!< sampleRate FRAMES_PER_BUFFER, //!< framesPerBuffer paClipOff, //!< streamFlags:we won't output out of range samples so don't bother clipping // StreamCB, //!< streamCallback // this ); //!< callback userData NULL, //!< streamCallback:no callback, use blocking API NULL ); //!< no callback, so no callback userData if( m_err != paNoError ) { throw m_err; } #ifdef HAVE_LIBPORTMIXER m_mixer = Px_OpenMixer( m_stream, 0 ); m_volume = Px_GetInputVolume( m_mixer ); #else #if defined(_WIN32) if ( InitMixer() == true ) { DWORD vol; GetMicrophoneLevel(&vol); } else { CloseMixer(); } #elif defined(__linux) const char* sound_device_names[] = SOUND_DEVICE_NAMES; m_device = -1; m_fd = -1; for ( int i = 0; i < SOUND_MIXER_NRDEVICES; i ++ ) { std::cout << " device name : " << sound_device_names[i] << std::endl; if ( strcmp( "mic", sound_device_names[i] ) == 0 ) { m_device = i; break; } } if ( ( m_fd = open( "/dev/mixer", O_RDONLY ) ) == -1 ) { perror( "open" ); } #endif #endif m_err = Pa_StartStream( m_stream ); if( m_err != paNoError ) { throw m_err; } //m_pa_mutex.unlock(); //by Irie Seisho } catch (...) { std::string error_str = Pa_GetErrorText(m_err); RTC_WARN(("PortAudio failed onActivated:%s", error_str.c_str())); return RTC::RTC_ERROR; } syncflg = true; is_active = true; RTC_DEBUG(("onActivated finish")); return RTC::RTC_OK; }