Skip to content

refactor(decoder): DecoderService in a worker thread - #77

Merged
blocksmith314 merged 1 commit into
mainfrom
refactor/decoder-service
Nov 23, 2026
Merged

blocksmith314 merged 1 commit into
mainfrom
refactor/decoder-service

Conversation

@blocksmith314

Copy link
Copy Markdown
Owner

Summary

Foundation for #70/#9: the single FFmpegDecoder now lives in a worker thread behind DecoderService.

  • New DecoderService (QObject moved to a QThread) owns the decoder and exposes Open, Close, Seek, DecodeNext via QVariantMap results.
  • MainWindow no longer holds or calls FFmpegDecoder directly; it builds the raw IDR index, passes it to Open, and caches has_timestamps, frame rate, duration and the last seek stats.
  • Shutdown closes the decoder through the service and joins the thread.
  • Cache stays in MainWindow for this PR.

Behaviour

Unchanged: calls are still blocking (BlockingQueuedConnection), so the GUI waits for decodes exactly as before. The value is that decoder ownership is now single and off the GUI thread, so the next PR can make Seek/DecodeNext asynchronous and add preview signals without moving code again.

Verification

  • ctest: 75/75 pass (GUI/decoder behaviour unchanged).
  • grep player_decoder_: no direct usage left in MainWindow.
  • ./test/tools/tidy.sh decoderservice.cpp decoderservice.h mainwindow.cpp mainwindow.h: 0 issues.

Next

  1. Async RequestSeek(frame, generation) + PreviewReady / FrameReady signals.
  2. Move FrameCache into the service.
  3. Move playback/audio to the service (Move parsing, decoding and audio off the GUI thread #9).

Refs #70, #9

Introduce DecoderService, a QObject living in a QThread that owns the single
FFmpegDecoder. MainWindow now opens, seeks and decodes through blocking
invokes and caches the stream metadata (timestamps, frame rate, duration,
seek stats) instead of touching the decoder directly.

Behaviour is unchanged for now: calls are still synchronous from the GUI.
This is the foundation for asynchronous seeking, preview frames, moving the
frame cache into the service, and eventually the playback/audio loop (refs
#70, #9).
@blocksmith314
blocksmith314 merged commit f614e37 into main Nov 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant