コード例 #1
0
    bool _Process()
    {
        //	if (!Grabber.IsUsingCustomOutput () )
        //		return false;
        //	if (!Grabber.IsLoaded() || !Grabber.IsPlaying() )
        //		return false;
        if (Grabber == null || !Grabber.IsStarted())
        {
            return(false);
        }

        AudioSamples p;

        if (Grabber.GrabFrame())
        {
            uint sz = Grabber.GetFrameSize();
            lock (_dataMutex) {
                p = CreatePacket();
            }
            if (p.samples == null || sz != p.samples.Length)
            {
                p.samples = new float[sz];
            }
            Grabber.CopyAudioFrame(p.samples);

            lock (_dataMutex) {
                _packets.Add(p);
                if (_packets.Count > 30)
                {
                    _packets.RemoveAt(0);
                }
                PacketsCount = _packets.Count;
            }
        }
        else
        {
            return(false);
        }

        return(true);
    }