Beispiel #1
0
        void IDualityBackend.Shutdown()
        {
            // Shut down the streaming thread
            if (streamWorker != null)
            {
                streamWorkerEnd = true;
                if (!streamWorker.Join(1000))
                {
                    streamWorker.Abort();
                }
                streamWorkerQueueEvent.Dispose();
                streamWorkerEnd        = false;
                streamWorkerQueueEvent = null;
                streamWorkerQueue      = null;
                streamWorker           = null;
            }

            if (masterTrack != null)
            {
                masterTrack.Stop();
                masterTrack.Dispose();
                masterTrack = null;
            }

            if (activeInstance == this)
            {
                activeInstance = null;
            }
        }
Beispiel #2
0
        void IDualityBackend.Shutdown()
        {
            // Shut down the streaming thread
            if (this.streamWorker != null)
            {
                this.streamWorkerEnd = true;
                if (!this.streamWorker.Join(1000))
                {
                    this.streamWorker.Abort();
                }
                this.streamWorkerQueueEvent.Dispose();
                this.streamWorkerEnd        = false;
                this.streamWorkerQueueEvent = null;
                this.streamWorkerQueue      = null;
                this.streamWorker           = null;
            }

            if (activeInstance == this)
            {
                activeInstance = null;
            }

            // Clear OpenAL source pool
            foreach (int alSource in this.sourcePool)
            {
                AL.DeleteSource(alSource);
            }

            // Shut down OpenAL context
            if (this.context != null)
            {
                this.context.Dispose();
                this.context = null;
            }
        }
Beispiel #3
0
        void IDualityBackend.Init()
        {
            App.Log("Available audio devices:" + Environment.NewLine + "{0}",
                    AudioContext.AvailableDevices.ToString(d => "  " + d + (d == AudioContext.DefaultDevice ? " (Default)" : ""), Environment.NewLine));

            // Create OpenAL audio context
            this.context = new AudioContext();
            App.Log("Current device: {0}", this.context.CurrentDevice);

            // Create extension interfaces
            try {
                this.extFx = new EffectsExtension();
                if (!this.extFx.IsInitialized)
                {
                    this.extFx = null;
                }
            } catch (Exception) {
                this.extFx = null;
            }

            activeInstance = this;

            // Log all OpenAL specs for diagnostic purposes
            LogOpenALSpecs();

            // Generate OpenAL source pool
            for (int i = 0; i < 256; i++)
            {
                int newSrc = AL.GenSource();
                if (!CheckOpenALErrors(true))
                {
                    this.sourcePool.Push(newSrc);
                }
                else
                {
                    break;
                }
            }
            this.availSources = this.sourcePool.Count;
            //Logs.Core.Write("{0} sources available", this.sourcePool.Count);

            // Set up the streaming thread
            this.streamWorkerEnd           = false;
            this.streamWorkerQueue         = new List <NativeAudioSource>();
            this.streamWorkerQueueEvent    = new AutoResetEvent(false);
            this.streamWorker              = new Thread(ThreadStreamFunc);
            this.streamWorker.IsBackground = true;
            this.streamWorker.Start();
        }
Beispiel #4
0
        void IDualityBackend.Init()
        {
            activeInstance = this;

            int bufferSize = AudioTrack.GetMinBufferSize(DefaultSampleRate, DefaultChannels, DefaultEncoding);

            masterTrack = new AudioTrack(Stream.Music, DefaultSampleRate, DefaultChannels, DefaultEncoding, bufferSize, AudioTrackMode.Stream);
            masterTrack.Play();

            bufferSizeSamples = bufferSize * sizeof(ushort);

            // Set up the streaming thread
            streamWorkerEnd           = false;
            streamWorkerQueue         = new RawList <NativeAudioSource>();
            streamWorkerQueueEvent    = new AutoResetEvent(false);
            streamWorker              = new Thread(ThreadStreamFunc);
            streamWorker.IsBackground = true;
            streamWorker.Start();
        }