Skip to content

Commit

Permalink
upipe-hls: fix freeze on empty playlists
Browse files Browse the repository at this point in the history
  • Loading branch information
quarium authored and cmassiot committed Feb 19, 2024
1 parent 3a3effb commit 78da2b4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/upipe-hls/upipe_hls_playlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "upipe-modules/upipe_probe_uref.h"
#include "upipe-modules/upipe_setflowdef.h"

#include "upipe/ubase.h"
#include "upipe/upipe_helper_inner.h"
#include "upipe/upipe_helper_uprobe.h"
#include "upipe/upipe_helper_bin_output.h"
Expand Down Expand Up @@ -1234,9 +1235,9 @@ static int upipe_hls_playlist_set_flow_def(struct upipe *upipe,
}

const char *type;
if (!ubase_check(uref_m3u_playlist_flow_get_type(flow_def_dup, &type)) ||
if (!ubase_check(uref_m3u_playlist_flow_get_type(input_flow_def, &type)) ||
(strcasecmp(type, "VOD") && strcasecmp(type, "EVENT")) ||
!ubase_check(uref_m3u_playlist_flow_get_endlist(flow_def_dup))) {
!ubase_check(uref_m3u_playlist_flow_get_endlist(input_flow_def))) {
upipe_dbg(upipe, "playlist need to be reloaded");

uint64_t old_media_sequence, media_sequence;
Expand All @@ -1251,7 +1252,7 @@ static int upipe_hls_playlist_set_flow_def(struct upipe *upipe,

uint64_t target_duration;
if (ubase_check(uref_m3u_playlist_flow_get_target_duration(
flow_def_dup, &target_duration))) {
input_flow_def, &target_duration))) {
if (old_media_sequence == media_sequence) {
upipe_dbg(upipe, "playlist media sequence has not changed");
target_duration /= 2;
Expand All @@ -1269,6 +1270,14 @@ static int upipe_hls_playlist_set_flow_def(struct upipe *upipe,
}
}
upipe_hls_playlist_store_input_flow_def(upipe, flow_def_dup);

if (unlikely(upipe_hls_playlist->reloading)) {
upipe_dbg(upipe, "playlist end");
upipe_hls_playlist_throw_reloaded(upipe);
}

upipe_hls_playlist_flush(upipe);
upipe_hls_playlist->reloading = true;
return UBASE_ERR_NONE;
}

Expand Down
4 changes: 4 additions & 0 deletions lib/upipe-modules/upipe_m3u_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,10 @@ static void upipe_m3u_reader_output_all(struct upipe *upipe,

upipe_m3u_reader_output(upipe, uref, upump_p);
}

if (first)
upipe_m3u_reader_output(upipe, NULL, NULL);

upipe_release(upipe);
}

Expand Down
1 change: 1 addition & 0 deletions tests/upipe_m3u_reader_test_files/2.m3u.logs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flow definition: block.m3u.

0 comments on commit 78da2b4

Please sign in to comment.