/** * Allocates and initializes a vlc object. * * @param i_size object byte size * * @return the new object, or NULL on error. */ void *vlc_object_create( vlc_object_t *p_this, size_t i_size ) { return vlc_custom_create( p_this, i_size, VLC_OBJECT_GENERIC, "generic" ); }
/* Helpers */ static filter_t *filter_chain_AppendFilterInternal( filter_chain_t *p_chain, const char *psz_name, config_chain_t *p_cfg, const es_format_t *p_fmt_in, const es_format_t *p_fmt_out ) { chained_filter_t *p_chained = vlc_custom_create( p_chain->p_this, sizeof(*p_chained), VLC_OBJECT_GENERIC, "filter" ); filter_t *p_filter = &p_chained->filter; if( !p_filter ) return NULL; vlc_object_attach( p_filter, p_chain->p_this ); if( !p_fmt_in ) { if( p_chain->last != NULL ) p_fmt_in = &p_chain->last->filter.fmt_out; else p_fmt_in = &p_chain->fmt_in; } if( !p_fmt_out ) { p_fmt_out = &p_chain->fmt_out; } es_format_Copy( &p_filter->fmt_in, p_fmt_in ); es_format_Copy( &p_filter->fmt_out, p_fmt_out ); p_filter->p_cfg = p_cfg; p_filter->b_allow_fmt_out_change = p_chain->b_allow_fmt_out_change; p_filter->p_module = module_need( p_filter, p_chain->psz_capability, psz_name, psz_name != NULL ); if( !p_filter->p_module ) goto error; if( p_filter->b_allow_fmt_out_change ) { es_format_Clean( &p_chain->fmt_out ); es_format_Copy( &p_chain->fmt_out, &p_filter->fmt_out ); } if( AllocatorInit( &p_chain->allocator, p_chained ) ) goto error; if( p_chain->last == NULL ) { assert( p_chain->first == NULL ); p_chain->first = p_chained; } else p_chain->last->next = p_chained; p_chained->prev = p_chain->last; p_chain->last = p_chained; p_chained->next = NULL; p_chain->length++; vlc_mouse_t *p_mouse = malloc( sizeof(*p_mouse) ); if( p_mouse ) vlc_mouse_Init( p_mouse ); p_chained->mouse = p_mouse; msg_Dbg( p_chain->p_this, "Filter '%s' (%p) appended to chain", psz_name ? psz_name : module_get_name(p_filter->p_module, false), p_filter ); return p_filter; error: if( psz_name ) msg_Err( p_chain->p_this, "Failed to create %s '%s'", p_chain->psz_capability, psz_name ); else msg_Err( p_chain->p_this, "Failed to create %s", p_chain->psz_capability ); if( p_filter->p_module ) module_unneed( p_filter, p_filter->p_module ); es_format_Clean( &p_filter->fmt_in ); es_format_Clean( &p_filter->fmt_out ); vlc_object_detach( p_filter ); vlc_object_release( p_filter ); return NULL; }
/** * Create and start an interface. * * @param playlist playlist and parent object for the interface * @param chain configuration chain string * @return VLC_SUCCESS or an error code */ int intf_Create( playlist_t *playlist, const char *chain ) { /* Allocate structure */ intf_thread_t *p_intf = vlc_custom_create( playlist, sizeof( *p_intf ), "interface" ); if( unlikely(p_intf == NULL) ) return VLC_ENOMEM; /* Variable used for interface spawning */ vlc_value_t val, text; var_Create( p_intf, "intf-add", VLC_VAR_STRING | VLC_VAR_HASCHOICE | VLC_VAR_ISCOMMAND ); text.psz_string = _("Add Interface"); var_Change( p_intf, "intf-add", VLC_VAR_SETTEXT, &text, NULL ); #if !defined(_WIN32) && defined(HAVE_ISATTY) if( isatty( 0 ) ) #endif { val.psz_string = (char *)"rc,none"; text.psz_string = (char *)_("Console"); var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text ); } val.psz_string = (char *)"telnet,none"; text.psz_string = (char *)_("Telnet"); var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text ); val.psz_string = (char *)"http,none"; text.psz_string = (char *)_("Web"); var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text ); val.psz_string = (char *)"logger,none"; text.psz_string = (char *)_("Debug logging"); var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text ); val.psz_string = (char *)"gestures,none"; text.psz_string = (char *)_("Mouse Gestures"); var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text ); var_AddCallback( p_intf, "intf-add", AddIntfCallback, playlist ); /* Choose the best module */ char *module; p_intf->p_cfg = NULL; free( config_ChainCreate( &module, &p_intf->p_cfg, chain ) ); p_intf->p_module = module_need( p_intf, "interface", module, true ); free(module); if( p_intf->p_module == NULL ) { msg_Err( p_intf, "no suitable interface module" ); goto error; } vlc_mutex_lock( &lock ); p_intf->p_next = pl_priv( playlist )->interface; pl_priv( playlist )->interface = p_intf; vlc_mutex_unlock( &lock ); return VLC_SUCCESS; error: if( p_intf->p_module ) module_unneed( p_intf, p_intf->p_module ); config_ChainDestroy( p_intf->p_cfg ); vlc_object_release( p_intf ); return VLC_EGENERIC; }
/***************************************************************************** * aout_New: initialize aout structure *****************************************************************************/ audio_output_t *aout_New( vlc_object_t * p_parent ) { audio_output_t *aout = vlc_custom_create (p_parent, sizeof (aout_instance_t), "audio output"); if (unlikely(aout == NULL)) return NULL; aout_owner_t *owner = aout_owner (aout); vlc_mutex_init (&owner->lock); owner->module = NULL; owner->input = NULL; vlc_mutex_init (&owner->volume.lock); owner->volume.multiplier = 1.0; owner->volume.mixer = NULL; aout->pf_play = aout_DecDeleteBuffer; aout_VolumeNoneInit (aout); vlc_object_set_destructor (aout, aout_Destructor); /* * Persistent audio output variables */ vlc_value_t val, text; char *str; var_Create (aout, "intf-change", VLC_VAR_VOID); /* Visualizations */ var_Create (aout, "visual", VLC_VAR_STRING | VLC_VAR_HASCHOICE); text.psz_string = _("Visualizations"); var_Change (aout, "visual", VLC_VAR_SETTEXT, &text, NULL); val.psz_string = (char *)""; text.psz_string = _("Disable"); var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); val.psz_string = (char *)"spectrometer"; text.psz_string = _("Spectrometer"); var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); val.psz_string = (char *)"scope"; text.psz_string = _("Scope"); var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); val.psz_string = (char *)"spectrum"; text.psz_string = _("Spectrum"); var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); val.psz_string = (char *)"vuMeter"; text.psz_string = _("Vu meter"); var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); /* Look for goom plugin */ if (module_exists ("goom")) { val.psz_string = (char *)"goom"; text.psz_string = (char *)"Goom"; var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); } /* Look for libprojectM plugin */ if (module_exists ("projectm")) { val.psz_string = (char *)"projectm"; text.psz_string = (char*)"projectM"; var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); } str = var_GetNonEmptyString (aout, "effect-list"); if (str != NULL) { var_SetString (aout, "visual", str); free (str); } /* Equalizer */ var_Create (aout, "equalizer", VLC_VAR_STRING | VLC_VAR_HASCHOICE); text.psz_string = _("Equalizer"); var_Change (aout, "equalizer", VLC_VAR_SETTEXT, &text, NULL); val.psz_string = (char*)""; text.psz_string = _("Disable"); var_Change (aout, "equalizer", VLC_VAR_ADDCHOICE, &val, &text); { module_config_t *cfg = config_FindConfig (VLC_OBJECT(aout), "equalizer-preset"); if (cfg != NULL) for (int i = 0; i < cfg->i_list; i++) { val.psz_string = (char *)cfg->ppsz_list[i]; text.psz_string = (char *)cfg->ppsz_list_text[i]; var_Change (aout, "equalizer", VLC_VAR_ADDCHOICE, &val, &text); } } var_Create (aout, "audio-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT); text.psz_string = _("Audio filters"); var_Change (aout, "audio-filter", VLC_VAR_SETTEXT, &text, NULL); var_Create (aout, "audio-visual", VLC_VAR_STRING | VLC_VAR_DOINHERIT); text.psz_string = _("Audio visualizations"); var_Change (aout, "audio-visual", VLC_VAR_SETTEXT, &text, NULL); /* Replay gain */ var_Create (aout, "audio-replay-gain-mode", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); text.psz_string = _("Replay gain"); var_Change (aout, "audio-replay-gain-mode", VLC_VAR_SETTEXT, &text, NULL); { module_config_t *cfg = config_FindConfig (VLC_OBJECT(aout), "audio-replay-gain-mode"); if( cfg != NULL ) for (int i = 0; i < cfg->i_list; i++) { val.psz_string = (char *)cfg->ppsz_list[i]; text.psz_string = (char *)cfg->ppsz_list_text[i]; var_Change (aout, "audio-replay-gain-mode", VLC_VAR_ADDCHOICE, &val, &text); } } return aout; }
/** * Create and start an interface. * * @param p_this the calling vlc_object_t * @param chain configuration chain string * @return VLC_SUCCESS or an error code */ int intf_Create( vlc_object_t *p_this, const char *chain ) { libvlc_int_t *p_libvlc = p_this->p_libvlc; intf_thread_t * p_intf; /* Allocate structure */ p_intf = vlc_custom_create( p_libvlc, sizeof( *p_intf ), "interface" ); if( !p_intf ) return VLC_ENOMEM; /* Variable used for interface spawning */ vlc_value_t val, text; var_Create( p_intf, "intf-add", VLC_VAR_STRING | VLC_VAR_HASCHOICE | VLC_VAR_ISCOMMAND ); text.psz_string = _("Add Interface"); var_Change( p_intf, "intf-add", VLC_VAR_SETTEXT, &text, NULL ); #if !defined(WIN32) && defined(HAVE_ISATTY) if( isatty( 0 ) ) #endif { val.psz_string = (char *)"rc"; text.psz_string = (char *)_("Console"); var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text ); } val.psz_string = (char *)"telnet"; text.psz_string = (char *)_("Telnet"); var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text ); val.psz_string = (char *)"http"; text.psz_string = (char *)_("Web"); var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text ); val.psz_string = (char *)"logger"; text.psz_string = (char *)_("Debug logging"); var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text ); val.psz_string = (char *)"gestures"; text.psz_string = (char *)_("Mouse Gestures"); var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text ); var_AddCallback( p_intf, "intf-add", AddIntfCallback, NULL ); /* Attach interface to LibVLC */ #if defined( __APPLE__ ) p_intf->b_should_run_on_first_thread = false; #endif /* Choose the best module */ p_intf->p_cfg = NULL; char *psz_parser = *chain == '$' ? var_CreateGetString(p_intf, chain+1) : strdup( chain ); char *module; char *psz_tmp = config_ChainCreate( &module, &p_intf->p_cfg, psz_parser ); free( psz_tmp ); free( psz_parser ); p_intf->p_module = module_need( p_intf, "interface", module, true ); free(module); if( p_intf->p_module == NULL ) { msg_Err( p_intf, "no suitable interface module" ); goto error; } vlc_mutex_lock( &lock ); #if defined( __APPLE__ ) /* Hack to get Mac OS X Cocoa runtime running * (it needs access to the main thread) */ if( p_intf->b_should_run_on_first_thread ) { if( vlc_clone( &p_intf->thread, MonitorLibVLCDeath, p_intf, VLC_THREAD_PRIORITY_LOW ) ) { msg_Err( p_intf, "cannot spawn libvlc death monitoring thread" ); vlc_mutex_unlock( &lock ); goto error; } assert( p_intf->pf_run ); p_intf->pf_run( p_intf ); /* It is monitoring libvlc, not the p_intf */ vlc_object_kill( p_intf->p_libvlc ); vlc_join( p_intf->thread, NULL ); } else #endif /* Run the interface in a separate thread */ if( p_intf->pf_run && vlc_clone( &p_intf->thread, RunInterface, p_intf, VLC_THREAD_PRIORITY_LOW ) ) { msg_Err( p_intf, "cannot spawn interface thread" ); vlc_mutex_unlock( &lock ); goto error; } p_intf->p_next = libvlc_priv( p_libvlc )->p_intf; libvlc_priv( p_libvlc )->p_intf = p_intf; vlc_mutex_unlock( &lock ); return VLC_SUCCESS; error: if( p_intf->p_module ) module_unneed( p_intf, p_intf->p_module ); config_ChainDestroy( p_intf->p_cfg ); vlc_object_release( p_intf ); return VLC_EGENERIC; }
encoder_t *sout_EncoderCreate( vlc_object_t *p_this ) { return vlc_custom_create( p_this, sizeof( encoder_t ), "encoder" ); }
/***************************************************************************** * sout_MuxNew: create a new mux *****************************************************************************/ sout_mux_t * sout_MuxNew( sout_instance_t *p_sout, const char *psz_mux, sout_access_out_t *p_access ) { sout_mux_t *p_mux; char *psz_next; p_mux = vlc_custom_create( p_sout, sizeof( *p_mux ), "mux" ); if( p_mux == NULL ) return NULL; p_mux->p_sout = p_sout; psz_next = config_ChainCreate( &p_mux->psz_mux, &p_mux->p_cfg, psz_mux ); free( psz_next ); p_mux->p_access = p_access; p_mux->pf_control = NULL; p_mux->pf_addstream = NULL; p_mux->pf_delstream = NULL; p_mux->pf_mux = NULL; p_mux->i_nb_inputs = 0; p_mux->pp_inputs = NULL; p_mux->p_sys = NULL; p_mux->p_module = NULL; p_mux->b_add_stream_any_time = false; p_mux->b_waiting_stream = true; p_mux->i_add_stream_start = -1; p_mux->p_module = module_need( p_mux, "sout mux", p_mux->psz_mux, true ); if( p_mux->p_module == NULL ) { FREENULL( p_mux->psz_mux ); vlc_object_release( p_mux ); return NULL; } /* *** probe mux capacity *** */ if( p_mux->pf_control ) { int b_answer = false; if( sout_MuxControl( p_mux, MUX_CAN_ADD_STREAM_WHILE_MUXING, &b_answer ) ) { b_answer = false; } if( b_answer ) { msg_Dbg( p_sout, "muxer support adding stream at any time" ); p_mux->b_add_stream_any_time = true; p_mux->b_waiting_stream = false; /* If we control the output pace then it's better to wait before * starting muxing (generates better streams/files). */ if( !p_sout->i_out_pace_nocontrol ) { b_answer = true; } else if( sout_MuxControl( p_mux, MUX_GET_ADD_STREAM_WAIT, &b_answer ) ) { b_answer = false; } if( b_answer ) { msg_Dbg( p_sout, "muxer prefers to wait for all ES before " "starting to mux" ); p_mux->b_waiting_stream = true; } } } return p_mux; }
/** * Creates an audio output object and initializes an output module. */ audio_output_t *aout_New (vlc_object_t *parent) { vlc_value_t val, text; audio_output_t *aout = vlc_custom_create (parent, sizeof (aout_instance_t), "audio output"); if (unlikely(aout == NULL)) return NULL; aout_owner_t *owner = aout_owner (aout); vlc_mutex_init (&owner->lock); vlc_mutex_init (&owner->req.lock); vlc_mutex_init (&owner->dev.lock); owner->req.device = (char *)unset_str; owner->req.volume = -1.f; owner->req.mute = -1; vlc_object_set_destructor (aout, aout_Destructor); /* Audio output module callbacks */ var_Create (aout, "volume", VLC_VAR_FLOAT); var_AddCallback (aout, "volume", var_Copy, parent); var_Create (aout, "mute", VLC_VAR_BOOL | VLC_VAR_DOINHERIT); var_AddCallback (aout, "mute", var_Copy, parent); var_Create (aout, "device", VLC_VAR_STRING); aout->event.volume_report = aout_VolumeNotify; aout->event.mute_report = aout_MuteNotify; aout->event.policy_report = aout_PolicyNotify; aout->event.device_report = aout_DeviceNotify; aout->event.hotplug_report = aout_HotplugNotify; aout->event.gain_request = aout_GainNotify; aout->event.restart_request = aout_RestartNotify; /* Audio output module initialization */ aout->start = NULL; aout->stop = NULL; aout->volume_set = NULL; aout->mute_set = NULL; aout->device_select = NULL; owner->module = module_need (aout, "audio output", "$aout", false); if (owner->module == NULL) { msg_Err (aout, "no suitable audio output module"); vlc_object_release (aout); return NULL; } /* * Persistent audio output variables */ module_config_t *cfg; char *str; /* Visualizations */ var_Create (aout, "visual", VLC_VAR_STRING | VLC_VAR_HASCHOICE); text.psz_string = _("Visualizations"); var_Change (aout, "visual", VLC_VAR_SETTEXT, &text, NULL); val.psz_string = (char *)""; text.psz_string = _("Disable"); var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); val.psz_string = (char *)"spectrometer"; text.psz_string = _("Spectrometer"); var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); val.psz_string = (char *)"scope"; text.psz_string = _("Scope"); var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); val.psz_string = (char *)"spectrum"; text.psz_string = _("Spectrum"); var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); val.psz_string = (char *)"vuMeter"; text.psz_string = _("Vu meter"); var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); /* Look for goom plugin */ if (module_exists ("goom")) { val.psz_string = (char *)"goom"; text.psz_string = (char *)"Goom"; var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); } /* Look for libprojectM plugin */ if (module_exists ("projectm")) { val.psz_string = (char *)"projectm"; text.psz_string = (char*)"projectM"; var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); } /* Look for VSXu plugin */ if (module_exists ("vsxu")) { val.psz_string = (char *)"vsxu"; text.psz_string = (char*)"Vovoid VSXu"; var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); } /* Look for glspectrum plugin */ if (module_exists ("glspectrum")) { val.psz_string = (char *)"glspectrum"; text.psz_string = (char*)"3D spectrum"; var_Change (aout, "visual", VLC_VAR_ADDCHOICE, &val, &text); } str = var_GetNonEmptyString (aout, "effect-list"); if (str != NULL) { var_SetString (aout, "visual", str); free (str); } /* Equalizer */ var_Create (aout, "equalizer", VLC_VAR_STRING | VLC_VAR_HASCHOICE); text.psz_string = _("Equalizer"); var_Change (aout, "equalizer", VLC_VAR_SETTEXT, &text, NULL); val.psz_string = (char*)""; text.psz_string = _("Disable"); var_Change (aout, "equalizer", VLC_VAR_ADDCHOICE, &val, &text); cfg = config_FindConfig (VLC_OBJECT(aout), "equalizer-preset"); if (likely(cfg != NULL)) for (unsigned i = 0; i < cfg->list_count; i++) { val.psz_string = cfg->list.psz[i]; text.psz_string = vlc_gettext(cfg->list_text[i]); var_Change (aout, "equalizer", VLC_VAR_ADDCHOICE, &val, &text); } var_Create (aout, "audio-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT); text.psz_string = _("Audio filters"); var_Change (aout, "audio-filter", VLC_VAR_SETTEXT, &text, NULL); var_Create (aout, "audio-visual", VLC_VAR_STRING | VLC_VAR_DOINHERIT); text.psz_string = _("Audio visualizations"); var_Change (aout, "audio-visual", VLC_VAR_SETTEXT, &text, NULL); /* Replay gain */ var_Create (aout, "audio-replay-gain-mode", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); text.psz_string = _("Replay gain"); var_Change (aout, "audio-replay-gain-mode", VLC_VAR_SETTEXT, &text, NULL); cfg = config_FindConfig (VLC_OBJECT(aout), "audio-replay-gain-mode"); if (likely(cfg != NULL)) for (unsigned i = 0; i < cfg->list_count; i++) { val.psz_string = cfg->list.psz[i]; text.psz_string = vlc_gettext(cfg->list_text[i]); var_Change (aout, "audio-replay-gain-mode", VLC_VAR_ADDCHOICE, &val, &text); } var_Create (aout, "equalizer-preamp", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT); var_Create (aout, "equalizer-bands", VLC_VAR_STRING | VLC_VAR_DOINHERIT); return aout; }
void system_Configure( libvlc_int_t *p_this, int i_argc, const char *const ppsz_argv[] ) { /* Raise default priority of the current process */ #ifndef ABOVE_NORMAL_PRIORITY_CLASS # define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000 #endif if( var_InheritBool( p_this, "high-priority" ) ) { if( SetPriorityClass( GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS ) || SetPriorityClass( GetCurrentProcess(), HIGH_PRIORITY_CLASS ) ) { msg_Dbg( p_this, "raised process priority" ); } else { msg_Dbg( p_this, "could not raise process priority" ); } } #if !defined(WINAPI_FAMILY_APP) if( var_InheritBool( p_this, "one-instance" ) || ( var_InheritBool( p_this, "one-instance-when-started-from-file" ) && var_InheritBool( p_this, "started-from-file" ) ) ) { HANDLE hmutex; msg_Info( p_this, "one instance mode ENABLED"); /* Use a named mutex to check if another instance is already running */ if( !( hmutex = CreateMutex( 0, TRUE, L"VLC ipc "VERSION ) ) ) { /* Failed for some reason. Just ignore the option and go on as * normal. */ msg_Err( p_this, "one instance mode DISABLED " "(mutex couldn't be created)" ); return; } if( GetLastError() != ERROR_ALREADY_EXISTS ) { /* We are the 1st instance. */ p_helper = vlc_custom_create( p_this, sizeof(*p_helper), "ipc helper" ); /* Run the helper thread */ hIPCHelperReady = CreateEvent( NULL, FALSE, FALSE, NULL ); hIPCHelper = _beginthreadex( NULL, 0, IPCHelperThread, p_helper, 0, NULL ); if( hIPCHelper ) WaitForSingleObject( hIPCHelperReady, INFINITE ); else { msg_Err( p_this, "one instance mode DISABLED " "(IPC helper thread couldn't be created)" ); vlc_object_release (p_helper); p_helper = NULL; } CloseHandle( hIPCHelperReady ); /* Initialization done. * Release the mutex to unblock other instances */ ReleaseMutex( hmutex ); } else { /* Another instance is running */ HWND ipcwindow; /* Wait until the 1st instance is initialized */ WaitForSingleObject( hmutex, INFINITE ); /* Locate the window created by the IPC helper thread of the * 1st instance */ if( !( ipcwindow = FindWindow( 0, L"VLC ipc "VERSION ) ) ) { msg_Err( p_this, "one instance mode DISABLED " "(couldn't find 1st instance of program)" ); ReleaseMutex( hmutex ); return; } /* We assume that the remaining parameters are filenames * and their input options */ if( i_argc > 0 ) { COPYDATASTRUCT wm_data; int i_opt; vlc_ipc_data_t *p_data; size_t i_data = sizeof (*p_data); for( i_opt = 0; i_opt < i_argc; i_opt++ ) { i_data += sizeof (size_t); i_data += strlen( ppsz_argv[ i_opt ] ) + 1; } p_data = malloc( i_data ); p_data->argc = i_argc; p_data->enqueue = var_InheritBool( p_this, "playlist-enqueue" ); i_data = 0; for( i_opt = 0; i_opt < i_argc; i_opt++ ) { size_t i_len = strlen( ppsz_argv[ i_opt ] ) + 1; /* Windows will never switch to an architecture * with stronger alignment requirements, right. */ *((size_t *)(p_data->data + i_data)) = i_len; i_data += sizeof (size_t); memcpy( &p_data->data[i_data], ppsz_argv[ i_opt ], i_len ); i_data += i_len; } i_data += sizeof (*p_data); /* Send our playlist items to the 1st instance */ wm_data.dwData = 0; wm_data.cbData = i_data; wm_data.lpData = p_data; SendMessage( ipcwindow, WM_COPYDATA, 0, (LPARAM)&wm_data ); } /* Initialization done. * Release the mutex to unblock other instances */ ReleaseMutex( hmutex ); /* Bye bye */ system_End( ); exit( 0 ); } } #endif }