void S9xInitDSP1() { static bool8 init = FALSE; if (!init) { InitDSP(); init = TRUE; } }
int wxSoundBackendOSS::OpenDSP(const wxSoundData *data) { int dev = -1; if ((dev = open(AUDIODEV, O_WRONLY, 0)) <0) return -1; if (!InitDSP(dev, data) || m_needConversion) { close(dev); return -1; } return dev; }
bool CMusikPlayer::Play( size_t nItem, int nStartPos, int nFadeType ) { if((m_bSuppressAutomaticSongPicking == false) && (m_Playlist.GetCount() < (size_t)wxGetApp().Prefs.nAutoDJChooseSongsToPlayInAdvance) && ( MUSIK_PLAYMODE_AUTO_DJ == m_Playmode || MUSIK_PLAYMODE_AUTO_DJ_ALBUM == m_Playmode) ) { if(m_Playlist.GetCount() == 0) nItem = 0; _AddRandomSongs(); if(m_Playlist.GetCount() == 0) // no songs could be chosen { m_Playing = false; return false; } } m_bSuppressAutomaticSongPicking = false; //--- check for an invalid playlist ---// if ( ( nItem >= m_Playlist.GetCount() ) || ( m_Playlist.GetCount() == 0 ) ) { m_Playing = false; return false; } if (IsPlaying() && _CurrentSongIsNetStream()) { if(m_SongIndex == nItem ) { return true; // already playing this stream } // _PostPlayRestart(); // will restart playing postponed // return true; } else if (_IsNETSTREAMConnecting()) { return true; } CSongPath sFilename; std::auto_ptr<CMusikSong> pNewSong = m_Playlist.Item( nItem ).Song(); sFilename = pNewSong->MetaData.Filename; if((pNewSong->MetaData.eFormat != MUSIK_FORMAT_NETSTREAM) && !sFilename.FileExists()) { // not a network stream // and // file does not exist wxMessageBox( _( "Cannot find file.\n Filename:" ) + sFilename.GetFullPath(), MUSIKAPPNAME_VERSION, wxICON_STOP ); Stop(); return false; } bool bNewSongStarted = (m_Playlist[nItem] != m_CurrentSong) && (nStartPos == 0); if(bNewSongStarted && IsPlaying()) { // player is currently playing, so we have to record history here, because Stop() is not // called between the playing of the songs of the playlist. wxGetApp().Library.RecordSongHistory(m_CurrentSong,GetTime(FMOD_MSEC)); } //---------------------------------------------// //--- start with the basics ---// //---------------------------------------------// m_Stopping = false; m_SongIndex = nItem; m_CurrentSong = m_Playlist.Item( m_SongIndex ); //---------------------------------------------// //--- if there is already a fade in ---// //--- progress, then we need to abort it ---// //---------------------------------------------// SetCrossfadeType( nFadeType ); //---------------------------------------------// //--- open a new stream and push it to the ---// //--- bottom of the m_ActiveStreams array ---// //---------------------------------------------// FSOUND_Stream_SetBufferSize( wxGetApp().Prefs.nSndBuffer ); FMODEngine::eOpenMode om = _CurrentSongNeedsMPEGACCURATE() ? FMODEngine::OpenMode_MPEGACCURATE : FMODEngine::OpenMode_Default; m_SndEngine.SetOpenMode(om); MUSIKStream* pNewStream = m_SndEngine.OpenMedia( ( const char* )ConvFn2A( sFilename.GetFullPath() )); if(pNewStream == NULL) { wxMessageBox( _( "Playback will be stopped, because loading failed.\n Filename:" ) + sFilename.GetFullPath(), MUSIKAPPNAME_VERSION, wxICON_STOP ); Stop(false); return false; } InitDSP(); if(_CurrentSongIsNetStream()&& _IsNETSTREAMConnecting() == false) { ClearOldStreams(true);// clear all streams m_MetaDataSong = CMusikSong(); m_MetaDataSong.MetaData.eFormat = MUSIK_FORMAT_NETSTREAM; m_p_NETSTREAM_Connecting = pNewStream; m_Playing = true; m_b_NETSTREAM_AbortConnect = false; bool bExit = false; do { int openstate = FSOUND_Stream_GetOpenState((FSOUND_STREAM*)pNewStream->GetStreamOut()->STREAM()); if ((openstate == -1) || (openstate == -3)) { wxMessageBox(_("ERROR: failed to open stream:")+ ConvA2W(FSOUND_Stream_Net_GetLastServerStatus())); m_b_NETSTREAM_AbortConnect = true; break; } switch(_NetStreamStatusUpdate(pNewStream)) { case FSOUND_STREAM_NET_READY: if(openstate == 0) bExit = true; break; case FSOUND_STREAM_NET_ERROR: m_b_NETSTREAM_AbortConnect = true; break; } wxGetApp().Yield(); } while (!bExit && !m_b_NETSTREAM_AbortConnect); m_p_NETSTREAM_Connecting = NULL; if( m_b_NETSTREAM_AbortConnect ) { delete pNewStream; Stop(false); m_b_NETSTREAM_AbortConnect = false; return false; } } //---------------------------------------------// //--- start playback on the new stream on ---// //--- the designated channel. ---// //---------------------------------------------// int retries = 2; bool bPlaySucceeded = false; pNewStream->SetTime( nStartPos * 1000 ); while( retries -- && (!bPlaySucceeded)) { if(!pNewStream->Play()) { wxCriticalSectionLocker lock(m_protectingStreamArrays); if(m_ActiveStreams.GetCount()) { delete( m_ActiveStreams[0] ); m_ActiveStreams.RemoveAt(0); } } else bPlaySucceeded = true; } if(!bPlaySucceeded) { wxMessageBox(_("Play failed, please try again.")); wxLogDebug(wxT("play failed:%s"),(const wxChar *) ConvA2W(m_SndEngine.ErrorString())); delete pNewStream; Stop(false); return false; } if(_CurrentSongIsNetStream()) { FSOUND_Stream_Net_SetMetadataCallback((FSOUND_STREAM*)pNewStream->GetStreamOut()->STREAM(), MetadataCallback, this); } pNewStream->SetVolume( 0.0 ); m_Playing = true; m_Paused = false; if(g_FaderThread) g_FaderThread->CrossfaderAbort(); //---------------------------------------------// //--- update the global arrays containing ---// //--- active channels and streams ---// //---------------------------------------------// { wxCriticalSectionLocker lock(m_protectingStreamArrays); m_ActiveStreams.Add( pNewStream ); } //---------------------------------------------// //--- playback has been started, update the ---// //--- user interface to reflect it ---// //---------------------------------------------// MusikPlayerEvent ev_start(this,wxEVT_MUSIKPLAYER_PLAY_START); ProcessEvent(ev_start); UpdateUI();//TODO: remove this. replace by event handling of playlistctrl etc. //---------------------------------------------// //--- record history in database ---// //---------------------------------------------// if(bNewSongStarted) { MusikPlayerEvent ev_songchange(this,wxEVT_MUSIKPLAYER_SONG_CHANGED); ProcessEvent(ev_songchange); wxGetApp().Library.UpdateItemLastPlayed ( m_CurrentSong );//TODO: replace by event handling of wxEVT_MUSIKPLAYER_SONG_CHANGED in library } //---------------------------------------------// //--- if fading is not enabled, shut down ---// //--- all of the old channels, and set the ---// //--- active stream to full volume ---// //---------------------------------------------// if ( wxGetApp().Prefs.bFadeEnable == 0 || wxGetApp().Prefs.bGlobalFadeEnable == 0 ) { if(pNewStream) pNewStream->SetVolume(1.0); ClearOldStreams(); } //---------------------------------------------// //--- tell the listening thread its time to ---// //--- start fading ---// //---------------------------------------------// else if ( wxGetApp().Prefs.bFadeEnable && wxGetApp().Prefs.bGlobalFadeEnable ) SetFadeStart(); return true; }