Skip to content

a playback into the audio player is not served from the player cache - #2246

Closed
nickakt wants to merge 1 commit into
sipwise:masterfrom
nickakt:fix/player-cache-audio-player
Closed

nickakt wants to merge 1 commit into
sipwise:masterfrom
nickakt:fix/player-cache-audio-player

Conversation

@nickakt

@nickakt nickakt commented Nov 16, 2026 •

Copy link
Copy Markdown

With player-cache on, a file played to a media that has an audio player goes wrong in two ways.

The packets of a cache entry are encoded by the codec handler of the first player of the file. When that player's media has an audio player, codec_handler_make_media_player() makes the handler decode into packet_decoded_audio_player(), which finds the audio player through the packet's media_out. The packets of the decoder thread have none, so the frames are dropped and the entry stays empty: this player and every later player of the file in that codec are sent nothing.

An entry filled through another media is sent as it is, or played by the kernel, past the audio player, so the receiver gets it as a second stream beside the audio player's.

A player whose media has an active audio player now leaves the cache alone and plays the file as it does without the cache, decoding into the audio player. call_play_media_for_ml() starts the audio player before the player looks for its cache entry. A player can now read a file itself after it has read one from the cache, so media_player_play_start() puts back the reader that media_player_cached_reader_start() replaced.

auto-daemon-tests-inject.pl runs its playback case with the cache on, and plays the same file once more without the injection, before it and after it.

@rfuchs

rfuchs commented Nov 17, 2026

Copy link
Copy Markdown
Member

I'm not sure if this is worth fixing. The point of the player cache is to play RTP without having to decode/encode it. Combining that with the audio player pretty much defeats its purpose.

@rfuchs

rfuchs commented Nov 17, 2026

Copy link
Copy Markdown
Member

I think a better solution would be to simply skip engaging the cached media player if an audio player is in use, and fall back to the regular player.

…er cache

With player-cache on, a file played to a media that has an audio player goes
wrong in two ways.

The packets of a cache entry are encoded by the codec handler of the first
player of the file. When that player's media has an audio player,
codec_handler_make_media_player() makes the handler decode into
packet_decoded_audio_player(), which finds the audio player through the
packet's media_out. The packets of the decoder thread have none, so the
frames are dropped and the entry stays empty: this player and every later
player of the file in that codec are sent nothing.

An entry filled through another media is sent as it is, or played by the
kernel, past the audio player, so the receiver gets it as a second stream
beside the audio player's.

A player whose media has an active audio player now leaves the cache alone
and plays the file as it does without the cache, decoding into the audio
player. call_play_media_for_ml() starts the audio player before the player
looks for its cache entry. A player can now read a file itself after it has
read one from the cache, so media_player_play_start() puts back the reader
that media_player_cached_reader_start() replaced.
@nickakt
nickakt force-pushed the fix/player-cache-audio-player branch from 041315f to 6ac063c Compare November 17, 2026 14:06
@nickakt nickakt changed the title a cached playback goes into the audio player of its media a playback into the audio player is not served from the player cache Nov 17, 2026
@nickakt

nickakt commented Nov 17, 2026

Copy link
Copy Markdown
Author

Done, could you please take a look?

Comment thread daemon/media_player.c
if (media_player_cache_entry_init(mp, dst_pt, codec_set))
return true;

mp->run_func = media_player_read_packet; // an earlier playback may have read from the cache

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, with this here it makes sense to remove this setting from media_player_new

I'll handle it

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Richard!

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.

2 participants