[vlc-devel] [PATCH] Extra meta data from mod files

Konstanty konstanty at ieee.org
Sun Apr 26 15:49:23 CEST 2009


This patch shows MOD file instruments and samples in the extra meta data
(These are usually used by artists for description etc)

This time following the style guide more closely.

---
 modules/demux/mod.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/modules/demux/mod.c b/modules/demux/mod.c
index bc7ec69..8b1726a 100644
--- a/modules/demux/mod.c
+++ b/modules/demux/mod.c
@@ -366,9 +366,52 @@ static int Control( demux_t *p_demux, int i_query,
va_list args )
     case DEMUX_GET_META:
     {
         vlc_meta_t *p_meta = (vlc_meta_t *)va_arg( args, vlc_meta_t* );
+        unsigned i_num_samples = ModPlug_NumSamples( p_sys->f ),
+            i_num_instruments = ModPlug_NumInstruments( p_sys->f );
+        uint32_t i_num_patterns = ModPlug_NumPatterns( p_sys->f ),
+            i_num_channels = ModPlug_NumChannels( p_sys->f );
+//      uint32_t modType = ModPlug_GetModuleType( p_sys->f );
+        char psz_temp[2048]; /* 32 * 240 max, but only need start  */
+        char *psz_module_info;
+        uint32_t i_temp_index = 0, i;
         const char *psz_name = ModPlug_GetName( p_sys->f );
         if( psz_name && *psz_name )
             vlc_meta_SetTitle( p_meta, psz_name );
+
+        if ( asprintf(&psz_module_info, "%i Channels, %i Patterns\n"
+            "%i Samples, %i Instruments\n",
+            i_num_channels, i_num_patterns, i_num_samples,
i_num_instruments ))
+        {
+            vlc_meta_AddExtra( p_meta, "Module Information",
psz_module_info );
+            free( psz_module_info );
+        }
+
+        /* Make list of samples */
+        for ( i = 0; i < i_num_samples && i_temp_index < sizeof(psz_temp);
i++ )
+        {
+            char lBuffer[33];
+            ModPlug_SampleName( p_sys->f, i, lBuffer );
+            if ( !lBuffer[0] ) continue; // don't add empty fields.
+            i_temp_index += snprintf( &psz_temp[i_temp_index],
sizeof(psz_temp) - i_temp_index, "%s\n", lBuffer );
+        }
+
+        vlc_meta_AddExtra( p_meta, "Samples", psz_temp );
+
+        /* Make list of instruments (XM, IT, etc) */
+        if (i_num_instruments)
+        {
+            i_temp_index = 0;
+            for ( i = 0; i < i_num_instruments && i_temp_index <
sizeof(psz_temp); i++ )
+            {
+                char lBuffer[33];
+                ModPlug_InstrumentName( p_sys->f, i, lBuffer );
+                if ( !lBuffer[0] ) continue; // don't add empty fields.
+                i_temp_index += snprintf( &psz_temp[i_temp_index],
sizeof(psz_temp) - i_temp_index, "%s\n", lBuffer );
+            }
+
+            vlc_meta_AddExtra( p_meta, "Instruments", psz_temp );
+        }
+
         return VLC_SUCCESS;
     }

-- 
1.6.0.6
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20090426/4dbbcd06/attachment.html>


More information about the vlc-devel mailing list