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

📄 snd_next.m

📁 Quake 2 Source code for students by Theerthan You can also download from idsoftwares.com
💻 M
📖 第 1 页 / 共 5 页
字号:
                msg_type_t samplingRateType;
                int samplingRate;
                msg_type_t encodingType;
                int encoding;
                msg_type_t useInterruptsType;
                int useInterrupts;
        } Request;

        typedef struct {
                msg_header_t Head;
                msg_type_t RetCodeType;
                kern_return_t RetCode;
        } Reply;

        union {
                Request In;
                Reply Out;
        } Mess;

        register Request *InP = &Mess.In;
        register Reply *OutP = &Mess.Out;

        msg_return_t msg_result;

#if	TypeCheck
        boolean_t msg_simple;
#endif	TypeCheck

        unsigned int msg_size = 64;

#if	UseStaticMsgType
        static const msg_type_t owner_portType = {
                /* msg_type_name = */		MSG_TYPE_PORT,
                /* msg_type_size = */		32,
                /* msg_type_number = */		1,
                /* msg_type_inline = */		TRUE,
                /* msg_type_longform = */	FALSE,
                /* msg_type_deallocate = */	FALSE,
                /* msg_type_unused = */		0,
        };
#endif	UseStaticMsgType

#if	UseStaticMsgType
        static const msg_type_t channelCountType = {
                /* msg_type_name = */		MSG_TYPE_INTEGER_32,
                /* msg_type_size = */		32,
                /* msg_type_number = */		1,
                /* msg_type_inline = */		TRUE,
                /* msg_type_longform = */	FALSE,
                /* msg_type_deallocate = */	FALSE,
                /* msg_type_unused = */		0,
        };
#endif	UseStaticMsgType

#if	UseStaticMsgType
        static const msg_type_t samplingRateType = {
                /* msg_type_name = */		MSG_TYPE_INTEGER_32,
                /* msg_type_size = */		32,
                /* msg_type_number = */		1,
                /* msg_type_inline = */		TRUE,
                /* msg_type_longform = */	FALSE,
                /* msg_type_deallocate = */	FALSE,
                /* msg_type_unused = */		0,
        };
#endif	UseStaticMsgType

#if	UseStaticMsgType
        static const msg_type_t encodingType = {
                /* msg_type_name = */		MSG_TYPE_INTEGER_32,
                /* msg_type_size = */		32,
                /* msg_type_number = */		1,
                /* msg_type_inline = */		TRUE,
                /* msg_type_longform = */	FALSE,
                /* msg_type_deallocate = */	FALSE,
                /* msg_type_unused = */		0,
        };
#endif	UseStaticMsgType

#if	UseStaticMsgType
        static const msg_type_t useInterruptsType = {
                /* msg_type_name = */		MSG_TYPE_INTEGER_32,
                /* msg_type_size = */		32,
                /* msg_type_number = */		1,
                /* msg_type_inline = */		TRUE,
                /* msg_type_longform = */	FALSE,
                /* msg_type_deallocate = */	FALSE,
                /* msg_type_unused = */		0,
        };
#endif	UseStaticMsgType

#if	UseStaticMsgType
        static const msg_type_t RetCodeCheck = {
                /* msg_type_name = */		MSG_TYPE_INTEGER_32,
                /* msg_type_size = */		32,
                /* msg_type_number = */		1,
                /* msg_type_inline = */		TRUE,
                /* msg_type_longform = */	FALSE,
                /* msg_type_deallocate = */	FALSE,
                /* msg_type_unused = */		0
        };
#endif	UseStaticMsgType

#if	UseStaticMsgType
        InP->owner_portType = owner_portType;
#else	UseStaticMsgType
        InP->owner_portType.msg_type_name = MSG_TYPE_PORT;
        InP->owner_portType.msg_type_size = 32;
        InP->owner_portType.msg_type_number = 1;
        InP->owner_portType.msg_type_inline = TRUE;
        InP->owner_portType.msg_type_longform = FALSE;
        InP->owner_portType.msg_type_deallocate = FALSE;
#endif	UseStaticMsgType

        InP->owner_port /* owner_port */ = /* owner_port */ owner_port;

#if	UseStaticMsgType
        InP->channelCountType = channelCountType;
#else	UseStaticMsgType
        InP->channelCountType.msg_type_name = MSG_TYPE_INTEGER_32;
        InP->channelCountType.msg_type_size = 32;
        InP->channelCountType.msg_type_number = 1;
        InP->channelCountType.msg_type_inline = TRUE;
        InP->channelCountType.msg_type_longform = FALSE;
        InP->channelCountType.msg_type_deallocate = FALSE;
#endif	UseStaticMsgType

        InP->channelCount /* channelCount */ = /* channelCount */ channelCount;

#if	UseStaticMsgType
        InP->samplingRateType = samplingRateType;
#else	UseStaticMsgType
        InP->samplingRateType.msg_type_name = MSG_TYPE_INTEGER_32;
        InP->samplingRateType.msg_type_size = 32;
        InP->samplingRateType.msg_type_number = 1;
        InP->samplingRateType.msg_type_inline = TRUE;
        InP->samplingRateType.msg_type_longform = FALSE;
        InP->samplingRateType.msg_type_deallocate = FALSE;
#endif	UseStaticMsgType

        InP->samplingRate /* samplingRate */ = /* samplingRate */ samplingRate;

#if	UseStaticMsgType
        InP->encodingType = encodingType;
#else	UseStaticMsgType
        InP->encodingType.msg_type_name = MSG_TYPE_INTEGER_32;
        InP->encodingType.msg_type_size = 32;
        InP->encodingType.msg_type_number = 1;
        InP->encodingType.msg_type_inline = TRUE;
        InP->encodingType.msg_type_longform = FALSE;
        InP->encodingType.msg_type_deallocate = FALSE;
#endif	UseStaticMsgType

        InP->encoding /* encoding */ = /* encoding */ encoding;

#if	UseStaticMsgType
        InP->useInterruptsType = useInterruptsType;
#else	UseStaticMsgType
        InP->useInterruptsType.msg_type_name = MSG_TYPE_INTEGER_32;
        InP->useInterruptsType.msg_type_size = 32;
        InP->useInterruptsType.msg_type_number = 1;
        InP->useInterruptsType.msg_type_inline = TRUE;
        InP->useInterruptsType.msg_type_longform = FALSE;
        InP->useInterruptsType.msg_type_deallocate = FALSE;
#endif	UseStaticMsgType

        InP->useInterrupts /* useInterrupts */ = /* useInterrupts */ useInterrupts;

        InP->Head.msg_simple = FALSE;
        InP->Head.msg_size = msg_size;
        InP->Head.msg_type = MSG_TYPE_NORMAL | MSG_TYPE_RPC;
        InP->Head.msg_request_port = kern_serv_port;
        InP->Head.msg_reply_port = mig_get_reply_port();
        InP->Head.msg_id = 1012;

        msg_result = msg_rpc(&InP->Head, MSG_OPTION_NONE, sizeof(Reply), 0, 0);
        if (msg_result != RPC_SUCCESS) {
                if (msg_result == RCV_INVALID_PORT)
                        mig_dealloc_reply_port();
                return msg_result;
        }

#if	TypeCheck
        msg_size = OutP->Head.msg_size;
        msg_simple = OutP->Head.msg_simple;
#endif	TypeCheck

        if (OutP->Head.msg_id != 1112)
                return MIG_REPLY_MISMATCH;

#if	TypeCheck
        if (((msg_size != 32) || (msg_simple != TRUE)) &&
            ((msg_size != sizeof(death_pill_t)) ||
             (msg_simple != TRUE) ||
             (OutP->RetCode == KERN_SUCCESS)))
                return MIG_TYPE_ERROR;
#endif	TypeCheck

#if	TypeCheck
#if	UseStaticMsgType
        if (* (int *) &OutP->RetCodeType != * (int *) &RetCodeCheck)
#else	UseStaticMsgType
        if ((OutP->RetCodeType.msg_type_inline != TRUE) ||
            (OutP->RetCodeType.msg_type_longform != FALSE) ||
            (OutP->RetCodeType.msg_type_name != MSG_TYPE_INTEGER_32) ||
            (OutP->RetCodeType.msg_type_number != 1) ||
            (OutP->RetCodeType.msg_type_size != 32))
#endif	UseStaticMsgType
                return MIG_TYPE_ERROR;
#endif	TypeCheck

        if (OutP->RetCode != KERN_SUCCESS)
                return OutP->RetCode;

        return OutP->RetCode;
}

