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

📄 cmdproc.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    /* Check for valid command program buffer */
    if (pMovieProgram == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcResumeMovieProgram: Invalid command program buffer!\n"));
        return (CMDPROC_NULL_POINTER);
    }

    /* Check for valid command program size */
    if (ulNumberOfCommands > MVOBJ_MAX_NAV_COMMANDS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcResumeMovieProgram: Invalid command program size!\n"));
        return (CMDPROC_FAILURE);
    }

    /* Check for valid starting command ID */
    if (ulCmdID >= ulNumberOfCommands)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcResumeMovieProgram: Invalid command ID!\n"));
        return (CMDPROC_FAILURE);
    }

    /* Check for valid status param pointer */
    if (pulStatusParam == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcProcessMovieProgram: Invalid status parameter pointer!\n"));
        return (CMDPROC_NULL_POINTER);
    }

    /*
     * If there is already a movie program active, do not allow this one to be processed.
     * The already active program must first be terminated.
     */
    if (hCmdProc->tState != CMDPROC_STATE_TERMINATED)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcResumeMovieProgram: Invalid state for processing a movie program!\n"));
    }
    else
    {
        NAVCMD_TYPE tCmdType;

        /* clear repeat flag */
        hCmdProc->fTitleRepeatOn = FALSE;

        /* Copy command program */
        memcpy( (void *)hCmdProc->MoviePrgm.aCommands, (void *)pMovieProgram, (ulNumberOfCommands * sizeof(MVOBJ_NAV_COMMAND) ) );

        /* Set command program length */
        hCmdProc->MoviePrgm.ulLength = ulNumberOfCommands;

        /* Get the command type of the current command ID */
        tCmdType = NavCmdGetCommandType(&hCmdProc->MoviePrgm.aCommands[ulCmdID]);

        /*
         * If the command that was suspended is a play playlist command, then resume
         * playback and go into the waiting state. Otherwise, load backup registers
         * and resume execution of the command program at the next command.
         */
        if ( (tCmdType == NAVCMD_PLAY_PL) || (tCmdType == NAVCMD_PLAY_PLATPI) ||
             (tCmdType == NAVCMD_PLAY_PLATMK) )
        {
            DBGPRINT(DBG_ON(DBG_TRACE), ("CmdProcResumeMovieProgram: Resuming playlist playback\n"));

            /* Entering playback control critical section */
            PlayCtrlTakeSemaphore();

            /* Tell playback control engine to resume playback */
            if (PlayCtrlResume() != PLAYCTRL_SUCCESS)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcResumeMovieProgram: Failed to resume playback!\n"));
            }
            else
            {
                /* Resume at the suspended command */
                hCmdProc->MoviePrgm.ulCurrentCmdID  = ulCmdID;

                /* Set the state of the command processor to waiting */
                hCmdProc->tState = CMDPROC_STATE_WAITING;

                /* Set return value to indicate that movie object has resumed playback */
                tStatus = CMDPROC_WAITING;
            }

            /* Leaving playback control critical section */
            PlayCtrlGiveSemaphore();
        }
        else
        {
            DBGPRINT(DBG_ON(DBG_TRACE), ("CmdProcResumeMovieProgram: Resuming command program execution\n"));

            /* Tell playback control engine to load backup PSR's */
            if (PlayCtrlLoadBackupPSR() != PLAYCTRL_SUCCESS)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcSuspendMovieProgram: Failed to backup PSR's!\n"));
                tStatus = CMDPROC_FAILURE;
            }

            /* Resume at the command after the suspended command */
            hCmdProc->MoviePrgm.ulCurrentCmdID  = ulCmdID + 1;

            /* Set the state of the command processor to processing */
            hCmdProc->tState                = CMDPROC_STATE_MOVIE_PROCESSING;
            hCmdProc->fTransitionPending    = FALSE;

            /* Resume execution of the command program */
            tStatus = CmdProcExecuteCommandProgram(&hCmdProc->MoviePrgm, pulStatusParam);
        }
    }

    return (tStatus);
}

