Example #1
0
/*****************************************************************************
 * Config handling
 *****************************************************************************/
static int vlclua_config_get( lua_State *L )
{
    vlc_object_t * p_this = vlclua_get_this( L );
    const char *psz_name = luaL_checkstring( L, 1 );
    switch( config_GetType( p_this, psz_name ) )
    {
        case VLC_VAR_STRING:
        {
            char *psz = config_GetPsz( p_this, psz_name );
            lua_pushstring( L, psz );
            free( psz );
            break;
        }

        case VLC_VAR_INTEGER:
            lua_pushinteger( L, config_GetInt( p_this, psz_name ) );
            break;

        case VLC_VAR_BOOL:
            lua_pushboolean( L, config_GetInt( p_this, psz_name ) );
            break;

        case VLC_VAR_FLOAT:
            lua_pushnumber( L, config_GetFloat( p_this, psz_name ) );
            break;

        default:
            return vlclua_error( L );

    }
    return 1;
}
Example #2
0
/**
 * Finds the value of a variable. If the specified object does not hold a
 * variable with the specified name, try the parent object, and iterate until
 * the top of the tree. If no match is found, the value is read from the
 * configuration.
 */
int var_Inherit( vlc_object_t *p_this, const char *psz_name, int i_type,
                 vlc_value_t *p_val )
{
    i_type &= VLC_VAR_CLASS;
    for( vlc_object_t *obj = p_this; obj != NULL; obj = obj->obj.parent )
    {
        if( var_GetChecked( obj, psz_name, i_type, p_val ) == VLC_SUCCESS )
            return VLC_SUCCESS;
    }

    /* else take value from config */
    switch( i_type & VLC_VAR_CLASS )
    {
        case VLC_VAR_STRING:
            p_val->psz_string = config_GetPsz( p_this, psz_name );
            if( !p_val->psz_string ) p_val->psz_string = strdup("");
            break;
        case VLC_VAR_FLOAT:
            p_val->f_float = config_GetFloat( p_this, psz_name );
            break;
        case VLC_VAR_INTEGER:
            p_val->i_int = config_GetInt( p_this, psz_name );
            break;
        case VLC_VAR_BOOL:
            p_val->b_bool = config_GetInt( p_this, psz_name );
            break;
        default:
            vlc_assert_unreachable();
        case VLC_VAR_ADDRESS:
            return VLC_ENOOBJ;
    }
    return VLC_SUCCESS;
}
Example #3
0
/*****************************************************************************
 * aout_VolumeDown : lower the output volume
 *****************************************************************************
 * If pi_volume != NULL, *pi_volume will contain the volume at the end of the
 * function.
 *****************************************************************************/
int __aout_VolumeDown( vlc_object_t * p_object, int i_nb_steps,
                       audio_volume_t * pi_volume )
{
    vlc_value_t val;
    aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
                               FIND_ANYWHERE );
    int i_result = 0, i_volume = 0, i_volume_step = 0;

    i_volume_step = config_GetInt( p_object->p_libvlc, "volume-step" );
    i_volume = config_GetInt( p_object, "volume" );
    i_volume -= i_volume_step * i_nb_steps;
    if ( i_volume < AOUT_VOLUME_MIN )
    {
        i_volume = AOUT_VOLUME_MIN;
    }
    config_PutInt( p_object, "volume", i_volume );
    var_Create( p_object->p_libvlc, "saved-volume", VLC_VAR_INTEGER );
    var_SetInteger( p_object->p_libvlc, "saved-volume", (audio_volume_t) i_volume );
    if ( pi_volume != NULL ) *pi_volume = (audio_volume_t) i_volume;

    val.b_bool = true;
    var_Set( p_object->p_libvlc, "volume-change", val );

    if ( p_aout == NULL ) return 0;

    aout_lock_mixer( p_aout );
    if ( !p_aout->mixer.b_error )
    {
        i_result = p_aout->output.pf_volume_set( p_aout, (audio_volume_t) i_volume );
    }
    aout_unlock_mixer( p_aout );

    vlc_object_release( p_aout );
    return i_result;
}
Example #4
0
File: intf.c Project: paa/vlc
/*****************************************************************************
 * aout_VolumeGet : get the volume of the output device
 *****************************************************************************/
int aout_VolumeGet( vlc_object_t * p_object, audio_volume_t * pi_volume )
{
    int i_result = 0;
    aout_instance_t * p_aout = findAout( p_object );

    if ( pi_volume == NULL ) return -1;

    if ( p_aout == NULL )
    {
        *pi_volume = (audio_volume_t)config_GetInt( p_object, "volume" );
        return 0;
    }

    aout_lock_volume( p_aout );
    aout_lock_mixer( p_aout );
    if ( p_aout->p_mixer )
    {
        i_result = p_aout->output.pf_volume_get( p_aout, pi_volume );
    }
    else
    {
        *pi_volume = (audio_volume_t)config_GetInt( p_object, "volume" );
    }
    aout_unlock_mixer( p_aout );
    aout_unlock_volume( p_aout );

    vlc_object_release( p_aout );
    return i_result;
}
Example #5
0
/*****************************************************************************
 * aout_VolumeGet : get the volume of the output device
 *****************************************************************************/
