MakeCurrent() публичный Метод

Makes the AudioContext current in the calling thread.
Only one AudioContext can be current in the application at any time, regardless of the number of threads.
/// Occurs if this function is called after the AudioContext has been disposed. /// /// Occurs when the AudioContext could not be made current. ///
public MakeCurrent ( ) : void
Результат void
Пример #1
0
        //int NextPlayingBuffer;
        //int numPLayedBuffer;
        /// <summary>
        /// Constructor for Sound class
        /// </summary>
        /// <param name="StartThread">Are we starting the sound thread?</param>
        public Sound(bool StartThread)
        {
            disposed = false;
            SoundList = new Dictionary<string, SoundType>();
            context = new AudioContext(); // default audio device
            lock (context)
            {
                context.MakeCurrent();
            }
            //XRamExtension XRam = new XRamExtension();

            /*SoundBuffers = AL.GenBuffers(4); // number of buffers
            SoundSource = AL.GenSource();
            SoundStreamSource = AL.GenSource();*/
            RunSoundThread = true;

            isPlaying = false;
            NowPlayingName = string.Empty;
            //NowPlayingBuffer = -1;
            NextPlayingName = string.Empty;
            //NextPlayingBuffer = -1;
            //numPLayedBuffer = 0; //??
            /*OpenTK.Vector3 v3 = new OpenTK.Vector3(1, 1, 1);
            AL.Source(AL.GenBuffer(), ALSource3f.Position, ref v3);*/

            //Debug.WriteLine(AL.Get(ALGetString.Version));

            tr = new System.Threading.Thread(new ThreadStart(PlayThread));
            if (StartThread)
            {
                RunThread();
            }
        }
Пример #2
0
 public void Init(Client tclient, ClientCVar cvar)
 {
     if (Context != null)
     {
         Context.Dispose();
     }
     TheClient = tclient;
     CVars = cvar;
     Context = new AudioContext(AudioContext.DefaultDevice, 0, 0, false, true);
     Context.MakeCurrent();
     try
     {
         if (Microphone != null)
         {
             Microphone.StopEcho();
         }
         Microphone = new MicrophoneHandler(this);
     }
     catch (Exception ex)
     {
         SysConsole.Output("Loading microphone handling", ex);
     }
     if (Effects != null)
     {
         foreach (SoundEffect sfx in Effects.Values)
         {
             sfx.Internal = -2;
         }
     }
     Effects = new Dictionary<string, SoundEffect>();
     PlayingNow = new List<ActiveSound>();
     Noise = LoadSound(new DataStream(Convert.FromBase64String(NoiseDefault.NoiseB64)), "noise");
 }
Пример #3
0
 public void MakeCurrent()
 {
     if (this.disposed)
     {
         throw new ObjectDisposedException(this.GetType().FullName);
     }
     AudioContext.MakeCurrent(this);
 }
Пример #4
0
        public static void Init()
        {
            ac = new AudioContext();
            ac.CheckErrors();
            ac.MakeCurrent();
            eax_sup = ac.SupportsExtension("EAX3.0");
            if (eax_sup)
                xram = new XRamExtension();

            mp3_sup = ac.SupportsExtension("AL_EXT_mp3");
            devices = Alc.GetString(IntPtr.Zero, AlcGetStringList.AllDevicesSpecifier);
        }
Пример #5
0
        public bool Init()
        {
            if (_Initialized)
                CloseAll();

            AC = new AudioContext();
            AC.MakeCurrent();
            

            closeproc = new CLOSEPROC(close_proc);
            _Initialized = true;

            _Streams = new List<AudioStreams>();
            return true;
        }
Пример #6
0
		/// <summary>
		/// Audio subsystem initialization<para/>
		/// Инициализация аудио подсистемы
		/// </summary>
		public static void Init() {

			// Creating context
			// Создание контекста
			Context = new AudioContext();
			Context.MakeCurrent();

			// Creating streaming sources list
			// Создание списка стримящихся источников
			Streaming = new List<StreamingAudio>();

			thread = new Thread(ThreadedUpdate);
			thread.IsBackground = true;
			thread.Priority = ThreadPriority.BelowNormal;
			//thread.Start();

			Dev.Console.Log("[AudioManager] Audio initialized");
		}
Пример #7
0
		public SDL2GameView (string title, int width, int height, bool fullscreen = false, bool vsync = true, 
		                     int x = SDL.SDL_WINDOWPOS_CENTERED, int y = SDL.SDL_WINDOWPOS_CENTERED) {
			_refCount++;
			_width = width;
			_height = height;

			_frameArgs = new FrameArgs();
			_frameArgs.Enqueue(new Start(new Vector2(_width, _height), 1.0f));
			_frameArgs.Enqueue(new Resize(new Vector2(_width, _height), 1.0f));
			_sdlEvents = new ConcurrentQueue<SDL.SDL_Event>();

			SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_MAJOR_VERSION, 2);
			SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_MINOR_VERSION, 1);
			SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_PROFILE_MASK, (int)SDL.SDL_GLprofile.SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
			SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_RED_SIZE, 8);
			SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_GREEN_SIZE, 8);
			SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_BLUE_SIZE, 8);
			SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_DEPTH_SIZE, 24);
			SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_MULTISAMPLEBUFFERS, 1);
			SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_MULTISAMPLESAMPLES, 4);

			_window = SDL.SDL_CreateWindow(
				title,
				x, y,
				width, height,
				SDL.SDL_WindowFlags.SDL_WINDOW_OPENGL
				| (fullscreen ? SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN : 0)
			);
			if (_window == IntPtr.Zero)
				throw new SDL2Exception();

			if (_alContext == null) {
				_alContext = new AudioContext();
				_alContext.MakeCurrent();
			}

			if(vsync)
				SDL.SDL_GL_SetSwapInterval(1);
			_windowId = SDL.SDL_GetWindowID(_window);
		}
Пример #8
0
        static AudioDevice()
        {
            // Create audio context (which create the ALCdevice and ALCcontext)
            _context = new AudioContext();
            _context.MakeCurrent();

            // Configure default state of listener
            _listenerVolume = 100f;
            _listenerPosition  = new Vector3(0f, 0f,  0f);
            _listenerDirection = new Vector3(0f, 0f, -1f);
            _listenerUpVector  = new Vector3(0f, 1f,  0f);


            // Apply the listener properties the user might have set
            float[] orientation = {_listenerDirection.X,
                                   _listenerDirection.Y,
                                   _listenerDirection.Z,
                                   _listenerUpVector.X,
                                   _listenerUpVector.Y,
                                   _listenerUpVector.Z};

            ALChecker.Check(() => AL.Listener(ALListenerf.Gain, _listenerVolume * 0.01f));
            ALChecker.Check(() => AL.Listener(ALListener3f.Position, _listenerPosition.X, _listenerPosition.Y, _listenerPosition.Z));
            ALChecker.Check(() => AL.Listener(ALListenerfv.Orientation, ref orientation));

            // Dispose Audio Device when exiting application
            AppDomain.CurrentDomain.ProcessExit += (s, e) => Free();
        }