/// <summary> /// /// </summary> protected void EnableInterrupt(Controller controller) { waitSyncRoot = null; slim = new ReaderWriterLockSlim(); disabledHandler = new InteractionDisabledHandler(DoCOMCallsDisabled); enabledHandler = new InteractionEnabledHandler(DoCOMCallsEnabled); // attach COM status handlers controller.DisabledEvent += disabledHandler; controller.EnabledEvent += enabledHandler; }
/// <summary> /// /// </summary> protected void DisableInterrupt(Controller controller) { // detach COM status handlers controller.DisabledEvent -= disabledHandler; controller.EnabledEvent -= enabledHandler; disabledHandler = null; enabledHandler = null; waitSyncRoot = null; slim.Dispose(); slim = null; }
/// <summary> /// Initialize the environment for an export or synchronize operation. /// </summary> private void Initialize() { Logger.WriteLine(base.name, String.Format("Export beginning, using encoder '{0}'", encoder.Name)); // attach COM status handlers disabledHandler = new InteractionDisabledHandler(DoCOMCallsDisabled); enabledHandler = new InteractionEnabledHandler(DoCOMCallsEnabled); controller.DisabledEvent += disabledHandler; controller.EnabledEvent += enabledHandler; // override current encoder if different than requested if (!encoder.IsEmpty) { if (!controller.CurrentEncoder.Name.Equals(encoder.Name)) { // remember user's preferred encoder saveEncoder = controller.CurrentEncoder; // set the temporary encoder for this playlist controller.CurrentEncoder = encoder; } } // ensure that 'location' exists before continuing. This will be more efficient // for cases that do not require further subdirectories but also sets the stage... if (!Directory.Exists(location)) { if (ScannerBase.isLive) { Directory.CreateDirectory(location); } } // if we do want subdirectories then ensure we can create them if (!createSubdirectories) { createSubdirectories = EnsureFolderCapability(); } // initialize and open the playlist writer if a playlist is requested if (ScannerBase.isLive && !playlistFormat.Equals(PlaylistFactory.NoFormat)) { writer = PlaylistFactory.CreateWriter( playlistFormat, location, exportPIDs.Name, createSubdirectories); writer.Open(); } // this ManualResetEvent is used to synchronize sequential processing of iTunes // tracks as they are encoded. iTunes encoding is an asynchronous procedure // however, iTunes does not allow concurrent encodings to occur. waitSyncRoot = null; reset = new ManualResetEvent(false); exports = new StringCollection(); }
//======================================================================================== // Constructor //======================================================================================== /// <summary> /// Initialize a new iTunesAppClass safe wrapper. /// </summary> public Controller() : base() { InitializeHost(); this.enabledHandler = null; this.disabledHandler = null; this.engine = LyricEngine.CreateEngine(); this.engine.LyricsUpdated += new TrackHandler(DoLyricsUpdated); this.engine.LyricsProgressReport += new LyricEngineProgress(DoLyricsProgressReport); if (this.track != null) { if (!this.track.HasLyrics && NetworkStatus.IsAvailable) { this.engine.RetrieveLyrics(this.track); } } this.librarian = Librarian.Create(this); this.timer = new Timer(1000); this.timer.Elapsed += new ElapsedEventHandler(DoUpdatePlayer); this.timer.Enabled = IsPlaying; }