Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from MusicPlayerDaemon:master #23

Merged
merged 35 commits into from
Jan 29, 2025

Conversation

pull[bot]
Copy link

@pull pull bot commented Jan 29, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

Summary by Sourcery

New Features:

  • Add support for initializing io_uring with parameters, setting maximum workers, and submitting requests while retrieving events.

MaxKellermann and others added 30 commits January 29, 2025 12:14
This eliminates the ScopeExchangeInputStreamHandler kludge.
If we only receive very little data from the InputStream, try a second
Read() call to get more data.  This works around tiny reads at input
buffer boundaries with the io_uring input plugin.  These tiny reads
are inefficient, and we can afford to wait one more low-level I/O
iteration to finish (but not more).

Closes #2186
…atorType&) to DereferenceIterator and TerminatedArray::iterator

It is required by std::distance and some std algos.
To only allow construction as part of TagPoolItem with its special var size allocator in TagPoolItem::Create.
Some streams send the same tags frequently, causing unnecessary player queue update events.
…am tag not changed.

Some streams send the same tags frequently, causeing unnecessary update
events.
For FFmpeg's DTS-WAV support, see code comment.

Closes #2158
These commands cannot possibly work with command lists because command
lists are supposed to be atomic, but suspended command execution
conflicts with that.

Closes #2167
release v0.23.17
Time was only in minutes before.
Seconds is more useful in analyzing the log for example
with issues of timeouts, and reponse times.
We don't want to get any completion events for "close".  It's
fire-and-forget.
@pull pull bot added the ⤵️ pull label Jan 29, 2025
@pull pull bot merged commit 2c7ca16 into CartoonFan:master Jan 29, 2025
Copy link

sourcery-ai bot commented Jan 29, 2025

Reviewer's Guide by Sourcery

This pull request introduces several enhancements and bug fixes, primarily focusing on improving I/O handling with io_uring, adding new features, and refactoring existing code for better performance and maintainability. It includes changes to the event loop, input streams, and tag handling, along with updates to the build process and documentation.

Sequence diagram for improved buffer handling in AsyncInputStream

sequenceDiagram
    participant Client
    participant AsyncInputStream
    participant Buffer
    Client->>AsyncInputStream: Read()
    AsyncInputStream->>Buffer: Read()
    alt buffer not empty
        Buffer-->>AsyncInputStream: data
        AsyncInputStream-->>Client: data
    else buffer empty
        Buffer-->>AsyncInputStream: empty
        AsyncInputStream->>Buffer: Clear()
        Note right of Buffer: Reset head and tail
        AsyncInputStream->>AsyncInputStream: Wait for more data
    end
Loading

Class diagram for Ring and Queue classes

classDiagram
    class Ring {
        -io_uring ring
        +Ring(entries: unsigned, flags: unsigned)
        +Ring(entries: unsigned, params: io_uring_params&)
        +~Ring()
        +SetMaxWorkers(values[2]: unsigned)
        +SetMaxWorkers(bounded: unsigned, unbounded: unsigned)
        +Submit()
        +SubmitAndGetEvents()
        +WaitCompletion()
        +PeekCompletion()
    }
    class Queue {
        -Ring ring
        +Queue(entries: unsigned, flags: unsigned)
        +Queue(entries: unsigned, params: io_uring_params&)
        +SetMaxWorkers(values[2]: unsigned)
        +SetMaxWorkers(bounded: unsigned, unbounded: unsigned)
        +SubmitAndGetEvents()
        +DispatchOneCompletion()
        +DispatchCompletions()
    }
    Queue --> Ring
Loading

Class diagram for Tag and TagItem classes

classDiagram
    class TagItem {
        +TagType type
        +char value[1]
        +bool operator==(const TagItem&)
        -TagItem()
    }
    class Tag {
        +double duration
        +bool has_playlist
        +unsigned num_items
        +bool operator==(const Tag&)
        +Clear()
    }
    Tag --> TagItem : contains
Loading

State diagram for EventLoop with Next events

stateDiagram-v2
    [*] --> Running
    Running --> ProcessingTimers: Handle Timers
    ProcessingTimers --> ProcessingEvents: Process Events
    ProcessingEvents --> ProcessingDeferred: Process Deferred
    ProcessingDeferred --> ProcessingIdle: Process Idle
    ProcessingIdle --> ProcessingNext: Process Next
    ProcessingNext --> WaitingForEvents: Wait
    WaitingForEvents --> Running: New Event
Loading

File-Level Changes

Change Details Files
Added a new constructor to the Ring class that accepts io_uring_params, and added methods to set max workers and submit and get events.
  • Added a constructor that takes io_uring_params.
  • Added SetMaxWorkers method to register max workers.
  • Added SubmitAndGetEvents method to submit and get events.
