And you should also check the return of input_item_GetDuration
Yes, I'm a firm believer in always checking the return value of method calls whenever appropriate or required.
However, I have just searched through all 159 MB of VLC source code (3,359 files in 315 folders) and the
input_item_GetDuration method is called many times, but the return value of this method is
*never* checked by any calling module.
Here are the results of my search:
Code: Select all
vlc-2.1.5\vlc-2.1.5\include\vlc_input_item.h :
VLC_API mtime_t input_item_GetDuration( input_item_t * p_i );
vlc-2.1.5\vlc-2.1.5\lib\media.c :
return from_mtime(input_item_GetDuration( p_md->p_input_item ));
vlc-2.1.5\vlc-2.1.5\modules\control\dbus\dbus.c :
dbus_int64_t i_mtime = input_item_GetDuration( p_input );
vlc-2.1.5\vlc-2.1.5\modules\gui\macosx\ControlsBar.m :
mtime_t dur = input_item_GetDuration(input_GetItem(p_input));
vlc-2.1.5\vlc-2.1.5\modules\gui\macosx\fspanel.m :
mtime_t dur = input_item_GetDuration(input_GetItem(p_input));
vlc-2.1.5\vlc-2.1.5\modules\gui\macosx\playlist.m :
mtime_t dur = input_item_GetDuration(p_item->p_input);
vlc-2.1.5\vlc-2.1.5\modules\gui\macosx\StringUtility.m :
mtime_t dur = input_item_GetDuration(input_GetItem(p_input));
vlc-2.1.5\vlc-2.1.5\modules\gui\qt4\adapters\chromaprint.cpp :
mtime_t t = input_item_GetDuration( p_item );
vlc-2.1.5\vlc-2.1.5\modules\gui\qt4\components\playlist\sorting.h :
i_duration = input_item_GetDuration( p_item ) / 1000000;
vlc-2.1.5\vlc-2.1.5\modules\lua\libs\input.c :
mtime_t duration = input_item_GetDuration( vlclua_input_item_get_internal( L ) );
vlc-2.1.5\vlc-2.1.5\modules\misc\audioscrobbler.c :
p_sys->p_current_song.i_l = input_item_GetDuration(p_item) / 1000000;
vlc-2.1.5\vlc-2.1.5\modules\misc\rtsp.c :
p_media->i_length = input_item_GetDuration( p_item );
vlc-2.1.5\vlc-2.1.5\modules\misc\playlist\html.c :
mtime_t i_duration = input_item_GetDuration( p_current->p_input );
vlc-2.1.5\vlc-2.1.5\modules\misc\playlist\m3u.c :
mtime_t i_duration = input_item_GetDuration( p_current->p_input );
vlc-2.1.5\vlc-2.1.5\modules\misc\playlist\xspf.c :
i_duration = input_item_GetDuration( p_item->p_input );
vlc-2.1.5\vlc-2.1.5\modules\stream_out\vod.c :
p_media->i_length = input_item_GetDuration( p_item );
vlc-2.1.5\vlc-2.1.5\src\libvlccore.sym :
input_item_GetDuration
vlc-2.1.5\vlc-2.1.5\src\input\input.c :
i_length = input_item_GetDuration( p_input->p->p_item );
vlc-2.1.5\vlc-2.1.5\src\input\item.c :
mtime_t input_item_GetDuration( input_item_t *p_i )
vlc-2.1.5\vlc-2.1.5\src\playlist\item.c :
mt_duration += input_item_GetDuration( p_input );
vlc-2.1.5\vlc-2.1.5\src\playlist\sort.c :
mtime_t time1 = input_item_GetDuration( first->p_input );
mtime_t time2 = input_item_GetDuration( second->p_input );
vlc-2.1.5\vlc-2.1.5\src\text\strings.c :
mtime_t i_duration = input_item_GetDuration( p_item );
mtime_t i_duration = input_item_GetDuration( p_item );
[b]Found 25 occurence(s) in 23 file(s).[/b]
I've looked at the code around each of these calls, and none of the methods check the return value of the
input_item_GetDuration method.
Also, just a suggestion .... some of the code in VLC could use more meaningful naming conventions (I have looked at a very small proportion of it so far). For example, this is in the
GetInputMeta method in the file
vlc-2.1.5\modules\control\dbus\dbus.c:
Code: Select all
/** The duration of the track can be expressed in second, milli-seconds and
µ-seconds */
dbus_int64_t i_mtime = input_item_GetDuration( p_input );
dbus_uint32_t i_time = i_mtime / 1000000;
dbus_int64_t i_length = i_mtime / 1000;
It's only a small module, and the comment is good and makes things clear, so it could be excused. However, far better names for these variables would be something like
i_usec_time instead of the confusing
i_mtime - which someone might misinterpret as "millisecond time" since it has an "m" in it, and
i_msec_time instead of the meaningless
i_length, and
i_sec_time instead of the meaningless
i_time.
Here's the code for the
input_item_GetDuration method in
vlc-2.1.5\src\playlist\item.c:
Code: Select all
mtime_t input_item_GetDuration( input_item_t *p_i )
{
vlc_mutex_lock( &p_i->lock );
mtime_t i_duration = p_i->i_duration;
vlc_mutex_unlock( &p_i->lock );
return i_duration;
}
So, there is no checking for errors / issues inside the method and therefore there is no return value to indicate an error may have occurred. This explains why no methods check the return value of the
input_item_GetDuration method.
OK, now on to getting this patch submitted ....