示例#1
0
// Open a digital sound file for streaming
//
// input:	filename	=>	disk filename of sound file
//				type		=> what type of audio stream do we want to open:
//									ASF_SOUNDFX
//									ASF_EVENTMUSIC
//									ASF_VOICE
//	
// returns:	success => handle to identify streaming sound
//				failure => -1
int audiostream_open(char* filename, int type)
{
	int i, rc;
	if (!Audiostream_inited || !snd_is_inited())
		return -1;

	for (i = 0; i < MAX_AUDIO_STREAMS; i++)
	{
		if (Audio_streams[i].status == ASF_FREE)
		{
			Audio_streams[i].status = ASF_USED;
			Audio_streams[i].type = type;
			break;
		}
	}

	if (i == MAX_AUDIO_STREAMS)
	{
		nprintf(("Sound", "SOUND => No more audio streams available!\n"));
		return -1;
	}

	rc = Audio_streams[i].Create(filename, m_pass);
	if (rc == 0)
	{
		Audio_streams[i].status = ASF_FREE;
		return -1;
	}
	else
		return i;
}
示例#2
0
// Open a digital sound file for streaming
//
// input:	filename	=>	disk filename of sound file
//				type		=> what type of audio stream do we want to open:
//									ASF_SOUNDFX
//									ASF_EVENTMUSIC
//									ASF_VOICE
//	
// returns:	success => handle to identify streaming sound
//				failure => -1
int audiostream_open( char * filename, int type )
{
	int i, rc;
	if (!Audiostream_inited || !snd_is_inited())
		return -1;

	for ( i = 0; i < MAX_AUDIO_STREAMS; i++ ) {
		if ( Audio_streams[i].status == ASF_FREE ) {
			Audio_streams[i].status = ASF_USED;
			Audio_streams[i].type = type;
			break;
		}
	}

	if ( i == MAX_AUDIO_STREAMS ) {
		nprintf(("Sound", "SOUND => No more audio streams available!\n"));
		return -1;
	}

	switch(type) {
	case ASF_VOICE:
	case ASF_SOUNDFX:
		Audio_streams[i].m_bits_per_sample_uncompressed = 8;
		break;
	case ASF_EVENTMUSIC:
		Audio_streams[i].m_bits_per_sample_uncompressed = 16;
		break;
	default:
		Int3();
		return -1;
	}
	
	rc = Audio_streams[i].Create(filename, m_pass);
	if ( rc == 0 ) {
		Audio_streams[i].status = ASF_FREE;
		return -1;
	}
	else
		return i;
}