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

📄 soundscheduleratom.java

📁 JAVA3D矩陈的相关类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                if (status == SOUND_OFF ||                    status == SOUND_PAUSED)                    action = START_AUDIBLE;                else                    action = RESTART_AUDIBLE;                break;            case ON:                if (debugFlag)                    debugPrint(" calcActiveSchedAction: ON");                if (status == SOUND_OFF)                    // should NOT see this, but if we do...                    action = START_AUDIBLE;		else if (status == SOUND_SILENT)                     action = MAKE_AUDIBLE;		else // status == SOUND_AUDIBLE                    action = LEAVE_AUDIBLE;                break;            case PENDING_OFF:                setEnableState(OFF);                if (debugFlag)                    debugPrint("enable = " + enabled +                               "enabled set to OFF");                // fail thru            case OFF:		// QUESTION: Why would enable status ever be OFF yet		// status SOUND_AUDIBLE or _SILENT?	        if (status == SOUND_AUDIBLE) {                    if (sgSound.release) {                        if (debugFlag)                            debugPrint("enable = " + enabled +                                    ", AUDIBLE, released, " +                                    "action <- LEAVE_AUDIBLE");                        if (enabled == PENDING_OFF) {                            // re-calculate EndTime                            calculateEndTime();                        }                        action = LEAVE_AUDIBLE;                    }                    else {                        if (debugFlag)                            debugPrint("enable = " + enabled +                                    ", AUDIBLE, not released, "+                                    "action <- TURN_OFF");                        action = TURN_OFF;                    }                }		else if (status == SOUND_SILENT) {                    if (sgSound.release) {                        if (debugFlag)                            debugPrint("enable = " + enabled +                                    ", SILENT, released, " +                                    "action <- MAKE_AUDIBLE");                        // re-calculate EndTime                        calculateEndTime();                        action = MAKE_AUDIBLE;                    }                    else   {                        if (debugFlag)                            debugPrint("enable = " + enabled +                                    ", SILENT, not released, " +                                    "action <- TURN_OFF");                        action = TURN_OFF;                    }                }   		else { //  status == SOUND_OFF                     action = LEAVE_OFF;                }                break;         } // switch on enabled flag         // if sounds pause state is PENDING_PAUSE modify action to perform.         if (paused == PENDING_PAUSE) {             // if this pause state is set to PAUSE then assume the sound is             // already paused, so any incoming action that leave the state             // as it already is, leaves the sound paused.             if (debugFlag)                debugPrint("    PENDING_PAUSE");            switch (action) {                case MAKE_AUDIBLE:                case LEAVE_AUDIBLE:                case RESUME_AUDIBLE:                    action = PAUSE_AUDIBLE;                    break;                    case MAKE_SILENT:                case LEAVE_SILENT:                case RESUME_SILENT:                    action = PAUSE_SILENT;                    break;                    default:                    // don't change action for any other cases                    break;            }	 }         // if sounds pause state is PENDING_UNPAUSE modify action	 else if (paused == PENDING_UNPAUSE) {	     debugPrint("    PENDING_UNPAUSE");	     switch (action) {                // When restart (audible or silent) pause flag is checked and                // explicitly set in SoundScheduler                case MAKE_AUDIBLE:                case LEAVE_AUDIBLE:                case PAUSE_AUDIBLE:                    action = RESUME_AUDIBLE;                    break;                    case MAKE_SILENT:                case LEAVE_SILENT:                case PAUSE_SILENT:                    action = RESUME_SILENT;                    break;                    default:                    // don't change action for any other cases                    break;            }        }        return(action);    } // end of calcActiveSchedAction    /**     * calcInactiveSchedAction()     * Calculate Sound Scheduler action for Inactive sound     *     * A big switch testing various SoundRetained fields to determine     * what SoundScheduler action to perform when sound is inactive.     *     set sound active flag false     *     switch on enable value, to set pending scheduling action     *         depending on continuous and release flags and sound status      */    synchronized int calcInactiveSchedAction() {        int action  = DO_NOTHING;        SoundRetained sgSound = sound.sgSound;	// Sound is Inactive	// Generally, sound is OFF unless continuous flag true 	// then sound is silently playing if on.	activated = false;        switch (enabled) {            case PENDING_ON:                if (debugFlag)                debugPrint("    calcInactiveSchedAction: PENDING_ON ");                setEnableState(ON);                if (sgSound.continuous) {                    if (status == SOUND_OFF)                        action = START_SILENT;                    else // status == SOUND_AUDIBLE or SOUND_SILENT                        action = RESTART_SILENT;                }                else { // sound is not continuous                    if (status == SOUND_OFF)                        action = LEAVE_OFF;                    else // status == SOUND_SILENT || SOUND_AUDIBLE                        action = TURN_OFF;                }                break;            case ON:                if (debugFlag)                    debugPrint("    calcInactiveSchedActio: ON ");                if (sgSound.continuous) {                    if (status == SOUND_AUDIBLE)                        action = MAKE_SILENT;                    else if (status == SOUND_OFF)                        action = START_SILENT;                    else // status == SOUND_SILENT                        action = LEAVE_SILENT;                }                else { // sound is not continuous                         // nothing to do if already off                    if (status == SOUND_OFF)                         action = LEAVE_OFF;                    else // status == SOUND_SILENT or SOUND_AUDIBLE                         action = TURN_OFF;                }                break;            case PENDING_OFF:                setEnableState(OFF);                if (debugFlag)                    debugPrint("Enable = " + enabled +                                    "enabled set to OFF");                // fall thru            case OFF:                if (sgSound.release && sgSound.continuous) {                     if (enabled == PENDING_OFF) {                         // re-calculate EndTime                         calculateEndTime();                     }		     if (status == SOUND_AUDIBLE) {                         if (debugFlag)                             debugPrint("Enable = " + enabled +                                      ", AUDIBLE, released & continuous - " +                                      "action <- MAKE_SILENT");                         action = MAKE_SILENT;                     }		     else if (status == SOUND_SILENT) {                         if (debugFlag)                             debugPrint("Enable = " + enabled +                                     ", SILENT, released & continuous - " +                                     "action <- TURN_OFF");                         action = LEAVE_SILENT;                     }                     else {                         if (debugFlag)                             debugPrint("Enable = " + enabled +                                     ", already OFF, action <- LEAVE_OFF");                         action = LEAVE_OFF;                     }                }                 else  { // continuous and release flag not both true                     if (status == SOUND_OFF) {                         if (debugFlag)                             debugPrint("Enable = " + enabled +                                     ", already OFF, action <- LEAVE_OFF");                         action = LEAVE_OFF;                     }                     else {                         if (debugFlag)                             debugPrint("Enable = " + enabled +                                     ", not already OFF, action <- TURN_OFF");                          action = TURN_OFF;                     }                }                break;            default:                break;         } // switch         // if sounds pause state is PENDING_PAUSE modify action to perform.         if (paused == PENDING_PAUSE) {             // if this pause state is set to PAUSE then assume the sound is             // already paused, so any incoming action that leave the state             // as it already is, leaves the sound paused.             switch (action) {                case MAKE_SILENT:                case LEAVE_SILENT:                case RESUME_SILENT:                    action = PAUSE_SILENT;                    break;                default:                    // don't change action for any other cases                    break;            }        }        // if sounds pause state is PENDING_UNPAUSE modify action        else if (paused == PENDING_UNPAUSE) {            switch (action) {                case LEAVE_SILENT:                    action = RESUME_SILENT;                    break;                default:                    // don't change action for any other cases                    break;            }        }        return (action);    } // end of calcInactiveSchedAction// XXXX: isPLaying// XXXX: setLoadingState    // Debug print mechanism for Sound nodes    static final boolean debugFlag = false;    static final boolean internalErrors = false;    void debugPrint(String message) {        if (debugFlag) {            System.err.println(message);	}    }    /**     * Set bit(s) in soundDirty field     * @param binary flag denotes bits to set ON     */     void setAttribsDirtyFlag(int bitFlag) {        attribsDirty |= bitFlag;        if (debugFlag)            debugPrint("setAttribsDirtyFlag = " + bitFlag);        return ;    }        void setStateDirtyFlag(int bitFlag) {        stateDirty |= bitFlag;        if (debugFlag)            debugPrint("setStateDirtyFlag = " + bitFlag);        return ;    }         /**     * Clear sound's dirty flag bit value.     * @param binary flag denotes bits to set OFF     */     void clearAttribsDirtyFlag(int bitFlag) {        if (debugFlag)            debugPrint("clearAttribsDirtyFlag = " + bitFlag);        attribsDirty &= ~bitFlag;        return ;    }    void clearAttribsDirtyFlag() {        // clear all bits        if (debugFlag)            debugPrint("clearAttribsDirtyFlag = ALL");        attribsDirty = 0x0;        return ;    }    void clearStateDirtyFlag(int bitFlag) {        if (debugFlag)            debugPrint("clearStateDirtyFlag = " + bitFlag);        stateDirty &= ~bitFlag;        return ;    }    void clearStateDirtyFlag() {        if (debugFlag)            debugPrint("clearStateDirtyFlag = ALL");        stateDirty = 0x0;        return ;    }      /**     * Test sound's dirty flag bit(s)     * @param field denotes which bitmask to set into     * @param binary flag denotes bits to set Test     * @return true if bit(s) in bitFlag are set dirty (on)     */     boolean testDirtyFlag(int field, int bitFlag) {        if ((field & bitFlag) > 0)            return true;        else            return false;    }     /**     * Test sound's dirty flags for ANY bits on     * @return true if any bit in bitFlag is flipped on     */     boolean testDirtyFlags() {        if ((attribsDirty & 0xFFFF) > 0)            return true;        else if ((stateDirty & 0xFFFF) > 0)            return true;        else            return false;    }}

⌨️ 快捷键说明

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