Commit d94b0e19 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Fix missing acquire

parent 7303aa6c
......@@ -119,7 +119,7 @@ void EventManager::handleMediaEvent(const libvlc_event_t* event, void* data)
cb->metaChanged( event->u.media_meta_changed.meta_type );
break;
case libvlc_MediaSubItemAdded:
cb->subItemAdded( Media( event->u.media_subitem_added.new_child ) );
cb->subItemAdded( Media( event->u.media_subitem_added.new_child, true ) );
break;
case libvlc_MediaDurationChanged:
cb->durationChanged( event->u.media_duration_changed.new_duration );
......@@ -128,13 +128,13 @@ void EventManager::handleMediaEvent(const libvlc_event_t* event, void* data)
cb->parsedChanged( event->u.media_parsed_changed.new_status );
break;
case libvlc_MediaFreed:
cb->freed( Media( event->u.media_freed.md ) );
cb->freed( Media( event->u.media_freed.md, true ) );
break;
case libvlc_MediaStateChanged:
cb->stateChanged( event->u.media_state_changed.new_state );
break;
case libvlc_MediaSubItemTreeAdded:
cb->subItemTreeAdded( Media( event->u.media_subitemtree_added.item ) );
cb->subItemTreeAdded( Media( event->u.media_subitemtree_added.item, true ) );
break;
default:
assert(false);
......@@ -147,7 +147,7 @@ void EventManager::handleMediaPlayerEvent(const libvlc_event_t* event, void* dat
switch ( event->type )
{
case libvlc_MediaPlayerMediaChanged:
cb->mediaChanged( Media( event->u.media_player_media_changed.new_media ) );
cb->mediaChanged( Media( event->u.media_player_media_changed.new_media, true ) );
break;
case libvlc_MediaPlayerNothingSpecial:
cb->nothingSpecial();
......@@ -226,16 +226,16 @@ void EventManager::handleMediaListEvent(const libvlc_event_t* event, void* data)
switch ( event->type )
{
case libvlc_MediaListItemAdded:
cb->itemAdded( Media( event->u.media_list_item_added.item ), event->u.media_list_item_added.index );
cb->itemAdded( Media( event->u.media_list_item_added.item, true ), event->u.media_list_item_added.index );
break;
case libvlc_MediaListWillAddItem:
cb->willAddItem( Media( event->u.media_list_will_add_item.item ), event->u.media_list_will_add_item.index );
cb->willAddItem( Media( event->u.media_list_will_add_item.item, true ), event->u.media_list_will_add_item.index );
break;
case libvlc_MediaListItemDeleted:
cb->itemDeleted( Media( event->u.media_list_item_deleted.item ), event->u.media_list_item_deleted.index );
cb->itemDeleted( Media( event->u.media_list_item_deleted.item, true ), event->u.media_list_item_deleted.index );
break;
case libvlc_MediaListWillDeleteItem:
cb->willDeleteItem( Media( event->u.media_list_will_delete_item.item ), event->u.media_list_will_delete_item.index );
cb->willDeleteItem( Media( event->u.media_list_will_delete_item.item, true ), event->u.media_list_will_delete_item.index );
break;
default:
assert(false);
......@@ -251,7 +251,7 @@ void EventManager::handleMediaListPlayerEvent(const libvlc_event_t* event, void*
cb->played();
break;
case libvlc_MediaListPlayerNextItemSet:
cb->nextItemSet( Media( event->u.media_list_player_next_item_set.item ) );
cb->nextItemSet( Media( event->u.media_list_player_next_item_set.item, true ) );
break;
case libvlc_MediaListPlayerStopped:
cb->stopped();
......
......@@ -62,7 +62,7 @@ Instance::~Instance()
Instance Instance::create( int argc, const char *const * argv )
{
InternalPtr ptr = libvlc_new( argc, argv );
return Instance( ptr );
return Instance( ptr, false );
}
int Instance::addIntf( const std::string& name )
......@@ -160,9 +160,11 @@ std::vector<AudioOutputDeviceDescription> Instance::audioOutputDeviceList(const
return res;
}
Instance::Instance(Internal::InternalPtr ptr)
Instance::Instance( Internal::InternalPtr ptr, bool increaseRefCount )
: Internal( ptr )
{
if ( increaseRefCount )
retain();
}
void Instance::release()
......
......@@ -243,7 +243,7 @@ public:
std::vector<AudioOutputDeviceDescription> audioOutputDeviceList(const std::string& aout);
private:
explicit Instance(InternalPtr ptr);
explicit Instance( InternalPtr ptr, bool increaseRefCount );
/**
* Decrement the reference count of a libvlc instance, and destroy it if
* it reaches zero.
......
......@@ -34,31 +34,31 @@ Media::Media()
Media Media::fromPath(Instance& instance, const std::string& path)
{
InternalPtr ptr = libvlc_media_new_path( instance, path.c_str() );
return Media(ptr);
return Media( ptr, false );
}
Media Media::fromLocation(Instance& instance, const std::string& location)
{
InternalPtr ptr = libvlc_media_new_location( instance, location.c_str() );
return Media(ptr);
return Media( ptr, false );
}
Media Media::fromFileDescriptor(Instance& instance, int fd)
{
InternalPtr ptr = libvlc_media_new_fd( instance, fd );
return Media( ptr );
return Media( ptr, false );
}
Media Media::fromList(MediaList& list)
{
InternalPtr ptr = libvlc_media_list_media( list );
return Media( ptr );
return Media( ptr, false );
}
Media Media::asNode(Instance& instance, const std::string& nodeName)
{
InternalPtr ptr = libvlc_media_new_as_node( instance, nodeName.c_str() );
return Media( ptr );
return Media( ptr, false );
}
Media::Media(const Media& another)
......@@ -116,7 +116,7 @@ std::string Media::mrl()
Media Media::duplicate()
{
InternalPtr obj = libvlc_media_duplicate(m_obj);
return Media( obj );
return Media( obj, true );
}
std::string Media::meta(libvlc_meta_t e_meta)
......@@ -202,10 +202,12 @@ std::vector<MediaTrack> Media::tracks()
return res;
}
Media::Media(Internal::InternalPtr ptr)
Media::Media(Internal::InternalPtr ptr, bool increaseRefCount )
: Internal(ptr)
, m_eventManager( NULL )
{
if ( increaseRefCount )
retain();
}
void Media::retain()
......
......@@ -330,7 +330,7 @@ public:
std::vector<MediaTrack> tracks();
private:
explicit Media(InternalPtr ptr);
explicit Media(InternalPtr ptr, bool increaseRefCount );
/**
* Retain a reference to a media descriptor object (libvlc_media_t). Use
* Media::release() to decrement the reference count of a media
......
......@@ -114,7 +114,7 @@ int MediaList::count()
Media MediaList::itemAtIndex(int i_pos)
{
Media::InternalPtr ptr = libvlc_media_list_item_at_index(m_obj, i_pos);
return Media( ptr );
return Media( ptr, false );
}
int MediaList::indexOfItem( Media &md )
......
......@@ -59,7 +59,7 @@ MediaListPlayer::~MediaListPlayer()
release();
}
MediaListPlayer MediaListPlayer::create(Instance& instance)
MediaListPlayer MediaListPlayer::create( Instance& instance )
{
InternalPtr ptr = libvlc_media_list_player_new( instance );
return MediaListPlayer( ptr );
......
......@@ -70,13 +70,13 @@ MediaPlayer::~MediaPlayer()
MediaPlayer MediaPlayer::create( Instance& instance )
{
InternalPtr ptr = libvlc_media_player_new( instance );
return MediaPlayer( ptr );
return MediaPlayer( ptr, false );
}
MediaPlayer MediaPlayer::fromMedia( Media& md )
{
InternalPtr ptr = libvlc_media_player_new_from_media( md );
return MediaPlayer( ptr );
return MediaPlayer( ptr, false );
}
void MediaPlayer::setMedia( Media& md )
......@@ -87,7 +87,7 @@ void MediaPlayer::setMedia( Media& md )
Media MediaPlayer::media()
{
libvlc_media_t* media = libvlc_media_player_get_media(m_obj);
return Media(media);
return Media( media, false );
}
EventManager& MediaPlayer::eventManager()
......@@ -648,10 +648,12 @@ void MediaPlayer::setAdjustFloat(unsigned option, float value)
libvlc_video_set_adjust_float(m_obj, option, value);
}
MediaPlayer::MediaPlayer( InternalPtr ptr )
MediaPlayer::MediaPlayer( InternalPtr ptr, bool increaseRefCount )
: Internal( ptr )
, m_eventManager( NULL )
{
if ( increaseRefCount )
retain();
}
void MediaPlayer::retain()
......
......@@ -1211,7 +1211,7 @@ public:
void setAdjustFloat(unsigned option, float value);
private:
explicit MediaPlayer( InternalPtr ptr );
explicit MediaPlayer( InternalPtr ptr, bool increaseRefCount );
/**
* Release a media_player after use Decrement the reference count of a
* media player object. If the reference count is 0, then
......
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