int __aout_VolumeGet( vlc_object_t * p_object, audio_volume_t * pi_volume )
{
    int i_result = 0;
    aout_instance_t * p_aout = vlc_object_find( p_object, VLC_OBJECT_AOUT,
                               FIND_ANYWHERE );

    if ( pi_volume == NULL ) return -1;

    if ( p_aout == NULL )
    {
        *pi_volume = (audio_volume_t)config_GetInt( p_object, "volume" );
        return 0;
    }

    aout_lock_mixer( p_aout );
    if ( !p_aout->mixer.b_error )
    {
        i_result = p_aout->output.pf_volume_get( p_aout, pi_volume );
    }
    else
    {
        *pi_volume = (audio_volume_t)config_GetInt( p_object, "volume" );
    }
    aout_unlock_mixer( p_aout );

    vlc_object_release( p_aout );
    return i_result;
}
Example #6
0
/*****************************************************************************
 * vlc_thread_set_priority: set the priority of the current thread when we
 * couldn't set it in vlc_thread_create (for instance for the main thread)
 *****************************************************************************/
int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
                               int i_line, int i_priority )
{
    vlc_object_internals_t *p_priv = vlc_internals( p_this );

    if( !p_priv->b_thread )
    {
        msg_Err( p_this, "couldn't set priority of non-existent thread" );
        return ESRCH;
    }

#if defined( LIBVLC_USE_PTHREAD )
# ifndef __APPLE__
    if( config_GetInt( p_this, "rt-priority" ) > 0 )
# endif
    {
        int i_error, i_policy;
        struct sched_param param;

        memset( &param, 0, sizeof(struct sched_param) );
        if( config_GetType( p_this, "rt-offset" ) )
            i_priority += config_GetInt( p_this, "rt-offset" );
        if( i_priority <= 0 )
        {
            param.sched_priority = (-1) * i_priority;
            i_policy = SCHED_RR;
        }
        else
        {
            param.sched_priority = i_priority;
            i_policy = SCHED_RR;
        }
        if( (i_error = pthread_setschedparam( p_priv->thread_id,
                                              i_policy, &param )) )
        {
            errno = i_error;
            msg_Warn( p_this, "couldn't set thread priority (%s:%d): %m",
                      psz_file, i_line );
            i_priority = 0;
        }
    }

#elif defined( WIN32 ) || defined( UNDER_CE )
    VLC_UNUSED( psz_file); VLC_UNUSED( i_line );

    if( !SetThreadPriority(p_priv->thread_id, i_priority) )
    {
        msg_Warn( p_this, "couldn't set a faster priority" );
        return 1;
    }

#endif

    return 0;
}
Example #7
0
/**
 * Finds the value of a variable. If the specified object does not hold a
 * variable with the specified name, try the parent object, and iterate until
 * the top of the tree. If no match is found, the value is read from the
 * configuration.
 */
int var_Inherit( vlc_object_t *p_this, const char *psz_name, int i_type,
                 vlc_value_t *p_val )
{
#ifndef NDEBUG
    if (p_this != VLC_OBJECT(p_this->p_libvlc)
     && unlikely(p_this->p_parent == NULL))
    {
        msg_Info (p_this, "%s(%s) on detached object", __func__, psz_name);
        //vlc_backtrace ();
    }
#endif
    i_type &= VLC_VAR_CLASS;
    for( vlc_object_t *obj = p_this; obj != NULL; obj = obj->p_parent )
    {
        if( var_GetChecked( obj, psz_name, i_type, p_val ) == VLC_SUCCESS )
            return VLC_SUCCESS;
#ifndef NDEBUG
        if (obj != p_this && obj != VLC_OBJECT(p_this->p_libvlc)
         && unlikely(obj->p_parent == NULL))
        {
            msg_Info (p_this, "%s(%s) on detached tree [%p] %s", __func__,
                      psz_name, obj, obj->psz_object_type);
            //vlc_backtrace ();
        }
#endif
    }

    /* else take value from config */
    switch( i_type & VLC_VAR_CLASS )
    {
        case VLC_VAR_STRING:
            p_val->psz_string = config_GetPsz( p_this, psz_name );
            if( !p_val->psz_string ) p_val->psz_string = strdup("");
            break;
        case VLC_VAR_FLOAT:
            p_val->f_float = config_GetFloat( p_this, psz_name );
            break;
        case VLC_VAR_INTEGER:
            p_val->i_int = config_GetInt( p_this, psz_name );
            break;
        case VLC_VAR_BOOL:
            p_val->b_bool = config_GetInt( p_this, psz_name );
            break;
        case VLC_VAR_ADDRESS:
            return VLC_ENOOBJ;
        default:
            msg_Warn( p_this, "Could not inherit value for var %s "
                              "from config. Invalid Type", psz_name );
            return VLC_ENOOBJ;
    }
    /*msg_Dbg( p_this, "Inherited value for var %s from config", psz_name );*/
    return VLC_SUCCESS;
}
Example #8
0
/*****************************************************************************
 * GtkAutoplayFile: Autoplay file depending on configuration settings
 *****************************************************************************/
