📄 audio_support.c
字号:
default: break; } index++; if (index > nodes_num) break; } return count; } } else return 0; //not active volume }uint32 CountFilesForDevice(t_duid did, t_bool include_audio_tracks,t_SearchMode search) { int16 count = 0; int16 vol = 0; // int16 index = 0; // [RB] unused // int16 nodes_num; // [RB] unused t_volume_selection_struct volume_selection_struct; if (b_FALSE == include_audio_tracks) //start with data volume (skip audio volume) vol = 1; volume_selection_struct.volume = vol; volume_selection_struct.direction = FORWARD; volume_selection_struct.audio_first = b_TRUE; volume_selection_struct.repeat = REPEAT_OFF; volume_selection_struct.device = did; while(1) { vol = XAR_FindNextVolume(&volume_selection_struct); //find volume for did volume_selection_struct.volume = vol; if (vol) { //now find song according to song_nr (see p. 81 in CIS 0.08 spec) count += CountFilesForVolume(vol,search) ; } else //unable to find next volume for device return count; //num of found files } }/******************************************************************************//* Function: CountDirsForDevice *//* *//*! \brief counts all nonempty dirs (containing some file) according to device * \param _duid device * \return int16 CIS dirs count * \remark *//******************************************************************************/uint32 CountDirsForDevice(t_duid device){ int16 index; int16 nodes_num; int16 DirCount = 0; int16 vol = 1; //don't include audio volume t_volume_selection_struct volume_selection_struct; volume_selection_struct.volume = vol; volume_selection_struct.direction = FORWARD; volume_selection_struct.audio_first = b_TRUE; volume_selection_struct.repeat = REPEAT_OFF; volume_selection_struct.device = device; while(1) { vol = XAR_FindNextVolume(&volume_selection_struct); //find volume for device volume_selection_struct.volume = vol; if (vol) { //now find all dirs containing files index = XAR_VolumeNode(vol); nodes_num = index + X_array[index].data.xvolume.nodes_num; index++; while(index < nodes_num) { if ((S_TRUE == XAR_IsDirectory(index)) && (X_array[index].data.xdir.address)) DirCount++; index++; } } else return DirCount; } }/******************************************************************************//* Function: FindIndexForItemNr *//* *//*! \brief Finds song of playlist index from Song/Playlist nr. according to CIS0.08 (p.81) * \param int16 song_nr, t_dir_num_style dir_numbering, t_duid did, t_bool audio_first * \return t_XItem song_index * \remark *//******************************************************************************/t_XItem FindIndexForItemNr(int16 song_nr, t_dir_num_style dir_numbering, t_duid did, t_SearchMode search) //Functionality according to CIS{ int32 vol,index,a,b; uint32 xtype; vol = 2; a = 0; // sum of all files while(1) { index = XAR_VolumeNode(vol); if(index<0) { return S_NOT_FOUND; } b = 0; if(did == XAR_VolNodeDevType(index)) { b = CountFilesForVolume(vol,search); } if(a+b>=song_nr) break; a += b; vol++; } // now index is equal to volume node where song has to be found // a is equal to sum of all songs in previous partitions while(1) { index++; if(index>=X_NEXTFREE_ITEM) return S_NOT_FOUND; switch(XAR_NodeType(index)) { case XTYPE_VOLUME: return S_NOT_FOUND; case XTYPE_DATA_FILE: xtype = XAR_XNodeType(index); if((xtype==CAFILE_MP3)#if(HAVE_WMA == 1) ||(xtype==CAFILE_WMA)#endif#if(HAVE_AAC == 1) ||(xtype==CAFILE_AAC)#endif ) { if(search!=SEARCH_PLAYABLE) break; if(dir_numbering == PATH_TABLE) { if((a+X_array[index].data.xfile.address) == song_nr ) return index; } else { a++; if(a==song_nr) return index; } } if((xtype==PLAYLIST_PLS)#if (0 == HAVE_WMDRM) ||(xtype==PLAYLIST_M3U)) #else ||(xtype==PLAYLIST_M3U) ||(xtype==PLAYLIST_PLA)) #endif { if(search!=SEARCH_PLAYLISTS) break; if(dir_numbering == PATH_TABLE) { if((a+X_array[index].data.xfile.address) == song_nr ) return index; } else { a++; if(a==song_nr) return index; } } if((search==SEARCH_SPECIAL)&&(xtype==DATA_FILE)) { a++; if(a==song_nr) return index; } break; default: break; } } return S_NOT_FOUND;}#if 0 // [RB] unusedint16 FindRelNrForIndex(t_XItem song_index){}#endif/******************************************************************************//* Function: FindSongNrForIndex *//* *//*! \brief Calculates Song nr. from song index according to CIS0.08 (p.81) * \param t_XItem song_index,t_dir_num_style dir_numbering, t_bool audio_first * \return int16 CIS song number * \remark *//******************************************************************************/int16 FindSongNrForIndex(t_XItem song_index, t_dir_num_style dir_numbering, t_bool audio_first) //Functionality according to CIS{ int16 index; //int16 nodes_num; int16 song_nr =0; t_duid device; int16 vol = 0,a; uint16 xtype; //t_volume_selection_struct volume_selection_struct; if (!song_index) //error occured, invalid input param!! return 0; device = XAR_DeviceTypeForItem(song_index); if (XAR_NodeType(song_index) == XTYPE_TRACK) { if(XAR_XNodeType(song_index) != TRACK_CDDA) return 0; index = song_nr = 1; while(index<song_index) { if(XAR_XNodeType(index) == TRACK_CDDA) song_nr ++; index++; } if(audio_first) return song_nr; vol = 2; a = 0; // sum of all ca files while(1) { index = XAR_VolumeNode(vol); if(index<0) { return a + song_nr; } if(device == XAR_VolNodeDevType(index)) { a += CountFilesForVolume(vol,SEARCH_PLAYABLE); } vol++; } } song_nr = 0; if((device == DEV_CD_ID) && audio_first) { index = 1; while(XAR_NodeType(index) == XTYPE_TRACK) { if(XAR_XNodeType(index) == TRACK_CDDA) song_nr++; index++; } } vol = 2; while(1) { index = XAR_VolumeNode(vol); if((index<0)||(index>song_index)) return song_nr; if(device == XAR_VolNodeDevType(index)) { if(index+X_array[index].data.xvolume.nodes_num < song_index) { song_nr += CountFilesForVolume(vol,SEARCH_PLAYABLE); } else { if(dir_numbering == PATH_TABLE) { // add sequential ordering number return song_nr + X_array[song_index].data.xfile.address; } do // otherwise count linear position { index++; xtype = XAR_XNodeType(index); if((xtype==CAFILE_MP3)|| (xtype==CAFILE_WMA)|| (xtype==CAFILE_AAC)) song_nr++; }while(index<song_index); return song_nr; } } vol++; } }/******************************************************************************//* Function: FindIndexForDirNr *//* *//*! \brief Finds dir index to Dir nr. according to CIS0.08 (p.81) * \param int16 DirNr, t_dir_num_style dir_numbering, t_duid did * \return dir_index (without AUDIO_TRACKS_OFFSET) * \remark *//******************************************************************************/t_XItem FindIndexForDirNr(int16 DirNr, t_dir_num_style dir_numbering, t_duid did) //Functionality according to CIS{ uint32 vol = 1; //don't include audio volume uint32 count = 0; t_XItem index; uint32 nodes_num,offs; t_volume_selection_struct volume_selection_struct; volume_selection_struct.volume = vol; volume_selection_struct.direction = FORWARD; volume_selection_struct.audio_first = b_TRUE; volume_selection_struct.repeat = REPEAT_OFF; volume_selection_struct.device = did; offs = 0; while(1) // loop through all volumes of device { vol = XAR_FindNextVolume(&volume_selection_struct); //find volume for did volume_selection_struct.volume = vol; if (vol) { //now find song according to song_nr (see p. 81 in CIS 0.08 spec) index = XAR_VolumeNode(vol); nodes_num = index + X_array[index].data.xvolume.nodes_num; // volume's last item index++; //goto root dir index // root = index; // dirs numbering is PARENT_CHILD //if (dir_numbering == PARENT_CHILD) //{ while(1) //go through all dirs in volume { if (S_TRUE == XAR_IsDirectory(index)) { if(X_array[index].data.xdir.address > 0) // non zero if some playable files { count++; if (dir_numbering == PARENT_CHILD) { if (count == DirNr) //dir found { return index; } } else // Sequential numbering { if((offs + X_array[index].data.xdir.address)==DirNr) return index; } } } index++; // next item if (index>nodes_num) break; //we are at the end of volume, try,to find next volume with same did } //} } else break; offs = count; // remember total number of dirs } return S_NOT_FOUND; }/******************************************************************************//* Function: FindDirNrForIndex *//* *//*! \brief Calculates Song nr. from song index according to CIS0.08 (p.81) * \param t_XItem dir_index, t_dir_num_style dir_numbering (without AUDIO_TRACKS_OFFSET) * \return int16 CIS dir number * \remark *//******************************************************************************/int16 FindDirNrForIndex(t_XItem dir_index, t_dir_num_style dir_numbering) //Functionality according to CIS{ int offs,i,odev; int index; int vol = 1; //don't include audio volume if ((!dir_index)||(XTYPE_DIRECTORY!=XAR_NodeType(dir_index))) //error occured, invalid input param!! return 0; index = XAR_VolumeNodeForItem(dir_index); odev = XAR_DeviceTypeForItem(dir_index); offs = 0; vol = 2; while(1) { i = XAR_VolumeNode(vol); if((i<0)&&(i!=index)) return 0; if(i==index) break; // check if same device if(odev == XAR_VolNodeDevType(i)) { i++; while((i<X_NEXTFREE_ITEM)&&(XTYPE_VOLUME!=XAR_NodeType(i))) { if(XTYPE_DIRECTORY == XAR_NodeType(i)) { if(X_array[i].data.xdir.address) // address is not zero offs++; // if directory is not empty } i++; } } vol++; } if(dir_numbering==PATH_TABLE) { return (offs+X_array[dir_index].data.xdir.address); } else { index += 1 ; // this should be a root directory while(index<X_NEXTFREE_ITEM) { if(XAR_NodeType(index)== XTYPE_VOLUME) return 0; // error if(XAR_NodeType(index)==XTYPE_DIRECTORY) { if(X_array[index].data.xdir.address) // address is not zero offs++; } if(index >=dir_index) return offs; index++; } } return 0; // error}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -