Commit 396acde3 authored by Rémi Duraffort's avatar Rémi Duraffort

mozilla plugin: fix compilation.

parent 992cf22c
...@@ -42,13 +42,11 @@ ...@@ -42,13 +42,11 @@
** Local helper macros and function ** Local helper macros and function
*/ */
#define COUNTNAMES(a,b,c) const int a::b = sizeof(a::c)/sizeof(NPUTF8 *) #define COUNTNAMES(a,b,c) const int a::b = sizeof(a::c)/sizeof(NPUTF8 *)
#define RETURN_ON_EXCEPTION(this,ex) \ #define RETURN_ON_ERROR \
do { if( libvlc_exception_raised(&ex) ) \ do { \
{ \ NPN_SetException(this, libvlc_errmsg()); \
NPN_SetException(this, libvlc_errmsg()); \ return INVOKERESULT_GENERIC_ERROR; \
libvlc_exception_clear(&ex); \ }while(0)
return INVOKERESULT_GENERIC_ERROR; \
} } while(false)
#define ERROR_EVENT_NOT_FOUND "ERROR: One or more events could not be found." #define ERROR_EVENT_NOT_FOUND "ERROR: One or more events could not be found."
#define ERROR_API_VERSION "ERROR: NPAPI version not high enough. (Gecko >= 1.9 needed)" #define ERROR_API_VERSION "ERROR: NPAPI version not high enough. (Gecko >= 1.9 needed)"
...@@ -180,9 +178,6 @@ RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index, ...@@ -180,9 +178,6 @@ RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index,
if( !isPluginRunning() ) if( !isPluginRunning() )
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
libvlc_exception_t ex;
libvlc_exception_init(&ex);
switch( index ) switch( index )
{ {
case ID_root_versionInfo: case ID_root_versionInfo:
...@@ -252,11 +247,10 @@ LibvlcAudioNPObject::getProperty(int index, NPVariant &result) ...@@ -252,11 +247,10 @@ LibvlcAudioNPObject::getProperty(int index, NPVariant &result)
if( isPluginRunning() ) if( isPluginRunning() )
{ {
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = p_plugin->getMD(&ex); libvlc_media_player_t *p_md = p_plugin->getMD();
RETURN_ON_EXCEPTION(this,ex); if( !p_md )
RETURN_ON_ERROR;
switch( index ) switch( index )
{ {
...@@ -306,11 +300,10 @@ LibvlcAudioNPObject::setProperty(int index, const NPVariant &value) ...@@ -306,11 +300,10 @@ LibvlcAudioNPObject::setProperty(int index, const NPVariant &value)
if( isPluginRunning() ) if( isPluginRunning() )
{ {
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = p_plugin->getMD(&ex); libvlc_media_player_t *p_md = p_plugin->getMD();
RETURN_ON_EXCEPTION(this,ex); if( !p_md )
RETURN_ON_ERROR;
switch( index ) switch( index )
{ {
...@@ -371,11 +364,9 @@ LibvlcAudioNPObject::invoke(int index, const NPVariant *args, ...@@ -371,11 +364,9 @@ LibvlcAudioNPObject::invoke(int index, const NPVariant *args,
if( isPluginRunning() ) if( isPluginRunning() )
{ {
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex; libvlc_media_player_t *p_md = p_plugin->getMD();
libvlc_exception_init(&ex); if( !p_md )
RETURN_ON_ERROR;
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
...@@ -467,23 +458,15 @@ LibvlcInputNPObject::getProperty(int index, NPVariant &result) ...@@ -467,23 +458,15 @@ LibvlcInputNPObject::getProperty(int index, NPVariant &result)
if( isPluginRunning() ) if( isPluginRunning() )
{ {
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex; libvlc_media_player_t *p_md = p_plugin->getMD();
libvlc_exception_init(&ex); if( !p_md )
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
if( libvlc_exception_raised(&ex) )
{ {
if( index != ID_input_state ) if( index != ID_input_state )
{ RETURN_ON_ERROR;
NPN_SetException(this, libvlc_errmsg());
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
else else
{ {
/* for input state, return CLOSED rather than an exception */ /* for input state, return CLOSED rather than an exception */
INT32_TO_NPVARIANT(0, result); INT32_TO_NPVARIANT(0, result);
libvlc_exception_clear(&ex);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
...@@ -511,7 +494,6 @@ LibvlcInputNPObject::getProperty(int index, NPVariant &result) ...@@ -511,7 +494,6 @@ LibvlcInputNPObject::getProperty(int index, NPVariant &result)
case ID_input_state: case ID_input_state:
{ {
int val = libvlc_media_player_get_state(p_md); int val = libvlc_media_player_get_state(p_md);
RETURN_ON_EXCEPTION(this,ex);
INT32_TO_NPVARIANT(val, result); INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
...@@ -547,11 +529,12 @@ LibvlcInputNPObject::setProperty(int index, const NPVariant &value) ...@@ -547,11 +529,12 @@ LibvlcInputNPObject::setProperty(int index, const NPVariant &value)
if( isPluginRunning() ) if( isPluginRunning() )
{ {
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex; libvlc_media_player_t *p_md = p_plugin->getMD();
libvlc_exception_init(&ex); if( !p_md )
{
libvlc_media_player_t *p_md = p_plugin->getMD(&ex); NPN_SetException(this, libvlc_errmsg() );
RETURN_ON_EXCEPTION(this,ex); return INVOKERESULT_GENERIC_ERROR;
}
switch( index ) switch( index )
{ {
...@@ -692,8 +675,6 @@ LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args, ...@@ -692,8 +675,6 @@ LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
if( isPluginRunning() ) if( isPluginRunning() )
{ {
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex;
libvlc_exception_init(&ex);
switch( index ) switch( index )
{ {
...@@ -817,8 +798,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -817,8 +798,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
if( isPluginRunning() ) if( isPluginRunning() )
{ {
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex;
libvlc_exception_init(&ex);
switch( index ) switch( index )
{ {
...@@ -895,24 +874,25 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -895,24 +874,25 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
} }
int item = p_plugin->playlist_add_extended_untrusted(url, name, int item = p_plugin->playlist_add_extended_untrusted(url, name,
i_options, const_cast<const char **>(ppsz_options), &ex); i_options, const_cast<const char **>(ppsz_options));
free(url); free(url);
free(name); free(name);
if( item == -1 )
RETURN_ON_ERROR;
for( int i=0; i< i_options; ++i ) for( int i=0; i< i_options; ++i )
{ {
free(ppsz_options[i]); free(ppsz_options[i]);
} }
free(ppsz_options); free(ppsz_options);
RETURN_ON_EXCEPTION(this,ex);
INT32_TO_NPVARIANT(item, result); INT32_TO_NPVARIANT(item, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_playlist_play: case ID_playlist_play:
if( argCount == 0 ) if( argCount == 0 )
{ {
p_plugin->playlist_play(&ex); p_plugin->playlist_play();
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
...@@ -920,8 +900,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -920,8 +900,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
case ID_playlist_playItem: case ID_playlist_playItem:
if( (argCount == 1) && isNumberValue(args[0]) ) if( (argCount == 1) && isNumberValue(args[0]) )
{ {
p_plugin->playlist_play_item(numberValue(args[0]),&ex); p_plugin->playlist_play_item(numberValue(args[0]));
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
...@@ -945,8 +924,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -945,8 +924,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
case ID_playlist_next: case ID_playlist_next:
if( argCount == 0 ) if( argCount == 0 )
{ {
p_plugin->playlist_next(&ex); p_plugin->playlist_next();
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
...@@ -954,8 +932,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -954,8 +932,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
case ID_playlist_prev: case ID_playlist_prev:
if( argCount == 0 ) if( argCount == 0 )
{ {
p_plugin->playlist_prev(&ex); p_plugin->playlist_prev();
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
...@@ -1146,11 +1123,9 @@ LibvlcSubtitleNPObject::getProperty(int index, NPVariant &result) ...@@ -1146,11 +1123,9 @@ LibvlcSubtitleNPObject::getProperty(int index, NPVariant &result)
if( isPluginRunning() ) if( isPluginRunning() )
{ {
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex; libvlc_media_player_t *p_md = p_plugin->getMD();
libvlc_exception_init(&ex); if( !p_md )
RETURN_ON_ERROR;
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
...@@ -1182,11 +1157,9 @@ LibvlcSubtitleNPObject::setProperty(int index, const NPVariant &value) ...@@ -1182,11 +1157,9 @@ LibvlcSubtitleNPObject::setProperty(int index, const NPVariant &value)
if( isPluginRunning() ) if( isPluginRunning() )
{ {
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex; libvlc_media_player_t *p_md = p_plugin->getMD();
libvlc_exception_init(&ex); if( !p_md )
RETURN_ON_ERROR;
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
...@@ -1225,11 +1198,9 @@ LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args, ...@@ -1225,11 +1198,9 @@ LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args,
if( isPluginRunning() ) if( isPluginRunning() )
{ {
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex; libvlc_media_player_t *p_md = p_plugin->getMD();
libvlc_exception_init(&ex); if( !p_md )
RETURN_ON_ERROR;
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
...@@ -1329,11 +1300,9 @@ LibvlcVideoNPObject::getProperty(int index, NPVariant &result) ...@@ -1329,11 +1300,9 @@ LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
if( isPluginRunning() ) if( isPluginRunning() )
{ {
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex; libvlc_media_player_t *p_md = p_plugin->getMD();
libvlc_exception_init(&ex); if( !p_md )
RETURN_ON_ERROR;
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
...@@ -1417,11 +1386,9 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &value) ...@@ -1417,11 +1386,9 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
if( isPluginRunning() ) if( isPluginRunning() )
{ {
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex; libvlc_media_player_t *p_md = p_plugin->getMD();
libvlc_exception_init(&ex); if( !p_md )
RETURN_ON_ERROR;
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
...@@ -1490,9 +1457,7 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &value) ...@@ -1490,9 +1457,7 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
{ {
if( isNumberValue(value) ) if( isNumberValue(value) )
{ {
libvlc_video_set_teletext(p_md, numberValue(value), &ex); libvlc_video_set_teletext(p_md, numberValue(value));
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_INVALID_VALUE; return INVOKERESULT_INVALID_VALUE;
...@@ -1523,11 +1488,9 @@ LibvlcVideoNPObject::invoke(int index, const NPVariant *args, ...@@ -1523,11 +1488,9 @@ LibvlcVideoNPObject::invoke(int index, const NPVariant *args,
if( isPluginRunning() ) if( isPluginRunning() )
{ {
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex; libvlc_media_player_t *p_md = p_plugin->getMD();
libvlc_exception_init(&ex); if( !p_md )
RETURN_ON_ERROR;
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
...@@ -1611,11 +1574,9 @@ LibvlcMarqueeNPObject::getProperty(int index, NPVariant &result) ...@@ -1611,11 +1574,9 @@ LibvlcMarqueeNPObject::getProperty(int index, NPVariant &result)
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex; libvlc_media_player_t *p_md = p_plugin->getMD();
libvlc_exception_init(&ex); if( !p_md )
RETURN_ON_ERROR;
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
...@@ -1627,21 +1588,19 @@ LibvlcMarqueeNPObject::getProperty(int index, NPVariant &result) ...@@ -1627,21 +1588,19 @@ LibvlcMarqueeNPObject::getProperty(int index, NPVariant &result)
case ID_marquee_x: case ID_marquee_x:
case ID_marquee_y: case ID_marquee_y:
INT32_TO_NPVARIANT( INT32_TO_NPVARIANT(
libvlc_video_get_marquee_int(p_md, marquee_idx[index], &ex), libvlc_video_get_marquee_int(p_md, marquee_idx[index]),
result ); result );
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
case ID_marquee_position: case ID_marquee_position:
STRINGZ_TO_NPVARIANT( position_bynumber( STRINGZ_TO_NPVARIANT( position_bynumber(
libvlc_video_get_marquee_int(p_md, libvlc_marquee_Position, &ex) ), libvlc_video_get_marquee_int(p_md, libvlc_marquee_Position) ),
result ); result );
RETURN_ON_EXCEPTION(this,ex);
break; break;
case ID_marquee_text: case ID_marquee_text:
psz = libvlc_video_get_marquee_string(p_md, libvlc_marquee_Text, &ex); psz = libvlc_video_get_marquee_string(p_md, libvlc_marquee_Text);
if( psz ) if( psz )
{ {
STRINGZ_TO_NPVARIANT(psz, result); STRINGZ_TO_NPVARIANT(psz, result);
...@@ -1661,10 +1620,9 @@ LibvlcMarqueeNPObject::setProperty(int index, const NPVariant &value) ...@@ -1661,10 +1620,9 @@ LibvlcMarqueeNPObject::setProperty(int index, const NPVariant &value)
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex; libvlc_media_player_t *p_md = p_plugin->getMD();
libvlc_exception_init(&ex); if( !p_md )
libvlc_media_player_t *p_md = p_plugin->getMD(&ex); RETURN_ON_ERROR;
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
...@@ -1677,8 +1635,7 @@ LibvlcMarqueeNPObject::setProperty(int index, const NPVariant &value) ...@@ -1677,8 +1635,7 @@ LibvlcMarqueeNPObject::setProperty(int index, const NPVariant &value)
if( NPVARIANT_IS_INT32( value ) ) if( NPVARIANT_IS_INT32( value ) )
{ {
libvlc_video_set_marquee_int(p_md, marquee_idx[index], libvlc_video_set_marquee_int(p_md, marquee_idx[index],
NPVARIANT_TO_INT32( value ), &ex); NPVARIANT_TO_INT32( value ));
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
break; break;
...@@ -1688,8 +1645,7 @@ LibvlcMarqueeNPObject::setProperty(int index, const NPVariant &value) ...@@ -1688,8 +1645,7 @@ LibvlcMarqueeNPObject::setProperty(int index, const NPVariant &value)
!position_byname( NPVARIANT_TO_STRING(value).utf8characters, i ) ) !position_byname( NPVARIANT_TO_STRING(value).utf8characters, i ) )
return INVOKERESULT_INVALID_VALUE; return INVOKERESULT_INVALID_VALUE;
libvlc_video_set_marquee_int(p_md, libvlc_marquee_Position, i, &ex); libvlc_video_set_marquee_int(p_md, libvlc_marquee_Position, i);
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
case ID_marquee_text: case ID_marquee_text:
...@@ -1697,9 +1653,8 @@ LibvlcMarqueeNPObject::setProperty(int index, const NPVariant &value) ...@@ -1697,9 +1653,8 @@ LibvlcMarqueeNPObject::setProperty(int index, const NPVariant &value)
{ {
char *psz_text = stringValue( NPVARIANT_TO_STRING( value ) ); char *psz_text = stringValue( NPVARIANT_TO_STRING( value ) );
libvlc_video_set_marquee_string(p_md, libvlc_marquee_Text, libvlc_video_set_marquee_string(p_md, libvlc_marquee_Text,
psz_text, &ex); psz_text);
free(psz_text); free(psz_text);
RETURN_ON_EXCEPTION(this,ex);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
break; break;
...@@ -1728,19 +1683,16 @@ LibvlcMarqueeNPObject::invoke(int index, const NPVariant *args, ...@@ -1728,19 +1683,16 @@ LibvlcMarqueeNPObject::invoke(int index, const NPVariant *args,
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex; libvlc_media_player_t *p_md = p_plugin->getMD();
libvlc_exception_init(&ex); if( !p_md )
RETURN_ON_ERROR;
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
case ID_marquee_enable: case ID_marquee_enable:
case ID_marquee_disable: case ID_marquee_disable:
libvlc_video_set_marquee_int(p_md, libvlc_marquee_Enable, libvlc_video_set_marquee_int(p_md, libvlc_marquee_Enable,
index!=ID_marquee_disable, &ex); index!=ID_marquee_disable);
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
...@@ -1780,10 +1732,9 @@ LibvlcLogoNPObject::getProperty(int index, NPVariant &result) ...@@ -1780,10 +1732,9 @@ LibvlcLogoNPObject::getProperty(int index, NPVariant &result)
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex; libvlc_media_player_t *p_md = p_plugin->getMD();
libvlc_exception_init(&ex); if( !p_md )
libvlc_media_player_t *p_md = p_plugin->getMD(&ex); RETURN_ON_ERROR;
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
...@@ -1794,17 +1745,13 @@ LibvlcLogoNPObject::getProperty(int index, NPVariant &result) ...@@ -1794,17 +1745,13 @@ LibvlcLogoNPObject::getProperty(int index, NPVariant &result)
case ID_logo_y: case ID_logo_y:
INT32_TO_NPVARIANT( INT32_TO_NPVARIANT(
libvlc_video_get_logo_int(p_md, logo_idx[index], &ex), result); libvlc_video_get_logo_int(p_md, logo_idx[index]), result);
RETURN_ON_EXCEPTION(this,ex);
break; break;
case ID_logo_position: case ID_logo_position:
STRINGZ_TO_NPVARIANT( position_bynumber( STRINGZ_TO_NPVARIANT( position_bynumber(
libvlc_video_get_logo_int(p_md, libvlc_logo_position, &ex) ), libvlc_video_get_logo_int(p_md, libvlc_logo_position) ),
result ); result );
RETURN_ON_EXCEPTION(this,ex);
break; break;
default: default:
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -1821,11 +1768,9 @@ LibvlcLogoNPObject::setProperty(int index, const NPVariant &value) ...@@ -1821,11 +1768,9 @@ LibvlcLogoNPObject::setProperty(int index, const NPVariant &value)
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
VlcPlugin* p_plugin = getPrivate<VlcPlugin>(); VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
libvlc_exception_t ex; libvlc_media_player_t *p_md = p_plugin->getMD();
libvlc_exception_init(&ex); if( !p_md )
RETURN_ON_ERROR;
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
...@@ -1838,9 +1783,7 @@ LibvlcLogoNPObject::setProperty(int index, const NPVariant &value) ...@@ -1838,9 +1783,7 @@ LibvlcLogoNPObject::setProperty(int index, const NPVariant &value)
return INVOKERESULT_INVALID_VALUE; return INVOKERESULT_INVALID_VALUE;
libvlc_video_set_logo_int(p_md, logo_idx[index], libvlc_video_set_logo_int(p_md, logo_idx[index],
NPVARIANT_TO_INT32( value ), &ex); NPVARIANT_TO_INT32( value ));
RETURN_ON_EXCEPTION(this,ex);
break; break;
case ID_logo_position: case ID_logo_position:
...@@ -1848,9 +1791,7 @@ LibvlcLogoNPObject::setProperty(int index, const NPVariant &value) ...@@ -1848,9 +1791,7 @@ LibvlcLogoNPObject::setProperty(int index, const NPVariant &value)
!position_byname( NPVARIANT_TO_STRING(value).utf8characters, i ) ) !position_byname( NPVARIANT_TO_STRING(value).utf8characters, i ) )
return INVOKERESULT_INVALID_VALUE; return INVOKERESULT_INVALID_VALUE;
libvlc_video_set_logo_int(p_md, libvlc_logo_position, i, &ex); libvlc_video_set_logo_int(p_md, libvlc_logo_position, i);
RETURN_ON_EXCEPTION(this,ex);
break; break;
default: default:
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -1881,10 +1822,9 @@ LibvlcLogoNPObject::invoke(int index, const NPVariant *args, ...@@ -1881,10 +1822,9 @@ LibvlcLogoNPObject::invoke(int index, const NPVariant *args,
if( !isPluginRunning() ) if( !isPluginRunning() )
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
libvlc_exception_t ex; libvlc_media_player_t *p_md = getPrivate<VlcPlugin>()->getMD();
libvlc_exception_init(&ex); if( !p_md )
libvlc_media_player_t *p_md = getPrivate<VlcPlugin>()->getMD(&ex); RETURN_ON_ERROR;
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
...@@ -1894,8 +1834,7 @@ LibvlcLogoNPObject::invoke(int index, const NPVariant *args, ...@@ -1894,8 +1834,7 @@ LibvlcLogoNPObject::invoke(int index, const NPVariant *args,
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
libvlc_video_set_logo_int(p_md, libvlc_logo_enable, libvlc_video_set_logo_int(p_md, libvlc_logo_enable,
index != ID_logo_disable, &ex); index != ID_logo_disable);
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
break; break;
...@@ -1923,9 +1862,8 @@ LibvlcLogoNPObject::invoke(int index, const NPVariant *args, ...@@ -1923,9 +1862,8 @@ LibvlcLogoNPObject::invoke(int index, const NPVariant *args,
} }
*h='\0'; *h='\0';
libvlc_video_set_logo_string(p_md, libvlc_logo_file, buf, &ex); libvlc_video_set_logo_string(p_md, libvlc_logo_file, buf);
free( buf ); free( buf );
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
break; break;
default: default:
...@@ -1973,10 +1911,9 @@ LibvlcDeinterlaceNPObject::invoke(int index, const NPVariant *args, ...@@ -1973,10 +1911,9 @@ LibvlcDeinterlaceNPObject::invoke(int index, const NPVariant *args,
if( !isPluginRunning() ) if( !isPluginRunning() )
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
libvlc_exception_t ex; libvlc_media_player_t *p_md = getPrivate<VlcPlugin>()->getMD();
libvlc_exception_init(&ex); if( !p_md )
libvlc_media_player_t *p_md = getPrivate<VlcPlugin>()->getMD(&ex); RETURN_ON_ERROR;
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
......
...@@ -449,7 +449,7 @@ void VlcPlugin::set_player_window() ...@@ -449,7 +449,7 @@ void VlcPlugin::set_player_window()
#endif #endif
} }
int VlcPlugin::playlist_add( const char *mrl, libvlc_exception_t *ex ) int VlcPlugin::playlist_add( const char *mrl )
{ {
int item = -1; int item = -1;
libvlc_media_t *p_m = libvlc_media_new(libvlc_instance,mrl); libvlc_media_t *p_m = libvlc_media_new(libvlc_instance,mrl);
...@@ -467,7 +467,7 @@ int VlcPlugin::playlist_add( const char *mrl, libvlc_exception_t *ex ) ...@@ -467,7 +467,7 @@ int VlcPlugin::playlist_add( const char *mrl, libvlc_exception_t *ex )
} }
int VlcPlugin::playlist_add_extended_untrusted( const char *mrl, const char *name, int VlcPlugin::playlist_add_extended_untrusted( const char *mrl, const char *name,
int optc, const char **optv, libvlc_exception_t *ex ) int optc, const char **optv )
{ {
libvlc_media_t *p_m = libvlc_media_new(libvlc_instance, mrl); libvlc_media_t *p_m = libvlc_media_new(libvlc_instance, mrl);
int item = -1; int item = -1;
...@@ -486,7 +486,7 @@ int VlcPlugin::playlist_add_extended_untrusted( const char *mrl, const char *nam ...@@ -486,7 +486,7 @@ int VlcPlugin::playlist_add_extended_untrusted( const char *mrl, const char *nam
return item; return item;
} }
bool VlcPlugin::playlist_select( int idx, libvlc_exception_t *ex ) bool VlcPlugin::playlist_select( int idx )
{ {
libvlc_media_t *p_m = NULL; libvlc_media_t *p_m = NULL;
......
...@@ -167,11 +167,10 @@ public: ...@@ -167,11 +167,10 @@ public:
NPError init(int argc, char* const argn[], char* const argv[]); NPError init(int argc, char* const argn[], char* const argv[]);
libvlc_instance_t* getVLC() libvlc_instance_t* getVLC()
{ return libvlc_instance; }; { return libvlc_instance; };
libvlc_media_player_t* getMD(libvlc_exception_t *ex) libvlc_media_player_t* getMD()
{ {
if( !libvlc_media_player ) if( !libvlc_media_player )
{ {
libvlc_exception_raise(ex);
libvlc_printerr("no mediaplayer"); libvlc_printerr("no mediaplayer");
} }
return libvlc_media_player; return libvlc_media_player;
...@@ -224,14 +223,14 @@ public: ...@@ -224,14 +223,14 @@ public:
char * psz_text; char * psz_text;
char * psz_target; char * psz_target;
void playlist_play(libvlc_exception_t *ex) void playlist_play()
{ {
if( libvlc_media_player||playlist_select(0,ex) ) if( libvlc_media_player||playlist_select(0) )
libvlc_media_player_play(libvlc_media_player); libvlc_media_player_play(libvlc_media_player);
} }
void playlist_play_item(int idx,libvlc_exception_t *ex) void playlist_play_item(int idx)
{ {
if( playlist_select(idx,ex) ) if( playlist_select(idx) )
libvlc_media_player_play(libvlc_media_player); libvlc_media_player_play(libvlc_media_player);
} }
void playlist_stop() void playlist_stop()
...@@ -239,14 +238,14 @@ public: ...@@ -239,14 +238,14 @@ public:
if( libvlc_media_player ) if( libvlc_media_player )
libvlc_media_player_stop(libvlc_media_player); libvlc_media_player_stop(libvlc_media_player);
} }
void playlist_next(libvlc_exception_t *ex) void playlist_next()
{ {
if( playlist_select(playlist_index+1,ex) ) if( playlist_select(playlist_index+1) )
libvlc_media_player_play(libvlc_media_player); libvlc_media_player_play(libvlc_media_player);
} }
void playlist_prev(libvlc_exception_t *ex) void playlist_prev()
{ {
if( playlist_select(playlist_index-1,ex) ) if( playlist_select(playlist_index-1) )
libvlc_media_player_play(libvlc_media_player); libvlc_media_player_play(libvlc_media_player);
} }
void playlist_pause() void playlist_pause()
...@@ -263,9 +262,9 @@ public: ...@@ -263,9 +262,9 @@ public:
return is_playing; return is_playing;
} }
int playlist_add( const char *, libvlc_exception_t * ); int playlist_add( const char * );
int playlist_add_extended_untrusted( const char *, const char *, int, int playlist_add_extended_untrusted( const char *, const char *, int,
const char **, libvlc_exception_t * ); const char ** );
int playlist_delete_item( int ); int playlist_delete_item( int );
void playlist_clear(); void playlist_clear();
int playlist_count(); int playlist_count();
...@@ -281,7 +280,7 @@ public: ...@@ -281,7 +280,7 @@ public:
EventObj events; EventObj events;
private: private:
bool playlist_select(int,libvlc_exception_t *); bool playlist_select(int);
void set_player_window(); void set_player_window();
/* VLC reference */ /* VLC reference */
......
...@@ -157,9 +157,6 @@ NPError NPP_SetValue( NPP instance, NPNVariable variable, void *value ) ...@@ -157,9 +157,6 @@ NPError NPP_SetValue( NPP instance, NPNVariable variable, void *value )
int16 NPP_HandleEvent( NPP instance, void * event ) int16 NPP_HandleEvent( NPP instance, void * event )
{ {
static UInt32 lastMouseUp = 0; static UInt32 lastMouseUp = 0;
libvlc_exception_t ex;
libvlc_exception_init(&ex);
if( instance == NULL ) if( instance == NULL )
{ {
return false; return false;
...@@ -182,8 +179,7 @@ int16 NPP_HandleEvent( NPP instance, void * event ) ...@@ -182,8 +179,7 @@ int16 NPP_HandleEvent( NPP instance, void * event )
if( (myEvent->when - lastMouseUp) < GetDblTime() ) if( (myEvent->when - lastMouseUp) < GetDblTime() )
{ {
/* double click */ /* double click */
p_plugin->toggle_fullscreen(&ex); p_plugin->toggle_fullscreen();
libvlc_exception_clear(&ex);
} }
return true; return true;
} }
...@@ -212,13 +208,12 @@ int16 NPP_HandleEvent( NPP instance, void * event ) ...@@ -212,13 +208,12 @@ int16 NPP_HandleEvent( NPP instance, void * event )
area.top = 0; area.top = 0;
area.right = npwindow.width; area.right = npwindow.width;
area.bottom = npwindow.height; area.bottom = npwindow.height;
libvlc_video_redraw_rectangle(p_plugin->getMD(&ex), &area, NULL); libvlc_video_redraw_rectangle(p_plugin->getMD(), &area, NULL);
#else #else
#warning disabled code #warning disabled code
#endif #endif
} }
} }
libvlc_exception_clear(&ex);
if( ! hasVout ) if( ! hasVout )
{ {
...@@ -372,9 +367,6 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -372,9 +367,6 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
control = p_plugin->getControlWindow(); control = p_plugin->getControlWindow();
#endif #endif
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_instance_t *p_vlc = p_plugin->getVLC(); libvlc_instance_t *p_vlc = p_plugin->getVLC();
/* /*
...@@ -413,8 +405,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -413,8 +405,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
clip.bottom = window->clipRect.bottom; clip.bottom = window->clipRect.bottom;
clip.right = window->clipRect.right; clip.right = window->clipRect.right;
#ifdef NOT_WORKING #ifdef NOT_WORKING
libvlc_video_set_viewport(p_vlc, p_plugin->getMD(&ex), &view, &clip, &ex); libvlc_video_set_viewport(p_vlc, p_plugin->getMD(), &view, &clip);
libvlc_exception_clear(&ex);
#else #else
#warning disabled code #warning disabled code
#endif #endif
...@@ -548,12 +539,11 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -548,12 +539,11 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
{ {
if( p_plugin->psz_target ) if( p_plugin->psz_target )
{ {
if( p_plugin->playlist_add( p_plugin->psz_target, NULL ) != -1 ) if( p_plugin->playlist_add( p_plugin->psz_target ) != -1 )
{ {
if( p_plugin->b_autoplay ) if( p_plugin->b_autoplay )
{ {
p_plugin->playlist_play(&ex); p_plugin->playlist_play();
libvlc_exception_clear(&ex);
} }
} }
p_plugin->b_stream = true; p_plugin->b_stream = true;
...@@ -627,11 +617,11 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname ) ...@@ -627,11 +617,11 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
return; return;
} }
if( p_plugin->playlist_add( stream->url, NULL ) != -1 ) if( p_plugin->playlist_add( stream->url ) != -1 )
{ {
if( p_plugin->b_autoplay ) if( p_plugin->b_autoplay )
{ {
p_plugin->playlist_play(NULL); p_plugin->playlist_play();
} }
} }
} }
...@@ -806,11 +796,8 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event ) ...@@ -806,11 +796,8 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
if( p_plugin && p_plugin->b_toolbar ) if( p_plugin && p_plugin->b_toolbar )
{ {
int i_playing; int i_playing;
libvlc_exception_t ex;
libvlc_exception_init( &ex ); libvlc_media_player_t *p_md = p_plugin->getMD();
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
libvlc_exception_clear( &ex );
i_playing = p_plugin->playlist_isplaying(); i_playing = p_plugin->playlist_isplaying();
...@@ -824,9 +811,7 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event ) ...@@ -824,9 +811,7 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
if( i_playing == 1 ) if( i_playing == 1 )
p_plugin->playlist_pause(); p_plugin->playlist_pause();
else else
p_plugin->playlist_play( &ex ); p_plugin->playlist_play();
libvlc_exception_clear( &ex );
} }
break; break;
......
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