Beispiel #1
0
 public void SubmitBlankBuffer()
 {
     if (sourceVoice.State.BuffersQueued > 0)
     {
         sourceVoice.Discontinuity();
     }
 }
Beispiel #2
0
        // The general mixing thread function
        void RunAudio()
        {
            int    delay    = _samples * 1000 / _sampleRate;
            size_t data_len = (size_t)_bufferSize;
            byte * data;

            // Loop, filling the audio buffers
            while (!_shutdown)
            {
                // Fill the current buffer with sound
                if (_enabled)
                {
                    data = _hidden.nextbuf;
                }
                else
                {
                    /*
                     * if the device isn't enabled, we still write to the
                     * work_buffer, so the app's callback will fire with
                     * a regular frequency, in case they depend on that
                     * for timing or progress. They can use hotplug
                     * now to know if the device failed.
                     */
                    data = null;
                }

                if (data == null)
                {
                    data = _workbuf;
                }

                lock (_lock)
                {
                    if (_paused)
                    {
                        Native.SetMemory(data, _waveFormat.Silence, data_len);
                    }
                    else
                    {
                        BufferQueueDrainCallback(data, data_len);
                    }
                }

                if (data == _workbuf)
                {
                    // nothing to do; pause like we queued a buffer to play.
                    Native.Delay(delay);
                }
                else// writing directly to the device.
                {
                    // queue this buffer and wait for it to finish playing.
                    PlayDevice();
                    WaitDevice();
                }
            }

            _sourceVoice.Discontinuity();

            // Wait for the audio to drain.
            Native.Delay(delay * 2);
        }