/* Routine BytesProcessed */
mig_external kern_return_t ntsoundBytesProcessed (
        port_t kern_serv_port,
        port_t owner_port,
        int *byte_count)
{
        typedef struct {
                msg_header_t Head;
                msg_type_t owner_portType;
                port_t owner_port;
        } Request;

        typedef struct {
                msg_header_t Head;
                msg_type_t RetCodeType;
                kern_return_t RetCode;
                msg_type_t byte_countType;
                int byte_count;
        } Reply;

        union {
                Request In;
                Reply Out;
        } Mess;

        register Request *InP = &Mess.In;
        register Reply *OutP = &Mess.Out;

        msg_return_t msg_result;

#if	TypeCheck
        boolean_t msg_simple;
#endif	TypeCheck

        unsigned int msg_size = 32;

#if	UseStaticMsgType
        static const msg_type_t owner_portType = {
                /* msg_type_name = */		MSG_TYPE_PORT,
                /* msg_type_size = */		32,
                /* msg_type_number = */		1,
                /* msg_type_inline = */		TRUE,
                /* msg_type_longform = */	FALSE,
                /* msg_type_deallocate = */	FALSE,
                /* msg_type_unused = */		0,
        };
#endif	UseStaticMsgType

#if	UseStaticMsgType
        static const msg_type_t RetCodeCheck = {
                /* msg_type_name = */		MSG_TYPE_INTEGER_32,
                /* msg_type_size = */		32,
                /* msg_type_number = */		1,
                /* msg_type_inline = */		TRUE,
                /* msg_type_longform = */	FALSE,
                /* msg_type_deallocate = */	FALSE,
                /* msg_type_unused = */		0
        };
#endif	UseStaticMsgType

#if	UseStaticMsgType
        static const msg_type_t byte_countCheck = {
                /* msg_type_name = */		MSG_TYPE_INTEGER_32,
                /* msg_type_size = */		32,
                /* msg_type_number = */		1,
                /* msg_type_inline = */		TRUE,
                /* msg_type_longform = */	FALSE,
                /* msg_type_deallocate = */	FALSE,
                /* msg_type_unused = */		0
        };
#endif	UseStaticMsgType

#if	UseStaticMsgType
        InP->owner_portType = owner_portType;
#else	UseStaticMsgType
        InP->owner_portType.msg_type_name = MSG_TYPE_PORT;
        InP->owner_portType.msg_type_size = 32;
        InP->owner_portType.msg_type_number = 1;
        InP->owner_portType.msg_type_inline = TRUE;
        InP->owner_portType.msg_type_longform = FALSE;
        InP->owner_portType.msg_type_deallocate = FALSE;
#endif	UseStaticMsgType

        InP->owner_port /* owner_port */ = /* owner_port */ owner_port;

        InP->Head.msg_simple = FALSE;
        InP->Head.msg_size = msg_size;
        InP->Head.msg_type = MSG_TYPE_NORMAL | MSG_TYPE_RPC;
        InP->Head.msg_request_port = kern_serv_port;
        InP->Head.msg_reply_port = mig_get_reply_port();
        InP->Head.msg_id = 1013;

        msg_result = msg_rpc(&InP->Head, MSG_OPTION_NONE, sizeof(Reply), 0, 0);
        if (msg_result != RPC_SUCCESS) {
                if (msg_result == RCV_INVALID_PORT)
                        mig_dealloc_reply_port();
                return msg_result;
        }

#if	TypeCheck
        msg_size = OutP->Head.msg_size;
        msg_simple = OutP->Head.msg_simple;
#endif	TypeCheck

        if (OutP->Head.msg_id != 1113)
                return MIG_REPLY_MISMATCH;

#if	TypeCheck
        if (((msg_size != 40) || (msg_simple != TRUE)) &&
            ((msg_size != sizeof(death_pill_t)) ||
             (msg_simple != TRUE) ||
             (OutP->RetCode == KERN_SUCCESS)))
                return MIG_TYPE_ERROR;
#endif	TypeCheck

#if	TypeCheck
#if	UseStaticMsgType
        if (* (int *) &OutP->RetCodeType != * (int *) &RetCodeCheck)
#else	UseStaticMsgType
        if ((OutP->RetCodeType.msg_type_inline != TRUE) ||
            (OutP->RetCodeType.msg_type_longform != FALSE) ||
            (OutP->RetCodeType.msg_type_name != MSG_TYPE_INTEGER_32) ||
            (OutP->RetCodeType.msg_type_number != 1) ||
            (OutP->RetCodeType.msg_type_size != 32))
#endif	UseStaticMsgType
                return MIG_TYPE_ERROR;
#endif	TypeCheck

        if (OutP->RetCode != KERN_SUCCESS)
                return OutP->RetCode;

#if	TypeCheck
#if	UseStaticMsgType
        if (* (int *) &OutP->byte_countType != * (int *) &byte_countCheck)
#else	UseStaticMsgType
        if ((OutP->byte_countType.msg_type_inline != TRUE) ||
            (OutP->byte_countType.msg_type_longform != FALSE) ||
            (OutP->byte_countType.msg_type_name != MSG_TYPE_INTEGER_32) ||
            (OutP->byte_countType.msg_type_number != 1) ||
            (OutP->byte_countType.msg_type_size != 32))
#endif	UseStaticMsgType
                return MIG_TYPE_ERROR;
#endif	TypeCheck

        *byte_count /* byte_count */ = /* *byte_count */ OutP->byte_count;

        return OutP->RetCode;
}

/* Routine DMACount */
mig_external kern_return_t ntsoundDMACount (
        port_t kern_serv_port,
        port_t owner_port,
        int *dma_count)
{
        typedef struct {
                msg_header_t Head;
                msg_type_t owner_portType;
                port_t owner_port;
        } Request;

        typedef struct {
                msg_header_t Head;
                msg_type_t RetCodeType;
                kern_return_t RetCode;
                msg_type_t dma_countType;
                int dma_count;
        } Reply;

        union {
                Request In;
                Reply Out;
        } Mess;

        register Request *InP = &Mess.In;
        register Reply *OutP = &Mess.Out;

⌨️ 快捷键说明

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