⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 masndseq.c

📁 是一个手机功能的模拟程序
💻 C
📖 第 1 页 / 共 3 页
字号:
		{
			if (ma_sndseq_info.repeat_mode[seq_type][file_id] != 0xFFFF)
				play_mode = ma_sndseq_info.repeat_mode[seq_type][file_id];
			ma_sndseq_info.play_mode[seq_type][file_id] = play_mode;
			ma_sndseq_info.save_mode[seq_type][file_id] = play_mode;
			ma_sndseq_info.loop_count[seq_type][file_id] = play_mode;
		}
		result = ma_srmcnv_func[func_id].Start( file_id, ext_args );
	}
	else
	{
		ma_sndseq_info.play_mode[seq_type][file_id] = play_mode;
		ma_sndseq_info.save_mode[seq_type][file_id] = play_mode;
		ma_sndseq_info.loop_count[seq_type][file_id] = 1;
		result = ma_srmcnv_func[func_id].Start( file_id, &save_play_mode );
	}

	if ( result < MASMW_SUCCESS )
	{
		ma_sndseq_info.state[func_id][file_id] = MASMW_STATE_READY;

		ma_sndseq_info.func_id[seq_type] = save_func_id;
		ma_sndseq_info.file_id[seq_type] = save_file_id;
	}

	return result;
}
/****************************************************************************
 *	MaSound_Pause
 *
 *	Function:
 *			Stops sequence data reproduction temporarily.
 *			For audio systems, this operation is same as Stop.
 *	Argument:
 *			func_id		function id
 *			file_id		file id
 *			ext_args	for future extenstion
 *	Return:
 *			0			success
 *			< 0			error code
 *
 ****************************************************************************/
SINT32 MaSound_Pause
(
	SINT32	func_id,					/* function id */
	SINT32	file_id,					/* file id */
	void * 	ext_args					/* for future extension */
)
{
	SINT32	result;						/* result of function */
	
	MASNDSEQ_DBGMSG(("MaSound_Pause: id=%ld hd=%ld\n", func_id, file_id));

	if ( ( ma_sndseq_info.srmcnv_map & (UINT32)(1 << func_id) ) == 0 )
	{
		return MASMW_ERROR;
	}

	if ( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_PLAYING )
	{
		return MASMW_ERROR;
	}

	result = ma_srmcnv_func[func_id].Stop( file_id, ext_args );

	if ( result >= MASMW_SUCCESS )
	{
		ma_sndseq_info.state[func_id][file_id] = MASMW_STATE_PAUSE;
	}

	return result;
}
/****************************************************************************
 *	MaSound_Restart
 *
 *	Function:
 *			Cancels pause of sequence data reproduction.
 *			For audio systems, this operation is the same as Start.
 *	Argument:
 *			func_id		function id
 *			file_id		file id
 *			ext_args	for future extension
 *	Return:
 *			0			success
 *			< 0			error code
 *
 ****************************************************************************/
SINT32 MaSound_Restart
(
	SINT32	func_id,					/* function id */
	SINT32	file_id,					/* file id */
	void * 	ext_args					/* for future extension */
)
{
	UINT8	seq_type;					/* type of sequence */
	UINT16	mode;						/* mode */
	SINT32	result;						/* result of function */

	MASNDSEQ_DBGMSG(("MaSound_Restart: id=%ld, hd=%ld\n", func_id, file_id));

	if ( ( ma_sndseq_info.srmcnv_map & (UINT32)(1 << func_id) ) == 0 )
	{
		return MASMW_ERROR;
	}

	if ( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_PAUSE )
	{
		return MASMW_ERROR;
	}

	ma_sndseq_info.state[func_id][file_id] = MASMW_STATE_PLAYING;


	seq_type = ma_seqtype[func_id];
	if ( seq_type != 1 )
	{
		ma_sndseq_info.start_extargs[func_id][file_id] = ext_args;

		result = ma_srmcnv_func[func_id].Start( file_id, ext_args );
	}
	else
	{
		mode = 0xFFFF;
		result = ma_srmcnv_func[func_id].Start( file_id, &mode );
	}

	if ( result < MASMW_SUCCESS )
	{
		ma_sndseq_info.state[func_id][file_id] = MASMW_STATE_PAUSE;
	}

	return result;
}
/****************************************************************************
 *	MaSound_Stop
 *
 *	Function:
 *			Performs stopping processing of Stream Converter.
 *	Argument:
 *			func_id		function id
 *			file_id		file id
 *			ext_args	for future extension
 *	Return:
 *			0			success
 *			< 0 		error code
 *
 ****************************************************************************/
SINT32 MaSound_Stop
(
	SINT32	func_id,					/* function id */
	SINT32	file_id,					/* file id */
	void *	ext_args					/* for future extension */
)
{
#if MA_STOPWAIT
	SINT32	time_out;					/* time out value */
#endif
	SINT32	result;						/* result of function */
	
	MASNDSEQ_DBGMSG(("MaSound_Stop: id=%ld hd=%ld\n", func_id, file_id));
	if ( ( ma_sndseq_info.srmcnv_map & (UINT32)(1 << func_id) ) == 0 )
	{
		return MASMW_ERROR;
	}

	if ( ma_sndseq_info.state[func_id][file_id] == MASMW_STATE_READY )
	{
		return MASMW_SUCCESS;
	}

	if ( ( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_PLAYING )
	  && ( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_PAUSE ) )
	{
		return MASMW_ERROR;
	}

	if ( ma_sndseq_info.state[func_id][file_id] == MASMW_STATE_PLAYING )
	{
		result = ma_srmcnv_func[func_id].Stop( file_id, ext_args );
	}
	else
	{
		result = MASMW_SUCCESS;
	}

	if ( result >= MASMW_SUCCESS )
	{
		ma_sndseq_info.state[func_id][file_id] = MASMW_STATE_READY;
	}

#if MA_STOPWAIT
	time_out = MA_STOPWAIT_TIMEOUT;
	while ( ( _ma_intstate != 0 ) && ( time_out > 0 ) )
	{
		machdep_Sleep(5);
		time_out -= 5;
	}
#endif

	return result;
}
/****************************************************************************
 *	MaSound_Close
 *
 *	Function:
 *			Performs closing processing of Stream Converter.
 *	Argument:
 *			func_id		function id
 *			file_id		file id
 *			ext_args	for future extension
 *	Return:
 *			0			success
 *			< 0			error code
 *
 ****************************************************************************/
SINT32 MaSound_Close
(
	SINT32	func_id,					/* function id */
	SINT32	file_id,					/* file id */
	void *	ext_args					/* for future extension */
)
{
	SINT32	result;						/* result of function */

	MASNDSEQ_DBGMSG(("MaSound_Close: id=%ld hd=%ld\n", func_id, file_id));

	if ( ( ma_sndseq_info.srmcnv_map & (UINT32)(1 << func_id) ) == 0 )
	{
		return MASMW_ERROR;
	}

	if ( ( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_READY )
	  && ( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_OPENED ) )
	{
		return MASMW_ERROR;
	}

	result = ma_srmcnv_func[func_id].Close( file_id, ext_args );

	if ( result >= MASMW_SUCCESS )
	{
		ma_sndseq_info.state[func_id][file_id] = MASMW_STATE_LOADED;
	}

	return result;
}
/****************************************************************************
 *	MaSound_Unload
 *
 *	Function:
 *			Performs unloading prcessing of Stream Converter.
 *	Argument:
 *			func_id		function id
 *			file_id		file id
 *			ext_args	for future extension
 *	Return:
 *			0			success
 *			< 0			error code
 *
 ****************************************************************************/
