This document explains the flow of acquiring the song map in the inLimbo Music Player. The process involves mapping inodes to file paths, traversing a Red-Black Tree (RBT) to organize song metadata, and eventually serializing the data into a binary file that can be parsed by the UI. Below is a step-by-step diagrammatic explanation of the flow, which includes how the inodes are mapped, metadata is processed, and the final song map is prepared for display.
The process of acquiring and displaying the song map follows these general stages:
TagLibParser.lib.bin) for easy access.InodeFileMapperWe begin by processing directories and mapping inodes to their respective file paths. This is achieved through the InodeFileMapper class, which stores the mappings in an internal unordered_map and writes them to a synchronization file (lib.sync).
processDirectory function reads each file in the specified directory, retrieves the inode using stat(), and adds it to the Red-Black Tree.addMapping method of InodeFileMapper.The inodes obtained from the previous step are inserted into a Red-Black Tree (RedBlackTree class) to maintain a balanced structure.
RedBlackTree via the insert() method.fixInsert() method to ensure that Red-Black Tree properties (such as node color and structure) are maintained.Once the tree is populated, we traverse it in an inorder fashion. During this traversal, we extract metadata for each file using the TagLibParser class. This metadata typically includes information such as the song title, artist, album, and more.
inorderHelper() method).TagLibParser to extract metadata from the corresponding file (song title, artist, etc.).SongTree, which stores the songs in a structured manner.lib.binAfter collecting the song metadata, we serialize the data into a binary file (lib.bin). This file is saved in the user's home directory ($HOME/.config/inLimbo) for future use.
SongTree is serialized into the lib.bin file for persistent storage.$HOME/.config/inLimbo/ directory.Finally, the lib.bin file is loaded by the UI, which parses the data structure to provide an interactive and user-friendly interface for browsing and controlling the music files.
lib.bin file to retrieve the stored song metadata.lib.bin as a cache file (static load of songmap)The flow from mapping inodes to building the song map is a multi-step process involving directory traversal, inode mapping, Red-Black Tree insertion, metadata extraction, serialization, and finally UI display. This ensures that inLimbo can efficiently process and manage large music libraries, making metadata accessible in a user-friendly manner.