示例#1
0
        public bool ToggleMute(AudioSource source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            lock (this.syncRoot)
            {
                AudioSource actual;
                if (!Sources.TryGetValue(source.Id, out actual))
                {
                    return(false);
                }

                AudioSource newSource = new AudioSource(actual);
                newSource.IsMuted = !actual.IsMuted;

                OwnedSources.Remove(source.OwnerId, source);
                Sources[newSource.Id] = newSource;
                OwnedSources.Add(source.OwnerId, source);

                return(newSource.IsMuted);
            }
        }
示例#2
0
        public void Add(AudioSource source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            var nsource = new AudioSource(source);

            OwnedSources.Add(source.OwnerId, nsource);
            Sources.Add(source.Id, nsource);
        }
示例#3
0
        public void Update(AudioSource source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            lock (syncRoot)
            {
                AudioSource oldSource;
                if (!Sources.TryGetValue(source.Id, out oldSource))
                {
                    Sources[source.Id] = source;
                    OwnedSources.Add(source.OwnerId, source);
                }
                else
                {
                    source.CopyTo(oldSource);
                }
            }
        }
示例#4
0
        public AudioSource Create(string name, IUserInfo owner, AudioCodecArgs audioArgs)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }
            if (audioArgs == null)
            {
                throw new ArgumentNullException("audioArgs");
            }

            if (OwnedSources.Contains(owner.UserId))
            {
                if (OwnedSources[owner.UserId].Any(s => s.Name == name))
                {
                    throw new ArgumentException("Duplicate source name", "name");
                }
            }

            int id = 1;

            if (Sources.Keys.Any())
            {
                id = Sources.Keys.Max() + 1;
            }

            var source = new AudioSource(name, id, owner.UserId, audioArgs);

            Sources.Add(source.Id, source);
            OwnedSources.Add(owner.UserId, source);

            return(source);
        }