当前位置: 首页>>代码示例>>C++>>正文


C++ nsRefPtr::Drain方法代码示例

本文整理汇总了C++中nsRefPtr::Drain方法的典型用法代码示例。如果您正苦于以下问题:C++ nsRefPtr::Drain方法的具体用法?C++ nsRefPtr::Drain怎么用?C++ nsRefPtr::Drain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nsRefPtr的用法示例。


在下文中一共展示了nsRefPtr::Drain方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: monitor


//.........这里部分代码省略.........
        if (NS_FAILED(rv)) {
          NS_WARNING("Seek failed");
          mPlaybackPosition = oldPosition;
          FirePositionChanged(PR_TRUE);
        }

        if (mState == STATE_SHUTDOWN) {
          break;
        }

        if (mState == STATE_SEEKING && mSeekTime == seekTime) {
          // Special case #1: if a seek was requested during metadata load,
          // mNextState will have been clobbered.  This can only happen when
          // we're instantiating a decoder to service a seek request after
          // playback has ended, so we know that the clobbered mNextState
          // was PAUSED.
          // Special case #2: if a seek is requested after the state machine
          // entered STATE_ENDED but before the user has seen the ended
          // event, playback has not ended as far as the user's
          // concerned--the state machine needs to return to the last
          // playback state.
          // Special case #3: if seeking to the end of the media, transition
          // directly into STATE_ENDED.
          State nextState = mNextState;
          if (nextState == STATE_SEEKING) {
            nextState = STATE_PAUSED;
          } else if (nextState == STATE_ENDED) {
            nextState = mPaused ? STATE_PAUSED : STATE_PLAYING;
          } else if (GetDuration() == seekTime) {
            nextState = STATE_ENDED;
          }
          ChangeState(nextState);
        }

        if (mState != STATE_SEEKING) {
          monitor.Exit();
          nsCOMPtr<nsIRunnable> stopEvent =
            NS_NewRunnableMethod(mDecoder, &nsWaveDecoder::SeekingStopped);
          NS_DispatchToMainThread(stopEvent, NS_DISPATCH_SYNC);
          monitor.Enter();
        }
      }
      break;

    case STATE_PAUSED:
      monitor.Wait();
      break;

    case STATE_ENDED:
      FirePositionChanged(PR_TRUE);

      if (mAudioStream) {
        monitor.Exit();
        mAudioStream->Drain();
        monitor.Enter();

        // After the drain call the audio stream is unusable. Close it so that
        // next time audio is used a new stream is created.
        CloseAudioStream();
      }

      mPlaybackEnded = PR_TRUE;

      if (mState == STATE_ENDED) {
        nsCOMPtr<nsIRunnable> event =
          NS_NewRunnableMethod(mDecoder, &nsWaveDecoder::PlaybackEnded);
        NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);

        // We've finished playback. Shutdown the state machine thread, 
        // in order to save memory on thread stacks, particuarly on Linux.
        event = new ShutdownThreadEvent(mDecoder->mPlaybackThread);
        NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
        mDecoder->mPlaybackThread = nsnull;
        return NS_OK;
      }
      break;

    case STATE_ERROR:
      {
        nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(mDecoder, &nsWaveDecoder::DecodeError);
        NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);

        monitor.Wait();

        if (mState != STATE_SHUTDOWN) {
          NS_WARNING("Invalid state transition");
          ChangeState(STATE_ERROR);
        }
      }
      break;

    case STATE_SHUTDOWN:
      mPlaybackEnded = PR_TRUE;
      CloseAudioStream();
      return NS_OK;
    }
  }

  return NS_OK;
}
开发者ID:h4ck3rm1k3,项目名称:v8monkey,代码行数:101,代码来源:nsWaveDecoder.cpp


注:本文中的nsRefPtr::Drain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。