[vlc-devel] commit: Implement reference counting in the libvlc logger ( Rémi Denis-Courmont )
git version control
git at videolan.org
Tue Feb 10 19:16:32 CET 2009
vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Tue Feb 10 20:15:20 2009 +0200| [92ed31deedfd5f79e9dc580de04ae699550a8883] | committer: Rémi Denis-Courmont
Implement reference counting in the libvlc logger
Now, this should work safely, although it requires heavy polling.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=92ed31deedfd5f79e9dc580de04ae699550a8883
---
src/control/log.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/control/log.c b/src/control/log.c
index 3a9f808..b87d5d8 100644
--- a/src/control/log.c
+++ b/src/control/log.c
@@ -53,7 +53,7 @@ static void handler( msg_cb_data_t *d, msg_item_t *p_item, unsigned i_drop )
if (d->count < VLC_MSG_QSIZE)
{
d->items[d->count++] = p_item;
- /* FIXME FIXME: yield the message item */
+ msg_Hold (p_item);
}
vlc_spin_unlock (&d->lock);
(void)i_drop;
@@ -117,6 +117,7 @@ void libvlc_log_close( libvlc_log_t *p_log, libvlc_exception_t *p_e )
assert( p_log->p_messages );
msg_Unsubscribe(p_log->p_messages);
libvlc_release( p_log->p_instance );
+ libvlc_log_clear( p_log, p_e );
vlc_spin_destroy( &p_log->data.lock );
free(p_log);
}
@@ -146,9 +147,13 @@ void libvlc_log_clear( libvlc_log_t *p_log, libvlc_exception_t *p_e )
if( p_log )
{
vlc_spin_lock (&p_log->data.lock);
+ msg_item_t *tab[p_log->data.count];
+ memcpy (tab, p_log->data.items, sizeof (tab));
p_log->data.count = 0;
- /* FIXME: release items */
vlc_spin_unlock (&p_log->data.lock);
+
+ for (unsigned i = 0; i < sizeof (tab) / sizeof (tab[0]); i++)
+ msg_Release (tab[i]);
}
else
RAISEVOID("Invalid log object!");
More information about the vlc-devel
mailing list