/// <summary> /// Handler for Close command /// </summary> private void DoCloseMedia() { lock (_workQueueThreadLock) { HLSTrace.WriteLine("DoCloseMedia"); _bwHistory.Close(); _playback.AbortStreamDownloads(); _isWorkQueueThreadStarted = false; _workQueueThread = null; _workQueue = null; _audioBuffer = null; _videoBuffer = null; _playlist = null; _playback = null; _program = null; if (_demux != null) { _demux.Dispose(); _demux = null; } } }
/// <summary> /// Implements Dispose logic /// </summary> /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { lock (_workQueueThreadLock) { // If we have a work queue, post a close message to it if (_workQueueThread != null && _workQueue != null) { // No need to respond to anything because we are shutting down _workQueue.ClearAndEnqueue(new WorkQueueElement(WorkQueueElement.Command.Close, null)); // Wait for the thread to close _workQueueThread.Join(3000); // Dispose the work queue _workQueue.Dispose(); _workQueue = null; } } } _disposed = true; } }
/// <summary> /// Another form of constructor, accepts potentially preloaded playlist and program. /// </summary> /// <param name="playlist">Playlist to play, required.</param> /// <param name="program">Program to play, can be null.</param> /*public HLSMediaStreamSource(HLSPlaylist playlist, HLSProgram program) { if (playlist == null) throw new ArgumentNullException("playlist"); _playlist = playlist; _program = program; Construct(); }*/ /// <summary> /// Internal common constructor /// </summary> private void Construct() { _workQueue = new WorkQueue(); _workQueueThread = new Thread(WorkerThread); _workQueueThread.Name = "HLS MSS Worker Thread"; }