Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
89fb0644
Commit
89fb0644
authored
Mar 21, 2009
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid event spaming on epg changes.
parent
feab3bbb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
62 deletions
+97
-62
src/input/item.c
src/input/item.c
+97
-62
No files found.
src/input/item.c
View file @
89fb0644
...
@@ -401,43 +401,6 @@ bool input_item_IsArtFetched( input_item_t *p_item )
...
@@ -401,43 +401,6 @@ bool input_item_IsArtFetched( input_item_t *p_item )
return
b_fetched
;
return
b_fetched
;
}
}
/**
* Get a info item from a given category in a given input item.
*
* \param p_i The input item to get info from
* \param psz_cat String representing the category for the info
* \param psz_name String representing the name of the desired info
* \return A pointer to the string with the given info if found, or an
* empty string otherwise. The caller should free the returned
* pointer.
*/
char
*
input_item_GetInfo
(
input_item_t
*
p_i
,
const
char
*
psz_cat
,
const
char
*
psz_name
)
{
vlc_mutex_lock
(
&
p_i
->
lock
);
for
(
int
i
=
0
;
i
<
p_i
->
i_categories
;
i
++
)
{
const
info_category_t
*
p_cat
=
p_i
->
pp_categories
[
i
];
if
(
!
psz_cat
||
strcmp
(
p_cat
->
psz_name
,
psz_cat
)
)
continue
;
for
(
int
j
=
0
;
j
<
p_cat
->
i_infos
;
j
++
)
{
if
(
!
strcmp
(
p_cat
->
pp_infos
[
j
]
->
psz_name
,
psz_name
)
)
{
char
*
psz_ret
=
strdup
(
p_cat
->
pp_infos
[
j
]
->
psz_value
);
vlc_mutex_unlock
(
&
p_i
->
lock
);
return
psz_ret
;
}
}
}
vlc_mutex_unlock
(
&
p_i
->
lock
);
return
strdup
(
""
);
}
static
void
input_item_Destroy
(
gc_object_t
*
p_gc
)
static
void
input_item_Destroy
(
gc_object_t
*
p_gc
)
{
{
input_item_t
*
p_item
=
vlc_priv
(
p_gc
,
input_item_t
);
input_item_t
*
p_item
=
vlc_priv
(
p_gc
,
input_item_t
);
...
@@ -478,17 +441,53 @@ out:
...
@@ -478,17 +441,53 @@ out:
return
err
;
return
err
;
}
}
int
input_item_AddInfo
(
input_item_t
*
p_i
,
/**
const
char
*
psz_cat
,
* Get a info item from a given category in a given input item.
const
char
*
psz_name
,
*
const
char
*
psz_format
,
...
)
* \param p_i The input item to get info from
* \param psz_cat String representing the category for the info
* \param psz_name String representing the name of the desired info
* \return A pointer to the string with the given info if found, or an
* empty string otherwise. The caller should free the returned
* pointer.
*/
char
*
input_item_GetInfo
(
input_item_t
*
p_i
,
const
char
*
psz_cat
,
const
char
*
psz_name
)
{
vlc_mutex_lock
(
&
p_i
->
lock
);
for
(
int
i
=
0
;
i
<
p_i
->
i_categories
;
i
++
)
{
const
info_category_t
*
p_cat
=
p_i
->
pp_categories
[
i
];
if
(
!
psz_cat
||
strcmp
(
p_cat
->
psz_name
,
psz_cat
)
)
continue
;
for
(
int
j
=
0
;
j
<
p_cat
->
i_infos
;
j
++
)
{
if
(
!
strcmp
(
p_cat
->
pp_infos
[
j
]
->
psz_name
,
psz_name
)
)
{
char
*
psz_ret
=
strdup
(
p_cat
->
pp_infos
[
j
]
->
psz_value
);
vlc_mutex_unlock
(
&
p_i
->
lock
);
return
psz_ret
;
}
}
}
vlc_mutex_unlock
(
&
p_i
->
lock
);
return
strdup
(
""
);
}
static
int
InputItemVaAddInfo
(
input_item_t
*
p_i
,
const
char
*
psz_cat
,
const
char
*
psz_name
,
const
char
*
psz_format
,
va_list
args
)
{
{
va_list
args
;
int
i
;
int
i
;
info_t
*
p_info
=
NULL
;
info_t
*
p_info
=
NULL
;
info_category_t
*
p_cat
=
NULL
;
info_category_t
*
p_cat
=
NULL
;
vlc_
mutex_lock
(
&
p_i
->
lock
);
vlc_
assert_locked
(
&
p_i
->
lock
);
for
(
i
=
0
;
i
<
p_i
->
i_categories
;
i
++
)
for
(
i
=
0
;
i
<
p_i
->
i_categories
;
i
++
)
{
{
...
@@ -500,11 +499,9 @@ int input_item_AddInfo( input_item_t *p_i,
...
@@ -500,11 +499,9 @@ int input_item_AddInfo( input_item_t *p_i,
}
}
if
(
!
p_cat
)
if
(
!
p_cat
)
{
{
if
(
!
(
p_cat
=
(
info_category_t
*
)
malloc
(
sizeof
(
info_category_t
)
))
)
if
(
!
(
p_cat
=
malloc
(
sizeof
(
*
p_cat
)
))
)
{
vlc_mutex_unlock
(
&
p_i
->
lock
);
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
}
p_cat
->
psz_name
=
strdup
(
psz_cat
);
p_cat
->
psz_name
=
strdup
(
psz_cat
);
p_cat
->
i_infos
=
0
;
p_cat
->
i_infos
=
0
;
p_cat
->
pp_infos
=
0
;
p_cat
->
pp_infos
=
0
;
...
@@ -523,11 +520,9 @@ int input_item_AddInfo( input_item_t *p_i,
...
@@ -523,11 +520,9 @@ int input_item_AddInfo( input_item_t *p_i,
if
(
!
p_info
)
if
(
!
p_info
)
{
{
if
(
(
p_info
=
(
info_t
*
)
malloc
(
sizeof
(
info_t
)
)
)
==
NULL
)
if
(
(
p_info
=
malloc
(
sizeof
(
*
p_info
)
)
)
==
NULL
)
{
vlc_mutex_unlock
(
&
p_i
->
lock
);
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
}
INSERT_ELEM
(
p_cat
->
pp_infos
,
p_cat
->
i_infos
,
p_cat
->
i_infos
,
p_info
);
INSERT_ELEM
(
p_cat
->
pp_infos
,
p_cat
->
i_infos
,
p_cat
->
i_infos
,
p_info
);
p_info
->
psz_name
=
strdup
(
psz_name
);
p_info
->
psz_name
=
strdup
(
psz_name
);
}
}
...
@@ -536,22 +531,52 @@ int input_item_AddInfo( input_item_t *p_i,
...
@@ -536,22 +531,52 @@ int input_item_AddInfo( input_item_t *p_i,
free
(
p_info
->
psz_value
);
free
(
p_info
->
psz_value
);
}
}
va_start
(
args
,
psz_format
);
if
(
vasprintf
(
&
p_info
->
psz_value
,
psz_format
,
args
)
==
-
1
)
if
(
vasprintf
(
&
p_info
->
psz_value
,
psz_format
,
args
)
==
-
1
)
p_info
->
psz_value
=
NULL
;
p_info
->
psz_value
=
NULL
;
return
p_info
->
psz_value
?
VLC_SUCCESS
:
VLC_ENOMEM
;
}
static
int
InputItemAddInfo
(
input_item_t
*
p_i
,
const
char
*
psz_cat
,
const
char
*
psz_name
,
const
char
*
psz_format
,
...
)
{
va_list
args
;
va_start
(
args
,
psz_format
);
const
int
i_ret
=
InputItemVaAddInfo
(
p_i
,
psz_cat
,
psz_name
,
psz_format
,
args
);
va_end
(
args
);
return
i_ret
;
}
int
input_item_AddInfo
(
input_item_t
*
p_i
,
const
char
*
psz_cat
,
const
char
*
psz_name
,
const
char
*
psz_format
,
...
)
{
va_list
args
;
vlc_mutex_lock
(
&
p_i
->
lock
);
va_start
(
args
,
psz_format
);
const
int
i_ret
=
InputItemVaAddInfo
(
p_i
,
psz_cat
,
psz_name
,
psz_format
,
args
);
va_end
(
args
);
va_end
(
args
);
vlc_mutex_unlock
(
&
p_i
->
lock
);
vlc_mutex_unlock
(
&
p_i
->
lock
);
if
(
p_info
->
psz_value
)
if
(
!
i_ret
)
{
{
vlc_event_t
event
;
vlc_event_t
event
;
event
.
type
=
vlc_InputItemInfoChanged
;
event
.
type
=
vlc_InputItemInfoChanged
;
vlc_event_send
(
&
p_i
->
event_manager
,
&
event
);
vlc_event_send
(
&
p_i
->
event_manager
,
&
event
);
}
}
return
p_info
->
psz_value
?
VLC_SUCCESS
:
VLC_ENOMEM
;
return
i_ret
;
}
}
int
input_item_DelInfo
(
input_item_t
*
p_i
,
int
input_item_DelInfo
(
input_item_t
*
p_i
,
const
char
*
psz_cat
,
const
char
*
psz_cat
,
const
char
*
psz_name
)
const
char
*
psz_name
)
...
@@ -628,6 +653,7 @@ void input_item_SetEpg( input_item_t *p_item,
...
@@ -628,6 +653,7 @@ void input_item_SetEpg( input_item_t *p_item,
input_item_DelInfo
(
p_item
,
psz_epg
,
NULL
);
input_item_DelInfo
(
p_item
,
psz_epg
,
NULL
);
#ifdef HAVE_LOCALTIME_R
#ifdef HAVE_LOCALTIME_R
vlc_mutex_lock
(
&
p_item
->
lock
);
for
(
int
i
=
0
;
i
<
p_epg
->
i_event
;
i
++
)
for
(
int
i
=
0
;
i
<
p_epg
->
i_event
;
i
++
)
{
{
const
vlc_epg_event_t
*
p_evt
=
p_epg
->
pp_event
[
i
];
const
vlc_epg_event_t
*
p_evt
=
p_epg
->
pp_event
[
i
];
...
@@ -641,14 +667,23 @@ void input_item_SetEpg( input_item_t *p_item,
...
@@ -641,14 +667,23 @@ void input_item_SetEpg( input_item_t *p_item,
1900
+
tm_start
.
tm_year
,
1
+
tm_start
.
tm_mon
,
tm_start
.
tm_mday
,
1900
+
tm_start
.
tm_year
,
1
+
tm_start
.
tm_mon
,
tm_start
.
tm_mday
,
tm_start
.
tm_hour
,
tm_start
.
tm_min
,
tm_start
.
tm_sec
);
tm_start
.
tm_hour
,
tm_start
.
tm_min
,
tm_start
.
tm_sec
);
if
(
p_evt
->
psz_short_description
||
p_evt
->
psz_description
)
if
(
p_evt
->
psz_short_description
||
p_evt
->
psz_description
)
input_item_
AddInfo
(
p_item
,
psz_epg
,
psz_start
,
"%s (%2.2d:%2.2d) - %s"
,
InputItem
AddInfo
(
p_item
,
psz_epg
,
psz_start
,
"%s (%2.2d:%2.2d) - %s"
,
p_evt
->
psz_name
,
p_evt
->
psz_name
,
p_evt
->
i_duration
/
60
/
60
,
(
p_evt
->
i_duration
/
60
)
%
60
,
p_evt
->
i_duration
/
60
/
60
,
(
p_evt
->
i_duration
/
60
)
%
60
,
p_evt
->
psz_short_description
?
p_evt
->
psz_short_description
:
p_evt
->
psz_description
);
p_evt
->
psz_short_description
?
p_evt
->
psz_short_description
:
p_evt
->
psz_description
);
else
else
input_item_AddInfo
(
p_item
,
psz_epg
,
psz_start
,
"%s (%2.2d:%2.2d)"
,
InputItemAddInfo
(
p_item
,
psz_epg
,
psz_start
,
"%s (%2.2d:%2.2d)"
,
p_evt
->
psz_name
,
p_evt
->
psz_name
,
p_evt
->
i_duration
/
60
/
60
,
(
p_evt
->
i_duration
/
60
)
%
60
);
p_evt
->
i_duration
/
60
/
60
,
(
p_evt
->
i_duration
/
60
)
%
60
);
}
vlc_mutex_unlock
(
&
p_item
->
lock
);
if
(
p_epg
->
i_event
>
0
)
{
vlc_event_t
event
;
event
.
type
=
vlc_InputItemInfoChanged
;
vlc_event_send
(
&
p_item
->
event_manager
,
&
event
);
}
}
#endif
#endif
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment