示例#1
0
static QWORD WINAPI ASAP_GetLength(void *inst, DWORD mode)
{
	ASAPSTREAM *stream = (ASAPSTREAM *) inst;
	if (mode != BASS_POS_BYTE)
		errorn(BASS_ERROR_NOTAVAIL);
	noerrorn((stream->duration * (ASAP_SAMPLE_RATE / 100) / 10) << stream->asap.module_info.channels); // assumes 16-bit
}
示例#2
0
static HSTREAM WINAPI StreamCreateProc(BASSFILE file, DWORD flags)
{
	BOOL unicode = FALSE;
	const char *filename;
	char aFilename[MAX_PATH];
	byte module[ASAP_MODULE_MAX];
	int module_len;
	ASAPSTREAM *stream;
	int song;
	int duration;
	HSTREAM handle;
	filename = (const char *) bassfunc->file.GetFileName(file, &unicode);
	if (filename == NULL)
		error(BASS_ERROR_NOTFILE);
	if (unicode) {
		if (WideCharToMultiByte(CP_ACP, 0, (LPCWSTR) filename, -1, aFilename, MAX_PATH, NULL, NULL) <= 0)
			error(BASS_ERROR_NOTFILE);
		filename = aFilename;
	}
	module_len = bassfunc->file.Read(file, module, sizeof(module));
	stream = malloc(sizeof(ASAPSTREAM));
	if (stream == NULL)
		error(BASS_ERROR_MEM);
	if (!ASAP_Load(&stream->asap, filename, module, module_len)) {
		free(stream);
		error(BASS_ERROR_FILEFORM);
	}
	flags &= BASS_SAMPLE_SOFTWARE | BASS_SAMPLE_LOOP | BASS_SAMPLE_3D | BASS_SAMPLE_FX
		| BASS_STREAM_DECODE | BASS_STREAM_AUTOFREE | 0x3f000000; // 0x3f000000 = all speaker flags
	song = stream->asap.module_info.default_song;
	if ((flags & BASS_MUSIC_LOOP) != 0 && stream->asap.module_info.loops[song])
		duration = -1;
	else
		duration = stream->asap.module_info.durations[song];
	stream->duration = duration;
	ASAP_PlaySong(&stream->asap, song, duration);
	handle = bassfunc->CreateStream(ASAP_SAMPLE_RATE, stream->asap.module_info.channels, flags, &StreamProc, stream, &ASAPfuncs);
	if (handle == 0) {
		free(stream);
		return 0; // CreateStream set the error code
	}
	bassfunc->file.SetStream(file, handle);
	noerrorn(handle);
}
示例#3
0
// NOTE: Invalid value of HSTREAM is 0, not INVALID_HANDLE_VALUE.
HSTREAM WINAPI StreamCreateProc(BASSFILE file, DWORD flags) {

    if (bassfunc->file.GetFlags(file)&BASSFILE_BUFFERED) error(BASS_ERROR_FILEFORM);

    TAKSTREAM *stream=(TAKSTREAM*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(TAKSTREAM));

    if (TAK_OpenFile(stream,file) != 0 ) {
        HeapFree(GetProcessHeap(),0,stream);
        error(BASS_ERROR_FILEFORM);
    }

    // restrict flags to valid ones, and create the BASS stream
    flags&=BASS_SAMPLE_FLOAT|BASS_SAMPLE_SOFTWARE|BASS_SAMPLE_LOOP|BASS_SAMPLE_3D|BASS_SAMPLE_FX
           |BASS_STREAM_DECODE|BASS_STREAM_AUTOFREE
           |0x3f000000; // 0x3f000000 = all speaker flags
    if (!(stream->handle=bassfunc->CreateStream((DWORD)stream->info.SAMPLERATE,stream->info.NCH,flags,(STREAMPROC*)&StreamProc,(DWORD)stream,&TAKfuncs))) {
        TAK_Free(stream->handle);
        return 0;
    }
    stream->flags=flags;
    bassfunc->file.SetStream(file,stream->handle); // set the stream associated with the file
    noerrorn(stream->handle);
}