Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • M medialibrary
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 71
    • Issues 71
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • VideoLANVideoLAN
  • medialibrary
  • Merge requests
  • !366

[RFC] Single instance

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Romain Vimont requested to merge rom1v/medialibrary:single_instance into master Feb 10, 2021
  • Overview 0
  • Commits 3
  • Pipelines 17
  • Changes 12

In VLC, loading the medialibrary module (Open()) is done during VLC start, unless --no-media-library is passed. The fact that the module is correctly opened determines if the medialib UI should be enabled.

However, the medialib initialization is lazy (Init()/initialize() is called the first time the medialib is needed, i.e. later).

To enforce a single medialib instance, we want to know immediately (on medialibrary module loading) if the single instance file lock can be acquired, to be able to enable/disable the medialib UI as needed. However, the file lock path depends on parameters passed to initialize() (ml.pid in the mlFolderPath), which is called later.

Therefore, split initialize() in two parts:

  1. configure(dbPath, mlFolderPath): set the db path and ml folder path
  2. initialize(mlCallback): initialize the database

The existing initialize(dbPath, mlFolderPath, mlCallback) is kept for convenience to do both configure(dbPath, mlFolderPath)+initialize(mlCallback) (and make the tests happy).

Then acquire the file lock on configure() (and return a bool to let the caller know if the database can be used).

Remarks:

  • the feature uses flock(), so something else is necessary for Windows.
  • the file lock is acquired during the configure() call, which is not obvious from the name.
  • the lock is ml.pid in the mlFolderPath directory, maybe its named should be derived from dbPath instead?

On VLC, this branch disables the medialib if the lock is already acquired): https://code.videolan.org/rom1v/vlc/-/commits/ml_single_instance

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: single_instance

VideoLAN code repository instance