<commit_before>/*****************************************************************************
 * input_ext-intf.c: services to the interface
 *****************************************************************************
 * Copyright (C) 1998-2001 VideoLAN
 * $Id: input_ext-intf.c,v 1.46 2002/12/25 23:39:01 sam Exp $
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include <string.h>                                    /* memcpy(), memset() */

#include <vlc/vlc.h>

#include "stream_control.h"
#include "input_ext-dec.h"
#include "input_ext-intf.h"
#include "input_ext-plugins.h"

/*****************************************************************************
 * input_SetStatus: change the reading status
 *****************************************************************************/
void __input_SetStatus( vlc_object_t * p_this, int i_mode )
{
    input_thread_t *p_input;

    p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_PARENT );

    if( p_input == NULL )
    {
        msg_Err( p_this, "no input found" );
        return;
    }

    vlc_mutex_lock( &p_input->stream.stream_lock );

    switch( i_mode )
    {
    case INPUT_STATUS_END:
        p_input->stream.i_new_status = PLAYING_S;
        p_input->b_eof = 1;
        msg_Dbg( p_input, "end of stream" );
        break;

    case INPUT_STATUS_PLAY:
        p_input->stream.i_new_status = PLAYING_S;
        msg_Dbg( p_input, "playing at normal rate" );
        break;

    case INPUT_STATUS_PAUSE:
        /* XXX: we don't need to check i_status, because input_clock.c
         * does it for us */
        p_input->stream.i_new_status = PAUSE_S;
        msg_Dbg( p_input, "toggling pause" );
        break;

    case INPUT_STATUS_FASTER:
        /* If we are already going too fast, go back to default rate */
        if( p_input->stream.control.i_rate * 8 <= DEFAULT_RATE )
        {
            p_input->stream.i_new_status = PLAYING_S;
            msg_Dbg( p_input, "playing at normal rate" );
        }
        else
        {
            p_input->stream.i_new_status = FORWARD_S;

            if( p_input->stream.control.i_rate < DEFAULT_RATE
                    && p_input->stream.control.i_status == FORWARD_S )
            {
                p_input->stream.i_new_rate =
                                    p_input->stream.control.i_rate / 2;
            }
            else
            {
                p_input->stream.i_new_rate = DEFAULT_RATE / 2;
            }
            msg_Dbg( p_input, "playing at %i:1 fast forward",
                     DEFAULT_RATE / p_input->stream.i_new_rate );
        }
        break;

    case INPUT_STATUS_SLOWER:
        /* If we are already going too slow, go back to default rate */
        if( p_input->stream.control.i_rate >= 8 * DEFAULT_RATE )
        {
            p_input->stream.i_new_status = PLAYING_S;
            msg_Dbg( p_input, "playing at normal rate" );
        }
        else
        {
            p_input->stream.i_new_status = FORWARD_S;

            if( p_input->stream.control.i_rate > DEFAULT_RATE
                    && p_input->stream.control.i_status == FORWARD_S )
            {
                p_input->stream.i_new_rate =
                                    p_input->stream.control.i_rate * 2;
            }
            else
            {
                p_input->stream.i_new_rate = DEFAULT_RATE * 2;
            }
            msg_Dbg( p_input, "playing at 1:%i slow motion",
                      p_input->stream.i_new_rate / DEFAULT_RATE );
        }
        break;

    default:
        break;
    }

    vlc_cond_signal( &p_input->stream.stream_wait );
    vlc_mutex_unlock( &p_input->stream.stream_lock );

    vlc_object_release( p_input );
}

/*****************************************************************************
 * input_Seek: changes the stream postion
 *****************************************************************************/
