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); } }
public virtual void Clear() { lock (this.syncRoot) { Sources.Clear(); OwnedSources.Clear(); } }
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); }
public virtual bool Remove(AudioSource source) { if (source == null) { throw new ArgumentNullException("source"); } lock (this.syncRoot) { OwnedSources.Remove(source.OwnerId, source); return(Sources.Remove(source.Id)); } }
public bool IsSourceNameTaken(IUserInfo user, string sourceName) { if (user == null) { throw new ArgumentNullException("user"); } if (sourceName == null) { throw new ArgumentNullException("sourceName"); } return(OwnedSources.Contains(user.UserId) && (OwnedSources[user.UserId].Any(s => s.Name == sourceName))); }
public virtual bool Remove(IUserInfo user) { if (user == null) { throw new ArgumentNullException("user"); } lock (this.syncRoot) { foreach (AudioSource source in OwnedSources[user.UserId]) { Sources.Remove(source.Id); } return(OwnedSources.Remove(user.UserId)); } }
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); } } }
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); }