Пример #1
0
    public void OnAudioFrame(float[] frame)
    {
        bool headphonesConnected = egpvgetHeadphonesConnected(pPhotonVoiceAudioOutput);

        if (headphonesConnected)
        {
            float[] frameCopy = instanceFramePool.AcquireOrCreate();
            AudioUtil.Resample(frame, frameCopy, frameCopy.Length / 2 * channelCount, channelCount);
            float[] frameCopy2 = instanceFramePool.AcquireOrCreate();
            AudioUtil.ForceToStereo(frameCopy, frameCopy2, channelCount);
            instanceFramePool.Release(frameCopy);
            lock (locker)
            {
                Queue <float> instanceFrameBuf;
                frameBuf.TryGetValue(this, out instanceFrameBuf);
                if (instanceFrameBuf != null)
                {
                    for (int i = 0; i < frameCopy2.Length; ++i)
                    {
                        instanceFrameBuf.Enqueue(frameCopy2[i]);
                    }
                }
            }
            instanceFramePool.Release(frameCopy2);
        }
        else
        {
            this.speakersOut.OnAudioFrame(frame);
        }
    }