void GtkAutoPlayFile( vlc_object_t *p_this )
{
    GtkWidget *cbautoplay;
    intf_thread_t *p_intf;
    int i_index;
    vlc_list_t *p_list = vlc_list_find( p_this, VLC_OBJECT_INTF,
                                        FIND_ANYWHERE );

    for( i_index = 0; i_index < p_list->i_count; i_index++ )
    {
        p_intf = (intf_thread_t *)p_list->p_values[i_index].p_object ;

        if( strcmp( MODULE_STRING, p_intf->p_module->psz_object_name ) )
        {
            continue;
        }
        cbautoplay = GTK_WIDGET( gtk_object_get_data(
                            GTK_OBJECT( p_intf->p_sys->p_window ),
                            "cbautoplay" ) );

        if( !config_GetInt( p_this, "pda-autoplayfile" ) )
        {
            p_intf->p_sys->b_autoplayfile = VLC_FALSE;
        }
        else
        {
            p_intf->p_sys->b_autoplayfile = VLC_TRUE;
        }
        gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( cbautoplay ),
                                      p_intf->p_sys->b_autoplayfile );
    }
    vlc_list_release( p_list );
}
Example #9
0
/*****************************************************************************
 * Activate: initialize and create stuff
 *****************************************************************************/
static int Activate( vlc_object_t *p_this )
{
    intf_thread_t *p_intf = (intf_thread_t*)p_this;
    int fd;

    if( config_GetInt( p_intf, "netsync-master" ) <= 0 )
    {
        char *psz_master = config_GetPsz( p_intf, "netsync-master-ip" );
        if( psz_master == NULL )
        {
            msg_Err( p_intf, "master address not specified" );
            return VLC_EGENERIC;
        }
        fd = net_ConnectUDP( VLC_OBJECT(p_intf), psz_master, NETSYNC_PORT, -1 );
        free( psz_master );
    }
    else
        fd = net_ListenUDP1( VLC_OBJECT(p_intf), NULL, NETSYNC_PORT );

    if( fd == -1 )
    {
        msg_Err( p_intf, "Netsync socket failure" );
        return VLC_EGENERIC;
    }

    p_intf->p_sys = (void *)(intptr_t)fd;
    p_intf->pf_run = Run;
    return VLC_SUCCESS;
}
Example #10
0
/*****************************************************************************
 * aout_VolumeMute : Mute/un-mute the output volume
 *****************************************************************************
 * If pi_volume != NULL, *pi_volume will contain the volume at the end of the
 * function (muted => 0).
 *****************************************************************************/
int __aout_VolumeMute( vlc_object_t * p_object, audio_volume_t * pi_volume )
{
    int i_result;
    audio_volume_t i_volume;

    i_volume = (audio_volume_t)config_GetInt( p_object, "volume" );
    if ( i_volume != 0 )
    {
        /* Mute */
        i_result = aout_VolumeSet( p_object, AOUT_VOLUME_MIN );
        var_Create( p_object->p_libvlc, "saved-volume", VLC_VAR_INTEGER );
        var_SetInteger( p_object->p_libvlc, "saved-volume", (int)i_volume );
        if ( pi_volume != NULL ) *pi_volume = AOUT_VOLUME_MIN;
    }
    else
    {
        /* Un-mute */
        var_Create( p_object->p_libvlc, "saved-volume", VLC_VAR_INTEGER );
        i_volume = (audio_volume_t)var_GetInteger( p_object->p_libvlc,
                   "saved-volume" );
        i_result = aout_VolumeSet( p_object, i_volume );
        if ( pi_volume != NULL ) *pi_volume = i_volume;
    }

    return i_result;
}
Example #11
0
int playlist_MLDump( playlist_t *p_playlist )
{
    char *psz_datadir;

    if( !config_GetInt( p_playlist, "media-library") )
        return VLC_SUCCESS;

    psz_datadir = config_GetUserDir( VLC_DATA_DIR );

    if( !psz_datadir ) /* XXX: This should never happen */
    {
        msg_Err( p_playlist, "no data directory, cannot save media library") ;
        return VLC_EGENERIC;
    }

    char psz_dirname[ strlen( psz_datadir ) + sizeof( DIR_SEP "ml.xspf")];
    strcpy( psz_dirname, psz_datadir );
    free( psz_datadir );
    if( config_CreateDir( (vlc_object_t *)p_playlist, psz_dirname ) )
    {
        return VLC_EGENERIC;
    }

    strcat( psz_dirname, DIR_SEP "ml.xspf" );

    stats_TimerStart( p_playlist, "ML Dump", STATS_TIMER_ML_DUMP );
    playlist_Export( p_playlist, psz_dirname, p_playlist->p_ml_category,
                     "export-xspf" );
    stats_TimerStop( p_playlist, STATS_TIMER_ML_DUMP );

    return VLC_SUCCESS;
}
Example #12
0
/**
 * Display current audio volume bitmap
 *
 * The OSD Menu audio volume bar is updated to reflect the new audio volume. Call this function
 * when the audio volume is updated outside the OSD menu command "menu up", "menu down" or "menu select".
 */
void osd_Volume( vlc_object_t *p_this )
{
    osd_button_t *p_button = NULL;
    int i_volume = 0;
    int i_steps = 0;

    osd_menu_t *p_osd = osd_FindVisible( p_this );
    if( p_osd == NULL )
        return;

    if( p_osd->p_state && p_osd->p_state->p_volume )
    {

        p_button = p_osd->p_state->p_volume;
        if( p_osd->p_state->p_volume )
            p_osd->p_state->p_visible = p_osd->p_state->p_volume;
        if( p_button && p_button->b_range )
        {
            /* Update the volume state images to match the current volume */
            i_volume = config_GetInt( p_this, "volume" );
            i_steps = osd_VolumeStep( p_this, i_volume, p_button->i_ranges );
            p_button->p_current_state = osd_VolumeStateChange( p_button->p_states, i_steps );

            osd_UpdateState( p_osd->p_state,
                    p_button->i_x, p_button->i_y,
                    p_button->p_current_state->i_width,
                    p_button->p_current_state->i_height,
                    p_button->p_current_state->p_pic );
            osd_SetMenuUpdate( p_osd, true );
            osd_SetMenuVisible( p_osd, true );
        }
    }
    vlc_mutex_unlock( &osd_mutex );
}
Example #13
0
File: sap.c Project: forthyen/SDesk
/**
 * Create the SAP handler
 *
 * \param p_announce the parent announce_handler
 * \return the newly created SAP handler or NULL on error
 */
