Better error handling
This commit is contained in:
parent
f4d72752a8
commit
3e2647782d
|
@ -65,6 +65,8 @@ LibvlcCamera::LibvlcCamera( int p_id, const std::string &p_path, int p_width, in
|
||||||
mLibvlcInstance = NULL;
|
mLibvlcInstance = NULL;
|
||||||
mLibvlcMedia = NULL;
|
mLibvlcMedia = NULL;
|
||||||
mLibvlcMediaPlayer = NULL;
|
mLibvlcMediaPlayer = NULL;
|
||||||
|
mLibvlcData.buffer = NULL;
|
||||||
|
mLibvlcData.prevBuffer = NULL;
|
||||||
|
|
||||||
/* Has to be located inside the constructor so other components such as zma will receive correct colours and subpixel order */
|
/* Has to be located inside the constructor so other components such as zma will receive correct colours and subpixel order */
|
||||||
if(colours == ZM_COLOUR_RGB32) {
|
if(colours == ZM_COLOUR_RGB32) {
|
||||||
|
@ -119,10 +121,15 @@ void LibvlcCamera::Initialise()
|
||||||
void LibvlcCamera::Terminate()
|
void LibvlcCamera::Terminate()
|
||||||
{
|
{
|
||||||
libvlc_media_player_stop(mLibvlcMediaPlayer);
|
libvlc_media_player_stop(mLibvlcMediaPlayer);
|
||||||
|
if(mLibvlcData.buffer != NULL)
|
||||||
|
{
|
||||||
zm_freealigned(mLibvlcData.buffer);
|
zm_freealigned(mLibvlcData.buffer);
|
||||||
|
}
|
||||||
|
if(mLibvlcData.prevBuffer != NULL)
|
||||||
|
{
|
||||||
zm_freealigned(mLibvlcData.prevBuffer);
|
zm_freealigned(mLibvlcData.prevBuffer);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int LibvlcCamera::PrimeCapture()
|
int LibvlcCamera::PrimeCapture()
|
||||||
{
|
{
|
||||||
|
@ -130,15 +137,15 @@ int LibvlcCamera::PrimeCapture()
|
||||||
|
|
||||||
mLibvlcInstance = libvlc_new (0, NULL);
|
mLibvlcInstance = libvlc_new (0, NULL);
|
||||||
if(mLibvlcInstance == NULL)
|
if(mLibvlcInstance == NULL)
|
||||||
Fatal("Unable to create libvlc instance due to: %s", strerror(errno));
|
Fatal("Unable to create libvlc instance due to: %s", libvlc_errmsg());
|
||||||
|
|
||||||
mLibvlcMedia = libvlc_media_new_location(mLibvlcInstance, mPath.c_str());
|
mLibvlcMedia = libvlc_media_new_location(mLibvlcInstance, mPath.c_str());
|
||||||
if(mLibvlcMedia == NULL)
|
if(mLibvlcMedia == NULL)
|
||||||
Fatal( "Unable to open input %s due to: %s", mPath.c_str(), strerror(errno) );
|
Fatal("Unable to open input %s due to: %s", mPath.c_str(), libvlc_errmsg());
|
||||||
|
|
||||||
mLibvlcMediaPlayer = libvlc_media_player_new_from_media(mLibvlcMedia);
|
mLibvlcMediaPlayer = libvlc_media_player_new_from_media(mLibvlcMedia);
|
||||||
if(mLibvlcMediaPlayer == NULL)
|
if(mLibvlcMediaPlayer == NULL)
|
||||||
Fatal( "Unable to create player for %s due to: %s", mPath.c_str(), strerror(errno) );
|
Fatal("Unable to create player for %s due to: %s", mPath.c_str(), libvlc_errmsg());
|
||||||
|
|
||||||
libvlc_video_set_format(mLibvlcMediaPlayer, mTargetChroma.c_str(), width, height, width * mBpp);
|
libvlc_video_set_format(mLibvlcMediaPlayer, mTargetChroma.c_str(), width, height, width * mBpp);
|
||||||
libvlc_video_set_callbacks(mLibvlcMediaPlayer, &LibvlcLockBuffer, &LibvlcUnlockBuffer, NULL, &mLibvlcData);
|
libvlc_video_set_callbacks(mLibvlcMediaPlayer, &LibvlcLockBuffer, &LibvlcUnlockBuffer, NULL, &mLibvlcData);
|
||||||
|
|
Loading…
Reference in New Issue