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

Metadata: Simplify startPlayback

We don't need to know if a video track was detected or not anymore
parent 0386e0b4
......@@ -30,7 +30,7 @@
namespace medialibrary
{
std::pair<medialibrary::parser::Task::Status, bool>
medialibrary::parser::Task::Status
medialibrary::MetadataCommon::startPlayback( parser::Task& task,
VLC::MediaPlayer& mp )
{
......@@ -83,7 +83,7 @@ medialibrary::MetadataCommon::startPlayback( parser::Task& task,
// In case the playback failed, we probably won't fetch anything interesting anyway.
if ( failedToStart == true || success == false )
return { parser::Task::Status::Fatal, false };
return parser::Task::Status::Fatal;
// If we have any kind of track, but not a video track, we don't have to wait long, tracks are usually
// being discovered together.
......@@ -104,7 +104,7 @@ medialibrary::MetadataCommon::startPlayback( parser::Task& task,
}
}
return { parser::Task::Status::Success, hasVideoTrack };
return parser::Task::Status::Success;
}
......
......@@ -30,8 +30,7 @@ namespace medialibrary
struct MetadataCommon
{
static std::pair<parser::Task::Status, bool> startPlayback( parser::Task& task,
VLC::MediaPlayer& mp );
static parser::Task::Status startPlayback( parser::Task& task, VLC::MediaPlayer& mp );
};
}
......@@ -80,9 +80,9 @@ parser::Task::Status VLCMetadataService::run( parser::Task& task )
if ( tracks.size() == 0 && task.vlcMedia.subitems()->count() == 0 )
LOG_WARN( "Failed to fetch any tracks for ", mrl, ". Falling back to playback" );
VLC::MediaPlayer mp( task.vlcMedia );
auto resPair = MetadataCommon::startPlayback( task, mp );
if ( resPair.first != parser::Task::Status::Success )
return resPair.first;
auto res = MetadataCommon::startPlayback( task, mp );
if ( res != parser::Task::Status::Success )
return res;
}
// Don't save the file parsing step yet, since all data are just in memory. Just mark
// the extraction as done.
......
......@@ -105,24 +105,24 @@ parser::Task::Status VLCThumbnailer::run( parser::Task& task )
setupVout( mp );
auto resPair = MetadataCommon::startPlayback( task, mp );
if ( resPair.first != parser::Task::Status::Success )
auto res = MetadataCommon::startPlayback( task, mp );
if ( res != parser::Task::Status::Success )
{
LOG_WARN( "Failed to generate ", file->mrl(), " thumbnail: Can't start playback" );
return resPair.first;
return res;
}
if ( duration <= 0 )
{
// Seek ahead to have a significant preview
auto res = seekAhead( mp );
res = seekAhead( mp );
if ( res != parser::Task::Status::Success )
{
LOG_WARN( "Failed to generate ", file->mrl(), " thumbnail: Failed to seek ahead" );
return res;
}
}
auto res = takeThumbnail( media, file, mp );
res = takeThumbnail( media, file, mp );
if ( res != parser::Task::Status::Success )
return res;
......
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