Kaydet (Commit) e62092da authored tarafından Minh Ngo's avatar Minh Ngo

Avmedia/VLC: Error handling & Fixing a bug with a zero duration.

Change-Id: I45baeca91b9f5fc725164490b5880c9040acd679
üst fcc436bc
......@@ -12,6 +12,7 @@
namespace
{
const char* ( *libvlc_get_version ) (void);
char * ( * libvlc_errmsg ) (void);
}
namespace avmedia
......@@ -24,7 +25,8 @@ bool Common::LoadSymbols()
{
ApiMap VLC_COMMON_API[] =
{
SYM_MAP( libvlc_get_version )
SYM_MAP( libvlc_get_version ),
SYM_MAP( libvlc_errmsg )
};
return InitApiMap( VLC_COMMON_API );
......@@ -34,6 +36,11 @@ const char* Common::Version()
{
return libvlc_get_version();
}
const char* Common::LastErrorMessage()
{
return libvlc_errmsg();
}
}
}
}
\ No newline at end of file
......@@ -21,6 +21,7 @@ namespace wrapper
public:
static bool LoadSymbols();
static const char* Version();
static const char* LastErrorMessage();
};
}
}
......
......@@ -12,6 +12,7 @@
#include "SymbolLoader.hxx"
#include "Instance.hxx"
#include "Types.hxx"
#include "Common.hxx"
struct libvlc_instance_t;
......@@ -27,6 +28,8 @@ namespace
void ( *libvlc_media_release ) ( libvlc_media_t *p_md );
void ( *libvlc_media_retain ) ( libvlc_media_t *p_md );
libvlc_time_t ( *libvlc_media_get_duration ) ( libvlc_media_t *p_md );
void ( *libvlc_media_parse ) ( libvlc_media_t *p_md );
int ( *libvlc_media_is_parsed ) ( libvlc_media_t *p_md );
libvlc_media_t* InitMedia( const rtl::OUString& url, Instance& instance )
{
......@@ -44,7 +47,9 @@ bool Media::LoadSymbols()
SYM_MAP( libvlc_media_new_path ),
SYM_MAP( libvlc_media_release ),
SYM_MAP( libvlc_media_retain ),
SYM_MAP( libvlc_media_get_duration )
SYM_MAP( libvlc_media_get_duration ),
SYM_MAP( libvlc_media_parse ),
SYM_MAP( libvlc_media_is_parsed )
};
return InitApiMap( VLC_MEDIA_API );
......@@ -71,9 +76,20 @@ const Media& Media::operator=( const Media& other )
int Media::getDuration() const
{
if ( !libvlc_media_is_parsed( mMedia ) )
libvlc_media_parse( mMedia );
const int duration = libvlc_media_get_duration( mMedia );
if (duration == -1)
{
SAL_WARN("avmedia", Common::LastErrorMessage());
return 0;
}
else if (duration == 0)
{
// A duration must be greater than 0
return 1;
}
return duration;
}
......
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