Coverage Report

Created: 2026-04-12 07:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vlc/src/playlist/playlist.c
Line
Count
Source
1
/*****************************************************************************
2
 * playlist/playlist.c
3
 *****************************************************************************
4
 * Copyright (C) 2018 VLC authors and VideoLAN
5
 *
6
 * This program is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU Lesser General Public License as published by
8
 * the Free Software Foundation; either version 2.1 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License
17
 * along with this program; if not, write to the Free Software Foundation,
18
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19
 *****************************************************************************/
20
21
#ifdef HAVE_CONFIG_H
22
# include "config.h"
23
#endif
24
25
#include "playlist.h"
26
27
#include <vlc_common.h>
28
#include <vlc_preparser.h>
29
30
#include "content.h"
31
#include "item.h"
32
#include "player.h"
33
34
vlc_playlist_t *
35
vlc_playlist_New(vlc_object_t *parent, enum vlc_playlist_preparsing rec,
36
                 unsigned preparse_max_threads, vlc_tick_t preparse_timeout)
37
0
{
38
0
    vlc_playlist_t *playlist = malloc(sizeof(*playlist));
39
0
    if (unlikely(!playlist))
40
0
        return NULL;
41
42
0
    if (rec != VLC_PLAYLIST_PREPARSING_DISABLED)
43
0
    {
44
0
        const struct vlc_preparser_cfg cfg = {
45
0
            .types = VLC_PREPARSER_TYPE_PARSE | VLC_PREPARSER_TYPE_FETCHMETA_LOCAL,
46
0
            .max_parser_threads = preparse_max_threads,
47
0
            .timeout = preparse_timeout,
48
#if !defined(HAVE_VLC_PROCESS_SPAWN)
49
        .external_process = false,
50
#else
51
0
        .external_process = true,
52
0
#endif
53
0
        };
54
0
        playlist->parser = vlc_preparser_New(parent, &cfg);
55
0
        if (playlist->parser == NULL)
56
0
        {
57
0
            free(playlist);
58
0
            return NULL;
59
0
        }
60
0
    }
61
0
    else
62
0
        playlist->parser = NULL;
63
0
    playlist->recursive = rec;
64
65
0
    bool ok = vlc_playlist_PlayerInit(playlist, parent);
66
0
    if (unlikely(!ok))
67
0
    {
68
0
        if (playlist->parser != NULL)
69
0
            vlc_preparser_Delete(playlist->parser);
70
0
        free(playlist);
71
0
        return NULL;
72
0
    }
73
0
    playlist->stopped_action = VLC_PLAYLIST_MEDIA_STOPPED_CONTINUE;
74
75
0
    vlc_vector_init(&playlist->items);
76
0
    randomizer_Init(&playlist->randomizer);
77
0
    playlist->current = -1;
78
0
    playlist->has_prev = false;
79
0
    playlist->has_next = false;
80
0
    vlc_list_init(&playlist->listeners);
81
0
    playlist->repeat = VLC_PLAYLIST_PLAYBACK_REPEAT_NONE;
82
0
    playlist->order = VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL;
83
0
    playlist->idgen = 0;
84
85
0
    return playlist;
86
0
}
87
88
void
89
vlc_playlist_Delete(vlc_playlist_t *playlist)
90
0
{
91
0
    assert(vlc_list_is_empty(&playlist->listeners));
92
93
0
    if (playlist->parser != NULL) {
94
0
        vlc_preparser_Delete(playlist->parser);
95
0
    }
96
97
0
    vlc_playlist_PlayerDestroy(playlist);
98
0
    randomizer_Destroy(&playlist->randomizer);
99
0
    vlc_playlist_ClearItems(playlist);
100
0
    free(playlist);
101
0
}
102
103
void
104
vlc_playlist_Lock(vlc_playlist_t *playlist)
105
0
{
106
0
    vlc_player_Lock(playlist->player);
107
0
}
108
109
void
110
vlc_playlist_Unlock(vlc_playlist_t *playlist)
111
0
{
112
0
    vlc_player_Unlock(playlist->player);
113
0
}