/**
 * CmdProcLoadMovieProgram -- Load a movie command program, but do not execute any of the navigation commands.
 *
 * @param
 *      pvMovieProgram  -- Pointer to buffer containing command program
 *      ulLength        -- Number of command in the command program.
 *      ulCmdID         -- Command ID of where the current navigation command to be loaded
 *
 *
 * @retval
 *      CMDPROC_STATUS
 *
 * @remark
 *      ccoble: The current command must be a "play playlist" command in order for
 *              this load movie object to be valid.
 */
CMDPROC_STATUS  CmdProcLoadMovieProgram(MVOBJ_NAV_COMMAND *pMovieProgram, ULONG ulNumberOfCommands, ULONG ulCmdID)
{
    CMDPROC_STATUS tStatus = CMDPROC_FAILURE;

    if (hCmdProc == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcLoadMovieProgram: Command Processor not initialized!\n"));
        return (CMDPROC_FAILURE);
    }

    /* Check for valid command program buffer */
    if (pMovieProgram == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcLoadMovieProgram: Invalid command program buffer!\n"));
        return (CMDPROC_NULL_POINTER);
    }

    /* Check for valid command program size */
    if (ulNumberOfCommands > MVOBJ_MAX_NAV_COMMANDS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcLoadMovieProgram: Invalid command program size!\n"));
        return (CMDPROC_FAILURE);
    }

    /* Check for valid starting command ID */
    if (ulCmdID >= ulNumberOfCommands)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcLoadMovieProgram: Invalid command ID!\n"));
        return (CMDPROC_FAILURE);
    }

    /*
     * If there is already a movie program active, do not allow this one to be processed.
     * The already active program must first be terminated.
     */
    if (hCmdProc->tState != CMDPROC_STATE_TERMINATED)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcLoadMovieProgram: Invalid state for processing a movie program!\n"));
    }
    else
    {
        NAVCMD_TYPE  tCmdType;

        /* clear repeat flag */
        hCmdProc->fTitleRepeatOn = FALSE;

        /* Copy command program */
        memcpy( (void *)hCmdProc->MoviePrgm.aCommands, (void *)pMovieProgram, (ulNumberOfCommands * sizeof(MVOBJ_NAV_COMMAND) ) );

        /* Set command program length */
        hCmdProc->MoviePrgm.ulLength = ulNumberOfCommands;

        /* Get the command type of the current command ID */
        tCmdType = NavCmdGetCommandType(&hCmdProc->MoviePrgm.aCommands[ulCmdID]);

        if ( (tCmdType == NAVCMD_PLAY_PL) || (tCmdType == NAVCMD_PLAY_PLATPI) ||
             (tCmdType == NAVCMD_PLAY_PLATMK) )
        {
            /* Set current command id */
            hCmdProc->MoviePrgm.ulCurrentCmdID  = ulCmdID;

            /* Set the state of the command processor to waiting */
            hCmdProc->tState = CMDPROC_STATE_WAITING;

            /* Set return value to indicate that movie object has resumed playback */
            tStatus = CMDPROC_WAITING;
        }
        else
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcLoadMovieProgram: Invalid current command for loading a movie program!\n"));
        }
    }

    return (tStatus);
}

/**
 * CmdProcTerminateMovieProgram -- Terminate a movie command program.
 *
 * @param
 *      none.
 *
 * @retval
 *      CMDPROC_SUCCESS if successful
 *      CMDPROC_FAILURE if not successful
 */
