@@ -462,10 +462,10 @@ auto maybeHandleEditActions(AppContext& ctx) -> bool
462462 }
463463
464464 // Persist updated SongMap to disk
465- SongTree tempSongTree ;
466- tempSongTree .clear ();
467- tempSongTree .newSongMap (g_songMap.snapshot ());
468- tempSongTree .saveToFile (ctx.m_binPath );
465+ SongLibrarySnapshot tempSongLib ;
466+ tempSongLib .clear ();
467+ tempSongLib .newSongMap (g_songMap.snapshot ());
468+ tempSongLib .saveToFile (ctx.m_binPath );
469469
470470 LOG_DEBUG (" Song object metadata updated successfully. Exiting app..." );
471471 return true ;
@@ -545,13 +545,13 @@ auto initializeContext(int argc, char** argv) -> AppContext
545545
546546void buildOrLoadLibrary (AppContext& ctx)
547547{
548- SongTree tempSongTree ;
549- bool rebuild = ctx.args .rebuildLibrary ;
548+ SongLibrarySnapshot tempSongLib ;
549+ bool rebuild = ctx.args .rebuildLibrary ;
550550
551551 try
552552 {
553- tempSongTree .loadFromFile (ctx.m_binPath );
554- if (tempSongTree .returnMusicPath () != ctx.m_musicDir )
553+ tempSongLib .loadFromFile (ctx.m_binPath );
554+ if (tempSongLib .returnMusicPath () != ctx.m_musicDir )
555555 rebuild = true ;
556556 }
557557 catch (...)
@@ -562,26 +562,28 @@ void buildOrLoadLibrary(AppContext& ctx)
562562 if (!rebuild)
563563 {
564564 LOG_INFO (" No song map rebuild. Loading song map and sorting..." );
565- g_songMap.replace (tempSongTree.moveSongMap ());
565+ g_songMap.replace (tempSongLib.moveSongMap ());
566+ // loads any changes in sorting plan from config
566567 const auto plan = config::sort::loadRuntimeSortPlan ();
567568 query::songmap::mut::sortSongMap (g_songMap, plan);
568569 return ;
569570 }
570571
571572 utils::Timer<> timer;
572573 timer.start ();
573- tempSongTree .clear ();
574+ tempSongLib .clear ();
574575
575- helpers::fs::dirWalkProcessAll (ctx.m_musicDir , ctx.m_tagLibParser , tempSongTree );
576+ helpers::fs::dirWalkProcessAll (ctx.m_musicDir , ctx.m_tagLibParser , tempSongLib );
576577
577- tempSongTree .setMusicPath (ctx.m_musicDir );
578- g_songMap.replace (tempSongTree .moveSongMap ());
579- // the song map is unordered so lets sort it
578+ tempSongLib .setMusicPath (ctx.m_musicDir );
579+ g_songMap.replace (tempSongLib .moveSongMap ());
580+ // the fresh song map is unordered so lets sort it
580581 //
581582 // note that by default, we are only sorting this following:
582583 //
583584 // -> artists in ascending order (lexicographically),
584585 // -> albums in ascending order (lexicographically),
586+ // -> discs in ascending order (numerically),
585587 // -> tracks in ascending order (numerically)
586588 //
587589 // as that is most logical.
@@ -592,10 +594,10 @@ void buildOrLoadLibrary(AppContext& ctx)
592594 query::songmap::mut::sortSongMap (g_songMap, plan);
593595
594596 // now let us save the newly sorted song map to disk
595- tempSongTree .newSongMap (g_songMap.snapshot ());
596- tempSongTree .saveToFile (ctx.m_binPath );
597+ tempSongLib .newSongMap (g_songMap.snapshot ());
598+ tempSongLib .saveToFile (ctx.m_binPath );
597599
598- // SongTree has destructor so mem shud clear here
600+ // SongLibrarySnapshot has destructor so mem shud clear here
599601 LOG_INFO (" Library rebuilt in {:.3f} ms" , timer.elapsed_ms ());
600602}
601603
@@ -637,10 +639,13 @@ void runFrontend(AppContext& ctx)
637639 LOG_INFO (" Fuzzy search song title query returned: '{}'" , song->metadata .title );
638640
639641 // ---------------------------------------------------------
640- // Create AudioService (owns AudioEngine)
642+ // Create audio::Service
641643 // ---------------------------------------------------------
642644 audio::Service audio (g_songMap, ctx.m_audioBackendName );
643645
646+ // ---------------------------------------------------------
647+ // Create mpris::Service (common backend logic)
648+ // ---------------------------------------------------------
644649 mpris::backend::Common mprisBackend (audio);
645650 mpris::Service mprisService (mprisBackend, APP_NAME );
646651
@@ -707,15 +712,15 @@ void runFrontend(AppContext& ctx)
707712 }
708713 catch (const utils::unix::LockFileError& e)
709714 {
710- LOG_ERROR (" Context threw LockFileError: {}" , e.what ());
715+ LOG_ERROR (" unix:: LockFileError: {}" , e.what ());
711716 }
712717 catch (const frontend::PluginError& e)
713718 {
714719 LOG_ERROR (" frontend::PluginError: Context threw Frontend error: {}" , e.what ());
715720 }
716721 catch (std::exception& e)
717722 {
718- LOG_ERROR (" Context threw generic std::exception: '{}'" , e.what ());
723+ LOG_ERROR (" inlimbp::runFrontend threw std::exception: '{}'" , e.what ());
719724 }
720725}
721726
0 commit comments