<commit_before>/*****************************************************************************
 * input_manager.cpp : Manage an input and interact with its GUI elements
 ****************************************************************************
 * Copyright (C) 2006 the VideoLAN team
 * $Id$
 *
 * Authors: <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#include <assert.h>

#include "qt4.hpp"
#include "input_manager.hpp"
#include "dialogs_provider.hpp"

static int ChangeVideo( vlc_object_t *p_this, const char *var, vlc_value_t o,
                        vlc_value_t n, void *param );
static int ChangeAudio( vlc_object_t *p_this, const char *var, vlc_value_t o,
                        vlc_value_t n, void *param );

/**********************************************************************
 * InputManager implementation
 **********************************************************************/

InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) :
                           QObject( parent ), p_intf( _p_intf )
{
    i_old_playing_status = END_S;
    p_input = NULL;
    ON_TIMEOUT( update() );
}

InputManager::~InputManager()
{
}

void InputManager::setInput( input_thread_t *_p_input )
{
    p_input = _p_input;
    emit positionUpdated( 0.0,0,0 );
    b_had_audio = b_had_video = b_has_audio = b_has_video = false;
    if( p_input )
    {
        vlc_value_t val;
        var_Change( p_input, "video-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
        b_has_video = val.i_int > 0;
        var_Change( p_input, "audio-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
        b_has_audio = val.i_int > 0;
        var_AddCallback( p_input, "audio-es", ChangeAudio, this );
        var_AddCallback( p_input, "video-es", ChangeVideo, this );
    }

}
void InputManager::delInput()
{
    if( p_input )
    {
        var_DelCallback( p_input, "audio-es", ChangeAudio, this );
        var_DelCallback( p_input, "video-es", ChangeVideo, this );
    }
}

void InputManager::update()
{
    /// \todo Emit the signals only if it changed
    if( !p_input ) return;

    if( p_input->b_dead || p_input->b_die )
    {
        emit positionUpdated( 0.0, 0, 0 );
        msg_Dbg( p_intf, "*********** NAV 0");
        emit navigationChanged( 0 );
        emit statusChanged( 0 ); // 0 = STOPPED, 1 = PLAY, 2 = PAUSE
    }

    if( !b_had_audio && b_has_audio )
        emit audioStarted();
    if( !b_had_video && b_has_video )
        emit videoStarted();

    /* Update position */
    mtime_t i_length, i_time;
    float f_pos;
    i_length = var_GetTime( p_input, "length" ) / 1000000;
    i_time = var_GetTime( p_input, "time") / 1000000;
    f_pos = var_GetFloat( p_input, "position" );
    emit positionUpdated( f_pos, i_time, i_length );

    /* Update disc status */
    vlc_value_t val; val.i_int = 0;
    var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL );
    if( val.i_int > 0 )
    {
        val.i_int = 0;
        var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val, NULL );
        if( val.i_int > 0 )
        {
            msg_Dbg( p_intf, "******* CHAPTER");
            emit navigationChanged( 1 ); // 1 = chapter, 2 = title, 0 = NO
        }
        else
        {
            msg_Dbg( p_intf, "******* TITLE");
            emit navigationChanged( 2 );
        }
    }
    else
    {
        msg_Dbg( p_intf, "******** NONE" );
        emit navigationChanged( 0 );
    }

    /* Update text */
    QString text;
    if( input_GetItem(p_input)->p_meta &&
        input_GetItem(p_input)->p_meta->psz_nowplaying &&
        *input_GetItem(p_input)->p_meta->psz_nowplaying )
    {
        text.sprintf( "%s - %s",
                  input_GetItem(p_input)->p_meta->psz_nowplaying,
                  input_GetItem(p_input)->psz_name );
    }
    else
    {
        text.sprintf( "%s", input_GetItem(p_input)->psz_name );
    }<commit_msg>Remove debug spammer - fixes #971<commit_after>/*****************************************************************************
 * input_manager.cpp : Manage an input and interact with its GUI elements
 ****************************************************************************
 * Copyright (C) 2006 the VideoLAN team
 * $Id$
 *
 * Authors: <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#include <assert.h>

#include "qt4.hpp"
#include "input_manager.hpp"
#include "dialogs_provider.hpp"

static int ChangeVideo( vlc_object_t *p_this, const char *var, vlc_value_t o,
                        vlc_value_t n, void *param );
static int ChangeAudio( vlc_object_t *p_this, const char *var, vlc_value_t o,
                        vlc_value_t n, void *param );

/**********************************************************************
 * InputManager implementation
 **********************************************************************/

InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) :
                           QObject( parent ), p_intf( _p_intf )
{
    i_old_playing_status = END_S;
    p_input = NULL;
    ON_TIMEOUT( update() );
}