sap_handler_t *announce_SAPHandlerCreate( announce_handler_t *p_announce )
{
    sap_handler_t *p_sap;

    p_sap = vlc_object_create( p_announce, sizeof( sap_handler_t ) );

    if( !p_sap )
    {
        msg_Err( p_announce, "out of memory" );
        return NULL;
    }

    vlc_mutex_init( p_sap, &p_sap->object_lock );

    p_sap->pf_add = announce_SAPAnnounceAdd;
    p_sap->pf_del = announce_SAPAnnounceDel;

    p_sap->i_sessions = 0;
    p_sap->i_addresses = 0;
    p_sap->i_current_session = 0;

    p_sap->b_control = config_GetInt( p_sap, "sap-flow-control");

    if( vlc_thread_create( p_sap, "sap handler", RunThread,
                       VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
    {
        msg_Dbg( p_announce, "Unable to spawn SAP handler thread");
        free( p_sap );
        return NULL;
    };
    msg_Dbg( p_announce, "thread created, %i sessions", p_sap->i_sessions);
    return p_sap;
}
Example #14
0
/*****************************************************************************
 * OpenFilter:
 *****************************************************************************/
static int OpenFilter( vlc_object_t *p_this )
{
    filter_t *p_filter = (filter_t *)p_this;
    filter_sys_t *p_sys;
    unsigned int i_out_rate  = p_filter->fmt_out.audio.i_rate;
    double d_factor;
    int i_filter_wing;

    if( p_filter->fmt_in.audio.i_rate == p_filter->fmt_out.audio.i_rate ||
        p_filter->fmt_in.i_codec != VLC_CODEC_FL32 )
    {
        return VLC_EGENERIC;
    }

#if !defined( SYS_DARWIN )
    if( !config_GetInt( p_this, "hq-resampling" ) )
    {
        return VLC_EGENERIC;
    }
#endif

    /* Allocate the memory needed to store the module's structure */
    p_filter->p_sys = p_sys = malloc( sizeof(struct filter_sys_t) );
    if( p_sys == NULL )
        return VLC_ENOMEM;

    /* Calculate worst case for the length of the filter wing */
    d_factor = (double)i_out_rate / p_filter->fmt_in.audio.i_rate;
    i_filter_wing = ((SMALL_FILTER_NMULT + 1)/2.0)
                      * __MAX(1.0, 1.0/d_factor) + 10;
    p_filter->p_sys->i_buf_size = p_filter->fmt_in.audio.i_channels *
        sizeof(int32_t) * 2 * i_filter_wing;

    /* Allocate enough memory to buffer previous samples */
    p_filter->p_sys->p_buf = malloc( p_filter->p_sys->i_buf_size );
    if( p_filter->p_sys->p_buf == NULL )
    {
        free( p_sys );
        return VLC_ENOMEM;
    }

    p_filter->p_sys->i_old_wing = 0;
    p_sys->b_first = true;
    p_sys->b_filter2 = true;
    p_filter->pf_audio_filter = Resample;

    msg_Dbg( p_this, "%4.4s/%iKHz/%i->%4.4s/%iKHz/%i",
             (char *)&p_filter->fmt_in.i_codec,
             p_filter->fmt_in.audio.i_rate,
             p_filter->fmt_in.audio.i_channels,
             (char *)&p_filter->fmt_out.i_codec,
             p_filter->fmt_out.audio.i_rate,
             p_filter->fmt_out.audio.i_channels);

    p_filter->fmt_out = p_filter->fmt_in;
    p_filter->fmt_out.audio.i_rate = i_out_rate;

    return 0;
}
Example #15
0
File: osd.c Project: paa/vlc
static int osd_VolumeStep( vlc_object_t *p_this, int i_volume, int i_steps )
{
    int i_volume_step = 0;
    (void)i_steps;

    i_volume_step = config_GetInt( p_this->p_libvlc, "volume-step" );
    return (i_volume/i_volume_step);
}
Example #16
0
/*****************************************************************************
 * Create: allocate linear resampler
 *****************************************************************************/
static int Create( vlc_object_t *p_this )
{
    aout_filter_t * p_filter = (aout_filter_t *)p_this;
    struct filter_sys_t * p_sys;
    double d_factor;
    int i_filter_wing;

    if ( p_filter->input.i_rate == p_filter->output.i_rate
          || p_filter->input.i_format != p_filter->output.i_format
          || p_filter->input.i_physical_channels
              != p_filter->output.i_physical_channels
          || p_filter->input.i_original_channels
              != p_filter->output.i_original_channels
          || p_filter->input.i_format != VLC_CODEC_FL32 )
    {
        return VLC_EGENERIC;
    }

#if !defined( __APPLE__ )
    if( !config_GetInt( p_this, "hq-resampling" ) )
    {
        return VLC_EGENERIC;
    }
#endif

    /* Allocate the memory needed to store the module's structure */
    p_sys = malloc( sizeof(filter_sys_t) );
    if( p_sys == NULL )
        return VLC_ENOMEM;
    p_filter->p_sys = (struct aout_filter_sys_t *)p_sys;

    /* Calculate worst case for the length of the filter wing */
    d_factor = (double)p_filter->output.i_rate
                        / p_filter->input.i_rate / AOUT_MAX_INPUT_RATE;
    i_filter_wing = ((SMALL_FILTER_NMULT + 1)/2.0)
                      * __MAX(1.0, 1.0/d_factor) + 10;
    p_sys->i_buf_size = aout_FormatNbChannels( &p_filter->input ) *
        sizeof(int32_t) * 2 * i_filter_wing;

    /* Allocate enough memory to buffer previous samples */
    p_sys->p_buf = malloc( p_sys->i_buf_size );
    if( p_sys->p_buf == NULL )
    {
        free( p_sys );
        return VLC_ENOMEM;
    }

    p_sys->i_old_wing = 0;
    p_sys->b_filter2 = false;           /* It seams to be a good valuefor this module */
    p_filter->pf_do_work = DoWork;

    /* We don't want a new buffer to be created because we're not sure we'll
     * actually need to resample anything. */
    p_filter->b_in_place = true;

    return VLC_SUCCESS;
}
Example #17
0
Volume::Volume( intf_thread_t *pIntf ): VarPercent( pIntf )
{
    // compute preferred step in [0.,1.] range
    m_step = (float)config_GetInt( pIntf, "volume-step" )
             / (float)AOUT_VOLUME_MAX;

    // set current volume from the playlist
    playlist_t* pPlaylist = pIntf->p_sys->p_playlist;
    setVolume( var_GetFloat( pPlaylist, "volume" ), false );
}
Example #18
0
File: xcb.c Project: FLYKingdom/vlc
static void Mapping( intf_thread_t *p_intf )
{
    static const xcb_keysym_t p_x11_modifier_ignored[] = {
        0,
        XK_Num_Lock,
        XK_Scroll_Lock,
        XK_Caps_Lock,
    };

    intf_sys_t *p_sys = p_intf->p_sys;

    p_sys->i_map = 0;
    p_sys->p_map = NULL;

    /* Registering of Hotkeys */
    for( struct hotkey *p_hotkey = p_intf->p_libvlc->p_hotkeys;
            p_hotkey->psz_action != NULL;
            p_hotkey++ )
    {
        char *psz_hotkey;
        if( asprintf( &psz_hotkey, "global-%s", p_hotkey->psz_action ) < 0 )
            break;

        const int i_vlc_action = p_hotkey->i_action;
        const int i_vlc_key = config_GetInt( p_intf, psz_hotkey );

        free( psz_hotkey );

        if( !i_vlc_key )
            continue;

        const xcb_keycode_t key = xcb_key_symbols_get_keycode( p_sys->p_symbols, GetX11Key( i_vlc_key & ~KEY_MODIFIER ) );
        const unsigned i_modifier = GetX11Modifier( p_sys->p_connection, p_sys->p_symbols, i_vlc_key & KEY_MODIFIER );

        for( int j = 0; j < sizeof(p_x11_modifier_ignored)/sizeof(*p_x11_modifier_ignored); j++ )
        {
            const unsigned i_ignored = GetModifier( p_sys->p_connection, p_sys->p_symbols, p_x11_modifier_ignored[j] );
            if( j != 0 && i_ignored == 0x00)
                continue;

            hotkey_mapping_t *p_map_old = p_sys->p_map;
            p_sys->p_map = realloc( p_sys->p_map, sizeof(*p_sys->p_map) * (p_sys->i_map+1) );
            if( !p_sys->p_map )
            {
                p_sys->p_map = p_map_old;
                break;
            }
            hotkey_mapping_t *p_map = &p_sys->p_map[p_sys->i_map++];

            p_map->i_x11 = key;
            p_map->i_modifier = i_modifier|i_ignored;
            p_map->i_action = i_vlc_action;
        }
    }
}
Example #19
0
/*****************************************************************************
 * OpenVideo: allocate QNX video thread output method
 *****************************************************************************
 * This function allocate and initialize a QNX vout method. It uses some of the
 * vout properties to choose the window size, and change them according to the
 * actual properties of the display.
 *****************************************************************************/
int E_(OpenVideo) ( vlc_object_t *p_this )
{
    vout_thread_t * p_vout = (vout_thread_t *)p_this;

    /* init connection to photon */
    if( PtInit( "/dev/photon" ) != 0 )
    {
        msg_Err( p_vout, "unable to connect to photon" );
        return( 1 );
    }

    /* allocate structure */
    p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
    if( p_vout->p_sys == NULL )
    {
        msg_Err( p_vout, "out of memory" );
        return( 1 );
    }

    memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );

    p_vout->b_fullscreen = config_GetInt( p_vout, "fullscreen" );
    p_vout->p_sys->i_mode = config_GetInt( p_vout, "overlay" ) ?
                                MODE_VIDEO_OVERLAY : MODE_VIDEO_MEM;
    p_vout->p_sys->dim.w = p_vout->i_window_width;
    p_vout->p_sys->dim.h = p_vout->i_window_height;

    /* init display and create window */
    if( QNXInitDisplay( p_vout ) || QNXCreateWnd( p_vout ) )
    {
        free( p_vout->p_sys );
        return( 1 );
    }

    p_vout->pf_init = QNXInit;
    p_vout->pf_end = QNXEnd;
    p_vout->pf_manage = QNXManage;
    p_vout->pf_render = NULL;
    p_vout->pf_display = QNXDisplay;

    return( 0 );
}
Example #20
0
/*****************************************************************************
 * Constructor.
 *****************************************************************************/
DialogsProvider::DialogsProvider( intf_thread_t *_p_intf, wxWindow *p_parent )
  :  wxFrame( p_parent, -1, wxT("") )
{
    /* Initializations */
    p_intf = _p_intf;
    p_open_dialog = NULL;
    p_file_dialog = NULL;
    p_playlist_dialog = NULL;
    p_messages_dialog = NULL;
    p_fileinfo_dialog = NULL;
    p_prefs_dialog = NULL;
    p_file_generic_dialog = NULL;
    p_wizard_dialog = NULL;
    p_bookmarks_dialog = NULL;
    p_dir_dialog = NULL;
    p_updatevlc_dialog = NULL;
    p_vlm_dialog = NULL;

    /* Give our interface a nice little icon */
    p_intf->p_sys->p_icon = new wxIcon( vlc_xpm );

    /* Create the messages dialog so it can begin storing logs */
    p_messages_dialog = new Messages( p_intf, p_parent ? p_parent : this );

    /* Check if user wants to show the bookmarks dialog by default */
    wxCommandEvent dummy_event;
    if( config_GetInt( p_intf, "wx-bookmarks" ) )
        OnBookmarks( dummy_event );

    /* Intercept all menu events in our custom event handler */
    PushEventHandler( new MenuEvtHandler( p_intf, NULL ) );


    WindowSettings *ws = p_intf->p_sys->p_window_settings;
    wxPoint p;
    wxSize  s;
    bool    b_shown;

#define INIT( id, w, N, S ) \
    if( ws->GetSettings( WindowSettings::id, b_shown, p, s ) && b_shown ) \
    {                           \
        if( !w )                \
            w = N;              \
        w->SetSize( s );        \
        w->Move( p );           \
        w->S( true );           \
    }

    INIT( ID_PLAYLIST, p_playlist_dialog, new Playlist(p_intf,this), ShowPlaylist );
    INIT( ID_MESSAGES, p_messages_dialog, new Messages(p_intf,this), Show );
    INIT( ID_FILE_INFO, p_fileinfo_dialog, new FileInfo(p_intf,this), Show );
    INIT( ID_BOOKMARKS, p_bookmarks_dialog, new BookmarksDialog(p_intf,this), Show);
#undef INIT
}
Example #21
0
void vlc_threads_setup (libvlc_int_t *p_libvlc)
{
    static vlc_mutex_t lock = VLC_STATIC_MUTEX;
    static bool initialized = false;

    vlc_mutex_lock (&lock);
    /* Initializes real-time priorities before any thread is created,
     * just once per process. */
    if (!initialized)
    {
#ifndef __APPLE__
        if (config_GetInt (p_libvlc, "rt-priority"))
#endif
        {
            rt_offset = config_GetInt (p_libvlc, "rt-offset");
            rt_priorities = true;
        }
        initialized = true;
    }
    vlc_mutex_unlock (&lock);
}
Example #22
0
static int Notify( vlc_object_t *p_this, const char *psz_temp )
{
    NotifyNotification * notification;
    notification = notify_notification_new( _("Now Playing"),
                                            psz_temp,
                                            DATA_PATH "/vlc48x48.png",NULL);
    notify_notification_set_timeout( notification,
                                     config_GetInt(p_this, "notify-timeout") );
    notify_notification_set_urgency( notification, NOTIFY_URGENCY_LOW );
    notify_notification_show( notification, NULL);
    return VLC_SUCCESS;
}
Example #23
0
void VideoWidget::SetFullScreen( bool b_fs )
{
    const Qt::WindowStates curstate = reparentable->windowState();
    Qt::WindowStates newstate = curstate;
    Qt::WindowFlags  newflags = reparentable->windowFlags();


    if( b_fs )
    {
        newstate |= Qt::WindowFullScreen;
        newflags |= Qt::WindowStaysOnTopHint;
    }
    else
    {
        newstate &= ~Qt::WindowFullScreen;
        newflags &= ~Qt::WindowStaysOnTopHint;
    }
    if( newstate == curstate )
        return; /* no changes needed */

    if( b_fs )
    {   /* Go full-screen */
        int numscreen =  config_GetInt( p_intf, "qt-fullscreen-screennumber" );
        /* if user hasn't defined screennumber, or screennumber that is bigger
         * than current number of screens, take screennumber where current interface
         * is
         */
        if( numscreen == -1 || numscreen > QApplication::desktop()->numScreens() )
            numscreen = QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi );

        QRect screenres = QApplication::desktop()->screenGeometry( numscreen );

        reparentable->setParent( NULL );
        reparentable->setWindowState( newstate );
        reparentable->setWindowFlags( newflags );
        /* To be sure window is on proper-screen in xinerama */
        if( !screenres.contains( reparentable->pos() ) )
        {
            msg_Dbg( p_intf, "Moving video to correct screen");
            reparentable->move( QPoint( screenres.x(), screenres.y() ) );
        }
        reparentable->show();
    }
    else
    {   /* Go windowed */
        reparentable->setWindowFlags( newflags );
        reparentable->setWindowState( newstate );
        layout->addWidget( reparentable );
    }
    videoSync();
}
Example #24
0
/**************************************************************************
 * Open Files and subtitles                                               *
 **************************************************************************/
FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
                                OpenPanel( _parent, _p_intf ), dialogBox( NULL )
{
    /* Classic UI Setup */
    ui.setupUi( this );

    /* Set Filters for file selection */
/*    QString fileTypes = "";
    ADD_FILTER_MEDIA( fileTypes );
    ADD_FILTER_VIDEO( fileTypes );
    ADD_FILTER_AUDIO( fileTypes );
    ADD_FILTER_PLAYLIST( fileTypes );
    ADD_FILTER_ALL( fileTypes );
    fileTypes.replace( QString(";*"), QString(" *")); */


/*    lineFileEdit = ui.fileEdit;
    //TODO later: fill the fileCompleteList with previous items played.
    QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
    fileCompleter->setModel( new QDirModel( fileCompleter ) );
    lineFileEdit->setCompleter( fileCompleter );*/
    if( config_GetInt( p_intf, "qt-embedded-open" ) )
    {
        ui.tempWidget->hide();
        BuildOldPanel();
    }

    /* Subtitles */
    /* Deactivate the subtitles control by default. */
    ui.subFrame->setEnabled( false );
    /* Build the subs size combo box */
    setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
                            ui.sizeSubComboBox );
    /* Build the subs align combo box */
    setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );

    /* Connects  */
    BUTTONACT( ui.fileBrowseButton, browseFile() );
    BUTTONACT( ui.removeFileButton, removeFile() );

    BUTTONACT( ui.subBrowseButton, browseFileSub() );
    CONNECT( ui.subCheckBox, toggled( bool ), this, toggleSubtitleFrame( bool ) );

    CONNECT( ui.fileListWidg, itemChanged( QListWidgetItem * ), this, updateMRL() );
    CONNECT( ui.subInput, textChanged( const QString& ), this, updateMRL() );
    CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
    CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
    updateButtons();
}
Example #25
0
/*****************************************************************************
 * VideoWindow constructor and destructor
 *****************************************************************************/
