Commit d2e18151 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

media_item: Use an id based comparaison when possible

parent 49919f62
......@@ -82,7 +82,7 @@ video_controller_file_update( video_controller* ctrl, const media_item* p_media_
{
const media_item* p_media_item = ctrl->pf_get_media_item(p_item);
if (!strcmp( p_media_item->psz_path, p_new_media_item->psz_path))
if ( media_item_identical( p_media_item, p_new_media_item) )
{
ctrl->pf_set_media_item(p_item, p_new_media_item);
return true;
......
......@@ -54,6 +54,7 @@ fileToMediaItem( FilePtr file )
LOGE( "Failed to create media_item for file %s", file->mrl().c_str() );
return nullptr;
}
mi->i_id = file->id();
media_item_set_meta(mi, MEDIA_ITEM_META_TITLE, file->name().c_str());
mi->i_duration = file->duration();
......
......@@ -64,6 +64,14 @@ media_item_copy(const media_item* p_item)
return p_new;
}
bool
media_item_identical(const media_item* p_left, const media_item* p_right)
{
if ( p_left->i_id != 0 && p_right->i_id != 0 )
return p_left->i_id == p_right->i_id && p_left->i_type == p_right->i_type;
return strcmp( p_left->psz_path, p_right->psz_path ) == 0;
}
void
media_item_destroy(media_item *p_mi)
{
......
......@@ -61,6 +61,7 @@ typedef struct media_item {
int i_w, i_h; /* in pixels */
char* psz_snapshot; /* Path to a snapshot file */
uint32_t i_id; /* Opaque file type specific ID, provided by the media library */
} media_item;
media_item *
......@@ -72,6 +73,9 @@ media_item_copy(const media_item* p_item);
void
media_item_destroy(media_item *p_mi);
bool
media_item_identical(const media_item* p_left, const media_item* p_right);
int
media_item_set_meta(media_item *p_mi, enum MEDIA_ITEM_META i_meta, const char *psz_meta);
......
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