Commit cc70e924 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

stats: remove the lock

The containing input item lock already must be held while reading or
writing statistics, so this is redundant.
parent 996f66c6
......@@ -389,8 +389,6 @@ VLC_API void libvlc_MetadataCancel( libvlc_int_t *, void * );
******************/
struct input_stats_t
{
vlc_mutex_t lock;
/* Input */
int64_t i_read_packets;
int64_t i_read_bytes;
......
......@@ -712,7 +712,6 @@ int libvlc_media_get_stats( libvlc_media_t *p_md,
return false;
}
vlc_mutex_lock( &p_itm_stats->lock );
p_stats->i_read_bytes = p_itm_stats->i_read_bytes;
p_stats->f_input_bitrate = p_itm_stats->f_input_bitrate;
......@@ -733,7 +732,6 @@ int libvlc_media_get_stats( libvlc_media_t *p_md,
p_stats->i_sent_packets = p_itm_stats->i_sent_packets;
p_stats->i_sent_bytes = p_itm_stats->i_sent_bytes;
p_stats->f_send_bitrate = p_itm_stats->f_send_bitrate;
vlc_mutex_unlock( &p_itm_stats->lock );
vlc_mutex_unlock( &item->lock );
return true;
}
......
......@@ -1715,7 +1715,6 @@ static int updateStatistics( intf_thread_t *p_intf, input_item_t *p_item )
if( !p_item ) return VLC_EGENERIC;
vlc_mutex_lock( &p_item->lock );
vlc_mutex_lock( &p_item->p_stats->lock );
msg_rc( "+----[ begin of statistical info ]" );
/* Input */
......@@ -1761,7 +1760,6 @@ static int updateStatistics( intf_thread_t *p_intf, input_item_t *p_item )
(float)(p_item->p_stats->f_send_bitrate*8)*1000 );
msg_rc("|");
msg_rc( "+----[ end of statistical info ]" );
vlc_mutex_unlock( &p_item->p_stats->lock );
vlc_mutex_unlock( &p_item->lock );
return VLC_SUCCESS;
......
......@@ -276,8 +276,6 @@ FREENULL( psz_##foo );
if (![self.window isVisible])
return;
vlc_mutex_lock(&p_item->p_stats->lock);
/* input */
[_readBytesTextField setStringValue: [NSString stringWithFormat:
@"%8.0f KiB", (float)(p_item->p_stats->i_read_bytes)/1024]];
......@@ -304,8 +302,6 @@ FREENULL( psz_##foo );
[_audioDecodedTextField setIntValue: p_item->p_stats->i_decoded_audio];
[_playedAudioBuffersTextField setIntValue: p_item->p_stats->i_played_abuffers];
[_lostAudioBuffersTextField setIntValue: p_item->p_stats->i_lost_abuffers];
vlc_mutex_unlock(&p_item->p_stats->lock);
}
- (void)updateStreamsList
......
......@@ -796,7 +796,6 @@ static int DrawStats(intf_thread_t *intf, input_thread_t *p_input)
vlc_mutex_lock(&item->lock);
p_stats = item->p_stats;
vlc_mutex_lock(&p_stats->lock);
for (int i = 0; i < item->i_es ; i++) {
i_audio += (item->es[i]->i_cat == AUDIO_ES);
......@@ -851,7 +850,6 @@ static int DrawStats(intf_thread_t *intf, input_thread_t *p_input)
p_stats->f_send_bitrate*8000);
if (sys->color) color_set(C_DEFAULT, NULL);
vlc_mutex_unlock(&p_stats->lock);
vlc_mutex_unlock(&item->lock);
return l;
......
......@@ -651,8 +651,6 @@ void InputStatsPanel::update( input_item_t *p_item )
if( p_item->p_stats == NULL )
return;
vlc_mutex_lock( &p_item->p_stats->lock );
#define UPDATE_INT( widget, calc... ) \
{ widget->setText( 1, QString::number( (qulonglong)calc ) ); }
......@@ -685,8 +683,6 @@ void InputStatsPanel::update( input_item_t *p_item )
#undef UPDATE_INT
#undef UPDATE_FLOAT
vlc_mutex_unlock(& p_item->p_stats->lock );
}
void InputStatsPanel::clear()
......
......@@ -198,7 +198,6 @@ static int vlclua_input_item_stats( lua_State *L )
input_stats_t *p_stats = p_item->p_stats;
if( p_stats != NULL )
{
vlc_mutex_lock( &p_item->p_stats->lock );
#define STATS_INT( n ) lua_pushinteger( L, p_item->p_stats->i_ ## n ); \
lua_setfield( L, -2, #n );
#define STATS_FLOAT( n ) lua_pushnumber( L, p_item->p_stats->f_ ## n ); \
......@@ -224,7 +223,6 @@ static int vlclua_input_item_stats( lua_State *L )
STATS_INT( lost_abuffers )
#undef STATS_INT
#undef STATS_FLOAT
vlc_mutex_unlock( &p_item->p_stats->lock );
}
vlc_mutex_unlock( &p_item->lock );
return 1;
......
......@@ -344,7 +344,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
vlc_mutex_lock( &p_item->lock );
if( !p_item->p_stats )
p_item->p_stats = stats_NewInputStats( p_input );
p_item->p_stats = calloc( 1, sizeof(*p_item->p_stats) );
/* setup the preparse depth of the item
* if we are preparsing, use the i_preparse_depth of the parent item */
......@@ -669,9 +669,10 @@ static void MainLoopStatistics( input_thread_t *p_input )
/* update current bookmark */
vlc_mutex_lock( &input_priv(p_input)->p_item->lock );
input_priv(p_input)->bookmark.i_time_offset = i_time;
vlc_mutex_unlock( &input_priv(p_input)->p_item->lock );
stats_ComputeInputStats( p_input, input_priv(p_input)->p_item->p_stats );
vlc_mutex_unlock( &input_priv(p_input)->p_item->lock );
input_SendEventStatistics( p_input );
}
......@@ -1479,8 +1480,11 @@ do { \
if( libvlc_stats( p_input ) )
{
input_item_t *item = priv->p_item;
/* make sure we are up to date */
stats_ComputeInputStats( p_input, priv->p_item->p_stats );
vlc_mutex_lock( &item->lock );
stats_ComputeInputStats( p_input, item->p_stats );
vlc_mutex_unlock( &item->lock );
CL_CO( input_bitrate );
CL_CO( demux_bitrate );
}
......
......@@ -53,10 +53,6 @@ void input_item_SetEpgOffline( input_item_t * );
input_thread_t *input_CreatePreparser(vlc_object_t *obj, input_item_t *item)
VLC_USED;
/* misc/stats.c
* FIXME it should NOT be defined here or not coded in misc/stats.c */
input_stats_t *stats_NewInputStats( input_thread_t *p_input );
/**
* This function deletes the current sout in the resources.
*/
......
......@@ -486,11 +486,7 @@ void input_item_Release( input_item_t *p_item )
free( p_item->psz_name );
free( p_item->psz_uri );
if( p_item->p_stats != NULL )
{
vlc_mutex_destroy( &p_item->p_stats->lock );
free( p_item->p_stats );
}
free( p_item->p_stats );
if( p_item->p_meta != NULL )
vlc_meta_Delete( p_item->p_meta );
......
......@@ -67,18 +67,6 @@ static inline float stats_GetRate(const counter_t *counter)
/ (float)(counter->pp_samples[0]->date - counter->pp_samples[1]->date);
}
input_stats_t *stats_NewInputStats( input_thread_t *p_input )
{
(void)p_input;
input_stats_t *p_stats = calloc( 1, sizeof(input_stats_t) );
if( !p_stats )
return NULL;
vlc_mutex_init( &p_stats->lock );
return p_stats;
}
void stats_ComputeInputStats(input_thread_t *input, input_stats_t *st)
{
input_thread_private_t *priv = input_priv(input);
......@@ -87,7 +75,6 @@ void stats_ComputeInputStats(input_thread_t *input, input_stats_t *st)
return;
vlc_mutex_lock(&priv->counters.counters_lock);
vlc_mutex_lock(&st->lock);
/* Input */
st->i_read_packets = priv->counters.read_packets;
......@@ -118,7 +105,6 @@ void stats_ComputeInputStats(input_thread_t *input, input_stats_t *st)
st->i_displayed_pictures = priv->counters.displayed_pictures;
st->i_lost_pictures = priv->counters.lost_pictures;
vlc_mutex_unlock(&st->lock);
vlc_mutex_unlock(&priv->counters.counters_lock);
}
......
......@@ -593,12 +593,8 @@ char *vlc_strfinput(input_thread_t *input, const char *s)
{
vlc_mutex_lock(&item->lock);
if (item->p_stats != NULL)
{
vlc_mutex_lock(&item->p_stats->lock);
vlc_memstream_printf(stream, "%"PRIi64,
item->p_stats->i_displayed_pictures);
vlc_mutex_unlock(&item->p_stats->lock);
}
else if (!b_empty_if_na)
vlc_memstream_putc(stream, '-');
vlc_mutex_unlock(&item->lock);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment