⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 audible.c

📁 基于EP7312的MP3播放器源代码,包括MCU和PC端代码.
💻 C
📖 第 1 页 / 共 2 页
字号:
    //    return(0);}//****************************************************************************//// AudibleGetNumSections returns the number of sections in the current Audible// program.////****************************************************************************unsigned longAudibleGetNumSections(void){    //    // Return the number of sections in the current program if the current file    // contains an Audible program.    //    if(sAudible.ulMetaDataOffset)    {        return(sAudible.ulNumSections);    }    //    // The current file does not contain an Audible program, so return 0.    //    return(0);}//****************************************************************************//// AudibleGetPreviousSection returns the time of the section that occurs// before the specified time in the Audible program.  If the specified time// is within the first 3 seconds of a section, then the time of the previous// section will be returned.////****************************************************************************unsigned longAudibleGetPreviousSection(unsigned long ulTime){    tFile sFile;    unsigned long *pulSections, ulIdx, ulAvailable, ulSection;    unsigned char *pucBuffer;    //    // Get a pointer to the file system's scratch buffer.    //    pucBuffer = FSGetScratch();    //    // If the current file does not contain an Audible program, then return 0    // to indicate that the previous "section" is at the start of the file.    //    if(!sAudible.ulMetaDataOffset)    {        return(0);    }    //    // Open the Audible meta-data file.    //    if(FSOpen(&sFile, sAudible.ulMetaDataOffset & 255, pusAudibleFile,              FS_OPEN_READ) == 0)    {        return(0);    }    //    // Seek to the block containing the meta-data.    //    if(FSSeek(&sFile, sAudible.ulMetaDataOffset & ~511) == 0)    {        FSClose(&sFile);        return(0);    }    //    // Read the block containing the meta-data.    //    if(FSRead(&sFile, pucBuffer, 512) != 512)    {        FSClose(&sFile);        return(0);    }    //    // Get a pointer to the table of section offsets.    //    pulSections = ((tAudibleMetaData *)(pucBuffer + 4))->pulSectionStart;    //    // There is enough space in the first block of meta-data for 17 section    // offsets.    //    ulAvailable = 17;    //    // The current previous section offset is zero.    //    ulSection = 0;    //    // Loop through all of the sections in this program.    //    for(ulIdx = 0; ulIdx < sAudible.ulNumSections; ulIdx++)    {        //        // See if there are any more section offsets available in this block of        // meta-data.        //        if(ulAvailable == 0)        {            //            // Get the offset of the next block of meta-data.            //            ulAvailable = *(unsigned long *)pucBuffer;            if(ulAvailable & 511)            {                FSClose(&sFile);                return(ulSection);            }            //            // Seek to the next block of meta-data.            //            if(FSSeek(&sFile, ulAvailable) == 0)            {                FSClose(&sFile);                return(ulSection);            }            //            // Read the next block of meta-data.            //            if(FSRead(&sFile, pucBuffer, 512) != 512)            {                FSClose(&sFile);                return(ulSection);            }            //            // Get a pointer to the table of section offsets.            //            pulSections = (unsigned long *)(pucBuffer + 4);            //            // There is enough space in the subsequent blocks of meta-data for            // 127 section offsets.            //            ulAvailable = 127;        }        //        // If this section offset is after the current time, or is less than        // three seconds before the current time, then the previous section        // offset is the one we should return.        //        if((*pulSections + 3000) > ulTime)        {            //            // Close the meta-data file.            //            FSClose(&sFile);            //            // Return the time of the previous section.            //            return(ulSection);        }        //        // Remember the current section offset as the new previous section        // offset, and skip to the next section offset in the table.        //        ulSection = *pulSections++;        //        // Decrement the number of section offsets available.        //        ulAvailable--;    }    //    // Close the meta-data file.    //    FSClose(&sFile);    //    // Since we fell out of the above loop, the last section offset from the    // table is the previous section in the program.    //    return(ulSection);}//****************************************************************************//// AudibleGetNextSection returns the time of the section that occurs after the// specified time in the Audible program.  If there is no section after the// specified time, then a time of -1 will be returned.////****************************************************************************unsigned longAudibleGetNextSection(unsigned long ulTime){    tFile sFile;    unsigned long *pulSections, ulIdx, ulAvailable;    unsigned char *pucBuffer;    //    // Get a pointer to the file system's scratch buffer.    //    pucBuffer = FSGetScratch();    //    // If the current file does not contain an Audible program, then return 0    // to indicate that the previous "section" is at the start of the file.    //    if(!sAudible.ulMetaDataOffset)    {        return(0);    }    //    // Open the Audible meta-data file.    //    if(FSOpen(&sFile, sAudible.ulMetaDataOffset & 255, pusAudibleFile,              FS_OPEN_READ) == 0)    {        return(0);    }    //    // Seek to the block containing the meta-data.    //    if(FSSeek(&sFile, sAudible.ulMetaDataOffset & ~511) == 0)    {        FSClose(&sFile);        return(0);    }    //    // Read the block containing the meta-data.    //    if(FSRead(&sFile, pucBuffer, 512) != 512)    {        FSClose(&sFile);        return(0);    }    //    // Get a pointer to the table of section offsets.    //    pulSections = ((tAudibleMetaData *)(pucBuffer + 4))->pulSectionStart;    //    // There is enough space in the first block of meta-data for 17 section    // offsets.    //    ulAvailable = 17;    //    // Loop through all of the sections in this program.    //    for(ulIdx = 0; ulIdx < sAudible.ulNumSections; ulIdx++)    {        //        // See if there are any more section offsets available in this block of        // meta-data.        //        if(ulAvailable == 0)        {            //            // Get the offset of the next block of meta-data.            //            ulAvailable = *(unsigned long *)pucBuffer;            if(ulAvailable & 511)            {                FSClose(&sFile);                return(-1);            }            //            // Seek to the next block of meta-data.            //            if(FSSeek(&sFile, ulAvailable) == 0)            {                FSClose(&sFile);                return(-1);            }            //            // Read the next block of meta-data.            //            if(FSRead(&sFile, pucBuffer, 512) != 512)            {                FSClose(&sFile);                return(-1);            }            //            // Get a pointer to the table of section offsets.            //            pulSections = (unsigned long *)(pucBuffer + 4);            //            // There is enough space in the subsequent blocks of meta-data for            // 127 section offsets.            //            ulAvailable = 127;        }        //        // If this section offset is after the current time then it is the        // section we should return.        //        if(*pulSections > (ulTime + 500))        {            //            // Close the meta-data file.            //            FSClose(&sFile);            //            // Return the time of this section.            //            return(*pulSections);        }        //        // Skip to the next section offset in the table.        //        pulSections++;        //        // Decrement the number of section offsets available.        //        ulAvailable--;    }    //    // Close the meta-data file.    //    FSClose(&sFile);    //    // Since we fell out of the above loop, we are already in the last section    // of the program.    //    return(-1);}//****************************************************************************//// AudibleSetPlayedThrough is used to indicate that we've played through the// entire Audible program.////****************************************************************************voidAudibleSetPlayedThrough(void){    //    // Set the played through indicator if the current file contains an Audible    // program.    //    if(sAudible.ulMetaDataOffset)    {        sAudible.ulMetaDataOffset |= 0x100;    }}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -