Exemplo n.º 1
0
 internal void UnmapDiscVolume(string uuid)
 {
     lock (this) {
         if (sources.ContainsKey(uuid))
         {
             AudioCdSource source = sources[uuid];
             source.StopPlayingDisc();
             ServiceManager.SourceManager.RemoveSource(source);
             sources.Remove(uuid);
             Log.DebugFormat("Unmapping audio CD ({0})", uuid);
         }
     }
 }
Exemplo n.º 2
0
        private void HandleDeviceCommand(AudioCdSource source, DeviceCommandAction action)
        {
            if ((action & DeviceCommandAction.Activate) != 0)
            {
                ServiceManager.SourceManager.SetActiveSource(source);
            }

            if ((action & DeviceCommandAction.Play) != 0)
            {
                ServiceManager.PlaybackController.NextSource = source;
                if (!ServiceManager.PlayerEngine.IsPlaying())
                {
                    ServiceManager.PlaybackController.Next();
                }
            }
        }
Exemplo n.º 3
0
        private bool DeviceCommandMatchesSource(AudioCdSource source, DeviceCommand command)
        {
            if (command.DeviceId.StartsWith("cdda:"))
            {
                try {
                    Uri    uri = new Uri(command.DeviceId);
                    string match_device_node = String.Format("{0}{1}", uri.Host,
                                                             uri.AbsolutePath).TrimEnd('/', '\\');
                    string device_node = source.DiscModel.Volume.DeviceNode;
                    return(device_node.EndsWith(match_device_node));
                } catch {
                }
            }

            return(false);
        }
Exemplo n.º 4
0
        public AudioCdRipper(AudioCdSource source)
        {
            if (ripper_extension_node != null)
            {
                ripper = (IAudioCdRipper)ripper_extension_node.CreateInstance();
                ripper.TrackFinished += OnTrackFinished;
                ripper.Progress      += OnProgress;
                ripper.Error         += OnError;
            }
            else
            {
                throw new ApplicationException("No AudioCdRipper extension is installed");
            }

            this.source = source;
        }
Exemplo n.º 5
0
        private void ImportOrDuplicateDisc(bool import)
        {
            InterfaceActionService uia_service = ServiceManager.Get <InterfaceActionService> ();

            if (uia_service == null)
            {
                return;
            }

            AudioCdSource source = uia_service.SourceActions.ActionSource as AudioCdSource;

            if (source != null)
            {
                if (import)
                {
                    source.ImportDisc();
                }
                else
                {
                    source.DuplicateDisc();
                }
            }
        }
Exemplo n.º 6
0
        private void MapDiscVolume(IDiscVolume volume)
        {
            lock (this) {
                if (!sources.ContainsKey(volume.Uuid) && volume.HasAudio)
                {
                    AudioCdSource source = new AudioCdSource(this, new AudioCdDiscModel(volume));
                    sources.Add(volume.Uuid, source);
                    ServiceManager.SourceManager.AddSource(source);

                    // If there are any queued device commands, see if they are to be
                    // handled by this new volume (e.g. --device-activate-play=cdda://sr0/)
                    try {
                        if (unhandled_device_commands != null)
                        {
                            foreach (DeviceCommand command in unhandled_device_commands)
                            {
                                if (DeviceCommandMatchesSource(source, command))
                                {
                                    HandleDeviceCommand(source, command.Action);
                                    unhandled_device_commands.Remove(command);
                                    if (unhandled_device_commands.Count == 0)
                                    {
                                        unhandled_device_commands = null;
                                    }
                                    break;
                                }
                            }
                        }
                    } catch (Exception e) {
                        Log.Exception(e);
                    }

                    Log.DebugFormat("Mapping audio CD ({0})", volume.Uuid);
                }
            }
        }
Exemplo n.º 7
0
        private void HandleDeviceCommand (AudioCdSource source, DeviceCommandAction action)
        {
            if ((action & DeviceCommandAction.Activate) != 0) {
                ServiceManager.SourceManager.SetActiveSource (source);
            }

            if ((action & DeviceCommandAction.Play) != 0) {
                ServiceManager.PlaybackController.NextSource = source;
                if (!ServiceManager.PlayerEngine.IsPlaying ()) {
                    ServiceManager.PlaybackController.Next ();
                }
            }
        }
Exemplo n.º 8
0
        private bool DeviceCommandMatchesSource (AudioCdSource source, DeviceCommand command)
        {
            if (command.DeviceId.StartsWith ("cdda:")) {
                try {
                    Uri uri = new Uri (command.DeviceId);
                    string match_device_node = String.Format ("{0}{1}", uri.Host,
                        uri.AbsolutePath).TrimEnd ('/', '\\');
                    string device_node = source.DiscModel.Volume.DeviceNode;
                    return device_node.EndsWith (match_device_node);
                } catch {
                }
            }

            return false;
        }
Exemplo n.º 9
0
        private void MapDiscVolume (IDiscVolume volume)
        {
            lock (this) {
                if (!sources.ContainsKey (volume.Uuid) && volume.HasAudio) {
                    AudioCdSource source = new AudioCdSource (this, new AudioCdDiscModel (volume));
                    sources.Add (volume.Uuid, source);
                    ServiceManager.SourceManager.AddSource (source);

                    // If there are any queued device commands, see if they are to be
                    // handled by this new volume (e.g. --device-activate-play=cdda://sr0/)
                    try {
                        if (unhandled_device_commands != null) {
                            foreach (DeviceCommand command in unhandled_device_commands) {
                                if (DeviceCommandMatchesSource (source, command)) {
                                    HandleDeviceCommand (source, command.Action);
                                    unhandled_device_commands.Remove (command);
                                    if (unhandled_device_commands.Count == 0) {
                                        unhandled_device_commands = null;
                                    }
                                    break;
                                }
                            }
                        }
                    } catch (Exception e) {
                        Log.Exception (e);
                    }

                    Log.DebugFormat ("Mapping audio CD ({0})", volume.Uuid);
                }
            }
        }