summaryrefslogtreecommitdiff
path: root/avmedia
diff options
context:
space:
mode:
authorMinh Ngo <nlminhtl@gmail.com>2013-09-15 19:40:15 +0300
committerMinh Ngo <nlminhtl@gmail.com>2013-09-15 19:42:28 +0300
commite62092da17170faa93b61a3a2d7a7ce4b29cc1fc (patch)
tree4480caa8f6b4c3cf345ee278102a04e06ac30e9e /avmedia
parentfcc436bc62cfd8d14efe12391f5f58e7e1d7e594 (diff)
Avmedia/VLC: Error handling & Fixing a bug with a zero duration.
Change-Id: I45baeca91b9f5fc725164490b5880c9040acd679
Diffstat (limited to 'avmedia')
-rw-r--r--avmedia/source/vlc/wrapper/Common.cxx9
-rw-r--r--avmedia/source/vlc/wrapper/Common.hxx1
-rw-r--r--avmedia/source/vlc/wrapper/Media.cxx18
3 files changed, 26 insertions, 2 deletions
diff --git a/avmedia/source/vlc/wrapper/Common.cxx b/avmedia/source/vlc/wrapper/Common.cxx
index a85103845ae9..1ed5256f1755 100644
--- a/avmedia/source/vlc/wrapper/Common.cxx
+++ b/avmedia/source/vlc/wrapper/Common.cxx
@@ -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
diff --git a/avmedia/source/vlc/wrapper/Common.hxx b/avmedia/source/vlc/wrapper/Common.hxx
index edfb3386b46b..9cdffcc213a4 100644
--- a/avmedia/source/vlc/wrapper/Common.hxx
+++ b/avmedia/source/vlc/wrapper/Common.hxx
@@ -21,6 +21,7 @@ namespace wrapper
public:
static bool LoadSymbols();
static const char* Version();
+ static const char* LastErrorMessage();
};
}
}
diff --git a/avmedia/source/vlc/wrapper/Media.cxx b/avmedia/source/vlc/wrapper/Media.cxx
index d0538df1a860..c2627dec3d1b 100644
--- a/avmedia/source/vlc/wrapper/Media.cxx
+++ b/avmedia/source/vlc/wrapper/Media.cxx
@@ -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;
}