Skip to content

Commit

Permalink
3rd MDK commit
Browse files Browse the repository at this point in the history
- fixed crashes on artwork images
  • Loading branch information
oomek authored and substring committed Dec 23, 2024
1 parent 08ca471 commit 02f8da9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
25 changes: 15 additions & 10 deletions src/fe_async_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ bool FeAsyncLoader::add_resource( const std::string input_file, bool async )
lock.unlock();
m_condition.notify_one();
}
return true;
}

bool FeAsyncLoader::add_resource_texture( const std::string file, bool async )
Expand Down Expand Up @@ -372,14 +373,12 @@ void FeAsyncLoader::release_resource( const std::string file )
// Stop the playback if it's a video resource
if (it != m_resources_map.end() && static_cast<FeAsyncLoaderEntryVideo*>(it->second->second)->type == FeAsyncLoaderEntryVideo::type)
{
Player* player = static_cast<FeAsyncLoaderEntryVideo*>(it->second->second)->get_player();
Player* player = get_player( file );
sf::Clock clk;
if (player != nullptr)
if ( player != nullptr )
{
// FeLog() << "! player->set(State::Stopped) " << std::endl;
player->seek( 0 );
player->set( State::Paused );
player->seek( 0, SeekFlag::Frame );
// FeLog() << "! player->set(State::Stopped) time:" << clk.getElapsedTime().asMilliseconds() << std::endl;
}
}
}
Expand All @@ -389,7 +388,7 @@ bool FeAsyncLoaderEntryVideo::load_from_file( const std::string file )
m_player.setMedia( file.c_str() );
m_player.prepare();
m_player.setPreloadImmediately( true );
m_player.setLoop(std::numeric_limits<int>::max());
// m_player.setLoop(std::numeric_limits<int>::max());

for(;;)
{
Expand All @@ -409,10 +408,16 @@ bool FeAsyncLoaderEntryVideo::load_from_file( const std::string file )

Player* FeAsyncLoader::get_player( const std::string& file )
{
ulock_t lock( m_mutex );
map_iterator_t it = m_resources_map.find ( file );
if ( it != m_resources_map.end() )
return static_cast<FeAsyncLoaderEntryVideo*>( it->second->second )->get_player();
else
return nullptr;
{
FeAsyncLoaderEntryBase* entry = it->second->second;
if ( entry != nullptr )
{
FeAsyncLoaderEntryVideo* video_entry = dynamic_cast<FeAsyncLoaderEntryVideo*>( entry );
if ( video_entry )
return video_entry->get_player();
}
}
return nullptr;
}
11 changes: 10 additions & 1 deletion src/fe_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ bool FeTextureContainer::try_to_load(
// m_texture = &m_empty_texture;
clear_texture(); // TODO: check if needed

if ( m_video_texture != NULL )
{
if ( m_mipmap ) m_video_texture->generateMipmap();
m_video_texture->setSmooth( m_smooth );
}

// FeLog() << "FeTextureContainer::try_to_load( " << filename << " ) took " << clk.getElapsedTime().asMicroseconds() << std::endl;

FeLog() << "try_to_load: " << clk.getElapsedTime().asMilliseconds() << std::endl;
Expand Down Expand Up @@ -589,7 +595,9 @@ void FeTextureContainer::internal_update_selection( FeSettings *feSettings )
bool FeTextureContainer::tick( FeSettings *feSettings, bool play_movies )
{
if ( m_player )
if ( m_player->state() != State::Playing ) m_player->set( State::Playing );
if ( m_player->state() != State::Playing )
m_player->set( State::Playing );

//
// We have an m_entry if the image is being loaded in the background
//
Expand Down Expand Up @@ -880,6 +888,7 @@ void FeTextureContainer::clear()
// FeLog() << "FeTextureContainer::clear() " << clk.getElapsedTime().asMilliseconds() << std::endl;
m_player = NULL;
m_file_name.clear();
m_video_texture = NULL;

#ifndef NO_MOVIE
// If a movie is running, close it...
Expand Down

0 comments on commit 02f8da9

Please sign in to comment.