[vlc-devel] [PATCH 1/2] meta: define string constants for replaygain tags

Anatoliy Anischovich lin.aaa.lin at gmail.com
Tue Jul 29 00:13:46 CEST 2014


---
 include/vlc_meta.h     |  9 ++++++++-
 modules/codec/vorbis.c | 14 +++++++-------
 src/input/meta.c       | 18 +++++++++++-------
 3 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/include/vlc_meta.h b/include/vlc_meta.h
index c3bf801..750a976 100644
--- a/include/vlc_meta.h
+++ b/include/vlc_meta.h
@@ -161,6 +161,13 @@ VLC_API int input_item_WriteMeta(vlc_object_t *, input_item_t *);
 #define VLC_META_SHOW_NAME          vlc_meta_TypeToLocalizedString( vlc_meta_ShowName )
 #define VLC_META_ACTORS             vlc_meta_TypeToLocalizedString( vlc_meta_Actors )
 
-#define VLC_META_EXTRA_MB_ALBUMID   "MB_ALBUMID"
+#define VLC_META_EXTRA_MB_ALBUMID    "MB_ALBUMID"
+#define VLC_META_EXTRA_RG_TRACK_GAIN "REPLAYGAIN_TRACK_GAIN"
+#define VLC_META_EXTRA_RG_TRACK_PEAK "REPLAYGAIN_TRACK_PEAK"
+#define VLC_META_EXTRA_RG_ALBUM_GAIN "REPLAYGAIN_ALBUM_GAIN"
+#define VLC_META_EXTRA_RG_ALBUM_PEAK "REPLAYGAIN_ALBUM_PEAK"
+#define VLC_META_EXTRA_RG_RADIO      "RG_RADIO"
+#define VLC_META_EXTRA_RG_PEAK       "RG_PEAK"
+#define VLC_META_EXTRA_RG_AUDIOPHILE "RG_AUDIOPHILE"
 
 #endif
diff --git a/modules/codec/vorbis.c b/modules/codec/vorbis.c
index 53b2c60..eaa87c9 100644
--- a/modules/codec/vorbis.c
+++ b/modules/codec/vorbis.c
@@ -574,31 +574,31 @@ static void ParseVorbisComments( decoder_t *p_dec )
             *psz_value = '\0';
             psz_value++;
 
-            if( !strcasecmp( psz_name, "REPLAYGAIN_TRACK_GAIN" ) ||
-                !strcasecmp( psz_name, "RG_RADIO" ) )
+            if( !strcasecmp( psz_name, VLC_META_EXTRA_RG_TRACK_GAIN ) ||
+                !strcasecmp( psz_name, VLC_META_EXTRA_RG_RADIO ) )
             {
                 audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
 
                 r->pb_gain[AUDIO_REPLAY_GAIN_TRACK] = true;
                 r->pf_gain[AUDIO_REPLAY_GAIN_TRACK] = us_atof( psz_value );
             }
-            else if( !strcasecmp( psz_name, "REPLAYGAIN_TRACK_PEAK" ) ||
-                     !strcasecmp( psz_name, "RG_PEAK" ) )
+            else if( !strcasecmp( psz_name, VLC_META_EXTRA_RG_TRACK_PEAK ) ||
+                     !strcasecmp( psz_name, VLC_META_EXTRA_RG_PEAK ) )
             {
                 audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
 
                 r->pb_peak[AUDIO_REPLAY_GAIN_TRACK] = true;
                 r->pf_peak[AUDIO_REPLAY_GAIN_TRACK] = us_atof( psz_value );
             }
-            else if( !strcasecmp( psz_name, "REPLAYGAIN_ALBUM_GAIN" ) ||
-                     !strcasecmp( psz_name, "RG_AUDIOPHILE" ) )
+            else if( !strcasecmp( psz_name, VLC_META_EXTRA_RG_ALBUM_GAIN ) ||
+                     !strcasecmp( psz_name, VLC_META_EXTRA_RG_AUDIOPHILE ) )
             {
                 audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
 
                 r->pb_gain[AUDIO_REPLAY_GAIN_ALBUM] = true;
                 r->pf_gain[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( psz_value );
             }
-            else if( !strcasecmp( psz_name, "REPLAYGAIN_ALBUM_PEAK" ) )
+            else if( !strcasecmp( psz_name, VLC_META_EXTRA_RG_ALBUM_PEAK ) )
             {
                 audio_replay_gain_t *r = &p_dec->fmt_out.audio_replay_gain;
 
diff --git a/src/input/meta.c b/src/input/meta.c
index 892b4af..b4519e0 100644
--- a/src/input/meta.c
+++ b/src/input/meta.c
@@ -308,30 +308,34 @@ void vlc_audio_replay_gain_MergeFromMeta( audio_replay_gain_t *p_dst,
     if( !p_meta )
         return;
 
-    if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_TRACK_GAIN")) ||
-        (psz_value = vlc_meta_GetExtra(p_meta, "RG_RADIO")) )
+#define GET_EXTRA( str ) (psz_value = vlc_meta_GetExtra( p_meta, (str) ))
+
+    if( GET_EXTRA( VLC_META_EXTRA_RG_TRACK_GAIN ) ||
+        GET_EXTRA( VLC_META_EXTRA_RG_RADIO ) )
     {
         p_dst->pb_gain[AUDIO_REPLAY_GAIN_TRACK] = true;
         p_dst->pf_gain[AUDIO_REPLAY_GAIN_TRACK] = us_atof( psz_value );
     }
 
-    if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_TRACK_PEAK" )) ||
-             (psz_value = vlc_meta_GetExtra(p_meta, "RG_PEAK" )) )
+    if( GET_EXTRA( VLC_META_EXTRA_RG_TRACK_PEAK ) ||
+        GET_EXTRA( VLC_META_EXTRA_RG_PEAK ) )
     {
         p_dst->pb_peak[AUDIO_REPLAY_GAIN_TRACK] = true;
         p_dst->pf_peak[AUDIO_REPLAY_GAIN_TRACK] = us_atof( psz_value );
     }
 
-    if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_ALBUM_GAIN" )) ||
-             (psz_value = vlc_meta_GetExtra(p_meta, "RG_AUDIOPHILE" )) )
+    if( GET_EXTRA( VLC_META_EXTRA_RG_ALBUM_GAIN ) ||
+        GET_EXTRA( VLC_META_EXTRA_RG_AUDIOPHILE ) )
     {
         p_dst->pb_gain[AUDIO_REPLAY_GAIN_ALBUM] = true;
         p_dst->pf_gain[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( psz_value );
     }
 
-    if( (psz_value = vlc_meta_GetExtra(p_meta, "REPLAYGAIN_ALBUM_PEAK" )) )
+    if( GET_EXTRA( VLC_META_EXTRA_RG_ALBUM_PEAK ) )
     {
         p_dst->pb_peak[AUDIO_REPLAY_GAIN_ALBUM] = true;
         p_dst->pf_peak[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( psz_value );
     }
+
+#undef GET_EXTRA
 }
-- 
2.0.1




More information about the vlc-devel mailing list