[vlc-devel] [PATCH] Extra meta data from mod files
Konstanty
konstanty at ieee.org
Sun Apr 26 15:10:30 CEST 2009
This patch adds additional meta data to vlc when playing MOD files
(libmodplug) - Specifically Instruments and Samples are shown (as these are
usually used by artists for description etc)
---
modules/demux/mod.c | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/modules/demux/mod.c b/modules/demux/mod.c
index bc7ec69..2a4b0a4 100644
--- a/modules/demux/mod.c
+++ b/modules/demux/mod.c
@@ -366,9 +366,47 @@ 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* );
+ uint32_t numSamples = ModPlug_NumSamples( p_sys->f ),
+ numInstruments = ModPlug_NumInstruments( p_sys->f );
+ uint32_t numPatterns = ModPlug_NumPatterns( p_sys->f ),
+ numChannels = ModPlug_NumChannels( p_sys->f );
+// uint32_t modType = ModPlug_GetModuleType( p_sys->f );
+ char psz_temp[1024];
+ uint32_t 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 );
+
+ snprintf(psz_temp, 99, "%i Channels, %i Patterns\n"
+ "%i Samples, %i Instruments\n",
+ numChannels, numPatterns, numSamples, numInstruments);
+ vlc_meta_AddExtra( p_meta, "Module Information", psz_temp);
+
+ for ( i = 0; i< numSamples && 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.
+ temp_index += snprintf(&psz_temp[temp_index],
sizeof(psz_temp)-temp_index,
+ "%s\n", lBuffer);
+ }
+
+ vlc_meta_AddExtra( p_meta, "Samples", psz_temp);
+
+ if (numInstruments) {
+ snprintf(psz_temp, 99, "%i\n", numInstruments);
+ vlc_meta_AddExtra( p_meta, "Number of Instruments", psz_temp);
+
+ temp_index = 0;
+ for ( i = 0; i< numInstruments && temp_index<sizeof(psz_temp); i++)
{
+ char lBuffer[33];
+ ModPlug_InstrumentName( p_sys->f, i, lBuffer );
+ temp_index += snprintf(&psz_temp[temp_index],
sizeof(psz_temp)-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/f3d0f6e2/attachment.html>
More information about the vlc-devel
mailing list