void __input_Seek( vlc_object_t * p_this, off_t i_position, int i_whence )
{
    input_thread_t *p_input;

    char psz_time1[OFFSETTOTIME_MAX_SIZE];<commit_msg>* ./src/input/input_ext_intf.c   - FASTER and SLOWER now take into account the current rate.<commit_after>/*****************************************************************************
 * input_ext-intf.c: services to the interface
 *****************************************************************************
 * Copyright (C) 1998-2001 VideoLAN
 * $Id: input_ext-intf.c,v 1.47 2003/01/21 14:15:05 hartman Exp $
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include <string.h>                                    /* memcpy(), memset() */

#include <vlc/vlc.h>

#include "stream_control.h"
#include "input_ext-dec.h"
#include "input_ext-intf.h"
#include "input_ext-plugins.h"

/*****************************************************************************
 * input_SetStatus: change the reading status
 *****************************************************************************/
void __input_SetStatus( vlc_object_t * p_this, int i_mode )
{
    input_thread_t *p_input;

    p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_PARENT );

    if( p_input == NULL )
    {
        msg_Err( p_this, "no input found" );
        return;
    }

    vlc_mutex_lock( &p_input->stream.stream_lock );

    switch( i_mode )
    {
    case INPUT_STATUS_END:
        p_input->stream.i_new_status = PLAYING_S;
        p_input->b_eof = 1;
        msg_Dbg( p_input, "end of stream" );
        break;

    case INPUT_STATUS_PLAY:
        p_input->stream.i_new_status = PLAYING_S;
        msg_Dbg( p_input, "playing at normal rate" );
        break;

    case INPUT_STATUS_PAUSE:
        /* XXX: we don't need to check i_status, because input_clock.c
         * does it for us */
        p_input->stream.i_new_status = PAUSE_S;
        msg_Dbg( p_input, "toggling pause" );
        break;

    case INPUT_STATUS_FASTER:
        /* If we are already going too fast, go back to default rate */
        if( p_input->stream.control.i_rate * 8 <= DEFAULT_RATE )
        {
            msg_Dbg( p_input, "can not play any faster" );
        }
        else
        {
            p_input->stream.i_new_status = FORWARD_S;
            p_input->stream.i_new_rate =
                                    p_input->stream.control.i_rate / 2;

            if ( p_input->stream.i_new_rate < DEFAULT_RATE )
            {
                msg_Dbg( p_input, "playing at %i:1 fast forward",
                     DEFAULT_RATE / p_input->stream.i_new_rate );
            }
            else if ( p_input->stream.i_new_rate > DEFAULT_RATE )
            {
                msg_Dbg( p_input, "playing at 1:%i slow motion",
                      p_input->stream.i_new_rate / DEFAULT_RATE );
            }
            else if ( p_input->stream.i_new_rate == DEFAULT_RATE )
            {
                p_input->stream.i_new_status = PLAYING_S;
                msg_Dbg( p_input, "playing at normal rate" );
            }
        }
        break;

    case INPUT_STATUS_SLOWER:
        /* If we are already going too slow, go back to default rate */
        if( p_input->stream.control.i_rate >= 8 * DEFAULT_RATE )
        {
            msg_Dbg( p_input, "can not play any slower" );
        }
        else
        {
            p_input->stream.i_new_status = FORWARD_S;
            p_input->stream.i_new_rate =
                                    p_input->stream.control.i_rate * 2;

            if ( p_input->stream.i_new_rate < DEFAULT_RATE )
            {
                msg_Dbg( p_input, "playing at %i:1 fast forward",
                     DEFAULT_RATE / p_input->stream.i_new_rate );
            }
            else if ( p_input->stream.i_new_rate > DEFAULT_RATE )
            {
                msg_Dbg( p_input, "playing at 1:%i slow motion",
                      p_input->stream.i_new_rate / DEFAULT_RATE );
            }
            else if ( p_input->stream.i_new_rate == DEFAULT_RATE )
            {
                p_input->stream.i_new_status = PLAYING_S;
                msg_Dbg( p_input, "playing at normal rate" );
            }
        }
        break;

    default:
        break;
    }

    vlc_cond_signal( &p_input->stream.stream_wait );
    vlc_mutex_unlock( &p_input->stream.stream_lock );

    vlc_object_release( p_input );
}

/*****************************************************************************
 * input_Seek: changes the stream postion
 *****************************************************************************/
void __input_Seek( vlc_object_t * p_this, off_t i_position, int i_whence )
{
    input_thread_t *p_input;

    char psz_time1[OFFSETTOTIME_MAX_SIZE];
{'fraction_non_alphanumeric': 0.21301662707838478, 'fraction_numerical': 0.008741092636579573, 'mean_word_length': 2.4264322916666665, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 70, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2943846', 'n_tokens_mistral': 3154, 'n_tokens_neox': 2919, 'n_words': 748}