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
a39f80a6
Commit
a39f80a6
authored
Feb 20, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
audioscrobbler: keep track of active input object
Fix callback leak.
parent
1fa7df90
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
35 deletions
+27
-35
modules/misc/audioscrobbler.c
modules/misc/audioscrobbler.c
+27
-35
No files found.
modules/misc/audioscrobbler.c
View file @
a39f80a6
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
# include "config.h"
# include "config.h"
#endif
#endif
#include <assert.h>
#include <time.h>
#include <time.h>
#include <vlc_common.h>
#include <vlc_common.h>
...
@@ -74,6 +75,7 @@ struct intf_sys_t
...
@@ -74,6 +75,7 @@ struct intf_sys_t
audioscrobbler_song_t
p_queue
[
QUEUE_MAX
];
/**< songs not submitted yet*/
audioscrobbler_song_t
p_queue
[
QUEUE_MAX
];
/**< songs not submitted yet*/
int
i_songs
;
/**< number of songs */
int
i_songs
;
/**< number of songs */
input_thread_t
*
p_input
;
/**< current input thread */
vlc_mutex_t
lock
;
/**< p_sys mutex */
vlc_mutex_t
lock
;
/**< p_sys mutex */
vlc_cond_t
wait
;
/**< song to submit event */
vlc_cond_t
wait
;
/**< song to submit event */
vlc_thread_t
thread
;
/**< thread to submit song */
vlc_thread_t
thread
;
/**< thread to submit song */
...
@@ -97,9 +99,6 @@ struct intf_sys_t
...
@@ -97,9 +99,6 @@ struct intf_sys_t
bool
b_submit
;
/**< do we have to submit ? */
bool
b_submit
;
/**< do we have to submit ? */
bool
b_state_cb
;
/**< if we registered the
* "state" callback */
bool
b_meta_read
;
/**< if we read the song's
bool
b_meta_read
;
/**< if we read the song's
* metadata already */
* metadata already */
};
};
...
@@ -156,20 +155,15 @@ static void DeleteSong(audioscrobbler_song_t* p_song)
...
@@ -156,20 +155,15 @@ static void DeleteSong(audioscrobbler_song_t* p_song)
/*****************************************************************************
/*****************************************************************************
* ReadMetaData : Read meta data when parsed by vlc
* ReadMetaData : Read meta data when parsed by vlc
*****************************************************************************/
*****************************************************************************/
static
void
ReadMetaData
(
intf_thread_t
*
p_this
)
static
void
ReadMetaData
(
intf_thread_t
*
p_this
,
input_thread_t
*
p_input
)
{
{
intf_sys_t
*
p_sys
=
p_this
->
p_sys
;
intf_sys_t
*
p_sys
=
p_this
->
p_sys
;
input_thread_t
*
p_input
=
pl_CurrentInput
(
p_this
);
assert
(
p_input
!=
NULL
);
if
(
!
p_input
)
return
;
input_item_t
*
p_item
=
input_GetItem
(
p_input
);
input_item_t
*
p_item
=
input_GetItem
(
p_input
);
if
(
!
p_item
)
if
(
p_item
==
NULL
)
{
vlc_object_release
(
p_input
);
return
;
return
;
}
#define ALLOC_ITEM_META(a, b) do { \
#define ALLOC_ITEM_META(a, b) do { \
char *psz_meta = input_item_Get##b(p_item); \
char *psz_meta = input_item_Get##b(p_item); \
...
@@ -220,7 +214,6 @@ static void ReadMetaData(intf_thread_t *p_this)
...
@@ -220,7 +214,6 @@ static void ReadMetaData(intf_thread_t *p_this)
end:
end:
vlc_mutex_unlock
(
&
p_sys
->
lock
);
vlc_mutex_unlock
(
&
p_sys
->
lock
);
vlc_object_release
(
p_input
);
}
}
/*****************************************************************************
/*****************************************************************************
...
@@ -331,7 +324,7 @@ static int PlayingChange(vlc_object_t *p_this, const char *psz_var,
...
@@ -331,7 +324,7 @@ static int PlayingChange(vlc_object_t *p_this, const char *psz_var,
if
(
!
p_sys
->
b_meta_read
&&
state
>=
PLAYING_S
)
if
(
!
p_sys
->
b_meta_read
&&
state
>=
PLAYING_S
)
{
{
ReadMetaData
(
p_intf
);
ReadMetaData
(
p_intf
,
p_input
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
...
@@ -355,31 +348,33 @@ static int PlayingChange(vlc_object_t *p_this, const char *psz_var,
...
@@ -355,31 +348,33 @@ static int PlayingChange(vlc_object_t *p_this, const char *psz_var,
static
int
ItemChange
(
vlc_object_t
*
p_this
,
const
char
*
psz_var
,
static
int
ItemChange
(
vlc_object_t
*
p_this
,
const
char
*
psz_var
,
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_data
)
vlc_value_t
oldval
,
vlc_value_t
newval
,
void
*
p_data
)
{
{
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_data
;
intf_thread_t
*
p_intf
=
p_data
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
input_thread_t
*
p_input
=
newval
.
p_address
;
VLC_UNUSED
(
p_this
);
VLC_UNUSED
(
psz_var
);
VLC_UNUSED
(
p_this
);
VLC_UNUSED
(
psz_var
);
VLC_UNUSED
(
oldval
);
VLC_UNUSED
(
newval
);
VLC_UNUSED
(
oldval
);
p_sys
->
b_state_cb
=
false
;
p_sys
->
b_meta_read
=
false
;
p_sys
->
b_meta_read
=
false
;
p_sys
->
b_submit
=
false
;
p_sys
->
b_submit
=
false
;
input_thread_t
*
p_input
=
pl_CurrentInput
(
p_intf
);
if
(
p_sys
->
p_input
!=
NULL
)
if
(
!
p_input
||
p_input
->
b_dead
)
{
var_DelCallback
(
p_sys
->
p_input
,
"intf-event"
,
PlayingChange
,
p_intf
);
vlc_object_release
(
p_sys
->
p_input
);
p_sys
->
p_input
=
NULL
;
}
if
(
p_input
==
NULL
)
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
input_item_t
*
p_item
=
input_GetItem
(
p_input
);
input_item_t
*
p_item
=
input_GetItem
(
p_input
);
if
(
!
p_item
)
if
(
p_item
==
NULL
)
{
vlc_object_release
(
p_input
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
if
(
var_CountChoices
(
p_input
,
"video-es"
))
if
(
var_CountChoices
(
p_input
,
"video-es"
))
{
{
msg_Dbg
(
p_this
,
"Not an audio-only input, not submitting"
);
msg_Dbg
(
p_this
,
"Not an audio-only input, not submitting"
);
vlc_object_release
(
p_input
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
...
@@ -387,15 +382,14 @@ static int ItemChange(vlc_object_t *p_this, const char *psz_var,
...
@@ -387,15 +382,14 @@ static int ItemChange(vlc_object_t *p_this, const char *psz_var,
time
(
&
p_sys
->
p_current_song
.
date
);
/* to be sent to last.fm */
time
(
&
p_sys
->
p_current_song
.
date
);
/* to be sent to last.fm */
p_sys
->
p_current_song
.
i_start
=
mdate
();
/* only used locally */
p_sys
->
p_current_song
.
i_start
=
mdate
();
/* only used locally */
p_sys
->
p_input
=
vlc_object_hold
(
p_input
);
var_AddCallback
(
p_input
,
"intf-event"
,
PlayingChange
,
p_intf
);
var_AddCallback
(
p_input
,
"intf-event"
,
PlayingChange
,
p_intf
);
p_sys
->
b_state_cb
=
true
;
if
(
input_item_IsPreparsed
(
p_item
))
if
(
input_item_IsPreparsed
(
p_item
))
ReadMetaData
(
p_intf
);
ReadMetaData
(
p_intf
,
p_input
);
/* if the input item was not preparsed, we'll do it in PlayingChange()
/* if the input item was not preparsed, we'll do it in PlayingChange()
* callback, when "state" == PLAYING_S */
* callback, when "state" == PLAYING_S */
vlc_object_release
(
p_input
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
...
@@ -423,7 +417,7 @@ static int Open(vlc_object_t *p_this)
...
@@ -423,7 +417,7 @@ static int Open(vlc_object_t *p_this)
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
}
}
var_AddCallback
(
pl_Get
(
p_intf
),
"
activity
"
,
ItemChange
,
p_intf
);
var_AddCallback
(
pl_Get
(
p_intf
),
"
input-current
"
,
ItemChange
,
p_intf
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
...
@@ -436,17 +430,15 @@ static void Close(vlc_object_t *p_this)
...
@@ -436,17 +430,15 @@ static void Close(vlc_object_t *p_this)
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_this
;
intf_thread_t
*
p_intf
=
(
intf_thread_t
*
)
p_this
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
intf_sys_t
*
p_sys
=
p_intf
->
p_sys
;
var_DelCallback
(
pl_Get
(
p_intf
),
"activity"
,
ItemChange
,
p_intf
);
vlc_cancel
(
p_sys
->
thread
);
vlc_cancel
(
p_sys
->
thread
);
vlc_join
(
p_sys
->
thread
,
NULL
);
vlc_join
(
p_sys
->
thread
,
NULL
);
input_thread_t
*
p_input
=
pl_CurrentInput
(
p_intf
);
var_DelCallback
(
pl_Get
(
p_intf
),
"input-current"
,
ItemChange
,
p_intf
);
if
(
p_input
)
if
(
p_sys
->
p_input
!=
NULL
)
{
{
if
(
p_sys
->
b_state_cb
)
var_DelCallback
(
p_sys
->
p_input
,
"intf-event"
,
PlayingChange
,
p_intf
);
var_DelCallback
(
p_input
,
"intf-event"
,
PlayingChange
,
p_intf
);
vlc_object_release
(
p_sys
->
p_input
);
vlc_object_release
(
p_input
);
}
}
int
i
;
int
i
;
...
...
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