InputManager::~InputManager()
{
}

void InputManager::setInput( input_thread_t *_p_input )
{
    p_input = _p_input;
    emit positionUpdated( 0.0,0,0 );
    b_had_audio = b_had_video = b_has_audio = b_has_video = false;
    if( p_input )
    {
        vlc_value_t val;
        var_Change( p_input, "video-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
        b_has_video = val.i_int > 0;
        var_Change( p_input, "audio-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
        b_has_audio = val.i_int > 0;
        var_AddCallback( p_input, "audio-es", ChangeAudio, this );
        var_AddCallback( p_input, "video-es", ChangeVideo, this );
    }

}
void InputManager::delInput()
{
    if( p_input )
    {
        var_DelCallback( p_input, "audio-es", ChangeAudio, this );
        var_DelCallback( p_input, "video-es", ChangeVideo, this );
    }
}

void InputManager::update()
{
    /// \todo Emit the signals only if it changed
    if( !p_input ) return;

    if( p_input->b_dead || p_input->b_die )
    {
        emit positionUpdated( 0.0, 0, 0 );
        msg_Dbg( p_intf, "*********** NAV 0");
        emit navigationChanged( 0 );
        emit statusChanged( 0 ); // 0 = STOPPED, 1 = PLAY, 2 = PAUSE
    }

    if( !b_had_audio && b_has_audio )
        emit audioStarted();
    if( !b_had_video && b_has_video )
        emit videoStarted();

    /* Update position */
    mtime_t i_length, i_time;
    float f_pos;
    i_length = var_GetTime( p_input, "length" ) / 1000000;
    i_time = var_GetTime( p_input, "time") / 1000000;
    f_pos = var_GetFloat( p_input, "position" );
    emit positionUpdated( f_pos, i_time, i_length );

    /* Update disc status */
    vlc_value_t val; val.i_int = 0;
    var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL );
    if( val.i_int > 0 )
    {
        val.i_int = 0;
        var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val, NULL );
        if( val.i_int > 0 )
        {
            msg_Dbg( p_intf, "******* CHAPTER");
            emit navigationChanged( 1 ); // 1 = chapter, 2 = title, 0 = NO
        }
        else
        {
            msg_Dbg( p_intf, "******* TITLE");
            emit navigationChanged( 2 );
        }
    }
    else
    {
        emit navigationChanged( 0 );
    }

    /* Update text */
    QString text;
    if( input_GetItem(p_input)->p_meta &&
        input_GetItem(p_input)->p_meta->psz_nowplaying &&
        *input_GetItem(p_input)->p_meta->psz_nowplaying )
    {
        text.sprintf( "%s - %s",
                  input_GetItem(p_input)->p_meta->psz_nowplaying,
                  input_GetItem(p_input)->psz_name );
    }
    else
    {
        text.sprintf( "%s", input_GetItem(p_input)->psz_name );
    }
{'fraction_non_alphanumeric': 0.18808032822284604, 'fraction_numerical': 0.012632260850788167, 'mean_word_length': 2.9183587140439933, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4605497', 'n_tokens_mistral': 3038, 'n_tokens_neox': 2858, 'n_words': 783}