using System;
using System.IO;
using NVorbis.OpenTKSupport;

namespace SharpQuake
{
	internal class NullCDAudioController
	{
		public NullCDAudioController()
		{
			this._Remap = new byte[100];
		}

		public bool IsInitialized
		{
			get
			{
				return true;
			}
		}

		public bool IsEnabled
		{
			get
			{
				return true;
			}
			set
			{
			}
		}

		public bool IsPlaying
		{
			get
			{
				return this._isPlaying;
			}
		}

		public bool IsPaused
		{
			get
			{
				return this._isPaused;
			}
		}

		public bool IsValidCD
		{
			get
			{
				return false;
			}
		}

		public bool IsLooping
		{
			get
			{
				return this._isLooping;
			}
		}

		public byte[] Remap
		{
			get
			{
				return this._Remap;
			}
		}

		public byte MaxTrack
		{
			get
			{
				return 0;
			}
		}

		public byte CurrentTrack
		{
			get
			{
				return 0;
			}
		}

		public float Volume
		{
			get
			{
				return this._Volume;
			}
			set
			{
				this._Volume = value;
			}
		}

		public void Init()
		{
			this.streamer = new OggStreamer(441000, 10f, true);
			this._Volume = snd.BgmVolume;
			if (!Directory.Exists(string.Format("{0}/{1}/music/", qparam.globalbasedir, qparam.globalgameid)))
			{
				this._noAudio = true;
			}
		}

		public void Play(byte track, bool looping)
		{
			if (!this._noAudio)
			{
				this.trackid = track.ToString("00");
				this.trackpath = string.Format("{0}/{1}/music/track{2}.ogg", qparam.globalbasedir, qparam.globalgameid, this.trackid);
				try
				{
					this._isLooping = looping;
					if (this.oggStream != null)
					{
						this.oggStream.Stop();
					}
					this.oggStream = new OggStream(this.trackpath, 3);
					this.oggStream.IsLooped = looping;
					this.oggStream.Play();
					this.oggStream.Volume = this._Volume;
					this._noPlayback = false;
				}
				catch (Exception)
				{
					Console.WriteLine("Could not find or play {0}", this.trackpath);
					this._noPlayback = true;
				}
			}
		}

		public void Stop()
		{
			if (this.streamer == null)
			{
				return;
			}
			if (this._noAudio)
			{
				return;
			}
			this.oggStream.Stop();
		}

		public void Pause()
		{
			if (this.streamer == null)
			{
				return;
			}
			if (this._noAudio)
			{
				return;
			}
			this.oggStream.Pause();
		}

		public void Resume()
		{
			if (this.streamer == null)
			{
				return;
			}
			this.oggStream.Resume();
		}

		public void Shutdown()
		{
			if (this.streamer == null)
			{
				return;
			}
			if (this._noAudio)
			{
				return;
			}
			this.streamer.Dispose();
		}

		public void Update()
		{
			if (this.streamer == null)
			{
				return;
			}
			if (this._noAudio)
			{
				return;
			}
			if (this._noPlayback)
			{
				return;
			}
			this._Volume = snd.BgmVolume;
			this.oggStream.Volume = this._Volume;
		}

		public void ReloadDiskInfo()
		{
		}

		public void CloseDoor()
		{
		}

		public void Eject()
		{
		}

		private byte[] _Remap;

		private OggStream oggStream;

		private OggStreamer streamer;

		private bool _isLooping;

		private string trackid;

		private string trackpath;

		private bool _noAudio;

		private bool _noPlayback;

		private float _Volume;

		private bool _isPlaying;

		private bool _isPaused;

		private int channels;

		private int sampleRate;

		private TimeSpan totalTime;
	}
}
