void DeinitEngine(void) { UINT8 curSFX; StopPlayback(&vgmPbMusic); for (curSFX = 0; curSFX < SFX_CHN_COUNT; curSFX ++) StopPlayback(&vgmPbSFX[curSFX]); OPL2_Write(0x04, 0x00); // disable all timers return; }
UINT8 StopSFX(UINT8 sfxChnID) { if (sfxChnID == 0xFF) { for (sfxChnID = 0; sfxChnID < SFX_CHN_COUNT; sfxChnID ++) StopPlayback(&vgmPbSFX[sfxChnID]); return 0x00; } if (sfxChnID >= SFX_CHN_COUNT) return 0xFF; StopPlayback(&vgmPbSFX[sfxChnID]); return 0x00; }
void FCEUI_StopMovie(void) { if(current < 0) StopPlayback(); #if 0 if(current > 0) StopRecording(); #endif }
void MainWindow::StartPlayback() { if (isPlaying) { StopPlayback(); } qDebug()<<"Starting playback"; if (currentRadio) { pbPlay->setText("Stop"); if (!dConnectionProgress) { dConnectionProgress=new ConnectionProgress(currentRadio->GetTitle(),this); connect(this,SIGNAL(ConnectionProgressUpdate(int)),dConnectionProgress,SLOT(OnConnectionProgressUpdate(int))); connect(this,SIGNAL(ConnectionEstablished()),dConnectionProgress,SLOT(OnConnectionEstablished())); connect(this,SIGNAL(ConnectionFailed()),dConnectionProgress,SLOT(OnConnectionFailed())); } currentRadioURL=0; dConnectionProgress->ChangeURL(currentRadio->GetURL(0)); dConnectionProgress->setTitle(currentRadio->GetTitle()); StartURL(currentRadio->GetURL(0)); QApplication::setOverrideCursor(Qt::WaitCursor); int tResult=dConnectionProgress->exec(); QApplication::restoreOverrideCursor(); delete dConnectionProgress; dConnectionProgress=NULL; if (tResult==QDialog::Rejected) { qDebug()<<"Connection aborted"; } }
static void LoadAndPlay(int song) { byte module[ASAP_MODULE_MAX]; int module_len; int duration; if (!loadModule(current_filename, module, &module_len)) return; if (songs > 0) { ClearSongsMenu(); StopPlayback(); songs = 0; EnableMenuItem(hTrayMenu, IDM_SAVE_WAV, MF_BYCOMMAND | MF_GRAYED); } if (!DoLoad(&asap, module, module_len)) return; if (!WaveOut_Open(asap.module_info.channels)) { ShowError("Error initalizing WaveOut"); return; } if (song < 0) song = asap.module_info.default_song; songs = asap.module_info.songs; EnableMenuItem(hTrayMenu, IDM_SAVE_WAV, MF_BYCOMMAND | MF_ENABLED); updateInfoDialog(current_filename, song); SetSongsMenu(songs); CheckMenuRadioItem(hSongMenu, 0, songs - 1, song, MF_BYPOSITION); current_song = song; duration = asap.module_info.durations[song]; if (asap.module_info.loops[song]) duration = -1; ASAP_PlaySong(&asap, song, duration); Tray_Modify(hPlayIcon); WaveOut_Start(); }
CMomReplayBase* CMomReplayManager::LoadReplay(const char* path, const char* pathID) { if (PlayingBack()) StopPlayback(); if (m_pPlaybackReplay) UnloadPlayback(); Log("Loading a replay from '%s'...\n", path); auto file = filesystem->Open(path, "r+b", pathID); if (!file) return nullptr; CBinaryReader reader(file); uint32 magic = reader.ReadUInt32(); if (magic != REPLAY_MAGIC_LE && magic != REPLAY_MAGIC_BE) { filesystem->Close(file); return nullptr; } if (magic == REPLAY_MAGIC_BE) reader.ShouldFlipEndianness(true); uint8 version = reader.ReadUInt8(); if (m_mapCreators.Find(version) == m_mapCreators.InvalidIndex()) { filesystem->Close(file); return nullptr; } Log("Loading replay '%s' of version '%d'...\n", path, version); // MOM_TODO (OrfeasZ): Verify that replay parsing was successful. m_pPlaybackReplay = m_mapCreators.Element(m_mapCreators.Find(version))->LoadReplay(&reader); filesystem->Close(file); Log("Successfully loaded replay.\n"); //Create the run entity here CMomentumReplayGhostEntity *pGhost = static_cast<CMomentumReplayGhostEntity *>(CreateEntityByName("mom_replay_ghost")); pGhost->SetRunStats(m_pPlaybackReplay->GetRunStats()); pGhost->m_RunData.m_flRunTime = m_pPlaybackReplay->GetRunTime(); pGhost->m_RunData.m_iRunFlags = m_pPlaybackReplay->GetRunFlags(); pGhost->m_flTickRate = m_pPlaybackReplay->GetTickInterval(); pGhost->SetPlaybackReplay(m_pPlaybackReplay); m_pPlaybackReplay->SetRunEntity(pGhost); return m_pPlaybackReplay; }
void CTestPage::OnPlay() ///////////////////////////////////////////////////////////////////////////// { static char BASED_CODE szFilter[] = "Wave Files(*.wav)|*.wav|All Files(*.*)|*.*||"; char szInitialDir[ _MAX_PATH ]; char szFileName[ _MAX_PATH ]; UpdateData( TRUE ); // Get data from the controls if( !m_pHalAdapter->IsOpen() ) { MessageBox( "Must Open Adapter First!" ); return; } if( m_nPlayMode == MODE_STOP ) { // Pop up the file dialog box CFileDialog dlg( TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, szFilter, this ); if( m_szFileName[0] ) { char szDrive[ _MAX_DRIVE ]; char szDir[ _MAX_DIR ]; char szBaseName[ _MAX_FNAME ]; char szExt[ _MAX_EXT ]; _splitpath( m_szFileName, szDrive, szDir, szBaseName, szExt ); sprintf( szInitialDir, "%s%s", szDrive, szDir ); sprintf( szFileName, "%s%s", szBaseName, szExt ); dlg.m_ofn.lpstrInitialDir = szInitialDir; dlg.m_ofn.lpstrFile = szFileName; } else dlg.m_ofn.lpstrInitialDir = "D:\\Audio"; if( dlg.DoModal() == IDCANCEL ) return; CString PathName; PathName = dlg.GetPathName(); strcpy( m_szFileName, PathName.GetBuffer( _MAX_PATH - 1 ) ); PathName.ReleaseBuffer(); StartPlayback(); } else { m_bRepeat = FALSE; UpdateData(FALSE); // Send data to the controls StopPlayback(); } }
UINT8 PlayMusic(VGM_FILE* vgmFile) { VGM_PBK* vgmPb = &vgmPbMusic; if (! vgmPb->vgmEnd) StopPlayback(vgmPb); vgmPb->file = vgmFile; StartPlayback(vgmPb); return 0x00; }
UINT8 PauseMusic(void) { if (vgmPbMusic.vgmEnd == 0xFF) return 0xFF; // not playing if (vgmPbMusic.vgmEnd == 0x01) return 0x80; // finished playing already if (vgmPbMusic.vgmEnd == 0x02) return 0x01; // is already paused StopPlayback(&vgmPbMusic); vgmPbMusic.vgmEnd = 0x02; return 0x00; }
void MythPianoService::NextSong() { StopPlayback(); if (m_Playlist != NULL) { m_CurrentSong = m_CurrentSong->next; } if (m_CurrentSong == NULL) { GetPlaylist(); } StartPlayback(); }
/* CXAudio2::DeInitVoices deinitializes the voice objects and buffers */ void CXAudio2::DeInitVoices(void) { if(pSourceVoice) { StopPlayback(); pSourceVoice->DestroyVoice(); pSourceVoice = NULL; } if(pMasterVoice) { pMasterVoice->DestroyVoice(); pMasterVoice = NULL; } if(soundBuffer) { delete [] soundBuffer; soundBuffer = NULL; } }
UINT8 PlaySFX(VGM_FILE* vgmFile, UINT8 sfxChnID) { VGM_PBK* vgmPb; if (sfxChnID >= SFX_CHN_COUNT) return 0xFF; vgmPb = &vgmPbSFX[sfxChnID]; if (! vgmPb->vgmEnd) StopPlayback(vgmPb); vgmPb->file = vgmFile; StartPlayback(vgmPb); return 0x00; }
void MDFNI_LoadMovie(char *fname) { gzFile fp; //puts("KAO"); if(current > 0) /* Can't interrupt recording.*/ return; #ifdef NETWORK if(MDFNnetplay) /* Playback is UNPOSSIBLE during netplay. */ { MDFN_DispMessage(_("Can't play movies during netplay.")); return; } #endif if(current < 0) /* Stop playback. */ { StopPlayback(); return; } if(fname) fp = gzopen(fname, "rb"); else { fp=gzopen(MDFN_MakeFName(MDFNMKF_MOVIE,CurrentMovie,0).c_str(),"rb"); } if(!fp) return; if(!MDFNSS_LoadFP(fp)) { MDFN_DispMessage(_("Error loading state portion of the movie.")); return; } current = CurrentMovie; slots[current] = fp; current = -1 - current; MovieStatus[CurrentMovie] = 1; MDFN_DispMessage(_("Movie playback started.")); }
VOID CALLBACK PlayTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) { MCI_STATUS_PARMS mciStatus; DWORD dwPos; if (!bIsOpened) KillTimer(hwnd, IDT_PLAYTIMER); mciStatus.dwItem = MCI_STATUS_POSITION; mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus); dwPos = mciStatus.dwReturn; if((UINT)dwPos >= MaxFilePos) { StopPlayback(hwnd); } else { SendMessage(hTrackBar, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) dwPos); } }
static VOID SeekForwPlayback(HWND hwnd) { MCI_STATUS_PARMS mciStatus; DWORD dwNewPos; if (!bIsOpened) return; mciStatus.dwItem = MCI_STATUS_POSITION; mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus); dwNewPos = mciStatus.dwReturn + 1; if((UINT)dwNewPos >= MaxFilePos) { StopPlayback(hwnd); } else { SeekPlayback(hwnd, dwNewPos); } }
static LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { int idc; POINT pt; PCOPYDATASTRUCT pcds; switch (msg) { case WM_COMMAND: idc = LOWORD(wParam); switch (idc) { case IDM_OPEN: SelectAndLoadFile(); break; case IDM_STOP: StopPlayback(); break; case IDM_FILE_INFO: showInfoDialog(hInst, hWnd, current_filename, current_song); break; case IDM_SAVE_WAV: SaveWav(); break; case IDM_ABOUT: ShowAbout(); break; case IDM_EXIT: PostQuitMessage(0); break; default: if (idc >= IDM_SONG1 && idc < IDM_SONG1 + songs) LoadAndPlay(idc - IDM_SONG1); break; } break; case WM_DESTROY: PostQuitMessage(0); break; case MYWM_NOTIFYICON: if (opening) { SetForegroundWindow(GetLastActivePopup(hWnd)); break; } switch (lParam) { case WM_LBUTTONDOWN: SelectAndLoadFile(); break; case WM_MBUTTONDOWN: if (songs <= 1) break; /* FALLTHROUGH */ case WM_RBUTTONUP: GetCursorPos(&pt); SetForegroundWindow(hWnd); TrackPopupMenu(lParam == WM_MBUTTONDOWN ? hSongMenu : hTrayMenu, TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hWnd, NULL); PostMessage(hWnd, WM_NULL, 0, 0); break; default: break; } break; case WM_COPYDATA: pcds = (PCOPYDATASTRUCT) lParam; if (pcds->dwData == 'O' && pcds->cbData <= sizeof(current_filename)) { if (errorShown) { HWND hChild = GetLastActivePopup(hWnd); if (hChild != hWnd) SendMessage(hChild, WM_CLOSE, 0, 0); } memcpy(current_filename, pcds->lpData, pcds->cbData); LoadAndPlay(-1); } break; default: if (msg == taskbarCreatedMessage) Shell_NotifyIcon(NIM_ADD, &nid); return DefWindowProc(hWnd, msg, wParam, lParam); } return 0; }
static void UpdateVGM(VGM_PBK* vgmPlay, UINT16 Samples) { const dword/*32*/ vgmLen = vgmPlay->file->dataLen; const UINT8* vgmData = vgmPlay->file->data; const UINT8* VGMPnt; dword/*32*/ VGMPos; dword/*32*/ VGMSmplPos; UINT8 Command; UINT8 blockType; dword/*32*/ blockLen; vgmPlay->pbSmplPos += Samples; VGMPos = vgmPlay->vgmPos; VGMSmplPos = vgmPlay->vgmSmplPos; while(VGMSmplPos < vgmPlay->pbSmplPos && ! vgmPlay->vgmEnd) { VGMPnt = &vgmData[VGMPos]; Command = VGMPnt[0x00]; switch(Command & 0xF0) { case 0x70: // small delay (1-16 samples) VGMSmplPos += (Command & 0x0F) + 0x01; VGMPos += 0x01; break; case 0x80: // DAC write + small delay (0-15 samples) VGMSmplPos += (Command & 0x0F); VGMPos += 0x01; break; case 0x60: switch(Command) { case 0x66: // End Of File vgmPlay->vgmPos = VGMPos; vgmPlay->vgmSmplPos = VGMSmplPos; if (! DoVgmLoop(vgmPlay)) vgmPlay->vgmEnd = 0x01; VGMPos = vgmPlay->vgmPos; VGMSmplPos = vgmPlay->vgmSmplPos; break; case 0x62: // 1/60s delay VGMSmplPos += 735; VGMPos += 0x01; break; case 0x63: // 1/50s delay VGMSmplPos += 882; VGMPos += 0x01; break; case 0x61: // xx Sample Delay VGMSmplPos += ReadLE16(&VGMPnt[0x01]); VGMPos += 0x03; break; case 0x67: // Data Block (PCM Data Stream) blockType = VGMPnt[0x02]; blockLen = ReadLE32(&VGMPnt[0x03]); blockLen &= 0x7FFFFFFF; VGMPos += 0x07 + blockLen; break; case 0x68: // PCM RAM write VGMPos += 0x0C; break; default: vgmPlay->vgmEnd = 0x01; break; } break; case 0x50: if (Command == 0x50) { VGMPos += 0x02; // SN76496 write break; } switch(Command) { case 0x51: // YM2413 write ym2413_write(vgmPlay, VGMPnt[0x01], VGMPnt[0x02]); break; case 0x5A: // YM3812 write ym3812_write(vgmPlay, VGMPnt[0x01], VGMPnt[0x02]); break; case 0x5B: // YM3526 write case 0x5C: // Y8950 write ym3512_write(vgmPlay, VGMPnt[0x01], VGMPnt[0x02]); break; case 0x5E: // YMF262 write, port 0 case 0x5F: // YMF262 write, port 1 ymf262_write(vgmPlay, Command & 0x01, VGMPnt[0x01], VGMPnt[0x02]); break; } VGMPos += 0x03; break; case 0x30: VGMPos += 0x02; break; case 0x40: case 0xA0: case 0xB0: VGMPos += 0x03; break; case 0xC0: case 0xD0: VGMPos += 0x04; break; case 0xE0: case 0xF0: VGMPos += 0x05; break; case 0x90: switch(Command) { case 0x90: // DAC Ctrl: Setup Chip VGMPos += 0x05; break; case 0x91: // DAC Ctrl: Set Data VGMPos += 0x05; break; case 0x92: // DAC Ctrl: Set Freq VGMPos += 0x06; break; case 0x93: // DAC Ctrl: Play from Start Pos VGMPos += 0x0B; break; case 0x94: // DAC Ctrl: Stop immediately VGMPos += 0x02; break; case 0x95: // DAC Ctrl: Play Block (small) VGMPos += 0x05; break; default: vgmPlay->vgmEnd = 0x01; break; } break; default: vgmPlay->vgmEnd = 0x01; return; } if (VGMPos >= vgmLen) vgmPlay->vgmEnd = 0x01; } vgmPlay->vgmPos = VGMPos; vgmPlay->vgmSmplPos = VGMSmplPos; if (vgmPlay->vgmEnd) StopPlayback(vgmPlay); return; }
void VDAudioOutputDirectSoundW32::ThreadRun() { if (!InitDirectSound()) { ShutdownDirectSound(); mMutex.Lock(); mbThreadInited = true; mbThreadInitSucceeded = false; mMutex.Unlock(); mUpdateEvent.signal(); return; } ThreadState threadState = kThreadStateStop; uint32 lastInitCount = 0; bool underflow = false; bool playing = false; uint32 dsStreamWritePosition = 0; if (!InitPlayback()) { ShutdownDirectSound(); mMutex.Lock(); mbThreadInited = true; mbThreadInitSucceeded = false; mMutex.Unlock(); mUpdateEvent.signal(); return; } mMutex.Lock(); mbThreadInited = true; mbThreadInitSucceeded = true; mUpdateEvent.signal(); mMutex.Unlock(); for(;;) { if (playing) mUpdateEvent.tryWait(10); else mUpdateEvent.wait(); mMutex.Lock(); threadState = (ThreadState)mThreadState; mMutex.Unlock(); if (threadState == kThreadStatePlay) { if (!underflow) { StartPlayback(); playing = true; } } else { StopPlayback(); playing = false; } if (threadState == kThreadStateExit) break; if (!playing) continue; Cursors cursors; if (!ReadCursors(cursors)) continue; uint32 level; mMutex.Lock(); level = mBufferLevel; // Compute current buffering level. sint32 bufferedLevel = mDSWriteCursor - cursors.mPlayCursor; if (bufferedLevel > (sint32)mDSBufferSizeHalf) bufferedLevel -= mDSBufferSize; else if (bufferedLevel < -(sint32)mDSBufferSizeHalf) bufferedLevel += mDSBufferSize; if (bufferedLevel < 0) { bufferedLevel = 0; mDSWriteCursor = cursors.mWriteCursor; } // Compute the stream play position. This should never go backward. If it // has, we have underflowed. uint32 newDSStreamPlayPos = dsStreamWritePosition - bufferedLevel; if (newDSStreamPlayPos < mDSStreamPlayPosition) { mDSStreamPlayPosition = dsStreamWritePosition; bufferedLevel = 0; } mDSBufferedBytes = bufferedLevel; mMutex.Unlock(); if (!level) { if (!underflow && playing) { // Check for underflow. if (!bufferedLevel) { StopPlayback(); playing = false; } } continue; } // compute how many bytes to copy uint32 toCopy = level; if (toCopy + bufferedLevel > mDSBufferSizeHalf) toCopy = mDSBufferSizeHalf - bufferedLevel; if (!toCopy) continue; // update local write position dsStreamWritePosition += toCopy; // lock and copy into DirectSound buffer const uint8 *src = mBuffer.data(); uint32 consumed = 0; while(toCopy > 0) { const uint32 tc2 = std::min<uint32>(toCopy, mBufferSize - mBufferReadOffset); const uint32 tc3 = std::min<uint32>(tc2, mDSBufferSize - mDSWriteCursor); WriteAudio(mDSWriteCursor, src + mBufferReadOffset, tc3); mBufferReadOffset += tc3; if (mBufferReadOffset >= mBufferSize) mBufferReadOffset = 0; mDSWriteCursor += tc3; if (mDSWriteCursor >= mDSBufferSize) mDSWriteCursor = 0; toCopy -= tc3; consumed += tc3; } mMutex.Lock(); mBufferLevel -= consumed; mMutex.Unlock(); // restart playback if we were in underflow state if (underflow && !playing) { underflow = false; playing = true; StartPlayback(); } mResponseEvent.signal(); } ShutdownPlayback(); ShutdownDirectSound(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setupUi(this); Finished_Init = false; AllowInit = false; PreBuf_timer = new QTimer; Update_timer= new QTimer; Ping_timer= new QTimer; Spectrum_timer = new QTimer; BufferStatusUpdate_timer= new QTimer; singleClickTimer=new QTimer; m_msgbox = NULL; isPlaying=false; syncLost=false; currentRadio=NULL; currentTrack=""; dConnectionProgress=NULL; dDelConfirm=NULL; dShowHistory=NULL; netManager=NULL; currentRadioURL=-1; streamsErrLoop=false; pSpec=NULL; mMoving=false; savedVolume=0.5; isMuted=false; treeSelectionChanged=false; isRecording=false; newVersionAnimation=NULL; recButtonAnimation=NULL; isRootOperation=false; #ifdef VISUALS isVisResized=false; isVisRendering=false; visWin=new VisWinCL(this); bigVis=false; bigVisRunning=false; #endif initBitRate(); initOggQualityMap(); qDebug()<<"Cheking BASS version"; if (HIWORD(BASS_GetVersion())!=BASSVERSION) { qDebug()<<"An incorrect version of BASS.DLL was loaded"; QMessageBox::warning(this,QString("warning"),QString("An incorrect version of BASS.DLL was loaded")); } BASS_SetConfigPtr(BASS_CONFIG_NET_AGENT, (void*) _T(PLAYER_HTTPAGENT)); #ifdef Q_OS_WIN if (BASS_PluginLoad("bass_aac.dll",0)==0) { qDebug()<<"Unable to load bass_aac.ddl BassError="<<BASS_ErrorGetCode(); } #elif Q_OS_LINUX if (BASS_PluginLoad("bass_aac.so",0)==0) { qDebug()<<"Unable to load bass_aac.ddl BassError="<<BASS_ErrorGetCode(); } #endif QSettings tSettings(AppPath+CONFIG_FILENAME,QSettings::IniFormat); tSettings.setIniCodec("ISO 8859-1"); Proxy=tSettings.value("proxy","").toString(); ProxyPort=tSettings.value("proxyport","").toString(); ProxyUser=tSettings.value("proxyuser","").toString(); ProxyPass=tSettings.value("proxypass","").toString(); visualPlugin=tSettings.value("visual",VIS_WIN_PLUG).toString(); qDebug()<<"visualPlugin="<<visualPlugin; recPath=tSettings.value("recpath","").toString(); recPath=recPath.replace("\\","\\\\"); #ifdef Q_OS_WIN if (recPath!="" && recPath.at(recPath.length()-1)!='\\') recPath=recPath+"\\"; #else if (recPath!="" && recPath.at(recPath.length()-1)!='/') recPath=recPath+"/"; #endif if (recPath=="") { #ifdef Q_OS_WIN recPath=QDir::toNativeSeparators(QStandardPaths::standardLocations(QStandardPaths::MusicLocation).at(0)+"/"); #endif #ifdef Q_OS_MAC recPath=AppPath.fromLatin1(argv[0]); recPath+="/"; #endif } qDebug()<<"Recording path ="<<recPath; if (Proxy!="") { qDebug()<<"Proxy="<<Proxy; QString tBassProxyStr=ProxyUser; if (ProxyPass!="") tBassProxyStr+=":"+ProxyPass; if (ProxyUser!="") tBassProxyStr+="@"; tBassProxyStr+=Proxy+":"+ProxyPort; qDebug()<<"BASSProxy="<<tBassProxyStr; qDebug()<<"BASSProxy="<<tBassProxyStr.toLatin1().data(); //strcpy(proxyStrChar,Proxy.toLatin1().data()); BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,tBassProxyStr.toLatin1().data()); //BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,&proxyStrChar); } else { BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY, NULL); } //if( !InitVersion() ) ErrorMsgBox(_T("\n Error Setting up Version strings \n")); if( !InitBassErrorMap() ) ErrorMsgBox(_T("\n Error setting up Error Msgs \n")); if (!BASS_Init(-1,44100,0,NULL,NULL)) { ErrorMsgBox(_T("\nUnable to initialize BASS library\n"), 86, false); exit(86); } savedVolume=BASS_GetVolume(); slVolume->setValue(savedVolume*slVolume->maximum()); #ifdef Q_OS_WIN // allocate ACM format buffer, using suggested buffer size acmformlen = BASS_Encode_GetACMFormat(0,NULL,0,NULL,0); acmform = (WAVEFORMATEX*)malloc(acmformlen); memset(acmform,0,acmformlen); acmduncil = (WAVEFORMATEX*)malloc(acmformlen); memset(acmduncil, 0, acmformlen); // #endif connect(radioTree,SIGNAL(AddStationSig(QModelIndex,RadioCL*)),this,SLOT(AddStation(QModelIndex,RadioCL*))); connect(radioTree, SIGNAL(treeSelectionChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(radioTreeSelectionChanges(const QModelIndex &, const QModelIndex &))); qDebug()<<"Connecting timers signals "; connect(PreBuf_timer, SIGNAL(timeout()), this, SLOT(prebufTimeout())); connect(Update_timer, SIGNAL(timeout()), this, SLOT(updateTimeout())); connect(Ping_timer, SIGNAL(timeout()),this, SLOT(pingRadio())); connect(Spectrum_timer, SIGNAL(timeout()), this, SLOT(specTimeout())); connect(BufferStatusUpdate_timer, SIGNAL(timeout()),this, SLOT(updateBufferStatus())); connect(singleClickTimer, SIGNAL(timeout()),this, SLOT(singleClickTimeout())); qDebug()<<"Connecting mgh signals"; connect( &mgh, SIGNAL(SendUpdTrackInfo(QString)), this, SLOT(on_UpdTrackInfo(QString)) ); connect( &mgh, SIGNAL(SendUpdRadioInfo(QString,QString,QString,QString)), this, SLOT(on_UpdRadioInfo(QString,QString,QString,QString))); connect( &mgh, SIGNAL(SendSyncLost()), this, SLOT(on_SyncLost()) ); connect( &mgh, SIGNAL(SendPlaybackStarts()), this, SLOT(on_PlaybackStarts()) ); connect( &mgh, SIGNAL(SendClickRecord()), this, SLOT(on_ClickRecord()) ); qDebug()<<"Creating actions"; createActions(); qDebug()<<"Creating tray icon"; createTrayIcon(); qDebug()<<"Setting tray icon"; setIcon(PLAYER_STATUS_INACTIVE); trayIcon->setVisible(true); trayIcon->show(); setWindowTitle(QString(PLAYER_NAME)+" v"+RADIOLA_VERSION); qDebug()<<"Initializing spectrum image"; specbuf = NULL; specmode = DEFAULT_SPEC_MODE; // spectrum mode specpos = 0; // spectrum mode (and marker pos for 2nd mode) pSpec = new QImage(SPECWIDTH, SPECHEIGHT, QImage::Format_Indexed8); // setup palette pSpec->setColor(0, qRgb(0,0,0)); for(int a=1; a < 128; a++) { pSpec->setColor(a, qRgb(2*a, 256-2*a, 0)); } for(int a=0; a < 32; a++) { pSpec->setColor(128+a, qRgb(0, 0, 8*a)); pSpec->setColor(128+32+a, qRgb(8*a, 0, 255)); pSpec->setColor(128+64+a, qRgb(255, 8*a, 8*(31-a))); //pSpec->setColor(128+64+a, qRgb(8*(31-a), 8*a, 8*a)); pSpec->setColor(128+96+a, qRgb(255, 255, 8*a)); //pSpec->setColor(128+96+a, qRgb(255, 255, 8*a)); } pSpec->setColor(254, qRgb(112, 112, 255)); pSpec->setColor(253, qRgb(255, 128, 128)); pSpec->setColor(255, qRgb(212,208,200)); // background color // create the bitmap specbuf = (BYTE*)pSpec->bits(); pSpec->fill(255); specButton->setSpec(pSpec); readSettings(); qDebug()<<"Connecting tray signals "; connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); setupRadioTree(); historyFile.setFileName(GetHistoryDir()); if (!historyFile.open(QIODevice::ReadWrite | QIODevice::Append)) { qDebug()<<"Unable to open history file for write"<<historyFile.fileName(); return; } StopPlayback(); QIcon icon = QIcon(MAINWIN_ICON); setWindowIcon(icon); new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S), this, SLOT(showSettings())); new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_E), this, SLOT(showRecPath())); new QShortcut(QKeySequence(Qt::Key_F1), this, SLOT(showHelp())); new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_H), this, SLOT(showHistory())); #ifdef Q_OS_WIN new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_V), this, SLOT(showVisualization())); #endif new QShortcut(QKeySequence(Qt::Key_Space), this, SLOT(on_pbPlay_clicked())); new QShortcut(QKeySequence(Qt::Key_MediaPlay), this, SLOT(on_pbPlay_clicked())); new QShortcut(QKeySequence(Qt::Key_Delete), this, SLOT(removeRow())); new QShortcut(QKeySequence(Qt::Key_Insert), this, SLOT(insertStation())); new QShortcut(QKeySequence(Qt::Key_Plus), this, SLOT(insertSubfolder())); QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect(); effect->setBlurRadius(1); //Adjust accordingly effect->setOffset(3,3); //Adjust accordingly setShadow(bnShowHistory); setShadow(pbPlay); setShadow(pbRecord); setShadow(pbQuit); recButtonAnimation=new QMovie(":/images/rec_animation.gif"); connect(recButtonAnimation,SIGNAL(frameChanged(int)),this,SLOT(setRecButtonIcon(int))); singleClickTimer->setInterval(QApplication::doubleClickInterval()); singleClickTimer->setSingleShot(true); CheckNewVersion(); netManager = new QNetworkAccessManager(this); if (Proxy!="") { netManager->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,Proxy,ProxyPort.toInt(),ProxyUser,ProxyPass)); } connect(netManager, SIGNAL(finished(QNetworkReply*)),this, SLOT(pingReply(QNetworkReply*))); }
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { switch (Message) { case WM_CREATE: InitControls(hwnd); break; case WM_NOTIFY: { LPNMHDR pnmhdr = (LPNMHDR)lParam; switch (pnmhdr->code) { case TTN_GETDISPINFO: { LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)lParam; UINT idButton = (UINT)lpttt->hdr.idFrom; switch (idButton) { case IDC_PLAY: lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PLAY); break; case IDC_STOP: lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_STOP); break; case IDC_EJECT: lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_EJECT); break; case IDC_BACKWARD: lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_BACKWARD); break; case IDC_SEEKBACK: lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SEEKBACK); break; case IDC_SEEKFORW: lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SEEKFORW); break; case IDC_FORWARD: lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_FORWARD); break; } break; } } } break; case WM_SIZING: { LPRECT pRect = (LPRECT)lParam; if (pRect->right - pRect->left < MAIN_WINDOW_MIN_WIDTH) pRect->right = pRect->left + MAIN_WINDOW_MIN_WIDTH; if (pRect->bottom - pRect->top != MAIN_WINDOW_HEIGHT) pRect->bottom = pRect->top + MAIN_WINDOW_HEIGHT; return TRUE; } case WM_SIZE: { RECT Rect; UINT Size; if (hToolBar && hTrackBar) { SendMessage(hToolBar, TB_AUTOSIZE, 0, 0); SendMessage(hToolBar, TB_GETITEMRECT, 1, (LPARAM)&Rect); Size = GetSystemMetrics(SM_CYMENU) + Rect.bottom; MoveWindow(hTrackBar, 0, 0, LOWORD(lParam), HIWORD(lParam) - Size, TRUE); } return 0L; } case WM_HSCROLL: { if (hTrackBar == (HWND) lParam) { if (bIsOpened) { DWORD dwNewPos = (DWORD) SendMessage(hTrackBar, TBM_GETPOS, 0, 0); SeekPlayback(hwnd, dwNewPos); } else { SendMessage(hTrackBar, TBM_SETPOS, TRUE, 0); } } } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_PLAY: if (bIsOpened) { if (bIsPaused) ResumePlayback(hwnd); else PausePlayback(hwnd); } else { if (szPrevFile[0] == _T('\0')) OpenFileDialog(hwnd); else PlayFile(hwnd, NULL); } break; case IDC_STOP: StopPlayback(hwnd); break; case IDC_EJECT: break; case IDC_BACKWARD: break; case IDC_SEEKBACK: SeekBackPlayback(hwnd); break; case IDC_SEEKFORW: SeekForwPlayback(hwnd); break; case IDC_FORWARD: break; case IDM_OPEN_FILE: OpenFileDialog(hwnd); return 0; case IDM_CLOSE_FILE: StopPlayback(hwnd); _tcscpy(szPrevFile, _T("\0")); break; case IDM_ABOUT: { HICON mplayIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN)); ShellAbout(hwnd, szAppTitle, 0, mplayIcon); DeleteObject(mplayIcon); break; } case IDM_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0); return 0; } break; case WM_DESTROY: StopPlayback(hwnd); PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, Message, wParam, lParam); }
void MDFNMOV_Stop(void) { if(current < 0) StopPlayback(); if(current > 0) StopRecording(); }
// TODO: make this function legible! (what are all these magic numbers and weirdly named variables and crazy unexplained loops?) void FCEUMOV_AddJoy(uint8 *js) { // int x,y; if(!current) return; // Not playback nor recording. if(current < 0) // Playback { while(nextts == framets || nextd == -1) { int tmp,ti; uint8 d; if(nextd != -1) { if(nextd&0x80) { //puts("Egads"); FCEU_DoSimpleCommand(nextd&0x1F); } else joop[(nextd >> 3)&0x3] ^= 1 << (nextd&0x7); } tmp = movie_readchar(); d = tmp; if(tmp < 0) { StopPlayback(); memcpy(&cur_input_display,js,4); return; } nextts = 0; tmp >>= 5; tmp &= 0x3; ti=0; int tmpfix = tmp; while(tmp--) { nextts |= movie_readchar() << (ti * 8); ti++; } // This fixes a bug in movies recorded before version 0.98.11 // It's probably not necessary, but it may keep away CRAZY PEOPLE who recorded // movies on <= 0.98.10 and don't work on playback. if(tmpfix == 1 && !nextts) { nextts |= movie_readchar()<<8; } else if(tmpfix == 2 && !nextts) { nextts |= movie_readchar()<<16; } if(nextd != -1) framets = 0; nextd = d; } memcpy(js,joop,4); } #if 0 else if(current > 0) // Recording
UINT8 StopMusic(void) { StopPlayback(&vgmPbMusic); return 0x00; }
// Donuts are a tasty treat and delicious with powdered sugar. void MDFNMOV_AddJoy(void *donutdata, uint32 donutlen) { gzFile fp; if(!current) return; /* Not playback nor recording. */ if(current < 0) /* Playback */ { int t; fp = slots[-1 - current]; while((t = gzgetc(fp)) >= 0 && t) { if(t == MDFNNPCMD_LOADSTATE) { uint32 len; StateMem sm; len = gzgetc(fp); len |= gzgetc(fp) << 8; len |= gzgetc(fp) << 16; len |= gzgetc(fp) << 24; if(len >= 5 * 1024 * 1024) // A sanity limit of 5MiB { StopPlayback(); return; } memset(&sm, 0, sizeof(StateMem)); sm.len = len; sm.data = (uint8 *)malloc(len); if(gzread(fp, sm.data, len) != len) { StopPlayback(); return; } if(!MDFNSS_LoadSM(&sm, 0, 0)) { StopPlayback(); return; } } else MDFN_DoSimpleCommand(t); } if(t < 0) { StopPlayback(); return; } if(gzread(fp, donutdata, donutlen) != donutlen) { StopPlayback(); return; } } else /* Recording */ { if(MDFN_StateEvilIsRunning()) { smem_putc(&RewindBuffer, 0); smem_write(&RewindBuffer, donutdata, donutlen); } else { fp = slots[current - 1]; gzputc(fp, 0); gzwrite(fp, donutdata, donutlen); } } }
void AReplayPlayer::EndPlay(const EEndPlayReason::Type EndPlayReason) { StopPlayback(); }
USHORT CTestPage::ServiceInterrupt( ULONG ulReason, PVOID pvContext ) ///////////////////////////////////////////////////////////////////////////// { //DPF(("<")); //DPF(("ServiceInterrupt\n")); switch( ulReason ) { case kReasonWave: //DPF(("W")); //DPF(("kReasonWave\n")); PHALWAVEDEVICE pHD; ULONG ulBytesToProcess, ulCircularBufferSize, ulBytesTransfered; LONG lBufferSize; pHD = (PHALWAVEDEVICE)pvContext; //DPF(("d%ld ", pHD->GetDeviceNumber() )); // Get the amount of free space on device //DPF(("GetTransferSize\n")); pHD->GetTransferSize( &ulBytesToProcess, &ulCircularBufferSize ); //DPF(("R%ld ", ulBytesToProcess )); if( pHD->IsRecord() ) { pHD->TransferAudio( m_pRecordBuffer, ulBytesToProcess, &ulBytesTransfered ); if( ulBytesToProcess != ulBytesTransfered ) DPF(("Did not transfer all the audio! %lu %lu\n", ulBytesToProcess, ulBytesTransfered )); m_WaveRecordFile.WriteBlock( (HPSTR)m_pRecordBuffer, ulBytesTransfered ); //DPF(("W%ld ", ulBytesTransfered )); } else { lBufferSize = m_WavePlayFile.ReadBlock( (HPSTR)m_pPlayBuffer, ulBytesToProcess ); // only call the hal if we have audio to transfer if( lBufferSize ) { //DPF(("T%ld ", lBufferSize )); pHD->TransferAudio( m_pPlayBuffer, lBufferSize, &ulBytesTransfered ); } else { DPF(("GetBytesRemaining\n")); if( !m_WavePlayFile.GetBytesRemaining() ) { StopPlayback(); } } } // make sure the limit register get set correctly //DPF(("TransferComplete\n")); pHD->TransferComplete( TRUE ); break; case kReasonDMABufferComplete: DPF(("kReasonDMA\n")); PHALWAVEDMADEVICE pHDD; ULONG ulSize; pHDD = (PHALWAVEDMADEVICE)pvContext; ulSize = 0; // release the last buffer to the application // ... // add a new buffer if available pHDD->GetDMA()->AddEntry( m_pPlayBuffer, ulSize, TRUE ); break; case kReasonMIDI: DPF(("kReasonMIDI\n")); break; default: DPF(("ServiceInterrupt: Invalid Parameter\n")); return( HSTATUS_INVALID_PARAMETER ); } //DPF((">")); return( HSTATUS_OK ); }