VideoWindow::VideoWindow(int v_width, int v_height, BRect frame,
                         vout_thread_t *p_videoout)
    : BWindow(frame, NULL, B_TITLED_WINDOW, B_NOT_CLOSABLE | B_NOT_MINIMIZABLE),
      i_width(frame.IntegerWidth()),
      i_height(frame.IntegerHeight()),
      winSize(frame),
      i_buffer(0),
      teardownwindow(false),
      fTrueWidth(v_width),
      fTrueHeight(v_height),
      fCachedFeel(B_NORMAL_WINDOW_FEEL),
      fInterfaceShowing(false),
      fInitStatus(B_ERROR),
      fSettings(new VideoSettings(*VideoSettings::DefaultSettings()))
{
    p_vout = p_videoout;

    // create the view to do the display
    view = new VLCView( Bounds(), p_vout );

    // create background view
    BView *mainView =  new BackgroundView( Bounds(), view );
    AddChild(mainView);
    mainView->AddChild(view);

    // allocate bitmap buffers
    for (int32_t i = 0; i < 3; i++)
        bitmap[i] = NULL;
    fInitStatus = _AllocateBuffers(v_width, v_height, &mode);

    // make sure we layout the view correctly
    FrameResized(i_width, i_height);

    if (fInitStatus >= B_OK && mode == OVERLAY)
    {
       overlay_restrictions r;

       bitmap[0]->GetOverlayRestrictions(&r);
       SetSizeLimits((i_width * r.min_width_scale), i_width * r.max_width_scale,
                     (i_height * r.min_height_scale), i_height * r.max_height_scale);
    }

    // vlc settings override settings from disk
    if (config_GetInt(p_vout, "fullscreen"))
        fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN);

    _SetToSettings();
}
Example #26
0
File: menus.cpp Project: Kafay/vlc
/**
 * Media ( File ) Menu
 * Opening, streaming and quit
 **/
QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf, QWidget *parent )
{
    QMenu *menu = new QMenu( parent );

    addDPStaticEntry( menu, qtr( "&Open File..." ),
        ":/type/file-asym", SLOT( simpleOpenDialog() ), "Ctrl+O" );
    addDPStaticEntry( menu, qtr( "Advanced Open File..." ),
        ":/type/file-asym", SLOT( openFileDialog() ), "Ctrl+Shift+O" );
    addDPStaticEntry( menu, qtr( I_OPEN_FOLDER ),
        ":/type/folder-grey", SLOT( PLOpenDir() ), "Ctrl+F" );
    addDPStaticEntry( menu, qtr( "Open &Disc..." ),
        ":/type/disc", SLOT( openDiscDialog() ), "Ctrl+D" );
    addDPStaticEntry( menu, qtr( "Open &Network Stream..." ),
        ":/type/network", SLOT( openNetDialog() ), "Ctrl+N" );
    addDPStaticEntry( menu, qtr( "Open &Capture Device..." ),
        ":/type/capture-card", SLOT( openCaptureDialog() ),
        "Ctrl+C" );

    menu->addSeparator();
    addDPStaticEntry( menu, qtr( "Open &Location from clipboard" ),
                      NULL, SLOT( openUrlDialog() ), "Ctrl+V" );

    if( config_GetInt( p_intf, "qt-recentplay" ) )
    {
        recentsMenu = new QMenu( qtr( "&Recent Media" ), menu );
        updateRecents( p_intf );
        menu->addMenu( recentsMenu );
    }
    menu->addMenu( SDMenu( p_intf, menu ) );
    menu->addSeparator();

    addDPStaticEntry( menu, qtr( I_PL_SAVE ), "", SLOT( saveAPlaylist() ),
        "Ctrl+Y" );
    menu->addSeparator();

#ifdef ENABLE_SOUT
    addDPStaticEntry( menu, qtr( "Conve&rt / Save..." ), "",
        SLOT( openAndTranscodingDialogs() ), "Ctrl+R" );
    addDPStaticEntry( menu, qtr( "&Streaming..." ),
        ":/menu/stream", SLOT( openAndStreamingDialogs() ),
        "Ctrl+S" );
    menu->addSeparator();
#endif

    addDPStaticEntry( menu, qtr( "&Quit" ) ,
        ":/menu/quit", SLOT( quit() ), "Ctrl+Q" );
    return menu;
}
Example #27
0
/*****************************************************************************
 * Open: initialize dummy interface
 *****************************************************************************/
