Playlist data structure establishment method and device, storage medium and electronic equipment
Patent Information
- Application Number
- CN202110795991.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-14
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2041-07-14
AI Technical Summary
[0002]相关技术中,播放列表存储于磁盘中,若在向磁盘中写入数据且磁盘正被拔出时,则可能损坏磁盘文件系统,进而导致无法正常读取磁盘文件系统中的数据
[0058]通过上述技术方案,建立的播放列表数据结构未记录各目录项的全路径,因此占用内存较小,如此,便可以将播放列表数据结构保存在小机内存中,以避免因磁盘拔出引起的数据损坏的问题,且记录的属性信息只包括有效文件夹的属性信息,进一步减小了内存占用。
Smart Images

Figure CN115617752B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of storage technology, and more specifically, to a method, apparatus, storage medium, and electronic device for establishing a playlist data structure. Background Technology
[0002] In related technologies, playlists are stored on disk. If data is written to the disk while the disk is being removed, the disk file system may be corrupted, leading to the inability to read data from the disk file system correctly. Therefore, playlists can be stored in the processor's memory to avoid disk file system corruption caused by disk insertion and removal. However, to store playlists in processor memory, it is crucial to ensure that the playlist occupies as little memory as possible; therefore, designing a playlist with a small memory footprint is essential. Summary of the Invention
[0003] The purpose of this disclosure is to provide a method, apparatus, storage medium, and electronic device for establishing a playlist data structure.
[0004] To achieve the above objectives, this disclosure provides a method for establishing a playlist data structure, including:
[0005] In response to the system startup operation, the system traverses preset directory entries. If a directory entry is a valid folder, the system determines the attribute information of the valid folder, wherein the valid folder is a folder containing files of a preset format.
[0006] Based on the attribute information of the valid folders, establish the playlist data structure;
[0007] The attribute information includes the cluster number and the number of files that are the preset format files.
[0008] Optionally, traversing the preset directory items includes:
[0009] Traverse the preset directory items according to the breadth-first traversal principle;
[0010] The playlist data structure then stores the attribute information of all valid folders obtained by traversing according to the breadth-first traversal principle.
[0011] Optionally, determining the attribute information of the valid folder includes:
[0012] Determine that the target directory entry does not exist in the valid folder, wherein the target directory entry is the preset format file and is a directory entry whose cluster number has changed compared to the previous directory entry of the preset format file;
[0013] Count the directory entries in the valid folder that contain the preset format file, and determine the first number of files in the valid folder that contain the preset format file based on the count results;
[0014] Determine the first cluster number of the valid folder;
[0015] The number of the first files and the first cluster number are determined as the attribute information of the valid folder.
[0016] Optionally, determining the attribute information of the valid folder includes:
[0017] Identify the target directory entries present in the valid folder;
[0018] Using the target directory entry as a dividing point, the directory entries containing the preset format files in the valid folder are divided, and multiple valid subfolders are determined based on the division results;
[0019] Count the number of directory entries in the valid subfolders that are files of the preset format, and determine the number of second files in the valid subfolders that are files of the preset format based on the count results;
[0020] Determine the second cluster number of the valid subfolder;
[0021] The attribute information of the valid subfolder is determined based on the second cluster number and the second number of files;
[0022] The step of establishing a playlist data structure based on the attribute information of the valid folder includes:
[0023] Based on the attribute information of the valid subfolders, establish the playlist data structure.
[0024] Optionally, determining the target directory entry existing in the valid folder includes:
[0025] Determine whether the number of directory entries of the preset format files that have been traversed in this round meets the first preset condition;
[0026] If the first preset condition is met, determine whether the cluster number of the current directory item being traversed meets the second preset condition.
[0027] If the second preset condition is met, the current directory item will be determined as the target directory item;
[0028] Starting from the current target directory entry, continue the next round of traversal for the valid folder, and return to execute the step of determining whether the directory entries that have been traversed in this round as the preset format file meet the first preset condition, until all directory entries in the valid folder have been traversed.
[0029] Optionally, the preset format file includes an audio format file, and the method further includes:
[0030] Obtain a playback request, wherein the playback request includes the number of the target file to be played;
[0031] The storage location of the target file is determined based on the number and the attribute information stored in the playlist data structure;
[0032] The target file's data is read from its storage location, and the read audio data is played.
[0033] Optionally, determining the storage location of the target file based on the number and the playlist data structure includes:
[0034] Based on the number and the number of files of the preset format in all folders stored in the playlist data structure, the index information is determined, wherein the index information includes the sequence number of the target file in the target folder;
[0035] Based on the cluster number of the target folder, determine all directory entries in the target folder;
[0036] The directory entry corresponding to the specified sequence number is located in the determined directory entries, and the byte information corresponding to the directory entry is parsed to determine the storage location of the target file.
[0037] Secondly, this disclosure provides a playlist data structure establishment apparatus, comprising:
[0038] The traversal module is used to respond to the system startup operation, traverse the preset directory entries, and determine the attribute information of the valid folder if the directory entry is a valid folder. The valid folder is a folder that includes files of a preset format.
[0039] A module is established to create a playlist data structure based on the attribute information of the valid folders;
[0040] The attribute information includes the cluster number and the number of files that are the preset format files.
[0041] Optionally, the traversal module includes:
[0042] The first determining submodule is used to determine that there is no target directory entry in the valid folder, wherein the target directory entry is the preset format file and is a directory entry whose cluster number has changed compared to the previous directory entry of the preset format file;
[0043] The first statistics submodule is used to count the directory entries in the valid folder that are files of the preset format, and to determine the number of first files in the valid folder that are files of the preset format based on the statistics results;
[0044] The first cluster number determination submodule is used to determine the first cluster number of the valid folder;
[0045] The first attribute information determination submodule is used to determine the number of files and the first cluster number as the attribute information of the valid folder.
[0046] Optionally, the traversal module includes:
[0047] The second determining submodule is used to determine the target directory entries existing in the valid folder;
[0048] The sub-module is used to divide the directory entries containing the preset format files in the valid folders, using the target directory entry as the dividing point, and to determine multiple valid subfolders based on the division results;
[0049] The second statistics submodule is used to count the number of directory entries in the valid subfolders that are files of the preset format, and to determine the number of second files in the valid subfolders that are files of the preset format based on the statistics results;
[0050] The second cluster number determination submodule is used to determine the second cluster number of the valid subfolder;
[0051] The second attribute information determination submodule is used to determine the attribute information of the valid subfolder based on the second cluster number and the second number of files;
[0052] The establishment module includes:
[0053] A submodule is created to establish the playlist data structure based on the attribute information of the valid subfolders.
[0054] Thirdly, this disclosure provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the steps of the method described in any of the first aspects above.
[0055] Fourthly, this disclosure provides an electronic device, comprising:
[0056] A memory on which computer programs are stored;
[0057] A processor for executing the computer program in the memory to implement the steps of the method described in any of the first aspects above.
[0058] The playlist data structure established through the above technical solution does not record the full path of each directory item, thus occupying less memory. In this way, the playlist data structure can be stored in the memory of the small machine to avoid data corruption caused by disk removal. Moreover, the recorded attribute information only includes the attribute information of the valid folders, further reducing memory usage.
[0059] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description
[0060] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the following detailed description to explain the present disclosure, but do not constitute a limitation thereof. In the drawings:
[0061] Figure 1 This is a flowchart illustrating a method for establishing a playlist data structure according to an exemplary embodiment of the present disclosure.
[0062] Figure 2 This is a schematic diagram illustrating a directory structure according to an exemplary embodiment of the present disclosure.
[0063] Figure 3 This is another flowchart illustrating a method for establishing a playlist data structure according to an exemplary embodiment of the present disclosure.
[0064] Figure 4 This is a schematic diagram illustrating a playlist data structure according to an exemplary embodiment of the present disclosure.
[0065] Figure 5 This is a block diagram illustrating a playlist data structure creation apparatus according to an exemplary embodiment of the present disclosure.
[0066] Figure 6 This is a schematic diagram of the structure of an electronic device according to an exemplary embodiment of the present disclosure. Detailed Implementation
[0067] The specific embodiments of this disclosure will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit this disclosure.
[0068] Figure 1 This is a method for establishing a playlist data structure according to an exemplary embodiment of the present disclosure, referring to... Figure 1 The method for establishing this playlist data structure includes the following steps:
[0069] Step S101: In response to the system startup operation, traverse the preset directory entries. If the directory entry is a valid folder, determine the attribute information of the valid folder. The valid folder is a folder that includes files of a preset format.
[0070] For example, traverse the preset directory entries, which can be the root directory. In this case, traverse the root directory and all the directory entries contained under the root directory.
[0071] For example, the preset format file may include at least one of audio format and video format, and this embodiment is not limited thereto. The following will further explain and illustrate the embodiments of this disclosure by using the preset format file including audio format.
[0072] Reference Figure 2 ,by Figure 2 Taking the root directory shown as an example, Figure 2 The Folder3 folder indicates that there are 10,000 directory entries. Taking the traversal of the root folder as an example, determining whether the root folder is a valid folder can specifically include: if the file extension of the directory entries under the root folder (e.g., a.MP3) matches a preset format file, then the root folder is a valid folder.
[0073] Step S102: Based on the attribute information of the valid folders, establish a playlist data structure, where the attribute information includes the cluster number and the number of files in the preset format.
[0074] It should be noted that the attribute information is used to determine the storage location of the target file, which is the file that the user is looking for.
[0075] For example, if the preset directory items are traversed according to the breadth-first traversal principle, the playlist data structure will sequentially store the attribute information of all valid folders obtained by traversing according to the breadth-first traversal principle.
[0076] The playlist data structure established in the above way does not record the full path of each directory item, thus occupying less memory. In this way, the playlist data structure can be stored in the memory of the small machine to avoid data corruption caused by disk removal. In addition, the recorded attribute information only includes the attribute information of the valid folders, further reducing memory usage.
[0077] In some possible ways, the steps for determining the attribute information of a valid folder may include: determining that there is no target directory entry in the valid folder; counting the directory entries in the valid folder that are files of a preset format, and determining the number of first files in the valid folder that are files of the preset format based on the counting results; determining the first cluster number of the valid folder; and determining the number of first files and the first cluster number as the attribute information of the valid folder.
[0078] Among them, the target directory entry is a preset format file, and is a directory entry whose cluster number has changed compared to the previous directory entry which is a preset format file.
[0079] It should be noted that determining whether a target directory entry exists in the valid folder and counting the directory entries containing files of the preset format and their first cluster numbers in the valid folder can be performed in parallel. In parallel execution, upon traversing each directory entry, it can be determined whether that entry is the target directory entry. If the entry is not the target directory entry but is a file of the preset format, the number of the first files in the valid folder is counted and updated.
[0080] For example, with Figure 2 Taking the directory structure shown as an example, when traversing the directory entries in Folder0, if the a.mp3 directory entry is not the target directory entry, but it is a directory entry for a file with a preset format, then the number of updated first files is counted as 1; then when the b.mp3 directory entry is traversed, if the b.mp3 directory entry is not the target directory entry, but it is a directory entry for a file with a preset format, then the number of updated first files is counted as 2.
[0081] In some possible ways, the steps for determining the attribute information of a valid folder may include: identifying the target directory entries present in the valid folder; dividing the directory entries in the valid folder into pre-formatted files using the target directory entries as demarcation points, and determining multiple valid subfolders based on the division results; counting the number of directory entries in the valid subfolders that are pre-formatted files, and determining the number of second files in the valid subfolders that are pre-formatted files based on the count results; determining the second cluster number of the valid subfolders; and determining the attribute information of the valid subfolders based on the second cluster number and the number of second files.
[0082] If the valid folder is split, step 103 above may include: establishing a playlist data structure based on the attribute information of the valid subfolders.
[0083] It should be noted that determining the target directory entries in the valid folder, counting the number of directory entries in the valid subfolders that are files of the preset format, and determining the second cluster number of the valid subfolders can be performed in parallel.
[0084] It should be noted that when determining the storage location of the target file based on the playlist data structure, the first step is to determine the target candidate folder containing the target file based on the file count attribute of each candidate folder (determined by the valid folder) and the target file's sequence number. Then, the cluster number of the target candidate folder is used to determine the starting position for searching the target file. From this starting position, the search continues for the directory entry corresponding to the sequence number of the target candidate folder containing the target file, and the byte information corresponding to that directory entry is parsed to determine the target file's storage location. Therefore, if the number of directory entries corresponding to the candidate folder is too large, it will increase the time spent searching for the directory entry corresponding to the sequence number of the target candidate folder containing the target file.
[0085] by Figure 2 Taking Folder3 as an example, this folder is a valid folder containing 10,000 directory entries (assuming all directory entries in Folder3 are pre-formatted files). If Folder3 is not split, and the target file happens to be located in Folder3 and at a later position among the 10,000 entries, the search time for the target file will be long and the search efficiency will be low. Therefore, this technical solution can divide valid folders such as Folder3 into multiple valid subfolders. This reduces the number of directory entries managed in the target candidate folder, that is, it determines the initial position closest to the target file, thus reducing the search time.
[0086] Therefore, by using the above method, when there are many directory entries containing files of the preset format in the valid folder, the valid folder is split, and the playlist data structure is established based on the attribute information of the split folders. This greatly reduces the time spent searching for the directory entry corresponding to the sequence number of the target candidate folder where the target file is located.
[0087] In one possible approach, the step of determining the target directory entry present in the valid folder may include: determining whether the number of directory entries of the preset format files traversed in the current round meets a first preset condition; if the first preset condition is met, determining whether the cluster number of the current directory entry meets a second preset condition; if the second preset condition is met, determining the current directory entry as the target directory entry; starting from the current target directory entry, continuing the next round of traversal for the valid folder, and returning to execute the step of determining whether the directory entries of the preset format files traversed in the current round meet the first preset condition, until all directory entries in the valid folder have been traversed.
[0088] The first preset condition is that the number of directory entries of the preset format files traversed in this round reaches a preset threshold. The second preset condition is that the cluster number of the current directory entry changes compared to the cluster number of the directory entry traversed in the previous round.
[0089] It should be noted that the size of the playlist data structure is determined by the number of valid folders and the multimedia files within those folders. This is because, to balance the time required to find the target file using the playlist data structure and the number of directory entries that the playlist data structure can manage, a preset threshold of 500 can be set. Alternatively, this preset threshold can also be other values. This embodiment does not limit this.
[0090] by Figure 2 Taking Folder3 (assuming that all directory entries in Folder3 are in a preset format) as an example, and the preset threshold is 500, when traversing to the 501st directory entry in Folder3, it is determined whether the cluster number of the 501st directory entry has changed compared to the cluster number of the 500th directory entry. If so, the 501st directory entry is determined as the target directory entry, and the next round of traversal for Folder3 continues from the 501st directory entry.
[0091] It should be noted that if the number of directory entries for the preset format files traversed in this round does not meet the first preset condition, or if the number of directory entries for the preset format files traversed in this round meets the first preset condition but the cluster number of the currently traversed directory entry does not meet the second preset condition, it indicates that the target directory entry has not been determined. In a possible manner, the method further includes: obtaining a playback request, the playback request including the number of the target file to be played; determining the storage location of the target file based on the number and attribute information stored in the playlist data structure; reading the data of the target file based on its storage location and playing the read audio data.
[0092] It should be noted that for some smart speakers without displays or products that do not need to display the full path name of a file, recording the full path information of each file in the playlist data structure is a huge waste of memory space. Therefore, for such application scenarios, a playlist data structure including attribute information is established, and the storage location of the target file is determined according to the number of the target file to be played. The data of the target file is read from the storage location and the read audio data is played, thus solving the problem of high memory consumption.
[0093] It should be noted that the size of the playlist data structure is determined by the number of valid folders and the multimedia files within those folders, such as... Figure 2Taking the directory structure shown as an example, the playlist data structure has a maximum of 23 folders. Recording each folder and its attribute information requires a maximum of 8 bytes, therefore, the required memory space is 23 * 8 = 184 bytes. In the most ideal scenario, each attribute information manages 500 directory entries, so 23 folders can manage 23 * 500 = 11500 directory entries. If we use the traditional method of directly recording the full file path in a playlist, recording the path information for each directory entry would require 512 bytes. Therefore, 11500 directory entries would require 11500 * 512 = 5750 KB of memory. However, this playlist data structure only requires 184 bytes of memory, thus reducing the memory footprint of the playlist data structure.
[0094] In one possible approach, the steps for determining the storage location of the target file based on the number and playlist data structure include: determining the index information based on the number and the number of files of the preset format in all folders stored in the playlist data structure; determining all directory entries in the target folder based on the cluster number of the target folder; searching for the directory entry corresponding to the sequence number in the determined directory entries, parsing the byte information corresponding to the directory entry, and determining the storage location of the target file.
[0095] It should be noted that the index information includes the sequence number of the target file within the target folder. Specifically, this refers to the sequence number of all directory entries within the target folder that are files in a preset format.
[0096] It should be noted that the byte information corresponding to the directory entry includes the file's storage location.
[0097] It should be noted that the above Figure 1 The steps shown can be executed in parallel, as follows: Figure 3 An embodiment of this disclosure that executes the steps in parallel will be further explained and illustrated. Still using... Figure 2 Taking the root directory structure shown below and traversing it using a breadth-first search approach as an example, the steps include:
[0098] Step 301: Set the initial value index of the folder i = 0, and the initial number of folder values num = 0.
[0099] Where num represents the number of folders stored in the playlist data structure.
[0100] Step 302: Start traversing the root directory and record the cluster number of the root directory as the cluster number of folder[0].
[0101] The root directory is... Figure 2The directory structure shown in Folder0 is as follows.
[0102] Step 303: Read the current directory entries and determine whether all the directory entries in the current directory have been read. If yes, proceed to step 304; otherwise, proceed to step 305.
[0103] For example, when traversing the directory entries in Folder0, the current directory is Folder0. When traversing the directory entries in Folder1, the current directory is Folder1. When the current directory is Folder1, after traversing d.mp3, e.mp3, and Folder3 in sequence, the next directory entry (the current directory entry) will be read. An empty directory entry will be read, and the file name of the directory entry will be empty. At this time, it is determined that the directory entries in Folder1 have been read.
[0104] Step 304: Determine if i is less than num. If yes, proceed to step 3041. If no, end the process.
[0105] Step 3041: Determine whether the number of files in the preset format in folder[i] is 0. If yes, proceed to step 3042; otherwise, proceed to step 3043.
[0106] Step 3042: Move the entire folder after i forward by one unit, num--, i--, and open the cluster number in folder[i+1], start traversing the directory entry corresponding to the cluster number, i++, and return to execute step 303.
[0107] Step 3042 means that the playlist data structure only stores the attribute information of folders containing files of a preset format.
[0108] For example, if folder[i] is folder[2], and folder[1], folder[2] and folder[3] have already been created, and the number of files in the preset format of folder[2] is 0, then folder[3] is changed to folder[2]. The overwrite method is used to avoid invalid folders (with 0 files) occupying memory space.
[0109] Step 3043: Open the cluster number in folder[i+1], start traversing the directory entries corresponding to the cluster number, increment i, and return to execute step 303.
[0110] Step 305: Determine if the current directory item is a folder; if it is a folder, proceed to step 3051; if it is not a folder, proceed to step 3052.
[0111] Step 3051: Create folder[num] and use the cluster number of the current directory entry as the cluster number value of folder[num], then increment num; then execute step 306: traverse the next directory entry.
[0112] Step 3052: Determine whether the current directory entry is a directory entry of a preset format file; if the current directory entry is not a directory entry of a preset format file, proceed to step 306; if the current directory entry is a directory entry of a preset format file, proceed to step 307.
[0113] Step 307: Determine whether the number of directory entries in folder[i] that are files of the preset format has reached the preset threshold, and determine whether the cluster number of the current directory entry has changed compared with the previous directory entry that is a file of the preset format. If neither of the above conditions is met at the same time, proceed to step 308. If both conditions are met, proceed to step 309.
[0114] Step 308: Increment the number of files in folder[i] by 1; and proceed to the next step, 306.
[0115] Step 309: Shift the entire folder after i+1 one unit to the right, and increment num.
[0116] For example, if folder[i] is folder[2], and folder[1], folder[2] and folder[3] have already been created, and there is a directory entry in folder[2] that reaches a preset threshold and changes compared to the cluster number of the previous directory entry which is a file with a preset format, then folder[3] is changed to folder[4].
[0117] Step 310: Create folder[i+1], determine the cluster number of the current directory entry as the cluster number of folder[i+1], and increment i.
[0118] For example, taking the example in step 309, the created folder[i+1] is folder[2+1], which is folder[3].
[0119] Step 310: Increment the number of files in folder[i] by 1, and proceed to the next step 306.
[0120] It should be noted that folder[i] is the folder name in the created playlist data structure, and Folder is... Figure 2 The folder names in the directory structure shown.
[0121] Specifically Figure 2The directory structure shown illustrates the entire traversal process. Specifically, initially i = 0, num = 1, starting the traversal of directory entries (i.e., Folder0) in the root directory. Since Folder0 is a folder, folder[0] is created, and the cluster number of the root directory is recorded as the cluster number of folder[0]. The traversal continues to the multimedia file a.mp3. The file extension of the directory entry is compared with the preset matching format (mp3). If the result is a match, the number of files in folder[0] is incremented by 1. The traversal continues to b.mp3 and c.mp3 in sequence, so the number of files in folder[0] is 3. Then the traversal continues to the folder Fold. er1, create folder[1], take the cluster number of folder1 as the cluster number of folder[1] member (directory entry of the default format file), since it is based on the breadth-first traversal principle, then traverse to Folder2, the same method as Folder1, record the cluster number of Folder2, the number of files is 0, the number of folders num is incremented by 1, and when traversing again, read the empty file information, thus completing the traversal of folder0. Since the initial i=0, if the folder index i is incremented by 1, it indicates that the traversal of folder1 has started.
[0122] The method of traversing Folder1 is the same as the method of traversing Folder0. The number of files in folder[1] is 3. Traverse to the new folder Folder3, take the cluster number of folder3 as the cluster number of folder[3] member, the number of files in folder[3] is 0, and the number of folders num is incremented by 1. Traverse to the new folder Folder4, take the cluster number of folder4 as the cluster number of folder[4] member, the number of files in folder[4] is 0, and the number of folders num is incremented by 1. Since i=1 at this time, if the folder index i is incremented by 1, it indicates that the traversal of Folder2 folder has started.
[0123] The method of traversing the Folder2 folder is the same as the previous traversal of Folder0 and Folder1. The file extensions g.txt and hc are compared with the preset matching format (mp3). They do not match. In the end, the number of files in the preset format in folder[2] is still 0. Then the information of folder[2] (cluster number and number of files) will be overwritten. The overwriting method is to move all folders after folder[2] forward by one unit. For example, the information of folder[3] overwrites the information of folder[2], the information of folder[4] overwrites the information of folder[3], and so on. The number of folders num is reduced by 1. The overwriting method is used to avoid invalid folders (the number of files is 0) occupying memory space. That is, the playlist data structure only records the attribute information of folders (valid folders) that contain preset format files. The folder index i is increased by 1, which indicates that the traversal of the Folder3 folder has started.
[0124] Next, traverse the Folder3 folder. The method for traversing the Folder3 folder is the same as the previous Folder. Traverse to the multimedia files with matching formats 1.mp3, 2.mp3...501.mp3. When traversing to the 501st (which can be set according to the actual situation) multimedia file, firstly, determine whether the cluster number of the directory entry of the 501st file 501.mp3 has changed compared to the cluster number of the directory entry of the 500th file 500.mp3. If it has changed, then perform the second step: insert a new folder after folder[3]. Before inserting the new folder, move the folders after folder[3] one unit to the right, such as moving folder[4] to folder[3]. 5], save the new folder information (including the cluster number of the 501st directory entry) to the location of folder[4], increment the folder count num by 1, increment the folder index i by 1, the cluster number of the members of folder[4] is the cluster number of the 501st directory entry that is a file with a preset format, and increment the number of files in folder[4] by 1; third, continue to traverse the next directory entry until there are a preset threshold number of multimedia files with matching formats in folder[4], and continue the processing in the first step above; if there is no change in the number of multimedia files with matching formats in folder[4], continue to traverse the next directory entry until the cluster number changes, and then execute the processing in the second step above. In this way, the splitting of Folder3 can be realized.
[0125] Next, the Folder4 folder is traversed using the same method as the previous Folder folders. The final playlist data structure is as follows: Figure 4 As shown.
[0126] It is worth noting that Figure 2 The Folder3 folder in the directory structure contains 10,000 directory entries, and among these 10,000 entries, there are directory entries containing files of a preset format that exceed a preset threshold. Therefore, Figure 4 The ellipsis indicates only the portion created based on the Folder3 folder. For example, if there are 600 directory entries with preset format files out of 10,000, and the cluster number of the first directory entry exceeding the preset threshold changes from the previous one, then the ellipsis represents the attribute information of one folder; if there are 1,100 directory entries with preset format files out of 10,000, then the ellipsis represents the attribute information of two folders, and so on.
[0127] For example, if Folder3 contains 10,000 directory entries with a preset file format, and the cluster number changes every 500 entries (e.g., the cluster number changes between the 500th and 501st entries), and the target file is found in the 510th directory entry of Folder3 (i.e., the target file's sequence number is 516), without splitting, each attribute information in the established playlist data structure would correspond to... Figure 2 Each folder shown includes a directory entry for a pre-formatted file. The first attribute is the cluster number of folder[0] (i.e., the cluster number of Folder0) / the number of multimedia files is 3. The second attribute is the cluster number of folder[1] (i.e., the cluster number of Folder1) / the number of multimedia files is 3. The third attribute is the cluster number of folder[2] (i.e., the cluster number of Folder3) / the number of multimedia files is 10000. The fourth attribute is the cluster number of folder[3] (i.e., the cluster number of Folder4) / the number of multimedia files is 2. Since the first and second attribute entries manage a total of 6 multimedia files and the third attribute entry manages 10000 multimedia files, the initial location for finding the target file is located at the position corresponding to the cluster number of folder2. The directory entries are traversed one by one from this position. If the target file is the 510th directory entry for a pre-formatted file in the folder3, then the 510 directory entries for the pre-formatted files need to be traversed one by one from this position to find the target file. If splitting is performed, the resulting playlist data structure only needs to include, for example: Figure 4The "greater than or equal to preset value" in the playlist data structure is modified to "equal to preset value". Specifically, the first attribute information is the cluster number of folder[0] (i.e., the cluster number of Folder0 folder) / the number of multimedia files is 3; the second attribute information is the cluster number of folder[1] (i.e., the cluster number of Folder1 folder) / the number of multimedia files is 3; the third attribute information is the cluster number of folder[2] (i.e., the cluster number of Folder3 folder) / the number of multimedia files is 500; the fourth attribute information is the cluster number of folder[3] (i.e., the cluster number of Folder3 folder) / the number of multimedia files is 500; the fifth to twentieth attribute information all manage a number of 500 multimedia files; and the twenty-first attribute information is the number of folder[2]...
[20] Cluster number (i.e., the cluster number of Folder4 folder) / number of multimedia files 2. Since the sequence number of the target file is 516, and the total number of multimedia files managed by the first, second and third attribute information is 506, and the number of multimedia files managed by the fourth attribute information is 500, the initial position of the target file can be located at the position corresponding to the cluster number of folder[3]. In this way, the directory entries can be traversed directly from the position corresponding to the cluster number of folder[3]. Then, the directory entry that is the tenth traversed is the target file. Compared with the number of traversals required without splitting, the splitting scheme reduces the number of traversals, thereby reducing the traversal time and improving the traversal efficiency.
[0128] by Figure 4 Taking the established playlist data structure as an example, when the sequence number of the target file is 5, the target file can be determined to be in folder [1] based on the number of multimedia files in each folder in the playlist data structure. At this time, the initial position for starting the search can be found based on the cluster number of folder [1] (i.e., the cluster number of Folder1). Then, based on the sequence number of the target file and the number of multimedia files in folder [1], the directory entries are traversed according to the position indicated by the cluster number of folder [1]. The second directory entry (i.e., the index information) that is traversed is in multimedia format is the target file to be searched. Then, by parsing the information of the second directory entry in multimedia format, the data of the directory entry can be obtained.
[0129] Based on the same inventive concept, this disclosure also discloses a playlist data structure establishment device, referring to... Figure 5 The playlist data structure creation device includes:
[0130] The traversal module 501 is used to respond to the system startup operation, traverse the preset directory entries, and determine the attribute information of the valid folder if the directory entry is a valid folder, wherein the valid folder is a folder containing files of a preset format.
[0131] Module 502 is used to establish a playlist data structure based on the attribute information of the valid folder;
[0132] The attribute information includes the cluster number and the number of files that are the preset format files.
[0133] Optionally, the traversal module 501 is used to traverse a preset directory item according to the breadth-first traversal principle;
[0134] The playlist data structure then stores the attribute information of all valid folders obtained by traversing according to the breadth-first traversal principle.
[0135] Optionally, the traversal module 501 includes:
[0136] The first determining submodule is used to determine that there is no target directory entry in the valid folder, wherein the target directory entry is the preset format file and is a directory entry whose cluster number has changed compared to the previous directory entry of the preset format file;
[0137] The first statistics submodule is used to count the directory entries in the valid folder that are files of the preset format, and to determine the number of first files in the valid folder that are files of the preset format based on the statistics results;
[0138] The first cluster number determination submodule is used to determine the first cluster number of the valid folder;
[0139] The first attribute information determination submodule is used to determine the first file quantity and the first cluster number as the attribute information of the valid folder.
[0140] Optionally, the traversal module 501 includes:
[0141] The second determining submodule is used to determine the target directory entries existing in the valid folder;
[0142] The sub-module is used to divide the directory entries containing the preset format files in the valid folders, using the target directory entry as the dividing point, and to determine multiple valid subfolders based on the division results;
[0143] The second statistics submodule is used to count the number of directory entries in the valid subfolders that are files of the preset format, and to determine the number of second files in the valid subfolders that are files of the preset format based on the statistics results;
[0144] The second cluster number determination submodule is used to determine the second cluster number of the valid subfolder;
[0145] The second attribute information determination submodule is used to determine the attribute information of the valid subfolder based on the second cluster number and the second number of files;
[0146] The establishment module 520 includes:
[0147] A submodule is created to establish the playlist data structure based on the attribute information of the valid subfolders.
[0148] Optionally, the second determining submodule is used to determine whether the number of directory entries of the preset format file that has been traversed in this round meets the first preset condition;
[0149] If the first preset condition is met, determine whether the cluster number of the current directory item being traversed meets the second preset condition.
[0150] If the second preset condition is met, the current directory item will be determined as the target directory item;
[0151] Starting from the current target directory entry, continue the next round of traversal for the valid folder, and return to execute the step of determining whether the directory entries that have been traversed in this round as the preset format file meet the first preset condition, until all directory entries in the valid folder have been traversed.
[0152] Optionally, the preset format file includes an audio format file, and the device 500 further includes:
[0153] The acquisition module is used to acquire a playback request, wherein the playback request includes the number of the target file to be played;
[0154] The storage location determination module is used to determine the storage location of the target file based on the number and the attribute information stored in the playlist data structure;
[0155] The playback module is used to read the data of the target file according to the storage location of the target file and play the read audio data.
[0156] Optionally, the storage location determination module includes:
[0157] The index information determination submodule is used to determine index information based on the number and the number of files of the preset format in all folders stored in the playlist data structure, wherein the index information includes the sequence number of the target file in the target folder;
[0158] The directory entry determination submodule is used to determine all directory entries in the target folder based on the cluster number of the target folder;
[0159] The storage location determination submodule is used to find the directory entry corresponding to the sequence number in the determined directory entries, parse the byte information corresponding to the directory entry, and determine the storage location of the target file.
[0160] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0161] Based on the same inventive concept, this disclosure also discloses a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, performs the steps of the playlist data structure establishment method described in the above method embodiments.
[0162] Based on the same inventive concept, this disclosure also discloses an electronic device, including:
[0163] A memory on which computer programs are stored;
[0164] A processor is configured to execute the computer program in the memory to implement the steps of the playlist data structure establishment method described in the above method embodiments.
[0165] Figure 6 This is a block diagram illustrating an electronic device 600 according to an exemplary embodiment. For example... Figure 6 As shown, the electronic device 600 may include a processor 601 and a memory 602. The electronic device 600 may also include one or more of a multimedia component 603, an input / output (I / O) interface 604, and a communication component 605.
[0166] The processor 601 controls the overall operation of the electronic device 600 to complete all or part of the steps in the playlist data structure establishment method described above. The memory 602 stores various types of data to support the operation of the electronic device 600. This data may include, for example, instructions for any application or method operating on the electronic device 600, and application-related data such as contact data, sent and received messages, pictures, audio, video, etc. The memory 602 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. Multimedia component 603 may include a screen and an audio component. The screen may be, for example, a touchscreen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signals may be further stored in memory 602 or transmitted via communication component 605. The audio component also includes at least one speaker for outputting audio signals. I / O interface 604 provides an interface between processor 601 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual or physical buttons. Communication component 605 is used for wired or wireless communication between the electronic device 600 and other devices. Wireless communication may include Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, or 4G, or a combination of these. Therefore, the corresponding communication component 605 may include a Wi-Fi module, a Bluetooth module, or an NFC module.
[0167] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the playlist data structure establishment method described above.
[0168] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, which, when executed by a processor, implement the steps of the playlist data structure establishment method described above. For example, the computer-readable storage medium may be the memory 602 including the program instructions described above, which may be executed by the processor 601 of the electronic device 600 to complete the playlist data structure establishment method described above.
[0169] The preferred embodiments of this disclosure have been described in detail above with reference to the accompanying drawings. However, this disclosure is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this disclosure, various simple modifications can be made to the technical solutions of this disclosure, and these simple modifications all fall within the protection scope of this disclosure.
[0170] It should also be noted that the various specific technical features described in the above embodiments can be combined in any suitable manner without contradiction. To avoid unnecessary repetition, this disclosure will not describe the various possible combinations separately.
[0171] Furthermore, various different embodiments of this disclosure can be combined in any way, as long as they do not violate the spirit of this disclosure, they should also be regarded as the content disclosed in this disclosure.
Claims
1. A method for establishing a playlist data structure, characterized in that, include: In response to the system startup operation, the system traverses preset directory entries. If a directory entry is a valid folder, the system determines the attribute information of the valid folder, wherein the valid folder is a folder containing files of a preset format. Based on the attribute information of the valid folders, establish the playlist data structure; The attribute information includes a cluster number and the number of files that are files in the preset format, wherein the cluster number corresponds to the storage location of the valid folder; The determination of the attribute information of the valid folder includes: Determine that the target directory entry does not exist in the valid folder, wherein the target directory entry is the preset format file and is a directory entry whose cluster number has changed compared to the previous directory entry of the preset format file; Count the directory entries in the valid folder that contain the preset format file, and determine the first number of files in the valid folder that contain the preset format file based on the count results; Determine the first cluster number of the valid folder; The first file count and the first cluster number are determined as the attribute information of the valid folder; Identify the target directory entries present in the valid folder; Using the target directory entry as a dividing point, the directory entries containing the preset format files in the valid folder are divided, and multiple valid subfolders are determined based on the division results; Count the number of directory entries in the valid subfolders that are files of the preset format, and determine the number of second files in the valid subfolders that are files of the preset format based on the count results; Determine the second cluster number of the valid subfolder; The attribute information of the valid subfolder is determined based on the second cluster number and the second number of files; The step of establishing a playlist data structure based on the attribute information of the valid folder includes: Based on the attribute information of the valid subfolders, establish the playlist data structure.
2. The method according to claim 1, characterized in that, The traversal of the preset directory items includes: Traverse the preset directory items according to the breadth-first traversal principle; The playlist data structure then stores the attribute information of all valid folders obtained by traversing according to the breadth-first traversal principle.
3. The method according to claim 1, characterized in that, The step of determining the target directory entries existing in the valid folder includes: Determine whether the number of directory entries of the preset format files that have been traversed in this round meets the first preset condition; If the first preset condition is met, determine whether the cluster number of the current directory item being traversed meets the second preset condition. If the second preset condition is met, the current directory item will be determined as the target directory item; Starting from the target directory entry, continue the next round of traversal for the valid folder, and return to the step of determining whether the number of directory entries of the preset format file traversed in this round meets the first preset condition, until all directory entries in the valid folder have been traversed.
4. The method according to any one of claims 1-3, characterized in that, The preset format file includes an audio format file, and the method further includes: Obtain a playback request, wherein the playback request includes the number of the target file to be played; The storage location of the target file is determined based on the number and the attribute information stored in the playlist data structure; The target file's data is read from its storage location, and the read audio data is played.
5. The method according to claim 4, characterized in that, Determining the storage location of the target file based on the number and the attribute information stored in the playlist data structure includes: Based on the number and the number of files of the preset format in all folders stored in the playlist data structure, the index information is determined, wherein the index information includes the sequence number of the target file in the target folder; Based on the cluster number of the target folder, determine all directory entries in the target folder; The directory entry corresponding to the specified sequence number is located in the determined directory entries, and the byte information corresponding to the directory entry is parsed to determine the storage location of the target file.
6. A playlist data structure creation device, characterized in that, include: The traversal module is used to respond to the system startup operation, traverse the preset directory entries, and determine the attribute information of the valid folder if the directory entry is a valid folder. The valid folder is a folder that includes files of a preset format. A module is established to create a playlist data structure based on the attribute information of the valid folders; The attribute information includes a cluster number and the number of files that are files in the preset format, wherein the cluster number corresponds to the storage location of the valid folder; The traversal module includes: The first determining submodule is used to determine that there is no target directory entry in the valid folder, wherein the target directory entry is the preset format file and is a directory entry whose cluster number has changed compared to the previous directory entry of the preset format file; The first statistics submodule is used to count the directory entries in the valid folder that are files of the preset format, and to determine the number of first files in the valid folder that are files of the preset format based on the statistics results; The first cluster number determination submodule is used to determine the first cluster number of the valid folder; The first attribute information determination submodule is used to determine the first file quantity and the first cluster number as the attribute information of the valid folder; The second determining submodule is used to determine the target directory entries existing in the valid folder; The sub-module is used to divide the directory entries containing the preset format files in the valid folders, using the target directory entry as the dividing point, and to determine multiple valid subfolders based on the division results; The second statistics submodule is used to count the number of directory entries in the valid subfolders that are files of the preset format, and to determine the number of second files in the valid subfolders that are files of the preset format based on the statistics results; The second cluster number determination submodule is used to determine the second cluster number of the valid subfolder; The second attribute information determination submodule is used to determine the attribute information of the valid subfolder based on the second cluster number and the second number of files; The establishment module includes: A submodule is created to establish the playlist data structure based on the attribute information of the valid subfolders.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements the steps of the method described in any one of claims 1-5.
8. An electronic device, characterized in that, include: A memory on which computer programs are stored; A processor for executing the computer program in the memory to implement the steps of the method according to any one of claims 1-5.