Exemplo n.º 1
0
	void MainWindow::radioOpenURLThread(string url) {
		radioStatus_currentMetadata = "";

		KillTimer(window, bufferTimerId);
		KillTimer(window, metaTimerId);

		if (currentStream != 0) {
			BASS_ChannelStop(currentStream);
			BASS_StreamFree(currentStream);
		}

		radioStatus = INETR_RS_Connecting;
		updateStatusLabel();

		HSTREAM tempStream = BASS_StreamCreateURL(url.c_str(), 0, 0, nullptr,
			0);

		if (currentStreamURL != url || radioStatus != INETR_RS_Connecting) {
			BASS_StreamFree(tempStream);
			return;
		}

		currentStream = tempStream;

		if (currentStream != 0) {
			SetTimer(window, bufferTimerId, 50, nullptr);
		} else {
			radioStatus = INETR_RS_ConnectionError;
			updateStatusLabel();
		}
	}
Exemplo n.º 2
0
void *OpenURL(char *url)
{
	DWORD c,r;
	pthread_mutex_lock(&lock); // make sure only 1 thread at a time can do the following
	r=++req; // increment the request counter for this request
	pthread_mutex_unlock(&lock);
	RemoveEventLoopTimer(prebuftimer); // stop prebuffer monitoring
	BASS_StreamFree(chan); // close old stream
	PostCustomEvent('open',0,0);
	c=BASS_StreamCreateURL(url,0,BASS_STREAM_BLOCK|BASS_STREAM_STATUS|BASS_STREAM_AUTOFREE,StatusProc,0);
	free(url); // free temp URL buffer
	pthread_mutex_lock(&lock);
	if (r!=req) { // there is a newer request, discard this stream
		pthread_mutex_unlock(&lock);
		if (c) BASS_StreamFree(c);
		return;
	}
	chan=c; // this is now the current stream
	pthread_mutex_unlock(&lock);
	if (!chan) {
		PostCustomEvent('end ',0,0);
//		Error("Can't play the stream");
	} else
		InstallEventLoopTimer(GetMainEventLoop(),kEventDurationNoWait,kEventDurationSecond/20,NewEventLoopTimerUPP(PrebufTimerProc),0,&prebuftimer); // start prebuffer monitoring
	return NULL;
}
Exemplo n.º 3
0
void Stream::Stop(HSTREAM cual)
{
    if(!IsPlay(cual))//if no sound
    {
        Timer->stop();

        BASS_ChannelStop(cual);
        BASS_StreamFree(cual); //free stream
        PuestaCero();
        return;
    }

    Timer->stop();

    if(FundirParar)
    {
        FaderOut(cual);
    }
    else
    {
        BASS_ChannelStop(cual);
        BASS_StreamFree(cual); //free stream
    }

    PuestaCero();//set all zero
}
Exemplo n.º 4
0
void *OpenURL(char *url)
{
	DWORD c,r;
	g_static_mutex_lock(&lock); // make sure only 1 thread at a time can do the following
	r=++req; // increment the request counter for this request
	g_static_mutex_unlock(&lock);
	if (prebuftimer) {
		g_source_remove(prebuftimer); // stop prebuffer monitoring
		prebuftimer=0;
	}
	BASS_StreamFree(chan); // close old stream
	gdk_threads_enter();
	gtk_label_set_text(GTK_LABEL(GetWidget("status1")),"");
	gtk_label_set_text(GTK_LABEL(GetWidget("status2")),"connecting...");
	gtk_label_set_text(GTK_LABEL(GetWidget("status3")),"");
	gdk_threads_leave();
	c=BASS_StreamCreateURL(url,0,BASS_STREAM_BLOCK|BASS_STREAM_STATUS|BASS_STREAM_AUTOFREE,StatusProc,0);
	free(url); // free temp URL buffer
	g_static_mutex_lock(&lock);
	if (r!=req) { // there is a newer request, discard this stream
		g_static_mutex_unlock(&lock);
		if (c) BASS_StreamFree(c);
		return NULL;
	}
	chan=c; // this is now the current stream
	g_static_mutex_unlock(&lock);
	if (!chan) {
		gdk_threads_enter();
		gtk_label_set_text(GTK_LABEL(GetWidget("status2")),"not playing");
		Error("Can't play the stream");
		gdk_threads_leave();
	} else
		prebuftimer=g_timeout_add(50,PrebufTimerProc,NULL); // start prebuffer monitoring
	return NULL;
}
Exemplo n.º 5
0
void OpenClicked(GtkButton *obj, gpointer data)
{
	int resp=gtk_dialog_run(GTK_DIALOG(filesel));
	gtk_widget_hide(filesel);
	if (resp==GTK_RESPONSE_ACCEPT) {
		char *file=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(filesel));
		// free both MOD and stream, it must be one of them! :)
		BASS_MusicFree(chan);
		BASS_StreamFree(chan);
		if (!(chan=BASS_StreamCreateFile(FALSE,file,0,0,BASS_SAMPLE_LOOP|BASS_SAMPLE_FLOAT))
			&& !(chan=BASS_MusicLoad(FALSE,file,0,0,BASS_MUSIC_RAMPS|BASS_SAMPLE_LOOP|BASS_SAMPLE_FLOAT,1))) {
			// whatever it is, it ain't playable
			gtk_button_set_label(obj,"click here to open a file...");
			Error("Can't play the file");
		} else {
			BASS_CHANNELINFO info;
			BASS_ChannelGetInfo(chan,&info);
			if (info.chans!=2) { // the DSP expects stereo
				gtk_button_set_label(obj,"click here to open a file...");
				BASS_MusicFree(chan);
				BASS_StreamFree(chan);
				Error("only stereo sources are supported");
			} else {
				gtk_button_set_label(obj,file);
				// setup DSPs on new channel and play it
				RotateToggled(GTK_TOGGLE_BUTTON(GetWidget("rotate")),0);
				EchoToggled(GTK_TOGGLE_BUTTON(GetWidget("echo")),0);
				FlangerToggled(GTK_TOGGLE_BUTTON(GetWidget("flanger")),0);
				BASS_ChannelPlay(chan,FALSE);
			}
		}
		g_free(file);
	}
}
Exemplo n.º 6
0
void Music::Stop()
{
	if (mp3Strewam != NULL)
		BASS_StreamFree(mp3Strewam);

	BASS_Free();
}
Exemplo n.º 7
0
bool BassPlayer::fileInfo(const QUrl & uri, IMediaInfo * info) {
    bool currently_played = media_url.isValid() && uri == media_url;

    int chUID;

    if (currently_played)
        chUID = chan;
    else {
        if (uri.isLocalFile())
            chUID = open(uri.toLocalFile(), LOCAL_PLAY_ATTRS);
        else
            chUID = openRemote(uri.toString(), REMOTE_PLAY_ATTRS);

        if (!chUID) return false;
    }

    float time = BASS_ChannelBytes2Seconds(chUID, BASS_ChannelGetLength(chUID, BASS_POS_BYTE)); // playback duration
    qint64 len = BASS_StreamGetFilePosition(chUID, BASS_FILEPOS_END); // file length

    info -> setDuration(time);
    info -> setBitrate((len / (125 * time) + 0.5));

    BASS_CHANNELINFO media_info;
    if (BASS_ChannelGetInfo(chUID, &media_info)) {
        info -> setSize(len + BASS_StreamGetFilePosition(chUID, BASS_FILEPOS_START));
        info -> setSampleRate(media_info.freq);
        info -> setChannels(media_info.chans);
    }

    if (!currently_played)
        BASS_StreamFree(chUID);
    return true;
}
Exemplo n.º 8
0
void TForm1::StartRecording()
{
	run=1;
    WAVEFORMATEX *wf;
    if (recbuf) { // free old recording
        BASS_StreamFree(chan);
        chan=0;
        free(recbuf);
        recbuf=NULL;
        // close output device before recording incase of half-duplex device
        BASS_Free();
    }
    // allocate initial buffer and make space for WAVE header
    recbuf=(char *)malloc(BUFSTEP);
    reclen=44;
    // fill the WAVE header
    memcpy(recbuf,"RIFF\0\0\0\0WAVEfmt \20\0\0\0",20);
    memcpy(recbuf+36,"data\0\0\0\0",8);
    wf=(WAVEFORMATEX*)(recbuf+20);
    wf->wFormatTag=1;
    wf->nChannels=CHANS;
    wf->wBitsPerSample=16;
    wf->nSamplesPerSec=FREQ;
    wf->nBlockAlign=wf->nChannels*wf->wBitsPerSample/8;
    wf->nAvgBytesPerSec=wf->nSamplesPerSec*wf->nBlockAlign;
    // start recording
	rchan=BASS_RecordStart(FREQ,CHANS,0,RecordingCallback,0);
    if (!rchan) {
        //Error("Couldn't start recording");
		free(recbuf);
		recbuf=0;
        return;
    }
    //MESS(10,WM_SETTEXT,0,"Stop");
}
Exemplo n.º 9
0
void StartRecording()
{
	WAVEFORMATEX wf;
	if (chan) { // free old recording
		BASS_StreamFree(chan);
		chan=0;
		EnableWindow(DLGITEM(11),FALSE);
		// close output device before recording incase of half-duplex device
		BASS_Free();
	}
	// open the output file
	if (!(rfp=_wfopen(L"bass.wav",L"wb"))) {
		Error(L"Can't create the file");
		return;
	}
	// write the WAVE header
	fwrite("RIFF\0\0\0\0WAVEfmt \20\0\0\0",1,20,rfp);
	wf.wFormatTag=WAVE_FORMAT_PCM;
	wf.nChannels=1;
	wf.wBitsPerSample=16;
	wf.nSamplesPerSec=44100;
	wf.nBlockAlign=wf.nChannels*wf.wBitsPerSample/8;
	wf.nAvgBytesPerSec=wf.nSamplesPerSec*wf.nBlockAlign;
	fwrite(&wf,1,16,rfp);
	fwrite("data\0\0\0\0",1,8,rfp);
	// start recording @ 44100hz 16-bit mono
	if (!(rchan=BASS_RecordStart(44100,1,0,&RecordingCallback,0))) {
		Error(L"Couldn't start recording");
		fclose(rfp);
		return;
	}
	MESS(10,WM_SETTEXT,0,L"Stop");
}
Exemplo n.º 10
0
void StartRecording()
{
	WAVEFORMATEX *wf;
	if (recbuf) { // free old recording
		BASS_StreamFree(chan);
		chan=0;
		free(recbuf);
		recbuf=NULL;
		EnableWindow(DLGITEM(11),FALSE);
		EnableWindow(DLGITEM(12),FALSE);
		// close output device before recording incase of half-duplex device
		BASS_Free();
	}
	// allocate initial buffer and make space for WAVE header
	recbuf=malloc(BUFSTEP);
	reclen=44;
	// fill the WAVE header
	memcpy(recbuf,"RIFF\0\0\0\0WAVEfmt \20\0\0\0",20);
	memcpy(recbuf+36,"data\0\0\0\0",8);
	wf=(WAVEFORMATEX*)(recbuf+20);
	wf->wFormatTag=1;
	wf->nChannels=2;
	wf->wBitsPerSample=16;
	wf->nSamplesPerSec=44100;
	wf->nBlockAlign=wf->nChannels*wf->wBitsPerSample/8;
	wf->nAvgBytesPerSec=wf->nSamplesPerSec*wf->nBlockAlign;
	// start recording @ 44100hz 16-bit stereo
	if (!(rchan=BASS_RecordStart(44100,2,0,&RecordingCallback,0))) {
		Error("Couldn't start recording");
		free(recbuf);
		recbuf=0;
		return;
	}
	MESS(10,WM_SETTEXT,0,"Stop");
}
Exemplo n.º 11
0
int Music_decode(text_t* path, MusicData* data)
{
    QWORD len;
    thrd_t id;

    if (thrd_busy == mtx_trylock(&s_mutex))
    {
	    Dialog_showError(TEXT("Decoding of stream already in-progress. Re-open after it's been completed."));
	    return 1;
    }

    // now this will break if we already have a thread running.

    free(data->fftData);
    data->fftData = 0;

	int flags = BASS_STREAM_DECODE | BASS_SAMPLE_MONO | BASS_POS_SCAN;

#ifdef _WIN32
	flags |= BASS_UNICODE;
#endif

	HSTREAM chan = BASS_StreamCreateFile(0, path, 0, 0, flags);

	if (!chan)
	{
	    Dialog_showError(TEXT("Unable to open stream for decode. No music data will be available."));
	    mtx_unlock(&s_mutex);
	    return 0;
	}

    len = BASS_ChannelGetLength(chan, BASS_POS_BYTE);

    if (len == -1)
    {
	    Dialog_showError(TEXT("Stream has no length. No music data will be available."));
        BASS_StreamFree(chan);
        mtx_unlock(&s_mutex);
        return 0;
    }

    ThreadFuncData* threadData = malloc(sizeof(ThreadFuncData));
    threadData->stream = chan;
    threadData->data = data;

    data->percentDone = 1;
    data->fftData = 0;

    // So there is a race-condition here as the mutex is unclocked while the thread is crated but in practice
    // this won't be a problem
    mtx_unlock(&s_mutex);

    if (thrd_create(&id, decodeFunc, threadData) != thrd_success)
    {
        printf("Unable to create decode thread. Stalling main thread and running...\n");
        decodeFunc(threadData);
    }

    return 1;
}
Exemplo n.º 12
0
CBSoundBuffer::~CBSoundBuffer()
{
	Stop();

	if (m_Stream)
	{
		BASS_StreamFree(m_Stream);
		m_Stream = NULL;
	}

	if(m_File)
	{
		Game->m_FileManager->CloseFile(m_File);
		m_File = NULL;
	}

#ifdef USE_LIBEFFECTS_REVERB
	if (m_context.hInstance != NULL)
	{
		free(m_context.InFrames32);
		free(m_context.OutFrames32);
		Reverb_free(&m_context);
		m_context.hInstance = NULL;
	}
#endif


	SAFE_DELETE_ARRAY(m_Filename);
}
Exemplo n.º 13
0
/**
 * @brief Starts the record and set default confuration for audio file. If start record is failure free RECBUF is comming.
 */