static int Open( vlc_object_t *p_this )
{
    intf_thread_t *p_intf = (intf_thread_t*) p_this;
    vlm_t *mediatheque;
    char *psz_address;
    vlc_url_t url;
    int i_telnetport;

    if( !(mediatheque = vlm_New( p_intf )) )
    {
        msg_Err( p_intf, "cannot start VLM" );
        return VLC_EGENERIC;
    }

    msg_Info( p_intf, "using the VLM interface plugin..." );

    i_telnetport = config_GetInt( p_intf, "telnet-port" );
    psz_address  = config_GetPsz( p_intf, "telnet-host" );

    vlc_UrlParse(&url, psz_address, 0);

    // There might be two ports given, resolve any potentially
    // conflict
    url.i_port = getPort(p_intf, url, i_telnetport);

    p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
    if( ( p_intf->p_sys->pi_fd = net_ListenTCP( p_intf, url.psz_host, url.i_port ) )
                == NULL )
    {
        msg_Err( p_intf, "cannot listen for telnet" );
        vlc_UrlClean(&url);
        free( psz_address );
        free( p_intf->p_sys );
        return VLC_EGENERIC;
    }
    msg_Info( p_intf, 
              "telnet interface started on interface %s %d",
              url.psz_host, url.i_port );

    p_intf->p_sys->i_clients   = 0;
    p_intf->p_sys->clients     = NULL;
    p_intf->p_sys->mediatheque = mediatheque;
    p_intf->pf_run = Run;

    vlc_UrlClean(&url);
    free( psz_address );
    return VLC_SUCCESS;
}
Example #28
0
/*****************************************************************************
 * Displays an OSD slider.
 * Types are: OSD_HOR_SLIDER and OSD_VERT_SLIDER.
 *****************************************************************************/
void vout_OSDSlider( vlc_object_t *p_caller, int i_channel, int i_position,
                     short i_type )
{
    vout_thread_t *p_vout = vlc_object_find( p_caller, VLC_OBJECT_VOUT,
                                             FIND_ANYWHERE );

    if( p_vout && ( config_GetInt( p_caller, "osd" ) || ( i_position >= 0 ) ) )
    {
        osd_Slider( p_caller, p_vout->p_spu, p_vout->render.i_width,
            p_vout->render.i_height, p_vout->fmt_in.i_x_offset,
            p_vout->fmt_in.i_height - p_vout->fmt_in.i_visible_height
                                    - p_vout->fmt_in.i_y_offset,
            i_channel, i_position, i_type );
    }
    vlc_object_release( p_vout );
}
Example #29
0
Volume::Volume( intf_thread_t *pIntf ): VarPercent( pIntf )
{
    m_step = (float)config_GetInt( pIntf, "volume-step" ) / AOUT_VOLUME_MAX;
    if( var_InheritBool( pIntf, "qt-volume-complete" ) )
    {
        m_max = 400;
        m_volumeMax = AOUT_VOLUME_MAX;
    }
    else
    {
        m_max = 200;
        m_volumeMax = AOUT_VOLUME_MAX / 2;
    }

    // Initial value
    audio_volume_t val = aout_VolumeGet( getIntf()->p_sys->p_playlist );
    set( val, false );
}
Example #30
0
/*****************************************************************************
 * BoolConfigControl implementation
 *****************************************************************************/
BoolConfigControl::BoolConfigControl( vlc_object_t *p_this,
                                      module_config_t *p_item, HWND parent,
                                      HINSTANCE hInst, int * py_pos )
  : ConfigControl( p_this, p_item, parent, hInst )
{
    checkbox = CreateWindow( _T("BUTTON"), _T(""),
                             WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
                             5, *py_pos, 15, 15,
                             parent, NULL, hInst, NULL );
    Button_SetCheck( checkbox, config_GetInt(p_this, p_item->psz_name) ? BST_CHECKED : BST_UNCHECKED );

    checkbox_label = CreateWindow( _T("STATIC"), _FROMMB(p_item->psz_text),
                                   WS_CHILD | WS_VISIBLE | SS_LEFT,
                                   5 + 15 + 5, *py_pos, 180, 15,
                                   parent, NULL, hInst, NULL );

    *py_pos += 15 + 10;
}