[PR #4199] [MERGED] Fix stream performance when opening/closing new streams. #9937

Closed
opened 2026-02-07 06:11:09 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/4199
Author: @ryanpetris
Created: 9/24/2020
Status: Merged
Merged: 10/13/2020
Merged by: @anthonylavado

Base: masterHead: livetv-locking


📝 Commits (1)

  • 4db5700 Don't take a lock if there's no intention to manipulate the list of open streams. Instead, use a ConcurrentDictionary so that, in those situations, thread-safe access to the dictionary is ensured.

📊 Changes

1 file changed (+17 additions, -34 deletions)

View changed files

📝 Emby.Server.Implementations/Library/MediaSourceManager.cs (+17 -34)

📄 Description

Due to locking, when starting a stream all other live streams are effectively paused. If a live stream takes a long time to start, other live streams will stop until the new live stream has started. This is undesired and existing streams should continue unimpeded.

Changes

  • Remove use of SemaphoreSlim in MediaResourceManager for functions that are merely inspecting _openStreams rather than adding/removing from it.
  • Since the _openStreams dictionary will now be accessed in parallel, use a ConcurrentDictionary to ensure thread safe access of the dictionary.

Issues
I don't know if there's an issue for this or not, however I have observed the previous behavior myself on version 10.6.4.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jellyfin/jellyfin/pull/4199 **Author:** [@ryanpetris](https://github.com/ryanpetris) **Created:** 9/24/2020 **Status:** ✅ Merged **Merged:** 10/13/2020 **Merged by:** [@anthonylavado](https://github.com/anthonylavado) **Base:** `master` ← **Head:** `livetv-locking` --- ### 📝 Commits (1) - [`4db5700`](https://github.com/jellyfin/jellyfin/commit/4db5700e18b98cb34784930707dc4ee2833865b6) Don't take a lock if there's no intention to manipulate the list of open streams. Instead, use a ConcurrentDictionary so that, in those situations, thread-safe access to the dictionary is ensured. ### 📊 Changes **1 file changed** (+17 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `Emby.Server.Implementations/Library/MediaSourceManager.cs` (+17 -34) </details> ### 📄 Description Due to locking, when starting a stream all other live streams are effectively paused. If a live stream takes a long time to start, other live streams will stop until the new live stream has started. This is undesired and existing streams should continue unimpeded. **Changes** * Remove use of SemaphoreSlim in MediaResourceManager for functions that are merely inspecting _openStreams rather than adding/removing from it. * Since the _openStreams dictionary will now be accessed in parallel, use a ConcurrentDictionary to ensure thread safe access of the dictionary. **Issues** I don't know if there's an issue for this or not, however I have observed the previous behavior myself on version 10.6.4. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-07 06:11:09 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#9937