* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "plugin.h"
libvlc_exception_init(&ex);
_p_instance->playlist_play(&ex);
- if( libvlc_exception_raised(&ex) )
- {
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
- }
- _p_instance->fireOnPlayEvent();
- return NOERROR;
+ HRESULT result = exception_bridge(&ex);
+ if( SUCCEEDED(result) )
+ _p_instance->fireOnPlayEvent();
+ return result;
};
STDMETHODIMP VLCControl::pause(void)
libvlc_exception_init(&ex);
libvlc_media_player_pause(p_md, &ex);
- if( libvlc_exception_raised(&ex) )
- {
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
- }
- _p_instance->fireOnPauseEvent();
- return NOERROR;
+ result = exception_bridge(&ex);
+ if( SUCCEEDED(result) )
+ _p_instance->fireOnPauseEvent();
}
return result;
};
libvlc_exception_init(&ex);
libvlc_media_player_stop(p_md, &ex);
- if( libvlc_exception_raised(&ex) )
- {
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
- }
- return NOERROR;
+ result = exception_bridge(&ex);
+ if( SUCCEEDED(result) )
+ _p_instance->fireOnStopEvent();
}
- _p_instance->fireOnStopEvent();
return result;
};
{
*isPlaying = libvlc_media_player_is_playing(p_md, NULL) ?
VARIANT_TRUE : VARIANT_FALSE;
- return NOERROR;
- }
- *isPlaying = VARIANT_FALSE;
+ } else *isPlaying = VARIANT_FALSE;
return result;
};
libvlc_exception_init(&ex);
*position = libvlc_media_player_get_position(p_md, &ex);
- if( ! libvlc_exception_raised(&ex) )
- {
- return NOERROR;
- }
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
+ result = exception_bridge(&ex);
}
return result;
};
libvlc_exception_init(&ex);
libvlc_media_player_set_position(p_md, position, &ex);
- if( ! libvlc_exception_raised(&ex) )
- {
- return NOERROR;
- }
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
+ result = exception_bridge(&ex);
}
return result;
};
libvlc_exception_init(&ex);
*seconds = libvlc_media_player_get_time(p_md, &ex);
- if( ! libvlc_exception_raised(&ex) )
- {
- return NOERROR;
- }
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
+ result = exception_bridge(&ex);
}
return result;
};
if( seconds < 0 ) seconds = 0;
libvlc_media_player_set_time(p_md, (int64_t)seconds, &ex);
- if( ! libvlc_exception_raised(&ex) )
- {
- return NOERROR;
- }
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
+ result = exception_bridge(&ex);
}
return result;
libvlc_exception_init(&ex);
*seconds = (double)libvlc_media_player_get_length(p_md, &ex);
- if( ! libvlc_exception_raised(&ex) )
- {
- return NOERROR;
- }
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
+ result = exception_bridge(&ex);
}
return result;
libvlc_exception_t ex;
libvlc_exception_init(&ex);
- if( ! libvlc_exception_raised(&ex) )
- {
- libvlc_media_player_set_rate(p_md, rate, &ex);
- if( ! libvlc_exception_raised(&ex) )
- {
- return NOERROR;
- }
- }
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
+ libvlc_media_player_set_rate(p_md, rate, &ex);
+ result = exception_bridge(&ex);
}
return result;
};
libvlc_exception_init(&ex);
libvlc_media_player_set_rate(p_md, rate, &ex);
- if( ! libvlc_exception_raised(&ex) )
- {
- return NOERROR;
- }
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
+ result = exception_bridge(&ex);
}
return result;
};
libvlc_exception_init(&ex);
libvlc_audio_toggle_mute(p_libvlc, &ex);
- if( libvlc_exception_raised(&ex) )
- {
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
- }
- return NOERROR;
+ result = exception_bridge(&ex);
}
return result;
};
FreeTargetOptions(cOptions, cOptionsCount);
CoTaskMemFree(cUri);
- if( libvlc_exception_raised(&ex) )
+ hr = exception_bridge(&ex);
+ if( SUCCEEDED(hr) )
+ {
+ if( mode & VLCPlayListAppendAndGo )
+ _p_instance->fireOnPlayEvent();
+ }
+ else
{
- _p_instance->setErrorInfo(IID_IVLCPlaylist,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
-
if( mode & VLCPlayListAppendAndGo )
_p_instance->fireOnStopEvent();
- return E_FAIL;
}
-
- if( mode & VLCPlayListAppendAndGo )
- _p_instance->fireOnPlayEvent();
- return NOERROR;
}
return hr;
};
libvlc_exception_init(&ex);
*index = _p_instance->playlist_get_current_index(&ex);
- if( libvlc_exception_raised(&ex) )
- {
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
- }
- return NOERROR;
+ result = exception_bridge(&ex);
}
return result;
};
libvlc_exception_init(&ex);
*count = _p_instance->playlist_count(&ex);
- if( libvlc_exception_raised(&ex) )
- {
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
- }
- return NOERROR;
+ return exception_bridge(&ex);
};
STDMETHODIMP VLCControl::playlistNext(void)
libvlc_exception_init(&ex);
_p_instance->playlist_next(&ex);
- if( libvlc_exception_raised(&ex) )
- {
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
- }
- return NOERROR;
+ result = exception_bridge(&ex);
}
return result;
};
libvlc_exception_init(&ex);
_p_instance->playlist_prev(&ex);
- if( libvlc_exception_raised(&ex) )
- {
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
- }
- return NOERROR;
+ result = exception_bridge(&ex);
}
return result;
};
libvlc_exception_init(&ex);
_p_instance->playlist_clear(&ex);
- if( libvlc_exception_raised(&ex) )
- {
- _p_instance->setErrorInfo(IID_IVLCControl,
- libvlc_exception_get_message(&ex));
- libvlc_exception_clear(&ex);
- return E_FAIL;
- }
- return NOERROR;
+ result = exception_bridge(&ex);
}
return result;
};
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef _VLCCONTROL_H_
{
public:
- VLCControl(VLCPlugin *p_instance) : _p_instance(p_instance), _p_typeinfo(NULL) {};
+ VLCControl(VLCPlugin *p_instance):
+ _p_instance(p_instance), _p_typeinfo(NULL) { }
virtual ~VLCControl();
// IUnknown methods
return NOERROR;
}
return _p_instance->pUnkOuter->QueryInterface(riid, ppv);
- };
+ }
- STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
- STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
+ STDMETHODIMP_(ULONG) AddRef(void)
+ { return _p_instance->pUnkOuter->AddRef(); }
+ STDMETHODIMP_(ULONG) Release(void)
+ { return _p_instance->pUnkOuter->Release(); }
// IDispatch methods
STDMETHODIMP GetTypeInfoCount(UINT*);
private:
HRESULT getTypeInfo();
+ HRESULT exception_bridge(libvlc_exception_t *ex)
+ {
+ if( ! libvlc_exception_raised(ex) )
+ return NOERROR;
+ _p_instance->setErrorInfo(IID_IVLCControl,
+ libvlc_exception_get_message(ex));
+ libvlc_exception_clear(ex);
+ return E_FAIL;
+ }
VLCPlugin *_p_instance;
ITypeInfo *_p_typeinfo;