/// <summary>
/// Call from derived classes to attempt to
/// get a valid stream from the streamComponent and
/// store it in _stream.
/// </summary>
protected void GetStream()
{
if (streamComponent == null)
{
streamComponent = gameObject.GetComponent(typeof(IGATAudioThreadStreamOwner));
}
if (streamIsTrack)
{
GATPlayer player = streamComponent as GATPlayer;
if (player == null)
{
throw new GATException("Cannot find GATPlayer to observe track stream. ");
}
if (streamIndex >= player.NbOfTracks)
{
throw new GATException("Track does not exist!");
}
GATTrack track = player.GetTrack(streamIndex);
_stream = track.GetAudioThreadStream(0);
}
else
{
IGATAudioThreadStreamOwner owner = streamComponent as IGATAudioThreadStreamOwner;
_stream = owner.GetAudioThreadStream(streamIndex);
if (owner == null)
{
throw new GATException("Component is not a stream!");
}
if (streamIndex >= owner.NbOfStreams)
{
throw new GATException("Requested stream index does not exist.");
}
}
}