void Widget::startRecording() {
    WAVEFORMATEX *wf;
    if (recbuf) { // free old recording;
        BASS_StreamFree(chan);
        chan=0;
        free(recbuf);
        recbuf=NULL;
        //ui->pushButton_2->setEnabled(false);
        ui->pushButton_3->setEnabled(false);
        // close output device before recording incase of half-duplex device;
        BASS_Free();
    }
    // allocate initial buffer and make space for WAVE header;
    recbuf=(char*)malloc(BUFSTEP);
    reclen=44;
    // fill the WAVE header;
    memcpy(recbuf,"RIFF\0\0\0\0WAVEfmt \20\0\0\0",20);
    memcpy(recbuf+36,"data\0\0\0\0",8);
    wf=(WAVEFORMATEX*)(recbuf+20);
    wf->wFormatTag=1;
    wf->nChannels=2;
    wf->wBitsPerSample=16;
    wf->nSamplesPerSec=44100;
    wf->nBlockAlign=wf->nChannels*wf->wBitsPerSample/8;
    wf->nAvgBytesPerSec=wf->nSamplesPerSec*wf->nBlockAlign;
    // start recording @ 44100hz 32-bit stereo;
    if (!(rchan=BASS_RecordStart(44100,2,0,&RecordingCallback,0))) {
        QDEBUG(BASS_ErrorGetCode());
        Error("Couldn't start recording");
        free(recbuf);
        recbuf=0;
        return;
    }
    ui->pushButton->setEnabled(false);
}
Exemplo n.º 14
0
HEFFECT CALL HGE_Impl::Effect_Load(const char *filename, DWORD size)
{
	DWORD _size, length, samples;
	HSAMPLE hs;
	HSTREAM hstrm;
	BASS_CHANNELINFO info;
	void *buffer, *data;

	if(hBass)
	{
		if(bSilent) return 1;

		if(size) { data=(void *)filename; _size=size; }
		else
		{
			data=Resource_Load(filename, &_size);
			if(!data) return NULL;
		}
	
		hs=BASS_SampleLoad(TRUE, data, 0, _size, 4, BASS_SAMPLE_OVER_VOL);
		if(!hs) {
			hstrm=BASS_StreamCreateFile(TRUE, data, 0, _size, BASS_STREAM_DECODE);
			if(hstrm) {
				length=(DWORD)BASS_ChannelGetLength(hstrm);
				BASS_ChannelGetInfo(hstrm, &info);
				samples=length;
				if(info.chans < 2) samples>>=1;
				if((info.flags & BASS_SAMPLE_8BITS) == 0) samples>>=1;
				buffer=BASS_SampleCreate(samples, info.freq, 2, 4, info.flags | BASS_SAMPLE_OVER_VOL);
				if(!buffer)
				{
					BASS_StreamFree(hstrm);
					_PostError("Can't create sound effect: Not enough memory");
				}
				else
				{
					BASS_ChannelGetData(hstrm, buffer, length);
					hs=BASS_SampleCreateDone();
					BASS_StreamFree(hstrm);
					if(!hs)	_PostError("Can't create sound effect");
				}
			}
		}

		if(!size) Resource_Free(data);
		return hs;
	}
Exemplo n.º 15
0
HFX CALLBACK SetCustFX (DWORD chan, DWORD type, int priority) {
if (type!=CUST_FX_TYPE_ID) return NULL;
BASS_CHANNELINFO info;
BASS_ChannelGetInfo(chan, &info);
HCustFX* hc = malloc(sizeof(HCustFX));
if (!hc) return NULL;
hc->flags = info.flags&( BASS_SAMPLE_FLOAT | BASS_SAMPLE_8BITS );
hc->push = BASS_StreamCreate(info.freq, info.chans, hc->flags | BASS_STREAM_DECODE, STREAMPROC_PUSH, NULL);
hc->pitch = BASS_FX_TempoCreate(hc->push, BASS_STREAM_DECODE);
HFX hfx = bassfunc->SetFX(chan, CustFXDSPProc, hc, priority, &CustFXFuncs);
if (hfx&&hc->pitch&&hc->push) return hfx;
if (hfx) BASS_ChannelRemoveFX(chan, hfx);
if (hc->pitch) BASS_StreamFree(hc->pitch);
if (hc->push) BASS_StreamFree(hc->push);
free(hc);
return NULL;
}
Exemplo n.º 16
0
void Player::stop() {
    if( playStatus == true)
    {
        BASS_Stop();
        BASS_StreamFree(stream);
        playStatus = false;
    }
}
Exemplo n.º 17
0
CSoundManager::~CSoundManager() {
	if (m_stream != NULL) {
        BASS_ChannelStop(m_stream);
		BASS_StreamFree(m_stream);
	}

	BASS_Free();
}
Exemplo n.º 18
0
void CAudio::Unload()
{
	if(m_dwChannel != 0)
	{
		// Free BASS stream
		BASS_StreamFree(m_dwChannel);
		m_dwChannel = 0;
	}
}
Exemplo n.º 19
0
void BassPlayer::closeChannel() {
    if (chan) {
        unregisterEQ();
        BASS_ChannelRemoveSync(chan, syncHandle);
        BASS_ChannelRemoveSync(chan, syncDownloadHandle);
        BASS_ChannelStop(chan);
        BASS_StreamFree(chan);
    }
}
Exemplo n.º 20
0
void error(char *reason){
	free_textures();
	if (music_file) BASS_StreamFree( music_file );
	if (fp) file_close( fp );
	BASS_Free();
	d3dwin_close();
	MessageBox(NULL, reason, NULL, MB_OK);
	exit(1);
}
Exemplo n.º 21
0
void NLS::Sound::operator = (Node n) {
	if (data == n.data->sound) {
		return;
	}
	if (stream) {
		BASS_StreamFree(stream);
		stream = 0;
	}
	data = n.data->sound;
}
Exemplo n.º 22
0
void CAudio::Unload()
{
	// Do we have a valid channel?
	if(m_dwChannel != 0) 
	{
		// Free BASS stream
		BASS_StreamFree(m_dwChannel);
		m_dwChannel = 0;
	}
}
Exemplo n.º 23
0
void CAudio::Unload()
{
	// Are we loaded?
	if(m_dwChannel != 0)
	{
		// Free our BASS stream
		BASS_StreamFree(m_dwChannel);
		m_dwChannel = 0;
	}
}
Exemplo n.º 24
0
void Fader::run()
{
    BASS_ChannelSlideAttribute(stream, BASS_ATTRIB_VOL, -1, Tiempo);
    this->msleep(Tiempo);
    BASS_ChannelStop(stream);
    BASS_StreamFree(stream); //lo liberamos
    // this->terminate();


}
Exemplo n.º 25
0
pascal OSStatus OpenEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
{
	NavDialogRef fileDialog;
	NavDialogCreationOptions fo;
	NavGetDefaultDialogCreationOptions(&fo);
	fo.optionFlags=0;
	fo.parentWindow=win;
	NavCreateChooseFileDialog(&fo,NULL,NULL,NULL,NULL,NULL,&fileDialog);
// if someone wants to somehow get the file selector to filter like in the Windows example, that'd be nice ;)
	if (!NavDialogRun(fileDialog)) {
		NavReplyRecord r;
		if (!NavDialogGetReply(fileDialog,&r)) {
			AEKeyword k;
			FSRef fr;
			if (!AEGetNthPtr(&r.selection,1,typeFSRef,&k,NULL,&fr,sizeof(fr),NULL)) {
				char file[256];
				FSRefMakePath(&fr,(BYTE*)file,sizeof(file));
				BASS_StreamFree(chan); // free old stream before opening new
				if (!(chan=BASS_StreamCreateFile(FALSE,file,0,0,BASS_SAMPLE_LOOP|BASS_SAMPLE_FLOAT))) {
					SetControlTitleWithCFString(inUserData,CFSTR("click here to open a file..."));
					{
						ControlRef cref=GetControl(11);
						SetControlData(cref,kControlNoPart,kControlStaticTextTextTag,0,"");
						DrawOneControl(cref);
					}
					SetControl32BitMaximum(GetControl(12),0);
					Error("Can't play the file");
				} else {
					CFStringRef cs=CFStringCreateWithCString(0,file,kCFStringEncodingUTF8);
					SetControlTitleWithCFString(inUserData,cs);
					CFRelease(cs);
					{ // display the file type and length
						QWORD bytes=BASS_ChannelGetLength(chan,BASS_POS_BYTE);
						DWORD time=BASS_ChannelBytes2Seconds(chan,bytes);
						BASS_CHANNELINFO info;
						BASS_ChannelGetInfo(chan,&info);
						sprintf(file,"channel type = %x (%s)\nlength = %llu (%u:%02u)",
							info.ctype,GetCTypeString(info.ctype,info.plugin),bytes,time/60,time%60);
						{
							ControlRef cref=GetControl(11);
							SetControlData(cref,kControlNoPart,kControlStaticTextTextTag,strlen(file),file);
							DrawOneControl(cref);
						}
						SetControl32BitMaximum(GetControl(12),time); // update scroller range
					}
					BASS_ChannelPlay(chan,FALSE);
				}
			}
			NavDisposeReply(&r);
		}
	}
	NavDialogDispose(fileDialog);
    return noErr;
}
Exemplo n.º 26
0
bool Player::Load(const char filename[])
{
    BASS_ChannelStop(stream);
    BASS_StreamFree(stream);
    stream = BASS_StreamCreateFile(false, filename, 0, 0, 0);
    if (stream == NULL)
        return false;
    stopped = true;
    paused = false;
    BASS_ChannelGetAttribute(stream, BASS_ATTRIB_FREQ, &defaulSampleRate);
    pitchedSampleRate = defaulSampleRate;
    return true;
}
Exemplo n.º 27
0
static void __cdecl openUrl(char* url) {
    if (chan != NULL) {
        BASS_StreamFree(chan);
    }
    chan = BASS_StreamCreateURL(url, 0, BASS_STREAM_BLOCK|BASS_STREAM_STATUS|BASS_STREAM_AUTOFREE, statusProc, 0);
    free(url);
    if (!chan) {
        // TODO: tell the user failed to open stream
    } else {

    }
    cthread = 0;
}
Exemplo n.º 28
0
void BassDecoder::_reset()
{
  if (
#if defined(LIBTOOLS_WINDOWS) && !defined(BASS_H)
       BASS_MusicFree && 
       BASS_StreamFree &&
#endif
      _music) {
    if (_mod) BASS_MusicFree((HMUSIC) _music);
	  else BASS_StreamFree((HSTREAM) _music);
  }
  _music = 0;
  _ended=true;
}
Exemplo n.º 29
0
// --[  Method  ]---------------------------------------------------------------
//
//  - Class     : CSoundStream
//  - prototype : bool Free()
//
//  - Purpose   : Frees the sound stream.
//
// -----------------------------------------------------------------------------
bool CSoundStream::Free()
{
    if(!IsValid())
    {
        return false;
    }

    BASS_StreamFree(m_handle);
    SAFE_DELETE(m_pBuffer);

    CSoundSystem::Instance().EraseSound(this);

    return BASS_ErrorGetCode() == BASS_OK;
}
Exemplo n.º 30
0
static int OnPlaySnd(WPARAM wParam, LPARAM lParam)
{
	TCHAR* ptszFile = (TCHAR*)lParam;
	SYSTEMTIME systime;
	BOOL doPlay = TRUE;

	GetLocalTime(&systime);
	WORD currtime = MAKEWORD(systime.wMinute, systime.wHour);

	WORD currstat = 1;
	switch (CallService(MS_CLIST_GETSTATUSMODE, 0, 0)) {
	case ID_STATUS_OUTTOLUNCH:   currstat <<= 1;
	case ID_STATUS_ONTHEPHONE:   currstat <<= 1;
	case ID_STATUS_INVISIBLE:    currstat <<= 1;
	case ID_STATUS_FREECHAT:     currstat <<= 1;
	case ID_STATUS_DND:          currstat <<= 1;
	case ID_STATUS_OCCUPIED:     currstat <<= 1;
	case ID_STATUS_NA:           currstat <<= 1;
	case ID_STATUS_AWAY:         currstat <<= 1;
	case ID_STATUS_ONLINE:       currstat <<= 1;
	}

	if (!db_get_b(NULL, "Skin", "UseSound", 0))
		doPlay = FALSE;

	if (QuietTime)
		if (
			((TimeWrd1 < TimeWrd2) && (TimeWrd1 <= currtime && currtime < TimeWrd2)) ||
			((TimeWrd2 < TimeWrd1) && (TimeWrd1 <= currtime || currtime < TimeWrd2))
			) doPlay = FALSE;

	if (!(currstat & StatMask))
		doPlay = FALSE;

	if (Preview || (int)wParam == 1)
		doPlay = TRUE;

	if (!ptszFile)
		doPlay = FALSE;

	if (doPlay) {
		BASS_StreamFree(sndSSnd[sndNSnd]);
		sndSSnd[sndNSnd] = BASS_StreamCreateFile(FALSE, ptszFile, 0, 0, BASS_STREAM_AUTOFREE);
		BASS_ChannelPlay(sndSSnd[sndNSnd], FALSE);
		sndNSnd = (sndNSnd + 1) % sndLimSnd;
	}

	Preview = FALSE;
	return 1;
}