2

I'm implementing the media handlers in Starboard, and I'm running into a situation where my client application in Cobalt doesn't buffer content aggressively enough. This results in it just idling with an empty buffer. What is the proper Starboard event to trigger when the platform's buffer is depleted? Should I be bubbling up an error somehow, or is there a signal I can give the client app to request more data?

Rick Viscomi
  • 8,180
  • 4
  • 35
  • 50

1 Answers1

5

When there is an underrun, the player implementation should handle it by pausing the video playback internally. To the end user the media playback is paused while the state of the media stack is still considered as "playing". This gives the player a chance to receive some video data before resuming playback again. In the reference implementation the PlayerWorker achieves this by pausing audio playback. As the media time and video playback are linked to the audio time, the whole player is paused.

When new data comes, the player should resume playback automatically. The player implementation may also choose to increase the amount of buffer required for preroll/resuming to avoid future underruns but this is usually not required.

As you mentioned that your app constantly runs into underruns. It is great to solve this for a better user experience even if underrun can be handled properly.

The first thing I'd check is that the test environment has enough network bandwidth for the requested video quality. If the app is targeted to a market with very poor network, consider buffer more media data.

If the app underruns when there is enough network bandwidth, it indicates that the media data is not processed fast enough. A good way is to check if kSbPlayerDecoderStateNeedsData is fired frequent enough and SbPlayerWriteSample() are called without much delay as this is the only place that moves media data across Starboard boundary.

xiaoming
  • 101
  • 2