src/io/uring/Ring.cxx
src/io/uring/Ring.hxx
Added new constructors and methods to the Queue class to support io_uring_params and max workers.
  • Added a constructor that takes io_uring_params.
  • Added SetMaxWorkers method to register max workers.
src/io/uring/Queue.hxx
src/io/uring/Queue.cxx
Added a new packed big-endian signed 16-bit integer class.
  • Added PackedSignedBE16 class.
src/util/PackedBigEndian.hxx
Reordered decoder plugins to prioritize FFmpeg for DTS-WAV files.
  • Moved sndfile and audiofile decoder plugins below ffmpeg_decoder_plugin.
src/decoder/DecoderList.cxx
Added a next defer list to the event loop and modified the event loop to handle next events.
  • Added a next defer list.
  • Modified Run method to handle next events.
  • Added AddNext method to add events to the next list.
src/event/Loop.cxx
src/event/Loop.hxx
Added a check to prevent async commands from being used in command lists.
  • Added IsAsyncCommmand function.
  • Added a check to prevent async commands in command lists.
src/client/Process.cxx
Modified ServerSocket to use SocketDescriptor and get peer credentials.
  • Modified get_remote_uid to use SocketDescriptor.
  • Modified get_remote_uid to use GetPeerCredentials.
src/event/ServerSocket.cxx
Modified read_stream_art to read more data if the initial read is small.
  • Added a check to read more data if the initial read is small.
src/command/FileCommands.cxx
Added methods to get and set ready flags for PipeEvent.
  • Added GetScheduledFlags method.
  • Added GetReadyFlags method.
  • Added SetReadyFlags method.
src/event/PipeEvent.hxx
Added a method to get the uring data pointer from an operation.
  • Added GetUringData method.
src/io/uring/Operation.hxx
Modified LockUpdateSongTag to only update the tag if it has changed.
  • Added a check to only update the tag if it has changed.
src/player/Thread.cxx
Modified AsyncInputStream and ThreadInputStream to clear the buffer when it becomes empty.
  • Added a check to clear the buffer when it becomes empty.
src/input/AsyncInputStream.cxx
src/input/ThreadInputStream.cxx
Modified UringManager to take entries and flags as parameters.
  • Modified the constructor to take entries and flags as parameters.
src/event/UringManager.cxx
src/event/UringManager.hxx
Added an equality operator to TagItem.
  • Added operator== to TagItem.
src/tag/Item.hxx
Added ScheduleNext method to DeferEvent.
  • Added ScheduleNext method.
src/event/DeferEvent.cxx
src/event/DeferEvent.hxx
Added an equality operator to Tag.
  • Added operator== to Tag.
src/tag/Tag.cxx
src/tag/Tag.hxx
Modified VFmtToBuffer and FmtToBuffer to be constexpr.
  • Modified VFmtToBuffer to be constexpr.
  • Modified FmtToBuffer to be constexpr.
src/lib/fmt/ToBuffer.hxx
Added a next defer list to the EventLoop class.
  • Added a next defer list.
src/event/Loop.hxx
Modified log_date to include seconds.
  • Modified log_date to include seconds.
src/LogBackend.cxx
Modified UpdateStreamTag to check if the tag has changed before updating.
  • Added a check to see if the tag has changed before updating.
src/decoder/Bridge.cxx
Modified ProcFdPath and ProcFdinfoPath to be constexpr.
  • Modified ProcFdPath to be constexpr.
  • Modified ProcFdinfoPath to be constexpr.
src/io/linux/ProcPath.hxx
Added an operator- to DereferenceIterator and TerminatedArray::iterator.
  • Added operator- to DereferenceIterator.
  • Added operator- to TerminatedArray::iterator.
src/util/DereferenceIterator.hxx
src/util/TerminatedArray.hxx
Modified the build workflow to use gcc12 instead of gcc10.
  • Modified the build workflow to use gcc12 instead of gcc10.
.github/workflows/build.yml
Modified io_uring close to skip success completion events.
  • Modified io_uring close to skip success completion events.
src/io/uring/Close.cxx

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

guardrails bot commented Jan 29, 2025

⚠️ We detected 2 security issues in this pull request:

Hard-Coded Secrets (2)
Severity Details Docs
Medium Title: Hex High Entropy String
source_hash = a695629dae047055b37d50a0ff4776d1d45d0a4c842cf4ccee158441f55ff7ee
📚
Medium Title: Hex High Entropy String
patch_hash = e4ffff014e06b805fbb36cd1e911e90829dc1e07301a3aee53231f9048758558
📚

More info on how to fix Hard-Coded Secrets in General.


👉 Go to the dashboard for detailed results.

📥 Happy? Share your feedback with us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants