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

Reduce the usage of word "File" when it's actually a "Media"

parent f7ca92fa
......@@ -36,8 +36,8 @@ class IMedia
public:
enum class Type : uint8_t
{
VideoType, // Any video file, not being a tv show episode
AudioType, // Any kind of audio file, not being an album track
VideoType,
AudioType,
UnknownType
};
virtual ~IMedia() = default;
......@@ -47,7 +47,7 @@ class IMedia
virtual const std::string& title() = 0;
virtual AlbumTrackPtr albumTrack() const = 0;
/**
* @brief duration Returns the file duration in ms
* @brief duration Returns the media duration in ms
*/
virtual int64_t duration() const = 0;
virtual ShowEpisodePtr showEpisode() const = 0;
......@@ -74,7 +74,7 @@ class IMedia
virtual std::vector<VideoTrackPtr> videoTracks() = 0;
virtual std::vector<AudioTrackPtr> audioTracks() = 0;
///
/// \brief thumbnail Returns the path of a thumbnail for this file
/// \brief thumbnail Returns the path of a thumbnail for this media
/// \return A path, relative to the thumbnailPath configured when initializing
/// The media library
///
......
......@@ -40,19 +40,17 @@ class IMediaLibraryCb
public:
virtual ~IMediaLibraryCb() = default;
/**
* @brief onFileAdded Will be called when a file gets added.
* Depending if the file is being restored or was just discovered,
* the file type might be a best effort guess. If the file was freshly
* @brief onFileAdded Will be called when a media gets added.
* Depending if the media is being restored or was just discovered,
* the media type might be a best effort guess. If the media was freshly
* discovered, it is extremely likely that no metadata will be
* available yet.
* @param file
*/
virtual void onFileAdded( MediaPtr file ) = 0;
virtual void onMediaAdded( MediaPtr media ) = 0;
/**
* @brief onFileUpdated Will be called when a file metadata gets updated.
* @param file The updated file.
*/
virtual void onFileUpdated( MediaPtr file ) = 0;
virtual void onFileUpdated( MediaPtr media ) = 0;
virtual void onDiscoveryStarted( const std::string& entryPoint ) = 0;
virtual void onDiscoveryCompleted( const std::string& entryPoint ) = 0;
......
......@@ -103,7 +103,7 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
unsigned int lastModificationDate();
/// Explicitely mark a file as fully parsed, meaning no metadata service needs to run anymore.
/// Explicitely mark a media as fully parsed, meaning no metadata service needs to run anymore.
//FIXME: This lacks granularity as we don't have a straight forward way to know which service
//needs to run or not.
void markParsed();
......
......@@ -232,15 +232,15 @@ std::shared_ptr<Media> MediaLibrary::addFile( const std::string& path, Folder& p
return nullptr;
}
if ( m_callback != nullptr )
m_callback->onFileAdded( fptr );
m_callback->onMediaAdded( fptr );
if ( m_parser != nullptr )
m_parser->parse( fptr );
return fptr;
}
bool MediaLibrary::deleteFile( const Media* file )
bool MediaLibrary::deleteFile(const Media* media )
{
return Media::destroy( m_dbConnection.get(), file->id() );
return Media::destroy( m_dbConnection.get(), media->id() );
}
bool MediaLibrary::deleteFolder( const Folder* folder )
......
......@@ -54,7 +54,7 @@ class MediaLibrary : public IMediaLibrary
virtual std::vector<MediaPtr> audioFiles() override;
virtual std::vector<MediaPtr> videoFiles() override;
std::shared_ptr<Media> addFile( const std::string& path, Folder& parentFolder, fs::IDirectory& parentFolderFs );
virtual bool deleteFile(const Media* file );
bool deleteFile( const Media* media );
bool deleteFolder( const Folder* folder );
std::shared_ptr<Device> device( const std::string& uuid );
......
......@@ -66,13 +66,13 @@ void Parser::addService( std::unique_ptr<IMetadataService> service )
});
}
void Parser::parse( std::shared_ptr<Media> file )
void Parser::parse( std::shared_ptr<Media> media )
{
std::lock_guard<std::mutex> lock( m_lock );
if ( m_services.size() == 0 )
return;
m_tasks.push( new Task( file, m_services, m_callback ) );
m_tasks.push( new Task( media, m_services, m_callback ) );
m_opToDo += m_services.size();
updateStats();
if ( m_paused == false )
......@@ -126,14 +126,14 @@ void Parser::run()
}
try
{
(*task->it)->run( task->file, task );
(*task->it)->run( task->media, task );
// Consider the task invalid starting from this point. If it completed
// it cleared itself afterward.
}
catch (const std::exception& ex)
{
LOG_ERROR( "Caught an exception during ", task->file->mrl(), " parsing: ", ex.what() );
done( task->file, IMetadataService::Status::Fatal, task );
LOG_ERROR( "Caught an exception during ", task->media->mrl(), " parsing: ", ex.what() );
done( task->media, IMetadataService::Status::Fatal, task );
}
}
LOG_INFO("Exiting Parser thread");
......@@ -168,15 +168,15 @@ void Parser::updateStats()
}
}
Parser::Task::Task( std::shared_ptr<Media> file, Parser::ServiceList& serviceList, IMediaLibraryCb* metadataCb )
: file( file )
Parser::Task::Task( std::shared_ptr<Media> media, Parser::ServiceList& serviceList, IMediaLibraryCb* metadataCb )
: media( media )
, it( serviceList.begin() )
, end( serviceList.end() )
, cb( metadataCb )
{
}
void Parser::done( std::shared_ptr<Media> file, IMetadataService::Status status, void* data )
void Parser::done( std::shared_ptr<Media> media, IMetadataService::Status status, void* data )
{
++m_opDone;
updateStats();
......@@ -191,13 +191,13 @@ void Parser::done( std::shared_ptr<Media> file, IMetadataService::Status status,
else if ( status == IMetadataService::Status::Success )
{
if ( t->cb != nullptr )
t->cb->onFileUpdated( file );
t->cb->onFileUpdated( media );
}
++t->it;
if (t->it == t->end)
{
file->markParsed();
media->markParsed();
delete t;
return;
}
......
......@@ -38,13 +38,13 @@ public:
Parser( DBConnection dbConnection, IMediaLibraryCb* cb );
~Parser();
void addService( std::unique_ptr<IMetadataService> service );
void parse( std::shared_ptr<Media> file );
void parse( std::shared_ptr<Media> media );
void start();
void pause();
void resume();
private:
virtual void done( std::shared_ptr<Media> file, IMetadataService::Status status, void* data ) override;
virtual void done( std::shared_ptr<Media> media, IMetadataService::Status status, void* data ) override;
void run();
// Queues all unparsed files for parsing.
void restore();
......@@ -55,8 +55,8 @@ private:
typedef std::vector<ServicePtr> ServiceList;
struct Task
{
Task( std::shared_ptr<Media> file, ServiceList& serviceList, IMediaLibraryCb* metadataCb );
std::shared_ptr<Media> file;
Task( std::shared_ptr<Media> media, ServiceList& serviceList, IMediaLibraryCb* metadataCb );
std::shared_ptr<Media> media;
ServiceList::iterator it;
ServiceList::iterator end;
IMediaLibraryCb* cb;
......
......@@ -56,26 +56,26 @@ unsigned int VLCMetadataService::priority() const
return 100;
}
void VLCMetadataService::run( std::shared_ptr<Media> file, void* data )
void VLCMetadataService::run( std::shared_ptr<Media> media, void* data )
{
if ( file->duration() != -1 )
if ( media->duration() != -1 )
{
LOG_INFO( file->mrl(), " was already parsed" );
m_cb->done( file, Status::Success, data );
LOG_INFO( media->mrl(), " was already parsed" );
m_cb->done( media, Status::Success, data );
return;
}
LOG_INFO( "Parsing ", file->mrl() );
LOG_INFO( "Parsing ", media->mrl() );
auto chrono = std::chrono::steady_clock::now();
auto ctx = new Context( file );
auto ctx = new Context( media );
std::unique_ptr<Context> ctxPtr( ctx );
ctx->media = VLC::Media( m_instance, file->mrl(), VLC::Media::FromPath );
ctx->vlcMedia = VLC::Media( m_instance, media->mrl(), VLC::Media::FromPath );
std::unique_lock<std::mutex> lock( m_mutex );
bool done = false;
ctx->media.eventManager().onParsedChanged([this, ctx, &done, &chrono](bool parsed) {
ctx->vlcMedia.eventManager().onParsedChanged([this, ctx, &done, &chrono](bool parsed) {
if ( parsed == false )
return;
auto duration = std::chrono::steady_clock::now() - chrono;
......@@ -84,17 +84,17 @@ void VLCMetadataService::run( std::shared_ptr<Media> file, void* data )
done = true;
m_cond.notify_all();
});
ctx->media.parseAsync();
ctx->vlcMedia.parseAsync();
auto success = m_cond.wait_for( lock, std::chrono::seconds( 5 ), [&done]() { return done == true; } );
if ( success == false )
m_cb->done( ctx->file, Status::Fatal, data );
m_cb->done( ctx->media, Status::Fatal, data );
else
{
auto status = handleMediaMeta( ctx->file, ctx->media );
m_cb->done( ctx->file, status, data );
auto status = handleMediaMeta( ctx->media, ctx->vlcMedia );
m_cb->done( ctx->media, status, data );
}
auto duration = std::chrono::steady_clock::now() - chrono;
LOG_DEBUG( "Parsed ", file->mrl(), " in ", std::chrono::duration_cast<std::chrono::milliseconds>( duration ).count(), "ms" );
LOG_DEBUG( "Parsed ", media->mrl(), " in ", std::chrono::duration_cast<std::chrono::milliseconds>( duration ).count(), "ms" );
}
IMetadataService::Status VLCMetadataService::handleMediaMeta( std::shared_ptr<Media> media, VLC::Media& vlcMedia ) const
......@@ -144,13 +144,13 @@ IMetadataService::Status VLCMetadataService::handleMediaMeta( std::shared_ptr<Me
/* Video files */
bool VLCMetadataService::parseVideoFile( std::shared_ptr<Media> file, VLC::Media& media ) const
bool VLCMetadataService::parseVideoFile( std::shared_ptr<Media> media, VLC::Media& vlcMedia ) const
{
file->setType( IMedia::Type::VideoType );
auto title = media.meta( libvlc_meta_Title );
media->setType( IMedia::Type::VideoType );
auto title = vlcMedia.meta( libvlc_meta_Title );
if ( title.length() == 0 )
return true;
auto showName = media.meta( libvlc_meta_ShowName );
auto showName = vlcMedia.meta( libvlc_meta_ShowName );
if ( showName.length() == 0 )
{
auto show = m_ml->show( showName );
......@@ -161,7 +161,7 @@ bool VLCMetadataService::parseVideoFile( std::shared_ptr<Media> file, VLC::Media
return false;
}
auto episodeIdStr = media.meta( libvlc_meta_Episode );
auto episodeIdStr = vlcMedia.meta( libvlc_meta_Episode );
if ( episodeIdStr.length() > 0 )
{
size_t endpos;
......@@ -172,7 +172,7 @@ bool VLCMetadataService::parseVideoFile( std::shared_ptr<Media> file, VLC::Media
return true;
}
std::shared_ptr<Show> s = std::static_pointer_cast<Show>( show );
s->addEpisode( *file, title, episodeId );
s->addEpisode( *media, title, episodeId );
}
}
else
......
......@@ -34,13 +34,13 @@ class VLCMetadataService : public IMetadataService
{
struct Context
{
explicit Context(std::shared_ptr<Media> file_)
: file( file_ )
explicit Context( std::shared_ptr<Media> media_ )
: media( media_ )
{
}
std::shared_ptr<Media> file;
VLC::Media media;
std::shared_ptr<Media> media;
VLC::Media vlcMedia;
};
public:
......@@ -48,13 +48,13 @@ class VLCMetadataService : public IMetadataService
virtual bool initialize( IMetadataServiceCb *callback, MediaLibrary* ml ) override;
virtual unsigned int priority() const override;
virtual void run( std::shared_ptr<Media> file, void *data ) override;
virtual void run( std::shared_ptr<Media> media, void *data ) override;
private:
Status handleMediaMeta( std::shared_ptr<Media> media , VLC::Media &vlcMedia ) const;
std::shared_ptr<Album> findAlbum(Media& media, VLC::Media& vlcMedia, const std::string& title, Artist* albumArtist ) const;
bool parseAudioFile(Media& media, VLC::Media &vlcMedia ) const;
bool parseVideoFile( std::shared_ptr<Media> file, VLC::Media &media ) const;
bool parseAudioFile( Media& media, VLC::Media &vlcMedia ) const;
bool parseVideoFile( std::shared_ptr<Media> media, VLC::Media& vlcMedia ) const;
std::pair<std::shared_ptr<Artist>, std::shared_ptr<Artist>> handleArtists(VLC::Media& vlcMedia ) const;
std::shared_ptr<AlbumTrack> handleTrack(std::shared_ptr<Album> album, Media& media, VLC::Media& vlcMedia , std::shared_ptr<Artist> artist) const;
bool link(Media& media, std::shared_ptr<Album> album, std::shared_ptr<Artist> albumArtist, std::shared_ptr<Artist> artist ) const;
......
......@@ -94,57 +94,57 @@ bool VLCThumbnailer::initialize(IMetadataServiceCb *callback, MediaLibrary* ml)
unsigned int VLCThumbnailer::priority() const
{
// This needs to be lower than the VLCMetadataService, since we want to know the file type.
// This needs to be lower than the VLCMetadataService, since we want to know the media type.
return 50;
}
void VLCThumbnailer::run(std::shared_ptr<Media> file, void *data )
void VLCThumbnailer::run( std::shared_ptr<Media> media, void *data )
{
if ( file->type() == IMedia::Type::UnknownType )
if ( media->type() == IMedia::Type::UnknownType )
{
// If we don't know the file type yet, it actually looks more like a bug
// since this should run after file type deduction, and not run in case
// If we don't know the media type yet, it actually looks more like a bug
// since this should run after media type deduction, and not run in case
// that step fails.
m_cb->done( file, Status::Fatal, data );
m_cb->done( media, Status::Fatal, data );
return;
}
else if ( file->type() != IMedia::Type::VideoType )
else if ( media->type() != IMedia::Type::VideoType )
{
// There's no point in generating a thumbnail for a non-video file.
m_cb->done( file, Status::Success, data );
// There's no point in generating a thumbnail for a non-video media.
m_cb->done( media, Status::Success, data );
return;
}
else if ( file->thumbnail().empty() == false )
else if ( media->thumbnail().empty() == false )
{
LOG_INFO(file->thumbnail(), " already has a thumbnail" );
m_cb->done( file, Status::Success, data );
LOG_INFO(media->thumbnail(), " already has a thumbnail" );
m_cb->done( media, Status::Success, data );
return;
}
LOG_INFO( "Generating ", file->mrl(), " thumbnail..." );
LOG_INFO( "Generating ", media->mrl(), " thumbnail..." );
VLC::Media media( m_instance, file->mrl(), VLC::Media::FromPath );
media.addOption( ":no-audio" );
VLC::MediaPlayer mp( media );
VLC::Media vlcMedia( m_instance, media->mrl(), VLC::Media::FromPath );
vlcMedia.addOption( ":no-audio" );
VLC::MediaPlayer mp( vlcMedia );
setupVout( mp );
if ( startPlayback( file, mp, data ) == false )
if ( startPlayback( media, mp, data ) == false )
{
LOG_WARN( "Failed to generate ", file->mrl(), " thumbnail" );
LOG_WARN( "Failed to generate ", media->mrl(), " thumbnail" );
return;
}
// Seek ahead to have a significant preview
if ( seekAhead( file, mp, data ) == false )
if ( seekAhead( media, mp, data ) == false )
{
LOG_WARN( "Failed to generate ", file->mrl(), " thumbnail" );
LOG_WARN( "Failed to generate ", media->mrl(), " thumbnail" );
return;
}
takeThumbnail( file, mp, data );
LOG_INFO( "Done generating ", file->mrl(), " thumbnail" );
takeThumbnail( media, mp, data );
LOG_INFO( "Done generating ", media->mrl(), " thumbnail" );
}
bool VLCThumbnailer::startPlayback(std::shared_ptr<Media> file, VLC::MediaPlayer &mp, void* data )
bool VLCThumbnailer::startPlayback(std::shared_ptr<Media> media, VLC::MediaPlayer &mp, void* data )
{
mp.eventManager().onPlaying([this]() {
......@@ -163,13 +163,13 @@ bool VLCThumbnailer::startPlayback(std::shared_ptr<Media> file, VLC::MediaPlayer
if ( success == false || s == libvlc_Error || s == libvlc_Ended )
{
// In case of timeout or error, don't go any further
m_cb->done( file, Status::Error, data );
m_cb->done( media, Status::Error, data );
return false;
}
return true;
}
bool VLCThumbnailer::seekAhead(std::shared_ptr<Media> file, VLC::MediaPlayer& mp, void* data )
bool VLCThumbnailer::seekAhead(std::shared_ptr<Media> media, VLC::MediaPlayer& mp, void* data )
{
std::unique_lock<std::mutex> lock( m_mutex );
float pos = .0f;
......@@ -186,7 +186,7 @@ bool VLCThumbnailer::seekAhead(std::shared_ptr<Media> file, VLC::MediaPlayer& mp
event->unregister();
if ( success == false )
{
m_cb->done( file, Status::Error, data );
m_cb->done( media, Status::Error, data );
return false;
}
return true;
......@@ -244,7 +244,7 @@ void VLCThumbnailer::setupVout( VLC::MediaPlayer& mp )
);
}
bool VLCThumbnailer::takeThumbnail(std::shared_ptr<Media> file, VLC::MediaPlayer &mp, void *data)
bool VLCThumbnailer::takeThumbnail(std::shared_ptr<Media> media, VLC::MediaPlayer &mp, void *data)
{
// lock, signal that we want a thumbnail, and wait.
{
......@@ -256,12 +256,12 @@ bool VLCThumbnailer::takeThumbnail(std::shared_ptr<Media> file, VLC::MediaPlayer
});
if ( success == false )
{
m_cb->done( file, Status::Error, data );
m_cb->done( media, Status::Error, data );
return false;
}
}
mp.stop();
return compress( file, data );
return compress( media, data );
}
#ifdef WITH_JPEG
......@@ -281,11 +281,11 @@ struct jpegError : public jpeg_error_mgr
#endif
bool VLCThumbnailer::compress( std::shared_ptr<Media> file, void *data )
bool VLCThumbnailer::compress( std::shared_ptr<Media> media, void *data )
{
auto path = m_ml->thumbnailPath();
path += "/";
path += std::to_string( file->id() ) +
path += std::to_string( media->id() ) +
#ifdef WITH_EVAS
".png";
#else
......@@ -302,7 +302,7 @@ bool VLCThumbnailer::compress( std::shared_ptr<Media> file, void *data )
if ( fOut == nullptr )
{
LOG_ERROR("Failed to open thumbnail file ", path);
m_cb->done( file, Status::Error, data );
m_cb->done( media, Status::Error, data );
return false;
}
......@@ -319,7 +319,7 @@ bool VLCThumbnailer::compress( std::shared_ptr<Media> file, void *data )
{
LOG_ERROR("JPEG failure: ", err.message);
jpeg_destroy_compress(&compInfo);
m_cb->done( file, Status::Error, data );
m_cb->done( media, Status::Error, data );
return false;
}
......@@ -368,10 +368,10 @@ bool VLCThumbnailer::compress( std::shared_ptr<Media> file, void *data )
#error FIXME
#endif
file->setThumbnail( path );
if ( file->save() == false )
m_cb->done( file, Status::Error, data );
media->setThumbnail( path );
if ( media->save() == false )
m_cb->done( media, Status::Error, data );
else
m_cb->done( file, Status::Success, data );
m_cb->done( media, Status::Success, data );
return true;
}
......@@ -46,17 +46,17 @@ class VLCThumbnailer : public IMetadataService
{
public:
explicit VLCThumbnailer( const VLC::Instance& vlc );
~VLCThumbnailer();
virtual ~VLCThumbnailer();
virtual bool initialize(IMetadataServiceCb *callback, MediaLibrary *ml) override;
virtual unsigned int priority() const override;
virtual void run(std::shared_ptr<Media> file, void *data) override;
virtual void run( std::shared_ptr<Media> media, void *data ) override;
private:
bool startPlayback( std::shared_ptr<Media> file, VLC::MediaPlayer& mp, void *data);
bool seekAhead(std::shared_ptr<Media> file, VLC::MediaPlayer &mp, void *data);
bool startPlayback( std::shared_ptr<Media> media, VLC::MediaPlayer& mp, void *data);
bool seekAhead( std::shared_ptr<Media> media, VLC::MediaPlayer &mp, void *data);
void setupVout(VLC::MediaPlayer &mp);
bool takeThumbnail(std::shared_ptr<Media> file, VLC::MediaPlayer &mp, void* data);
bool compress(std::shared_ptr<Media> file, void* data );
bool takeThumbnail(std::shared_ptr<Media> media, VLC::MediaPlayer &mp, void* data);
bool compress(std::shared_ptr<Media> media, void* data );
private:
// Force a base width, let height be computed depending on A/R
......
......@@ -33,7 +33,7 @@ namespace mock
class WaitForDiscoveryComplete : public IMediaLibraryCb
{
public:
virtual void onFileAdded( MediaPtr ) override
virtual void onMediaAdded( MediaPtr ) override
{
}
......
......@@ -21,7 +21,7 @@ public:
bool waitForParsingComplete();
private:
void onFileAdded(MediaPtr) {}
void onMediaAdded(MediaPtr) {}
void onFileUpdated(MediaPtr) {}
void onDiscoveryStarted(const std::string&) {}
void onDiscoveryCompleted(const std::string&);
......
......@@ -62,8 +62,8 @@ TEST_F( AlbumTracks, Artist )
Reload();
// Don't reuse the "track" and "f" variable, their type differ
auto file = ml->media( f->id() );
auto albumTrack = file->albumTrack();
auto media = ml->media( f->id() );
auto albumTrack = media->albumTrack();
artist = albumTrack->artist();
ASSERT_NE( nullptr, artist );
ASSERT_EQ( newArtist->name(), artist->name() );
......
......@@ -114,8 +114,8 @@ TEST_F( DeviceFs, RemoveDisk )
auto files = ml->files();
ASSERT_EQ( 5u, files.size() );
auto file = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ASSERT_NE( nullptr, file );
auto media = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ASSERT_NE( nullptr, media );
fsMock->removeDevice( RemovableDeviceUuid );
......@@ -127,8 +127,8 @@ TEST_F( DeviceFs, RemoveDisk )
files = ml->files();
ASSERT_EQ( 3u, files.size() );
file = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ASSERT_EQ( nullptr, file );
media = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ASSERT_EQ( nullptr, media );
}
TEST_F( DeviceFs, UnmountDisk )
......@@ -141,8 +141,8 @@ TEST_F( DeviceFs, UnmountDisk )
auto files = ml->files();
ASSERT_EQ( 5u, files.size() );
auto file = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ASSERT_NE( nullptr, file );
auto media = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ASSERT_NE( nullptr, media );
auto device = std::static_pointer_cast<mock::Device>( fsMock->createDevice( RemovableDeviceUuid ) );
device->setPresent( false );
......@@ -155,8 +155,8 @@ TEST_F( DeviceFs, UnmountDisk )
files = ml->files();
ASSERT_EQ( 3u, files.size() );
file = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ASSERT_EQ( nullptr, file );
media = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ASSERT_EQ( nullptr, media );
}
TEST_F( DeviceFs, ReplugDisk )
......@@ -169,8 +169,8 @@ TEST_F( DeviceFs, ReplugDisk )
auto files = ml->files();
ASSERT_EQ( 5u, files.size() );
auto file = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ASSERT_NE( nullptr, file );
auto media = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ASSERT_NE( nullptr, media );
auto device = fsMock->removeDevice( RemovableDeviceUuid );
......@@ -182,8 +182,8 @@ TEST_F( DeviceFs, ReplugDisk )
files = ml->files();
ASSERT_EQ( 3u, files.size() );
file = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ASSERT_EQ( nullptr, file );
media = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ASSERT_EQ( nullptr, media );
fsMock->addDevice( device );
cbMock->prepareForReload();
......@@ -194,8 +194,8 @@ TEST_F( DeviceFs, ReplugDisk )
files = ml->files();
ASSERT_EQ( 5u, files.size() );
file = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ASSERT_NE( nullptr, file );
media = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ASSERT_NE( nullptr, media );
}
TEST_F( DeviceFs, ReplugDiskWithExtraFiles )
......@@ -240,18 +240,18 @@ TEST_F( DeviceFs, RemoveAlbum )
// Create an album on a non-removable device
{
auto album = std::static_pointer_cast<Album>( ml->createAlbum( "album" ) );
auto file = ml->media( mock::FileSystemFactory::Root + "audio.mp3" );
album->addTrack( static_cast<Media&>( *file ), 1, 1 );
auto media = ml->media( mock::FileSystemFactory::Root + "audio.mp3" );
album->addTrack( static_cast<Media&>( *media ), 1, 1 );
auto artist = ml->createArtist( "artist" );
album->setAlbumArtist( artist.get() );
}
// And an album that will disappear, along with its artist
{
auto album = std::static_pointer_cast<Album>( ml->createAlbum( "album 2" ) );
auto file = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
auto media = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ml->media( RemovableDeviceMountpoint + "removablefile2.mp3" );
album->addTrack( static_cast<Media&>( *file ), 1, 1 );
album->addTrack( static_cast<Media&>( *file ), 2, 1 );
album->addTrack( static_cast<Media&>( *media ), 1, 1 );
album->addTrack( static_cast<Media&>( *media ), 2, 1 );
auto artist = ml->createArtist( "artist 2" );
album->setAlbumArtist( artist.get() );
}
......@@ -283,13 +283,13 @@ TEST_F( DeviceFs, PartialAlbumRemoval )
{
auto album = std::static_pointer_cast<Album>( ml->createAlbum( "album" ) );
auto file = ml->media( mock::FileSystemFactory::SubFolder + "subfile.mp4" );
auto media = ml->media( mock::FileSystemFactory::SubFolder + "subfile.mp4" );
auto file2 = ml->media( RemovableDeviceMountpoint + "removablefile2.mp3" );
album->addTrack( static_cast<Media&>( *file ), 1, 1 );
album->addTrack( static_cast<Media&>( *media ), 1, 1 );
album->addTrack( static_cast<Media&>( *file2 ), 2, 1 );
auto newArtist = ml->createArtist( "artist" );
album->setAlbumArtist( newArtist.get() );
newArtist->addMedia( static_cast<Media&>( *file ) );
newArtist->addMedia( static_cast<Media&>( *media ) );
newArtist->addMedia( static_cast<Media&>( *file2 ) );
}
......@@ -321,7 +321,7 @@ TEST_F( DeviceFs, ChangeDevice )
bool discovered = cbMock->wait();
ASSERT_TRUE( discovered );
// Fetch a removable file's ID
// Fetch a removable media's ID
auto f = ml->media( RemovableDeviceMountpoint + "removablefile.mp3" );
ASSERT_NE( f, nullptr );
auto firstRemovableFileId = f->id();
......
......@@ -166,8 +166,8 @@ TEST_F( Folders, ListFolders )
auto subFiles = subFolder->files();
ASSERT_EQ( 1u, subFiles.size() );
auto file = subFiles[0];
ASSERT_EQ( mock::FileSystemFactory::SubFolder + "subfile.mp4", file->mrl() );
auto media = subFiles[0];
ASSERT_EQ( mock::FileSystemFactory::SubFolder + "subfile.mp4", media->mrl() );
// Now again, without cache. No need to wait for fs discovery reload here
Reload();
......@@ -180,8 +180,8 @@ TEST_F( Folders, ListFolders )
subFiles = subFolder->files();
ASSERT_EQ( 1u, subFiles.size() );
file = subFiles[0];
ASSERT_EQ( mock::FileSystemFactory::SubFolder + "subfile.mp4", file->mrl() );
media = subFiles[0];
ASSERT_EQ( mock::FileSystemFactory::SubFolder + "subfile.mp4", media->mrl() );
}
TEST_F( Folders, NewFolderWithFile )
......@@ -231,10 +231,10 @@ TEST_F( Folders, NewFileInSubFolder )
ASSERT_TRUE( reloaded );