void BassPlayer::closeChannel() { if (chan) { unregisterEQ(); BASS_ChannelRemoveSync(chan, syncHandle); BASS_ChannelRemoveSync(chan, syncDownloadHandle); BASS_ChannelStop(chan); BASS_StreamFree(chan); } }
void KNMusicBackendBassThread::releaseSyncHandle() { //Remove all the sync in the list. while(!m_syncHandles.isEmpty()) { BASS_ChannelRemoveSync(m_channel, m_syncHandles.takeLast()); } }
inline void KNMusicBackendBassThread::removeChannelSyncs() { //Get all the handlers. for(auto i=m_syncHandlers.begin(); i!=m_syncHandlers.end(); ++i) { //Remove all the sync from the list. BASS_ChannelRemoveSync(m_channel, *i); } //Clear the hanlder list. m_syncHandlers.clear(); }
void CBassAudio::Destroy ( void ) { RemoveCallbackId( m_uiCallbackId ); m_uiCallbackId = 0; if ( m_pSound ) { // Remove all callbacks BASS_FX_BPM_BeatFree( m_pSound ); BASS_FX_BPM_Free( m_pSound ); BASS_ChannelRemoveSync( m_pSound, m_hSyncDownload ); BASS_ChannelRemoveSync( m_pSound, m_hSyncEnd ); BASS_ChannelRemoveSync( m_pSound, m_hSyncFree ); BASS_ChannelRemoveSync( m_pSound, m_hSyncMeta ); // Best way to minimize a freeze during BASS_ChannelStop: // * BASS_ChannelPause // * wait a little bit // * BASS_ChannelStop BASS_ChannelPause ( m_pSound ); g_pClientGame->GetManager()->GetSoundManager()->QueueAudioStop( this ); } else delete this; }
HRESULT CBSoundBuffer::SetLoopStart(DWORD Pos) { m_LoopStart = Pos; if (m_Stream) { if (m_Sync) { BASS_ChannelRemoveSync(m_Stream, m_Sync); m_Sync = NULL; } if (m_LoopStart > 0) { QWORD len = BASS_ChannelGetLength(m_Stream, BASS_POS_BYTE); m_Sync = BASS_ChannelSetSync(m_Stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, CBSoundBuffer::LoopSyncProc, (void*)this); } } return S_OK; }
void CFusicCartsDlg::OnBnClickedBtnLogout() { //ensure we want to logout: int res = MessageBox("Are you sure you want to log out?\nNOTE: All user carts will be " "halted when you logout.", "Fusic", MB_YESNO | MB_ICONQUESTION); if(res == IDNO) { //don't logout: return; } //stop all user carts: //(stop all nav buttons): for(std::vector<SNavigationStreams>::iterator i = m_vecNavStreamsBottom.begin(); i != m_vecNavStreamsBottom.end(); i++) { //fade out the cart (500 ms): BASS_ChannelSlideAttribute(i->stream, BASS_ATTRIB_VOL, 0, 500); //also remove from the map: for(T_mapCallback::iterator j = g_mapCartCallbacks.end(); j != g_mapCartCallbacks.end(); j++) { if(j->first == i->syncHandle) { g_mapCartCallbacks.erase(j); break; } } //remove old end sync: BASS_ChannelRemoveSync(i->stream, i->syncHandle); //create a new sync at the end of the slide: //NOTE: We should be safe to call this callback function, it is a part of a class //that will be destroyed when the window is, however, it is a static function and //therefore //does not need a class to be created in order to use the function: BASS_ChannelSetSync(i->stream, BASS_SYNC_SLIDE, 0, &CCallbackButton::fnSlideCallback, NULL); } //(stop page buttons): for(mapCart::iterator i = m_mapBtnCartBottom.begin(); i != m_mapBtnCartBottom.end(); i++) { i->second->fnStop(true); } //add all the currently playing fuse carts: //(current wall): for(mapCart::iterator i = m_mapBtnCartTop.begin(); i != m_mapBtnCartTop.end(); i++) { if(i->second->fnGetCurrentStream() != 0) { CString strTitle; SCartsList lst; HSYNC callbackSync; //remove the callback from the global map: for(T_mapCallback::iterator j = g_mapCartCallbacks.begin(); j != g_mapCartCallbacks.end(); j++) { if(j->first == i->second->fnGetCurrentSync()) { g_mapCartCallbacks.erase(j); break; } } //reset the callback: BASS_ChannelRemoveSync(i->second->fnGetCurrentStream(), i->second->fnGetCurrentSync()); callbackSync = BASS_ChannelSetSync(i->second->fnGetCurrentStream(), BASS_SYNC_END, 0, CFusicLoginDlg::fnLoginDialogCartCallback, m_pLoginDlg); //create a new cart list element: i->second->GetWindowTextA(strTitle); lst.hstCartsStream = i->second->fnGetCurrentStream(); lst.hsyCartsSync = 0; lst.strTitle = strTitle; lst.hsyCartsSync = callbackSync; lst.intPageNumber = m_intCurrnetDialogPageTop; lst.strCartPosistion = i->first; m_pLoginDlg->fnAddCartToList(lst); }//if }//for //(nav walls): for(std::vector<SNavigationStreams>::iterator ii = m_vecNavStreamsTop.begin(); ii != m_vecNavStreamsTop.end(); ii++) { CString strTitle; SCartsList lst; HSYNC callbackSync; lst.hstCartsStream = ii->stream; lst.intPageNumber = ii->intPageNumber; lst.strCartPosistion = ii->btnIterator->first; //remove the callback from the global map: for(T_mapCallback::iterator j = g_mapCartCallbacks.begin(); j != g_mapCartCallbacks.end(); j++) { if(j->first == ii->syncHandle) { g_mapCartCallbacks.erase(j); break; } } //change the callbacks: BASS_ChannelRemoveSync(ii->stream, ii->syncHandle); callbackSync = BASS_ChannelSetSync(ii->stream, BASS_SYNC_END, 0, CFusicLoginDlg::fnLoginDialogCartCallback, m_pLoginDlg); lst.hsyCartsSync = callbackSync; //to get the title we will need to do an SQL query :-( CString strQuery; CString strPageNumber; strPageNumber.Format("%d", ii->intPageNumber); strQuery = "SELECT Cart_Title FROM tbl_carts WHERE Show_ID = 0 AND Cart_ID = "; strQuery += strPageNumber; strQuery += ii->btnIterator->first; //do the query: mysqlpp::StoreQueryResult res = fnGetResultSetForQuery(strQuery); lst.strTitle = res[0]["Cart_Title"]; m_pLoginDlg->fnAddCartToList(lst); } //kill the main dialog: m_pMainDlg->doOk(); //logout of the fusic carts screen: OnOK(); }
BOOL CFusicCartsDlg::OnInitDialog() { mysqlpp::StoreQueryResult resFuse; mysqlpp::StoreQueryResult resUser; CDialog::OnInitDialog(); //set the stop all button dialog pointer: m_ctlBtnStopall.fnSetCartsDialogPointer((void*)this); //set up button maps: fnSetupButtonMaps(); //set up all nav buttons: for(mapNav::iterator i = m_mapBtnNavBottom.begin(); i != m_mapBtnNavBottom.end(); i++) { i->second->fnSetupNavButtonForPage(i->first, USERCARTS, (void*)this); } for(mapNav::iterator i = m_mapBtnNavTop.begin(); i != m_mapBtnNavTop.end(); i++) { i->second->fnSetupNavButtonForPage(i->first, FUSECARTS, (void*)this); } //setup all carts buttons: for(mapCart::iterator i = m_mapBtnCartBottom.begin(); i != m_mapBtnCartBottom.end(); i++) { i->second->fnSetDefaultButton(); } for(mapCart::iterator i = m_mapBtnCartTop.begin(); i != m_mapBtnCartTop.end(); i++) { i->second->fnSetDefaultButton(); } //setup stopall button: m_ctlBtnStopall.fnSetBackColour(255,0,0, true); m_ctlBtnStopall.fnSetFontColour(255,255,0); m_ctlBtnStopall.fnSetEdgeColour(255,255,0); m_ctlBtnStopall.fnSetClickColourChange(true); //setup logout button: m_ctlBtnLogout.fnSetBackColour(255,0,0,true); m_ctlBtnLogout.fnSetFontColour(255,255,0); m_ctlBtnLogout.fnSetEdgeColour(255,255,0); m_ctlBtnLogout.fnSetClickColourChange(true); //setup reconnect button: m_ctlBtnReconnect.fnSetBackColour(255,0,0,true); m_ctlBtnReconnect.fnSetFontColour(255,255,0); m_ctlBtnReconnect.fnSetEdgeColour(255,255,0); m_ctlBtnReconnect.fnSetClickColourChange(true); //setup refresh button: m_ctlBtnRefresh.fnSetBackColour(255,0,0,true); m_ctlBtnRefresh.fnSetFontColour(255,255,0); m_ctlBtnRefresh.fnSetEdgeColour(255,255,0); m_ctlBtnRefresh.fnSetClickColourChange(true); //create the connection to mysql: if(!connect()) { //we didnt connect: CString strError; strError = "Error: could not connecto the mysql database: "; strError += m_PMYSQLConn->error(); strError += "."; MessageBox(strError, "Carts Pane", MB_OK | MB_ICONERROR); } //need to get all fuse carts: resFuse = fnGetResultSetForQuery("SELECT * FROM tbl_carts where Show_ID = 0 and Cart_ID like '1%'"); //setup fuse carts: fnSetupButtonForPageData(resFuse, FUSECARTS); //do the query for user carts: CString strQuery; CString strShowID; strShowID.Format("%d", g_intShowID); strQuery = "SELECT * FROM tbl_carts where Show_ID = "; strQuery += strShowID; strQuery += " and Cart_ID like '1%'"; //do the query: resUser = fnGetResultSetForQuery(strQuery); //setup the user buttons: fnSetupButtonForPageData(resUser, USERCARTS); //we need now to get carts that where left playing on logout: for(std::vector<SCartsList>::iterator i = m_pLoginDlg->m_vecCartsList.begin(); i != m_pLoginDlg->m_vecCartsList.end(); i++) { //we want to set all current first buttons up (as these will be displaied first): //get the button we firstly need to change: CCartsButton* curBtn = NULL; if(i->intPageNumber == 1) { curBtn = m_mapBtnCartTop[i->strCartPosistion]; if(curBtn == NULL) break; for(T_mapCallback::iterator j = g_mapCartCallbacks.begin(); j != g_mapCartCallbacks.end(); j++) { if(j->first == i->hsyCartsSync) { g_mapCartCallbacks.erase(j); break; } } //set all settings back; curBtn->fnPageMoveOn(i->hstCartsStream, i->hsyCartsSync); //also reset the callback: BASS_ChannelRemoveSync(i->hstCartsStream, i->hsyCartsSync); //set the new callback for the button: HSYNC callback = BASS_ChannelSetSync(i->hstCartsStream, BASS_SYNC_END, 0, &CCallbackButton::fnEndCallback, 0); //add to the callback map: g_mapCartCallbacks[callback] = (CCallbackButton*)curBtn; } else { //the other buttons arn't on the first page. //so we need to put them back into the Navigation stream vector: //fist find the nav button that this cart will corrispond to: CNavigationButton* navBtn = m_mapBtnNavTop[i->intPageNumber]; //remove the callback before we change it from the map: for(T_mapCallback::iterator j = g_mapCartCallbacks.begin(); j != g_mapCartCallbacks.end(); j++) { if(j->first == i->hsyCartsSync) { g_mapCartCallbacks.erase(j); break; } } BASS_ChannelRemoveSync(i->hstCartsStream, i->hsyCartsSync); HSYNC synx = BASS_ChannelSetSync(i->hstCartsStream, BASS_SYNC_END,0, &CCallbackButton::fnEndCallback, 0); SNavigationStreams sNav; sNav.intPageNumber = i->intPageNumber; sNav.stream = i->hstCartsStream; sNav.syncHandle = i->hsyCartsSync; sNav.syncHandle = synx; //sNav. //now the tricky part, we need to create a std::mapCart::iterator for the //button that we can store in the struct; the only way I can see of doing this //is to iterate over the buttons untill we find one with the appropriate ID: for(mapCart::iterator ii = m_mapBtnCartTop.begin(); ii != m_mapBtnCartTop.end(); ii++) { if(ii->first == i->strCartPosistion) { sNav.btnIterator = ii; break; } } //reset the callback: g_mapCartCallbacks[i->hsyCartsSync] = navBtn; //incrase the reference count on the nav button (to start it flashing): navBtn->fnIncreasePlayCount(); //also add to the nav stream map: m_vecNavStreamsTop.push_back(sNav); } } //allow the window to be changed. AllowSetForegroundWindow(ASFW_ANY); //clear out the vector on the login dialog for the next logout population: m_pLoginDlg->m_vecCartsList.clear(); //begin the fader start timer: SetTimer(WM_USER + 10, 10, NULL); return TRUE; // return TRUE unless you set the focus to a control }
void SetLoopEnd(QWORD pos) { loop[1]=pos; BASS_ChannelRemoveSync(chan,lsync); // remove old sync lsync=BASS_ChannelSetSync(chan,BASS_SYNC_POS|BASS_SYNC_MIXTIME,loop[1],LoopSyncProc,0); // set new sync }