Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

get_metadata() change
Monday, August 13th, 2007 at 3:45:09pm UTC 

  1. commit f28eac4a1b603f27a13fe7ea427bcd50b91bc180
  2. Author: Nicolas Pennequin <[email protected]>
  3. Date:   Tue Aug 7 19:54:05 2007 +0200
  4.  
  5.     Make get_metadata act on a struct mp3entry rather than a struct track_info.
  6.    
  7.     This should make it easy to use a buffer handle to put the ID3 data in.
  8.     The changes in get_metadata are mostly search and replace. The only thing
  9.     it actually used to do on the struct track_info was set taginfo_ready to
  10.     true.
  11.  
  12. diff --git a/apps/metadata.c b/apps/metadata.c
  13. index 15813c6..72f3b6f 100644
  14. --- a/apps/metadata.c
  15. +++ b/apps/metadata.c
  16. @@ -99,7 +99,7 @@ unsigned int probe_file_format(const char *filename)
  17.  /* Get metadata for track - return false if parsing showed problems with the
  18.   * file that would prevent playback.
  19.   */
  20. -bool get_metadata(struct track_info* track, int fd, const char* trackname,
  21. +bool get_metadata(struct mp3entry* id3, int fd, const char* trackname,
  22.                    bool v1first)
  23.  {
  24.  #if CONFIG_CODEC == SWCODEC
  25. @@ -109,15 +109,15 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
  26.  #endif
  27.  
  28.      /* Take our best guess at the codec type based on file extension */
  29. -    track->id3.codectype = probe_file_format(trackname);
  30. +    id3->codectype = probe_file_format(trackname);
  31.  
  32.      /* Load codec specific track tag information and confirm the codec type. */
  33. -    switch (track->id3.codectype)
  34. +    switch (id3->codectype)
  35.      {
  36.      case AFMT_MPA_L1:
  37.      case AFMT_MPA_L2:
  38.      case AFMT_MPA_L3:
  39. -        if (!get_mp3_metadata(fd, &track->id3, trackname, v1first))
  40. +        if (!get_mp3_metadata(fd, id3, trackname, v1first))
  41.          {
  42.              return false;
  43.          }
  44. @@ -126,7 +126,7 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
  45.  
  46.  #if CONFIG_CODEC == SWCODEC
  47.      case AFMT_FLAC:
  48. -        if (!get_flac_metadata(fd, &(track->id3)))
  49. +        if (!get_flac_metadata(fd, id3))
  50.          {
  51.              return false;
  52.          }
  53. @@ -134,28 +134,28 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
  54.          break;
  55.  
  56.      case AFMT_WMA:
  57. -        if (!get_asf_metadata(fd, &(track->id3)))
  58. +        if (!get_asf_metadata(fd, id3))
  59.          {
  60.              return false;
  61.          }
  62.          break;
  63.  
  64.      case AFMT_APE:
  65. -        if (!get_monkeys_metadata(fd, &(track->id3)))
  66. +        if (!get_monkeys_metadata(fd, id3))
  67.          {
  68.              return false;
  69.          }
  70. -        read_ape_tags(fd, &(track->id3));
  71. +        read_ape_tags(fd, id3);
  72.          break;
  73.  
  74.      case AFMT_MPC:
  75. -        if (!get_musepack_metadata(fd, &(track->id3)))
  76. +        if (!get_musepack_metadata(fd, id3))
  77.              return false;
  78. -        read_ape_tags(fd, &(track->id3));
  79. +        read_ape_tags(fd, id3);
  80.          break;
  81.      
  82.      case AFMT_OGG_VORBIS:
  83. -        if (!get_vorbis_metadata(fd, &(track->id3)))/*detects and handles Ogg/Speex files*/
  84. +        if (!get_vorbis_metadata(fd, id3))/*detects and handles Ogg/Speex files*/
  85.          {
  86.              return false;
  87.          }
  88. @@ -163,7 +163,7 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
  89.          break;
  90.  
  91.      case AFMT_SPEEX:
  92. -        if (!get_speex_metadata(fd, &(track->id3)))
  93. +        if (!get_speex_metadata(fd, id3))
  94.          {
  95.              return false;
  96.          }
  97. @@ -171,7 +171,7 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
  98.          break;
  99.  
  100.      case AFMT_PCM_WAV:
  101. -        if (!get_wave_metadata(fd, &(track->id3)))
  102. +        if (!get_wave_metadata(fd, id3))
  103.          {
  104.              return false;
  105.          }
  106. @@ -186,7 +186,7 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
  107.           */
  108.  
  109.          /* Use the trackname part of the id3 structure as a temporary buffer */
  110. -        buf = (unsigned char *)track->id3.path;
  111. +        buf = (unsigned char *)id3->path;
  112.        
  113.          for (i = 0; i < 256; ++i) {
  114.  
  115. @@ -211,8 +211,8 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
  116.              return false;
  117.          }
  118.  
  119. -        track->id3.vbr = true;   /* All WavPack files are VBR */
  120. -        track->id3.filesize = filesize (fd);
  121. +        id3->vbr = true;   /* All WavPack files are VBR */
  122. +        id3->filesize = filesize (fd);
  123.  
  124.          if ((buf [20] | buf [21] | buf [22] | buf [23]) &&
  125.              (buf [12] & buf [13] & buf [14] & buf [15]) != 0xff)
  126. @@ -221,24 +221,24 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
  127.  
  128.              if (srindx == 15)
  129.              {
  130. -                track->id3.frequency = 44100;
  131. +                id3->frequency = 44100;
  132.              }
  133.              else
  134.              {
  135. -                track->id3.frequency = wavpack_sample_rates[srindx];
  136. +                id3->frequency = wavpack_sample_rates[srindx];
  137.              }
  138.  
  139.              totalsamples = get_long_le(&buf[12]);
  140. -            track->id3.length = totalsamples / (track->id3.frequency / 100) * 10;
  141. -            track->id3.bitrate = filesize (fd) / (track->id3.length / 8);
  142. +            id3->length = totalsamples / (id3->frequency / 100) * 10;
  143. +            id3->bitrate = filesize (fd) / (id3->length / 8);
  144.          }
  145.  
  146. -        read_ape_tags(fd, &track->id3);     /* use any apetag info we find */
  147. +        read_ape_tags(fd, id3);     /* use any apetag info we find */
  148.          break;
  149.  
  150.      case AFMT_A52:
  151.          /* Use the trackname part of the id3 structure as a temporary buffer */
  152. -        buf = (unsigned char *)track->id3.path;
  153. +        buf = (unsigned char *)id3->path;
  154.          
  155.          if ((lseek(fd, 0, SEEK_SET) < 0) || (read(fd, buf, 5) < 5))
  156.          {
  157. @@ -259,25 +259,25 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
  158.              return false;
  159.          }
  160.        
  161. -        track->id3.bitrate = a52_bitrates[i >> 1];
  162. -        track->id3.vbr = false;
  163. -        track->id3.filesize = filesize(fd);
  164. +        id3->bitrate = a52_bitrates[i >> 1];
  165. +        id3->vbr = false;
  166. +        id3->filesize = filesize(fd);
  167.  
  168.          switch (buf[4] & 0xc0)
  169.          {
  170.          case 0x00:
  171. -            track->id3.frequency = 48000;
  172. -            track->id3.bytesperframe=track->id3.bitrate * 2 * 2;
  173. +            id3->frequency = 48000;
  174. +            id3->bytesperframe=id3->bitrate * 2 * 2;
  175.              break;
  176.              
  177.          case 0x40:
  178. -            track->id3.frequency = 44100;
  179. -            track->id3.bytesperframe = a52_441framesizes[i];
  180. +            id3->frequency = 44100;
  181. +            id3->bytesperframe = a52_441framesizes[i];
  182.              break;
  183.          
  184.          case 0x80:
  185. -            track->id3.frequency = 32000;
  186. -            track->id3.bytesperframe = track->id3.bitrate * 3 * 2;
  187. +            id3->frequency = 32000;
  188. +            id3->bytesperframe = id3->bitrate * 3 * 2;
  189.              break;
  190.          
  191.          default:
  192. @@ -287,13 +287,13 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
  193.          }
  194.  
  195.          /* One A52 frame contains 6 blocks, each containing 256 samples */
  196. -        totalsamples = track->id3.filesize / track->id3.bytesperframe * 6 * 256;
  197. -        track->id3.length = totalsamples / track->id3.frequency * 1000;
  198. +        totalsamples = id3->filesize / id3->bytesperframe * 6 * 256;
  199. +        id3->length = totalsamples / id3->frequency * 1000;
  200.          break;
  201.  
  202.      case AFMT_ALAC:
  203.      case AFMT_AAC:
  204. -        if (!get_mp4_metadata(fd, &(track->id3)))
  205. +        if (!get_mp4_metadata(fd, id3))
  206.          {
  207.              return false;
  208.          }
  209. @@ -301,9 +301,9 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
  210.          break;
  211.  
  212.      case AFMT_SHN:
  213. -        track->id3.vbr = true;
  214. -        track->id3.filesize = filesize(fd);
  215. -        if (!skip_id3v2(fd, &(track->id3)))
  216. +        id3->vbr = true;
  217. +        id3->filesize = filesize(fd);
  218. +        if (!skip_id3v2(fd, id3))
  219.          {
  220.              return false;
  221.          }
  222. @@ -311,22 +311,22 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
  223.          break;
  224.  
  225.      case AFMT_SID:
  226. -        if (!get_sid_metadata(fd, &(track->id3)))
  227. +        if (!get_sid_metadata(fd, id3))
  228.          {
  229.              return false;
  230.          }
  231.          break;
  232.      case AFMT_SPC:
  233. -        if(!get_spc_metadata(fd, &(track->id3)))
  234. +        if(!get_spc_metadata(fd, id3))
  235.          {
  236.              DEBUGF("get_spc_metadata error\n");
  237.          }
  238.  
  239. -        track->id3.filesize = filesize(fd);
  240. -        track->id3.genre_string = id3_get_num_genre(36);
  241. +        id3->filesize = filesize(fd);
  242. +        id3->genre_string = id3_get_num_genre(36);
  243.          break;
  244.      case AFMT_ADX:
  245. -        if (!get_adx_metadata(fd, &(track->id3)))
  246. +        if (!get_adx_metadata(fd, id3))
  247.          {
  248.              DEBUGF("get_adx_metadata error\n");
  249.              return false;
  250. @@ -334,19 +334,19 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
  251.          
  252.          break;
  253.      case AFMT_NSF:
  254. -        buf = (unsigned char *)track->id3.path;
  255. +        buf = (unsigned char *)id3->path;
  256.          if ((lseek(fd, 0, SEEK_SET) < 0) || ((read(fd, buf, 8)) < 8))
  257.          {
  258.              DEBUGF("lseek or read failed\n");
  259.              return false;
  260.          }
  261. -        track->id3.vbr = false;
  262. -        track->id3.filesize = filesize(fd);
  263. +        id3->vbr = false;
  264. +        id3->filesize = filesize(fd);
  265.          if (memcmp(buf,"NESM",4) && memcmp(buf,"NSFE",4)) return false;
  266.          break;
  267.  
  268.      case AFMT_AIFF:
  269. -        if (!get_aiff_metadata(fd, &(track->id3)))
  270. +        if (!get_aiff_metadata(fd, id3))
  271.          {
  272.              return false;
  273.          }
  274. @@ -367,13 +367,12 @@ bool get_metadata(struct track_info* track, int fd, const char* trackname,
  275.  #ifndef __PCTOOL__
  276.      if (cuesheet_is_enabled() && look_for_cuesheet_file(trackname, NULL))
  277.      {
  278. -        track->id3.cuesheet_type = 1;
  279. +        id3->cuesheet_type = 1;
  280.      }
  281.  #endif
  282.      
  283.      lseek(fd, 0, SEEK_SET);
  284. -    strncpy(track->id3.path, trackname, sizeof(track->id3.path));
  285. -    track->taginfo_ready = true;
  286. +    strncpy(id3->path, trackname, sizeof(id3->path));
  287.  
  288.      return true;
  289.  }
  290. diff --git a/apps/metadata.h b/apps/metadata.h
  291. index f790146..4682b35 100644
  292. --- a/apps/metadata.h
  293. +++ b/apps/metadata.h
  294. @@ -23,7 +23,7 @@
  295.  #include "playback.h"
  296.  
  297.  unsigned int probe_file_format(const char *filename);
  298. -bool get_metadata(struct track_info* track, int fd, const char* trackname,
  299. +bool get_metadata(struct mp3entry* id3, int fd, const char* trackname,
  300.                    bool v1first);
  301.  
  302.  #endif
  303. diff --git a/apps/playback.c b/apps/playback.c
  304. index 43c3b0a..13167e3 100644
  305. --- a/apps/playback.c
  306. +++ b/apps/playback.c
  307. @@ -2746,8 +2746,9 @@ static bool audio_load_track(int offset, bool start_play, bool rebuffer)
  308.      /* Get track metadata if we don't already have it. */
  309.      if (!tracks[track_widx].taginfo_ready)
  310.      {
  311. -        if (get_metadata(&tracks[track_widx],current_fd,trackname,v1first))
  312. +        if (get_metadata(&(tracks[track_widx].id3),current_fd,trackname,v1first))
  313.          {
  314. +            tracks[track_widx].taginfo_ready = true;
  315.              if (start_play)
  316.              {
  317.                  track_changed = true;
  318. @@ -2887,10 +2888,11 @@ static bool audio_read_next_metadata(void)
  319.      if (fd < 0)
  320.          return false;
  321.  
  322. -    status = get_metadata(&tracks[next_idx],fd,trackname,v1first);
  323. +    status = get_metadata(&(tracks[next_idx].id3),fd,trackname,v1first);
  324.      /* Preload the glyphs in the tags */
  325.      if (status)
  326.      {
  327. +        tracks[next_idx].taginfo_ready = true;
  328.          if (tracks[next_idx].id3.title)
  329.              lcd_getstringsize(tracks[next_idx].id3.title, NULL, NULL);
  330.          if (tracks[next_idx].id3.artist)
  331. diff --git a/apps/plugin.h b/apps/plugin.h
  332. index a424531..863ff8e 100644
  333. --- a/apps/plugin.h
  334. +++ b/apps/plugin.h
  335. @@ -617,7 +617,7 @@ struct plugin_api {
  336.  
  337.      int (*codec_load_file)(const char* codec, struct codec_api *api);
  338.      const char *(*get_codec_filename)(int cod_spec);
  339. -    bool (*get_metadata)(struct track_info* track, int fd, const char* trackname,
  340. +    bool (*get_metadata)(struct mp3entry* id3, int fd, const char* trackname,
  341.                           bool v1first);
  342.  #endif
  343.      void (*led)(bool on);
  344. diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c
  345. index 0e388ce..c29094b 100644
  346. --- a/apps/plugins/test_codec.c
  347. +++ b/apps/plugins/test_codec.c
  348. @@ -536,7 +536,7 @@ static enum plugin_status test_track(char* filename)
  349.      /* Clear the id3 struct */
  350.      rb->memset(&track.id3, 0, sizeof(struct mp3entry));
  351.  
  352. -    if (!rb->get_metadata(&track, fd, filename,
  353. +    if (!rb->get_metadata(&(track.id3), fd, filename,
  354.                      rb->global_settings->id3_v1_first))
  355.      {
  356.          log_text("Cannot read metadata",true);
  357. diff --git a/apps/tagcache.c b/apps/tagcache.c
  358. index da51e0c..8bb99c9 100644
  359. --- a/apps/tagcache.c
  360. +++ b/apps/tagcache.c
  361. @@ -1658,7 +1658,7 @@ static void add_tagcache(char *path)
  362.      memset(&track, 0, sizeof(struct track_info));
  363.      memset(&entry, 0, sizeof(struct temp_file_entry));
  364.      memset(&tracknumfix, 0, sizeof(tracknumfix));
  365. -    ret = get_metadata(&track, fd, path, false);
  366. +    ret = get_metadata(&(track.id3), fd, path, false);
  367.      close(fd);
  368.  
  369.      if (!ret)

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right
worth-right
worth-right