Coverage Report

Created: 2023-03-26 06:11

/src/vlc/src/playlist/item.c
Line
Count
Source (jump to first uncovered line)
1
/*****************************************************************************
2
 * playlist/item.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 "item.h"
26
27
#include <vlc_playlist.h>
28
#include <vlc_input_item.h>
29
30
vlc_playlist_item_t *
31
vlc_playlist_item_New(input_item_t *media, uint64_t id)
32
0
{
33
0
    vlc_playlist_item_t *item = malloc(sizeof(*item));
34
0
    if (unlikely(!item))
35
0
        return NULL;
36
37
0
    vlc_atomic_rc_init(&item->rc);
38
0
    item->id = id;
39
0
    item->media = media;
40
0
    input_item_Hold(media);
41
0
    return item;
42
0
}
43
44
void
45
vlc_playlist_item_Hold(vlc_playlist_item_t *item)
46
0
{
47
0
    vlc_atomic_rc_inc(&item->rc);
48
0
}
49
50
void
51
vlc_playlist_item_Release(vlc_playlist_item_t *item)
52
0
{
53
0
    if (vlc_atomic_rc_dec(&item->rc))
54
0
    {
55
0
        input_item_Release(item->media);
56
0
        free(item);
57
0
    }
58
0
}
59
60
input_item_t *
61
vlc_playlist_item_GetMedia(vlc_playlist_item_t *item)
62
0
{
63
0
    return item->media;
64
0
}
65
66
uint64_t
67
vlc_playlist_item_GetId(vlc_playlist_item_t *item)
68
0
{
69
0
    return item->id;
70
0
}