Exemple #1
0
        private void InitBuffer(byte[] samples, int bufferId, int freq)
        {
            ByteBuffer data = sfxDataBuffer.Slice();

            data.Put(samples).Flip();
            AL10.AlBufferData(buffers.Get(bufferId), AL10.AL_FORMAT_MONO16, data, freq);
        }
Exemple #2
0
        public static void UpdateStream(ByteBuffer samples, int count, int format, int rate)
        {
            EnableStreaming();
            int         source     = channels[numChannels].sourceId;
            int         processed  = AL10.AlGetSourcei(source, AL10.AL_BUFFERS_PROCESSED);
            bool        playing    = (AL10.AlGetSourcei(source, AL10.AL_SOURCE_STATE) == AL10.AL_PLAYING);
            bool        interupted = !playing && streamQueue > 2;
            Int32Buffer buffer     = tmp;

            if (interupted)
            {
                UnqueueStreams();
                buffer.Put(0, buffers.Get(Sound.MAX_SFX + streamQueue++));
                Com.DPrintf("queue " + (streamQueue - 1) + '\\');
            }
            else if (processed < 2)
            {
                if (streamQueue >= Sound.STREAM_QUEUE)
                {
                    return;
                }
                buffer.Put(0, buffers.Get(Sound.MAX_SFX + streamQueue++));
                Com.DPrintf("queue " + (streamQueue - 1) + '\\');
            }
            else
            {
                AL10.AlSourceUnqueueBuffers(source, buffer);
            }

            samples.Position = 0;
            samples.Limit    = count;
            AL10.AlBufferData(buffer.Get(0), format, samples, rate);
            AL10.AlSourceQueueBuffers(source, buffer);
            if (streamQueue > 1 && !playing)
            {
                Com.DPrintf("start sound\\n");
                AL10.AlSourcePlay(source);
            }
        }