private int _sceAudioChReserve(Func<PspAudioChannel> ChannelGet, int SampleCount, PspAudio.FormatEnum Format)
{
if (!Enum.IsDefined(typeof(PspAudio.FormatEnum), Format))
{
throw (new SceKernelException(SceKernelErrors.ERROR_AUDIO_INVALID_FORMAT));
}
try
{
var Channel = ChannelGet();
if (!Channel.Available) throw (new InvalidChannelException());
Channel.Available = false;
Channel.SampleCount = SampleCount;
Channel.Format = Format;
Channel.Updated();
return Channel.Index;
}
catch (NoChannelsAvailableException)
{
throw (new SceKernelException(SceKernelErrors.ERROR_AUDIO_NO_CHANNELS_AVAILABLE));
}
catch (InvalidChannelException)
{
throw (new SceKernelException(SceKernelErrors.ERROR_AUDIO_INVALID_CHANNEL));
}
}