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

📄 player.c

📁 本程序为ST公司开发的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    else          //out of range, select last playlist      player_playlist.fileNr = CountFilesForDevice(player_params.device, b_FALSE, SEARCH_PLAYLISTS);  }      //selected playlist is different from current, update playlist params  if (player_playlist.fileNr!= saved_playlist_nr)  {    player_playlist.xfile = FindIndexForItemNr(player_playlist.fileNr, player_dir_numbering, player_params.device, SEARCH_PLAYLISTS);       player_playlist.array_index = 0;    player_playlist.prepared_array_index = 0;    player_playlist.array_items = 0;    player_playlist.parsed = b_FALSE;    player_playlist.set = b_TRUE;  }  //if same don't change params   return b_TRUE;}/******************************************************************************//* Function:  player_shuffle_set_params			                                  *//*                                                                            *//*! \brief	  sets/resets params for shuffle functionality  *  \param    t_range range, t_repeat repeat, t_player_params * player_params  *  \return   t_bool b_TRUE if params set correctly *  \remark *//******************************************************************************/extern uint8 AudioTracksMarks[];t_bool player_shuffle_set_params(t_XItem current_song, t_player_params * player_params, t_player_playlist * player_playlist){	t_XItem dir = 0;	t_XItem song_index;	t_XNodeType node_type;	uint32  volume;	uint32 cd_tracks_count;		    //find proper volume for current song  if (XAR_XNodeType(current_song) == TRACK_CDDA)    {        volume = 1;  }  else  {    volume = XAR_VolumeForItem(current_song);  }    if (SHUFFLE_ON == player_params->shuffle)  {        if ((player_params->range_from == 0) && (player_params->range_num == 0))    {            if (!XAR_IsActiveVolume(volume))        return b_FALSE;      player_params->shuffle_index = 0;  		switch (player_params->range)  		{  			case RANGE_TRACK:  				return b_FALSE;		//unallowed combination  				  			case RANGE_DIRECTORY:   			  //range test and preparation  				if (volume>1)   				{            dir = XAR_DirFromFile(current_song);            if (S_NOT_FOUND == dir)             {              return b_FALSE;            }            player_params->range_num = 0;                     //reinit number of files            player_params->range_from = 0;            song_index = XAR_DirFirstFile(dir);            if (song_index)     //at least 1 song is in dir  (should exist, because dir is taken from current song)                            {               while (1) //calculate number of playable files in defined range              {                node_type = XAR_XNodeType(song_index);                if ((CAFILE_MP3 == node_type) || (node_type == CAFILE_WMA) || (node_type == CAFILE_AAC))                {                  //set first playable file                  if (!player_params->range_from)                    player_params->range_from = song_index;                                    (player_params->range_num)++;                                                   }                                song_index = XAR_NextFile(song_index,0);                              if (!song_index)    //no next file in current dir                  break;                              }            }            else            {              return b_FALSE; //no files found            }          }#ifdef AUDIO_AS_DIRECTORY		          else if (volume == 1)          {            player_params->range_num = CountFilesForVolume(1,SEARCH_PLAYABLE);            if (player_params->range_num)            {                              player_params->range_from = 1;              //automatically mark unplayable tracks              for (song_index = 1; song_index<=player_params->range_num;song_index ++)              {                if (XAR_XNodeType(song_index) == TRACK_ROM)                  //if rom track choosen(range audio but data track is not playable),mark it, choose next song imeediatelly                {                                	//if it is data track, mark imeediatelly                 	                  MarkSongAsPlayed(song_index, player_playlist);                     (player_params->shuffle_index)++;                }              }              return b_TRUE;            }            else              return b_FALSE; //no files found          }#endif          else            return b_FALSE; //not allowed for audio CDs set range directory          break;            			case RANGE_SUBDIRS:  			  //range test and preparation  				if (volume>1)   				{                        player_params->range_num = 0;                     //reinit number of files            player_params->range_from = 0;            song_index = XAR_DirFirstFile(dir);            if (song_index)     //at least 1 song is in dir  (should exist, because dir is taken from current song)                            {               while (1) //calculate number of playable files in defined range              {                node_type = XAR_XNodeType(song_index);                if ((CAFILE_MP3 == node_type) || (node_type == CAFILE_WMA) || (node_type == CAFILE_AAC))                {                  //set first playable file                  if (!player_params->range_from)                    player_params->range_from = song_index;                      							dir = XAR_DirFromFile(song_index);    							while (dir!=0)    							{    								if (player_params->parent_index == dir)    									break; 	//ok file is inside the parent    								else    									dir = XAR_DirParent(dir);    							}    							if (dir == 0)	//we went outside with file from current parent tree                    break;                  (player_params->range_num)++;                                                   }                                song_index = XAR_NextSong(volume, song_index,0);                            if (!song_index)    //no next file in current dir                  break;                              }            }            else            {              return b_FALSE;   //no files found in current context            }          }#ifdef AUDIO_AS_DIRECTORY		          else if (volume==1)          {            player_params->range_num = CountFilesForVolume(1,SEARCH_PLAYABLE);            if (player_params->range_num)            {                              player_params->range_from = 1;              //automatically mark unplayable tracks              for (song_index = 1; song_index<=player_params->range_num;song_index ++)              {                if (XAR_XNodeType(song_index) == TRACK_ROM)                  //if rom track choosen(range audio but data track is not playable),mark it, choose next song imeediatelly                {                                	//if it is data track, mark imeediatelly                 	                  MarkSongAsPlayed(song_index, player_playlist);                      player_params->shuffle_index++;                }              }                            return b_TRUE;            }            else              return b_FALSE; //no files found          }#endif                    else          {            return b_FALSE;  //not allowed for audio CDs set range directory          }          break;            			case RANGE_VOLUME:  			  if (volume == 1)   //separate for audio CDs  			  {  			    player_params->range_from = find_next_track(0, FORWARD, FALSE);   			    if (player_params->range_from)              player_params->range_num = CountFilesForVolume(1,SEARCH_PLAYABLE);			            //automatically mark unplayable tracks            for (song_index = 1; song_index<=player_params->range_num;song_index ++)            {              if (toc_is_track_rom(song_index))                  //if rom track choosen(range audio but data track is not playable),mark it, choose next song imeediatelly              {                              	//if it is data track, mark imeediatelly                 	                MarkSongAsPlayed(song_index, player_playlist);                    player_params->shuffle_index++;              }            }  			      			  }  			  else if (volume > 0)  			  {  			    player_params->range_num = CountFilesForVolume(volume,SEARCH_PLAYABLE);  			    if (player_params->range_num)    			    player_params->range_from = XAR_NextSong(0,volume,0);   //find first file  			  }  			  else   			    return b_FALSE;    //volume not specified  				break;  			case RANGE_DEVICE:				          if (DEV_NO_DEVICE != player_params->device)          {            player_params->range_num = CountFilesForDevice(player_params->device, b_TRUE,SEARCH_PLAYABLE);            //all non audio tracks            if (player_params->range_num)              player_params->range_from = 1;                        //automatically mark unplayable tracks            cd_tracks_count = CountFilesForVolume(1,SEARCH_PLAYABLE);                       for (song_index = 1; song_index<=cd_tracks_count;song_index ++)            {             if (XAR_XNodeType(song_index) == TRACK_ROM)                  //if rom track choosen(range audio but data track is not playable),mark it, choose next song imeediatelly             {                              	//if it is data track, mark imeediatelly                 	               MarkSongAsPlayed(song_index, player_playlist);                  player_params->shuffle_index++;             }            }              			    break;  			  }  			  else  			    return b_FALSE;  			case RANGE_ALL_VOLUMES:  			   player_params->range_num = CountFilesForDevice(DEV_NO_DEVICE,b_TRUE,SEARCH_PLAYABLE); //all non audio  			   if (player_params->range_num)  	  		   player_params->range_from = 1;  			              //automatically mark unplayable tracks           cd_tracks_count = CountFilesForVolume(1,SEARCH_PLAYABLE);                      for (song_index = 1; song_index<=cd_tracks_count;song_index ++)           {             if (toc_is_track_rom(song_index))                  //if rom track choosen(range audio but data track is not playable),mark it, choose next song imeediatelly             {                              	//if it is data track, mark imeediatelly                 	               MarkSongAsPlayed(song_index, player_playlist);                  player_params->shuffle_index++;             }           }   				 break;				   				   		  case RANGE_PLAYLIST:          //playlists handling                if ((player_playlist->enabled) && (player_playlist->parsed) && (player_playlist->array_items))          {      	    //tbd handle situation, when playlist is set but not yet processed            player_params->range_num = player_playlist->array_items;          }          break;  		}    }    if (player_params->range_num)      return b_TRUE;    else      return b_FALSE;  }   //end of shuffle_on  else  {     //shuffle off    if (XAR_XNodeType(current_song) == TRACK_CDDA)     //audio tracks range    { //clear audio marks anyway      ClearAudioTracksMarks(AudioTracksMarks, AUDIO_TRACKS_MARKS_BUFFER_SIZE);    }    ClearSongMarks(current_song, player_params, player_playlist);    player_params->range_from = 0;    player_params->range_num = 0;        player_params->shuffle_index = 0;#ifdef PLAYER_DEBUG    printf("player: Clearing shuffle index = 0\r\n");#endif      	                                    return b_TRUE;       }   //end of shuffle_off}/******************************************************************************//* Function:  player_song_is_in_current_range			                            *//*                                                                            *//*! \brief	  checks if song is in currently set range  *  \param    int16 song,const t_player_params * player_params, const t_player_playlist * player_playlist *  \return   t_bool  *  \remark *//******************************************************************************/t_bool player_song_is_in_current_range(t_XItem song, t_XItem current_song, const t_player_params * player_params, const t_player_playlist * player_playlist){  uint32  song_volume;	uint32  volume;    uint8   i;  t_XItem song_dir;  t_XItem dir;  t_duid  song_device;  //find proper volume for current song  if (XAR_NodeType(current_song) == XTYPE_TRACK)  {        volume = 1;  }  else  {    volume = XAR_VolumeForItem(current_song);  }  if (0 == song)    return b_FALSE;   //unallowed song nr.	switch (player_params->range)	{    case RANGE_TRACK:		  if (song == current_song)		    return b_TRUE;		  else			  return b_FALSE;							case RANGE_DIRECTORY: 		  if (XAR_NodeType(song) != XTYPE_TRACK)    //data track		  {		            song_dir = XAR_DirFromFile(song);        if (XAR_NodeType(current_song) == XTYPE_TRACK)          return b_FALSE;        else        {          dir = XAR_DirFromFile(current_song);          if (dir == song_dir)            return b_TRUE;    		  else    			  return b_FALSE;					        }		  }		  else  //audo tracks check		  {#ifdef AUDIO_AS_DIRECTORY				    if (XAR_NodeType(current_song) == XTYPE_TRACK)          return b_TRUE;  		  else  			  return b_FALSE;					#else        return b_FALSE;#endif		  }      		case RANGE_SUBDIRS:				  if (XAR_NodeType(song) != XTYPE_TRACK)    //data track		  {		            dir = XAR_DirFromFile(song);  			while (dir!=0)  			{  				if (player_params->parent_index == dir)  					return b_TRUE; 	//ok file is inside the parent

⌨️ 快捷键说明

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