<commit_before>/*
 * media_player.c - libvlc smoke test
 *
 * $Id$
 */

/**********************************************************************
 *  Copyright (C) 2007 <NAME>.                           *
 *  This program is free software; you can redistribute and/or modify *
 *  it under the terms of the GNU General Public License as published *
 *  by the Free Software Foundation; 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, you can get it from:             *
 *  http://www.gnu.org/copyleft/gpl.html                              *
 **********************************************************************/

#include "test.h"

static void test_media_player_play_stop(const char** argv, int argc)
{
    libvlc_instance_t *vlc;
    libvlc_media_t *md;
    libvlc_media_player_t *mi;
    const char * file = test_default_sample;

    log ("Testing play and pause of %s\n", file);

    libvlc_exception_init (&ex);
    vlc = libvlc_new (argc, argv, &ex);
    catch ();

    md = libvlc_media_new (vlc, file, &ex);
    catch ();

    mi = libvlc_media_player_new_from_media (md, &ex);
    catch ();

    libvlc_media_release (md);

    libvlc_media_player_play (mi, &ex);
    catch ();

    /* Wait a correct state */
    libvlc_state_t state;
    do {
        state = libvlc_media_player_get_state (mi, &ex);
        catch ();
    } while( state != libvlc_Playing &&
             state != libvlc_Error &&
             state != libvlc_MediaPlayerEndReached );

    assert( state == libvlc_Playing || state == libvlc_MediaPlayerEndReached );

    libvlc_media_player_stop (mi, &ex);
    catch ();

    libvlc_media_player_release (mi);
    catch ();

    libvlc_release (vlc);
    catch ();
}

static void test_media_player_pause_stop(const char** argv, int argc)
{
    libvlc_instance_t *vlc;
    libvlc_media_t *md;
    libvlc_media_player_t *mi;
    const char * file = test_default_sample;

    log ("Testing play and pause of %s\n", file);

    libvlc_exception_init (&ex);
    vlc = libvlc_new (argc, argv, &ex);
    catch ();

    md = libvlc_media_new (vlc, file, &ex);
    catch ();

    mi = libvlc_media_player_new_from_media (md, &ex);
    catch ();

    libvlc_media_release (md);

    libvlc_media_player_play (mi, &ex);
    catch ();

    /* Wait a correct state */
    libvlc_state_t state;
    do {
        state = libvlc_media_player_get_state (mi, &ex);
        catch ();
    } while( state != libvlc_Playing &&
             state != libvlc_Error &&
             state != libvlc_MediaPlayerEndReached );

    assert( state == libvlc_Playing || state == libvlc_MediaPlayerEndReached );

    libvlc_media_player_pause (mi, &ex);

    /* Wait a correct state */
    do {
        state = libvlc_media_player_get_state (mi, &ex);
        catch ();
    } while( state != libvlc_Paused &&
            state != libvlc_Error &&
            state != libvlc_MediaPlayerEndReached );

    assert( libvlc_media_player_get_state (mi, &ex) == libvlc_Paused );
    catch();
<commit_msg>test: Fix media_player test.<commit_after>/*
 * media_player.c - libvlc smoke test
 *
 * $Id$
 */

/**********************************************************************
 *  Copyright (C) 2007 <NAME>.                           *
 *  This program is free software; you can redistribute and/or modify *
 *  it under the terms of the GNU General Public License as published *
 *  by the Free Software Foundation; 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, you can get it from:             *
 *  http://www.gnu.org/copyleft/gpl.html                              *
 **********************************************************************/

#include "test.h"

static void test_media_player_play_stop(const char** argv, int argc)
{
    libvlc_instance_t *vlc;
    libvlc_media_t *md;
    libvlc_media_player_t *mi;
    const char * file = test_default_sample;

    log ("Testing play and pause of %s\n", file);

    libvlc_exception_init (&ex);
    vlc = libvlc_new (argc, argv, &ex);
    catch ();

    md = libvlc_media_new (vlc, file, &ex);
    catch ();

    mi = libvlc_media_player_new_from_media (md, &ex);
    catch ();

    libvlc_media_release (md);

    libvlc_media_player_play (mi, &ex);
    catch ();

    /* Wait a correct state */
    libvlc_state_t state;
    do {
        state = libvlc_media_player_get_state (mi, &ex);
        catch ();
    } while( state != libvlc_Playing &&
             state != libvlc_Error &&
             state != libvlc_Ended );

    assert( state == libvlc_Playing || state == libvlc_Ended );

    libvlc_media_player_stop (mi, &ex);
    catch ();

    libvlc_media_player_release (mi);
    catch ();

    libvlc_release (vlc);
    catch ();
}

static void test_media_player_pause_stop(const char** argv, int argc)
{
    libvlc_instance_t *vlc;
    libvlc_media_t *md;
    libvlc_media_player_t *mi;
    const char * file = test_default_sample;

    log ("Testing pause and stop of %s\n", file);

    libvlc_exception_init (&ex);
    vlc = libvlc_new (argc, argv, &ex);
    catch ();

    md = libvlc_media_new (vlc, file, &ex);
    catch ();

    mi = libvlc_media_player_new_from_media (md, &ex);
    catch ();

    libvlc_media_release (md);

    libvlc_media_player_play (mi, &ex);
    catch ();

    log ("Waiting for playing\n");

    /* Wait a correct state */
    libvlc_state_t state;
    do {
        state = libvlc_media_player_get_state (mi, &ex);
        catch ();
    } while( state != libvlc_Playing &&
             state != libvlc_Error &&
             state != libvlc_Ended );

    assert( state == libvlc_Playing || state == libvlc_Ended );

    libvlc_media_player_pause (mi, &ex);
    catch();

    log ("Waiting for pause\n");

    /* Wait a correct state */
    do {
        state = libvlc_media_player_get_state (mi, &ex);
        catch ();
    } while( state != libvlc_Paused &&
            state != libvlc_Error &&
            state != libvlc_Ended );

    assert( state == libvlc_Paused || state == libvlc_Ended );
    catch();

{'fraction_non_alphanumeric': 0.13903966597077244, 'fraction_numerical': 0.0013917884481558804, 'mean_word_length': 2.2663636363636366, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1177300', 'n_tokens_mistral': 2239, 'n_tokens_neox': 2162, 'n_words': 606}