X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Fgme.cpp;h=e24f04b9d059b8134d3ffea83ecc0a39f1c08bf1;hb=4a590357633e5ad7419034bd7f20bf175cc12f45;hp=d6ef6e90d2c7b2f2e1638616d9077918e91f26ee;hpb=763ec5c2a42d5146bffadfbcec453533ed3ff821;p=vlc diff --git a/modules/demux/gme.cpp b/modules/demux/gme.cpp index d6ef6e90d2..e24f04b9d0 100644 --- a/modules/demux/gme.cpp +++ b/modules/demux/gme.cpp @@ -24,10 +24,13 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include /* malloc(), free() */ -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include #include "Nsf_Emu.h" #include "Gbs_Emu.h" @@ -47,15 +50,15 @@ using namespace std; static int Open ( vlc_object_t * ); static void Close ( vlc_object_t * ); -vlc_module_begin(); - set_shortname( "GME"); - set_description( _("GME demuxer (Game_Music_Emu)" ) ); - set_capability( "demux2", 10 ); - set_category( CAT_INPUT ); - set_subcategory( SUBCAT_INPUT_DEMUX ); - set_callbacks( Open, Close ); - add_shortcut( "gme" ); -vlc_module_end(); +vlc_module_begin () + set_shortname( "GME") + set_description( N_("GME demuxer (Game_Music_Emu)" ) ) + set_capability( "demux", 10 ) + set_category( CAT_INPUT ) + set_subcategory( SUBCAT_INPUT_DEMUX ) + set_callbacks( Open, Close ) + add_shortcut( "gme" ) +vlc_module_end () /***************************************************************************** * Local prototypes @@ -114,9 +117,9 @@ static int Open( vlc_object_t *p_this ) char *ext; int i; vlc_value_t val; - + /* We accept file based on extention match */ - if( strcasecmp( p_demux->psz_demux, "gme" ) ) + if( !p_demux->b_force ) { if( ( ext = strrchr( p_demux->psz_path, '.' ) ) == NULL || stream_Size( p_demux->s ) == 0 ) return VLC_EGENERIC; @@ -159,7 +162,7 @@ static int Open( vlc_object_t *p_this ) } /* Prepare emulator */ - + #ifdef HAVE_ZLIB_H if (i == 4) /* gzipped vgm */ { @@ -167,7 +170,7 @@ static int Open( vlc_object_t *p_this ) size_t i_outsize; inflate_gzbuf( p_sys->p_data, p_sys->i_data, &p_outbuffer, &i_outsize ); - + if (p_outbuffer == NULL) { msg_Err( p_demux, "failed to understand the file : unable to inflate vgz file" ); @@ -182,11 +185,11 @@ static int Open( vlc_object_t *p_this ) p_sys->p_data = p_outbuffer; p_sys->i_data = i_outsize; - } + } #endif - p_sys->p_reader = new Emu_Mem_Reader( p_sys->p_data, p_sys->i_data ); - + p_sys->p_reader = new Emu_Mem_Reader( p_sys->p_data, p_sys->i_data ); + switch(i) { case 0: @@ -216,17 +219,15 @@ static int Open( vlc_object_t *p_this ) p_emu->init( 44100 ); \ p_sys->p_musicemu = p_emu; \ p_sys->p_reader->read( &header, sizeof(header) ); \ - p_error = p_emu->load( header, *(p_sys->p_reader) ); + p_error = p_emu->load( header, *(p_sys->p_reader) ); p_sys->p_meta = vlc_meta_New(); char psz_temp[512]; -#define SET_META(vlc_meta, meta_info...) \ - snprintf( psz_temp, 511, meta_info ); \ - vlc_meta_Add( p_sys->p_meta, vlc_meta, psz_temp ); - - SET_META( VLC_META_CODEC_NAME, type_str[p_sys->i_type]) - + + /// \todo Reinstate meta codec name + //SET_META( VLC_META_CODEC_NAME, type_str[p_sys->i_type]) + const char * p_error; switch(p_sys->i_type) @@ -236,9 +237,9 @@ static int Open( vlc_object_t *p_this ) INIT_EMU(Nsf) if (p_error == NULL) { - SET_META( VLC_META_TITLE, "%s", header.game ) - SET_META( VLC_META_AUTHOR, "%s", header.author ) - SET_META( VLC_META_COPYRIGHT, "%s", header.copyright ) + vlc_meta_SetTitle( p_meta, header.game ); + vlc_meta_SetArtist( p_meta, header.author ); + vlc_meta_SetCopyright( p_meta, header.copyright ); p_sys->i_tracks = p_emu->track_count(); } } @@ -248,9 +249,9 @@ static int Open( vlc_object_t *p_this ) INIT_EMU(Gbs) if (p_error == NULL) { - SET_META( VLC_META_TITLE, "%s", header.game ) - SET_META( VLC_META_AUTHOR, "%s", header.author ) - SET_META( VLC_META_COPYRIGHT, "%s", header.copyright ) + vlc_meta_SetTitle( p_meta, header.game ); + vlc_meta_SetArtist( p_meta, header.author ); + vlc_meta_SetCopyright( p_meta, header.copyright ); p_sys->i_tracks = p_emu->track_count(); } } @@ -269,8 +270,9 @@ static int Open( vlc_object_t *p_this ) INIT_EMU(Spc) if (p_error == NULL) { - SET_META( VLC_META_TITLE, "%s (%s)", header.song, header.game ) - SET_META( VLC_META_AUTHOR, "%s", header.author ) + snprintf( psz_temp, 511, "%s (%s)", header.song, header.game ); + vlc_meta_SetTitle( p_meta, psz_temp ); + vlc_meta_SetArtist( p_meta, header.author ); p_sys->i_tracks = p_emu->track_count(); } } @@ -280,13 +282,14 @@ static int Open( vlc_object_t *p_this ) INIT_EMU(Gym) if (p_error == NULL) { - SET_META( VLC_META_TITLE, "%s (%s)", header.song, header.game ) - SET_META( VLC_META_COPYRIGHT, "%s", header.copyright ) + snprintf( psz_temp, 511, "%s (%s)", header.song, header.game ); + vlc_meta_SetTitle( p_meta, psz_temp ); + vlc_meta_SetCopyright( p_meta, header.copyright ); p_sys->i_tracks = p_emu->track_count(); } } break; - } + } if( p_error != NULL ) { @@ -316,7 +319,7 @@ static int Open( vlc_object_t *p_this ) p_sys->fmt.audio.i_channels = 2; p_sys->fmt.audio.i_bitspersample = 16; p_sys->es = es_out_Add( p_demux->out, &p_sys->fmt ); - + return VLC_SUCCESS; } @@ -353,7 +356,7 @@ static int Demux( demux_t *p_demux ) p_frame = block_New( p_demux, i_buf ); p_sys->p_musicemu->play( i_emubuf, p_emubuf ); - + /* if( p_error != NULL ) { @@ -417,7 +420,6 @@ switch( i_query ) { ModPlug_Seek( p_sys->f, i64 / 1000 ); p_sys->i_time = i64 + 1; - es_out_Control( p_demux->out, ES_OUT_RESET_PCR ); return VLC_SUCCESS; } @@ -440,7 +442,6 @@ switch( i_query ) { ModPlug_Seek( p_sys->f, i64 / 1000 ); p_sys->i_time = i64 + 1; - es_out_Control( p_demux->out, ES_OUT_RESET_PCR ); return VLC_SUCCESS; } @@ -470,7 +471,7 @@ switch( i_query ) case DEMUX_SET_TITLE: i_idx = (int)va_arg( args, int ); - p_sys->p_musicemu->start_track( i_idx ); + p_sys->p_musicemu->start_track( i_idx ); p_demux->info.i_title = i_idx; p_demux->info.i_update = INPUT_UPDATE_TITLE; msg_Dbg( p_demux, "set title %i", i_idx); @@ -533,8 +534,8 @@ static void inflate_gzbuf(uint8_t * p_buffer, size_t i_size, uint8_t ** pp_obuff (*pi_osize) = out_size - z_str.avail_out; inflateEnd(&z_str); - - out_buffer = (uint8_t *)realloc(out_buffer, *pi_osize); + + out_buffer = (uint8_t *)realloc(out_buffer, *pi_osize); (*pp_obuffer) = out_buffer; } #endif