Commit 76beeb83 authored by Rémi Duraffort's avatar Rémi Duraffort

mozilla: factorize.

parent b3958ce9
...@@ -255,36 +255,31 @@ LibvlcAudioNPObject::getProperty(int index, NPVariant &result) ...@@ -255,36 +255,31 @@ LibvlcAudioNPObject::getProperty(int index, NPVariant &result)
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
case ID_audio_mute: case ID_audio_mute:
{ {
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
bool muted = libvlc_audio_get_mute(p_md); bool muted = libvlc_audio_get_mute(p_md);
BOOLEAN_TO_NPVARIANT(muted, result); BOOLEAN_TO_NPVARIANT(muted, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_audio_volume: case ID_audio_volume:
{ {
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
int volume = libvlc_audio_get_volume(p_md); int volume = libvlc_audio_get_volume(p_md);
INT32_TO_NPVARIANT(volume, result); INT32_TO_NPVARIANT(volume, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_audio_track: case ID_audio_track:
{ {
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
int track = libvlc_audio_get_track(p_md); int track = libvlc_audio_get_track(p_md);
INT32_TO_NPVARIANT(track, result); INT32_TO_NPVARIANT(track, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_audio_count: case ID_audio_count:
{ {
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
// get the number of audio track available // get the number of audio track available
int i_track = libvlc_audio_get_track_count(p_md); int i_track = libvlc_audio_get_track_count(p_md);
// return it // return it
...@@ -293,8 +288,6 @@ LibvlcAudioNPObject::getProperty(int index, NPVariant &result) ...@@ -293,8 +288,6 @@ LibvlcAudioNPObject::getProperty(int index, NPVariant &result)
} }
case ID_audio_channel: case ID_audio_channel:
{ {
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
int channel = libvlc_audio_get_channel(p_md); int channel = libvlc_audio_get_channel(p_md);
INT32_TO_NPVARIANT(channel, result); INT32_TO_NPVARIANT(channel, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
...@@ -316,13 +309,14 @@ LibvlcAudioNPObject::setProperty(int index, const NPVariant &value) ...@@ -316,13 +309,14 @@ LibvlcAudioNPObject::setProperty(int index, const NPVariant &value)
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
case ID_audio_mute: case ID_audio_mute:
if( NPVARIANT_IS_BOOLEAN(value) ) if( NPVARIANT_IS_BOOLEAN(value) )
{ {
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
libvlc_audio_set_mute(p_md, libvlc_audio_set_mute(p_md,
NPVARIANT_TO_BOOLEAN(value)); NPVARIANT_TO_BOOLEAN(value));
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
...@@ -331,8 +325,6 @@ LibvlcAudioNPObject::setProperty(int index, const NPVariant &value) ...@@ -331,8 +325,6 @@ LibvlcAudioNPObject::setProperty(int index, const NPVariant &value)
case ID_audio_volume: case ID_audio_volume:
if( isNumberValue(value) ) if( isNumberValue(value) )
{ {
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
libvlc_audio_set_volume(p_md, numberValue(value)); libvlc_audio_set_volume(p_md, numberValue(value));
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
...@@ -340,8 +332,6 @@ LibvlcAudioNPObject::setProperty(int index, const NPVariant &value) ...@@ -340,8 +332,6 @@ LibvlcAudioNPObject::setProperty(int index, const NPVariant &value)
case ID_audio_track: case ID_audio_track:
if( isNumberValue(value) ) if( isNumberValue(value) )
{ {
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
libvlc_audio_set_track(p_md, numberValue(value)); libvlc_audio_set_track(p_md, numberValue(value));
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
...@@ -349,8 +339,6 @@ LibvlcAudioNPObject::setProperty(int index, const NPVariant &value) ...@@ -349,8 +339,6 @@ LibvlcAudioNPObject::setProperty(int index, const NPVariant &value)
case ID_audio_channel: case ID_audio_channel:
if( isNumberValue(value) ) if( isNumberValue(value) )
{ {
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
libvlc_audio_set_channel(p_md, numberValue(value)); libvlc_audio_set_channel(p_md, numberValue(value));
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
...@@ -386,13 +374,14 @@ LibvlcAudioNPObject::invoke(int index, const NPVariant *args, ...@@ -386,13 +374,14 @@ LibvlcAudioNPObject::invoke(int index, const NPVariant *args,
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
switch( index ) switch( index )
{ {
case ID_audio_togglemute: case ID_audio_togglemute:
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
libvlc_audio_toggle_mute(p_md); libvlc_audio_toggle_mute(p_md);
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
...@@ -406,9 +395,6 @@ LibvlcAudioNPObject::invoke(int index, const NPVariant *args, ...@@ -406,9 +395,6 @@ LibvlcAudioNPObject::invoke(int index, const NPVariant *args,
int i_trackID, i_limit, i; int i_trackID, i_limit, i;
libvlc_track_description_t *p_trackDesc; libvlc_track_description_t *p_trackDesc;
libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
RETURN_ON_EXCEPTION(this,ex);
/* get tracks description */ /* get tracks description */
p_trackDesc = libvlc_audio_get_track_description(p_md); p_trackDesc = libvlc_audio_get_track_description(p_md);
if( !p_trackDesc ) if( !p_trackDesc )
...@@ -945,8 +931,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -945,8 +931,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
case ID_playlist_togglepause: case ID_playlist_togglepause:
if( argCount == 0 ) if( argCount == 0 )
{ {
p_plugin->playlist_pause(&ex); p_plugin->playlist_pause();
RETURN_ON_EXCEPTION(this,ex);
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
......
...@@ -249,7 +249,7 @@ public: ...@@ -249,7 +249,7 @@ public:
if( playlist_select(playlist_index-1,ex) ) if( playlist_select(playlist_index-1,ex) )
libvlc_media_player_play(libvlc_media_player); libvlc_media_player_play(libvlc_media_player);
} }
void playlist_pause(libvlc_exception_t *ex) void playlist_pause()
{ {
if( libvlc_media_player ) if( libvlc_media_player )
libvlc_media_player_pause(libvlc_media_player); libvlc_media_player_pause(libvlc_media_player);
......
...@@ -822,7 +822,7 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event ) ...@@ -822,7 +822,7 @@ static void ControlHandler( Widget w, XtPointer closure, XEvent *event )
case clicked_Pause: case clicked_Pause:
{ {
if( i_playing == 1 ) if( i_playing == 1 )
p_plugin->playlist_pause( &ex ); p_plugin->playlist_pause();
else else
p_plugin->playlist_play( &ex ); p_plugin->playlist_play( &ex );
......
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