CMDPROC_STATUS  CmdProcTerminateMovieProgram(void)
{
    CMDPROC_STATUS tStatus = CMDPROC_SUCCESS;

    if (hCmdProc == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcTerminateMovieProgram: Command Processor not initialized!\n"));
        return (CMDPROC_FAILURE);
    }

    /*
     * If a Movie program is active, terminate it.
     */
    if ( (hCmdProc->tState == CMDPROC_STATE_TERMINATED) || (hCmdProc->tState == CMDPROC_STATE_INVALID) )
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcTerminateMovieProgram: Invalid state to terminate!\n"));
        tStatus = CMDPROC_FAILURE;
    }
    else
    {
        /*
         * If command processor is waiting during playlist playback,
         * terminate the playlist.
         */
        if (hCmdProc->tState == CMDPROC_STATE_WAITING)
        {
            DBGPRINT(DBG_ON(DBG_TRACE), ("CmdProcTerminateMovieProgram: Terminating playlist playback\n"));

            /* Entering playback control critical section */
            PlayCtrlTakeSemaphore();

            /* Tell playback control engine to terminate playlist */
            if (PlayCtrlStop() != PLAYCTRL_SUCCESS)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcTerminateMovieProgram: Failed to terminate playlist!\n"));
                tStatus = CMDPROC_FAILURE;
            }

            /* Leaving playback control critical section */
            PlayCtrlGiveSemaphore();
        }

        /* Set the command processor state to terminated */
        hCmdProc->tState = CMDPROC_STATE_TERMINATED;
    }

    return (tStatus);
}

/**
 * CmdProcPlaybackComplete -- Notify the command processor that the playback of
 *                            a playlist is complete.  Upon notification, the command
 *                            processor will continue processing a Movie Object command
 *                            program.
 *
 * @param
 *      pulStatusParam  -- Pointer to parameter that is associated with the return status code
 *
 * @retval
 *      CMDPROC_STATUS
 */
CMDPROC_STATUS  CmdProcPlaybackComplete(ULONG *pulStatusParam)
{
    CMDPROC_STATUS tStatus = CMDPROC_FAILURE;

    if (hCmdProc == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcPlaybackComplete: Command Processor not initialized!\n"));
        return (CMDPROC_FAILURE);
    }

    /* Check for valid status param pointer */
    if (pulStatusParam == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcProcessMovieProgram: Invalid status parameter pointer!\n"));
        return (CMDPROC_NULL_POINTER);
    }

    /*
     * If command processor is not in the waiting state, this notification
     * is invalid.
     */
    if (hCmdProc->tState != CMDPROC_STATE_WAITING)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcPlaybackComplete: Invalid state for playback complete!\n"));
    }
    else
    {
        /*
         * If we are in repeat mode, then restart the movie object once the playlist completes.
         * If we are not in repeat mode, then increment the navigation command id to the next
         * command.
         */
        if (hCmdProc->fTitleRepeatOn == TRUE)
        {
            hCmdProc->MoviePrgm.ulCurrentCmdID = 0;
        }
        else
        {
            /* Increment the command ID of the Movie Object command program */
            hCmdProc->MoviePrgm.ulCurrentCmdID++;
        }

        /* Set the state of the command processor to processing */
        hCmdProc->tState                = CMDPROC_STATE_MOVIE_PROCESSING;
        hCmdProc->fTransitionPending    = FALSE;

        /* Continue execution of the command program */
        tStatus = CmdProcExecuteCommandProgram(&hCmdProc->MoviePrgm, pulStatusParam);
    }

    return (tStatus);
}

/**
 * CmdProcProcessButtonProgram --Process a button command program
 *
 * @param
 *      pvButtonProgram -- Pointer to buffer containing command program
 *      ulLength        -- Number of commands in the command program.
 *      pulStatusParam  -- Pointer to parameter that is associated with the return status code
 *
 * @retval
 *      CMDPROC_STATUS
 */
CMDPROC_STATUS  CmdProcProcessButtonProgram(MVOBJ_NAV_COMMAND *pButtonProgram, ULONG ulNumberOfCommands, ULONG *pulStatusParam)
{
    CMDPROC_STATUS tStatus = CMDPROC_FAILURE;

    if (hCmdProc == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("CmdProcProcessButtonProgram: Command Processor not initialized!\n"));
        return (CMDPROC_FAILURE);

⌨️ 快捷键说明

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