SINT32 MaSound_Unload
(
	SINT32	func_id,					/* function id */
	SINT32	file_id,					/* file id */
	void *	ext_args					/* for future extension */
)
{
	SINT32 result;						/* result of function */

	MASNDSEQ_DBGMSG(("MaSound_Unload: id=%ld hd=%ld\n", func_id, file_id));

	if ( ( ma_sndseq_info.srmcnv_map & (UINT32)(1 << func_id) ) == 0 )
	{
		return MASMW_ERROR;
	}

	if ( file_id == 0 )
	{
		return MASMW_SUCCESS;
	}

	if ( ma_sndseq_info.state[func_id][file_id] != MASMW_STATE_LOADED )
	{
		return MASMW_ERROR;
	}

	result = ma_srmcnv_func[func_id].Unload( file_id, ext_args );

	if ( result >= MASMW_SUCCESS )
	{
		ma_sndseq_info.state[func_id][file_id] = MASMW_STATE_IDLE;
	}

	return result;
}
/****************************************************************************
 *	MaSound_Delete
 *
 *	Function:
 *			Deletes Stream Converter that has been registered with func_id.
 *	Argument:
 *			func_id		function id
 *	Return:
 *			0			success
 *			< 0			error code
 *
 ****************************************************************************/
SINT32 MaSound_Delete
(
	SINT32	func_id						/* function id */
)
{
	UINT32	i;							/* loop counter */
	SINT32	result;						/* result of function */
	
	MASNDSEQ_DBGMSG(("MaSound_Delete: id=%ld\n", func_id));

	if ( ( ma_sndseq_info.srmcnv_map & (UINT32)(1 << func_id) ) == 0 )
	{
		return MASMW_ERROR;
	}

	for ( i = 0; i < MASMW_NUM_FILE; i++ )
	{
		if ( ma_sndseq_info.state[func_id][i] != MASMW_STATE_IDLE )
		{
			return MASMW_ERROR;
		}
	}

	result = ma_srmcnv_func[func_id].End();

	ma_sndseq_info.srmcnv_map ^= (UINT32)(1 << func_id);

	return result;
}
/****************************************************************************
 *	MaSound_DeviceControl
 *
 *	Function:
 *			Control the hardware.
 *	Argument:
 *			cmd		command number
 *			param1	parameter 1
 *			param2	parameter 2
 *			param3	parameter 3
 *	Return:
 *			>= 0	success
 *			< 0		error code
 *
 ****************************************************************************/
SINT32 MaSound_DeviceControl
(
	UINT8	cmd,						/* command number */
	UINT8	param1,						/* parameter 1 */
	UINT8	param2,						/* parameter 2 */
	UINT8	param3						/* parameter 3 */
)
{
	SINT32	result;						/* result of function */

	MASNDSEQ_DBGMSG(("MaSound_DeviceControl: cmd=%d p1=%d p2=%d p3=%d\n", cmd, param1, param2, param3));

	result = MaSndDrv_DeviceControl( cmd, param1, param2, param3 );

	return result;
}
/****************************************************************************
 *	MaSound_Initialize
 *
 *	Function:
 *			Initialize the MA Sound Sequencer.
 *	Argument:
 *			None
 *	Return:
 *			0		success
 *			< 0 	error code
 *
 ****************************************************************************/
SINT32 MaSound_Initialize
(
	void
)
{
	UINT32	i, j;						/* loop counter */
	SINT32	result;						/* result of function */

	MASNDSEQ_DBGMSG(("MaSound_Initialize\n"));

	/* Initialzie stream converter mapping flag */
	ma_sndseq_info.srmcnv_map = 0;

	/* Initillize the all internal status */
	for ( i = 0; i < MASMW_NUM_SRMCNV; i++ )
	{
		for ( j = 0; j < MASMW_NUM_FILE; j++ )
		{
			ma_sndseq_info.state[i][j] = MASMW_STATE_IDLE;
			ma_sndseq_info.clback_func[i][j] = NULL;
		}
	}

	/* Initialize MA Device Driver */
	result = MaDevDrv_Initialize();
	if ( result != MASMW_SUCCESS )
	{
		return result;
	}

	/* Initialize MA Resource Manager */
	MaResMgr_Initialize();

	/* Initialize MA Sound Driver */
	MaSndDrv_Initialize();

#if MASMW_SRMCNV_SMAF_PHRASE
	PhrAudCnv_Initialize();
#endif

	return MASMW_SUCCESS;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -