Commit 085558eb authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Do not use internal libvlc symbol outside of libvlc

parent 71992c5f
...@@ -30,7 +30,6 @@ libvlc_event_detach ...@@ -30,7 +30,6 @@ libvlc_event_detach
libvlc_event_manager_new libvlc_event_manager_new
libvlc_event_manager_register_event_type libvlc_event_manager_register_event_type
libvlc_event_manager_release libvlc_event_manager_release
libvlc_event_send
libvlc_event_type_name libvlc_event_type_name
libvlc_free libvlc_free
libvlc_get_changeset libvlc_get_changeset
......
...@@ -14,7 +14,6 @@ extra_check_verbose__0 = $(extra_check_verbose_0) ...@@ -14,7 +14,6 @@ extra_check_verbose__0 = $(extra_check_verbose_0)
############################################################################### ###############################################################################
check_PROGRAMS = \ check_PROGRAMS = \
test_libvlc_core \ test_libvlc_core \
test_libvlc_events \
test_libvlc_media \ test_libvlc_media \
test_libvlc_media_list \ test_libvlc_media_list \
test_libvlc_media_player \ test_libvlc_media_player \
...@@ -60,11 +59,6 @@ test_libvlc_core_LDADD = $(top_builddir)/src/libvlc.la ...@@ -60,11 +59,6 @@ test_libvlc_core_LDADD = $(top_builddir)/src/libvlc.la
test_libvlc_core_CFLAGS = $(CFLAGS_tests) test_libvlc_core_CFLAGS = $(CFLAGS_tests)
test_libvlc_core_LDFLAGS = $(LDFLAGS_tests) test_libvlc_core_LDFLAGS = $(LDFLAGS_tests)
test_libvlc_events_SOURCES = libvlc/events.c
test_libvlc_events_LDADD = $(top_builddir)/src/libvlc.la
test_libvlc_events_CFLAGS = $(CFLAGS_tests)
test_libvlc_events_LDFLAGS = $(LDFLAGS_tests)
test_libvlc_media_SOURCES = libvlc/media.c test_libvlc_media_SOURCES = libvlc/media.c
test_libvlc_media_LDADD = $(top_builddir)/src/libvlc.la test_libvlc_media_LDADD = $(top_builddir)/src/libvlc.la
test_libvlc_media_CFLAGS = $(CFLAGS_tests) test_libvlc_media_CFLAGS = $(CFLAGS_tests)
......
/*
* events.c - libvlc smoke test
*
* $Id$
*/
/**********************************************************************
* Copyright (C) 2007 Rémi Denis-Courmont. *
* Copyright (C) 2008 Pierre d'Herbemont. *
* 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"
/* This one is an internal API. We use it here to run tests that
* don't depends on playback, and only test the event framework */
extern void libvlc_event_send( libvlc_event_manager_t *, libvlc_event_t *);
static void test_events_dummy_callback( const libvlc_event_t * event, void * user_data)
{
(void)event;
bool * callback_was_called = user_data;
*callback_was_called = true;
}
static void test_events_callback_and_detach( const libvlc_event_t * event, void * user_data)
{
bool * callback_was_called = user_data;
libvlc_event_manager_t *em;
em = libvlc_media_player_event_manager (event->p_obj);
libvlc_event_detach (em, event->type, test_events_callback_and_detach, user_data);
*callback_was_called = true;
}
static void test_event_type_reception( libvlc_event_manager_t * em, libvlc_event_type_t event_type, bool * callback_was_called )
{
libvlc_event_t event;
event.type = event_type;
*callback_was_called = false;
libvlc_event_send (em, &event);
assert (*callback_was_called);
}
#include <string.h>
static void test_events (const char ** argv, int argc)
{
libvlc_instance_t *vlc;
libvlc_media_player_t *mi;
libvlc_event_manager_t *em;
bool callback_was_called;
libvlc_event_type_t mi_events[] = {
libvlc_MediaPlayerNothingSpecial,
libvlc_MediaPlayerOpening,
libvlc_MediaPlayerBuffering,
libvlc_MediaPlayerPlaying,
libvlc_MediaPlayerPaused,
libvlc_MediaPlayerStopped,
libvlc_MediaPlayerEndReached,
libvlc_MediaPlayerEncounteredError,
libvlc_MediaPlayerTimeChanged,
libvlc_MediaPlayerPositionChanged,
};
int mi_events_len = sizeof(mi_events)/sizeof(*mi_events);
log ("Testing events\n");
vlc = libvlc_new (argc, argv);
assert (vlc != NULL);
mi = libvlc_media_player_new (vlc);
assert (mi != NULL);
em = libvlc_media_player_event_manager (mi);
for( int i = 0; i < 0x700; i++ )
strlen(libvlc_event_type_name( i ));
log ("+ Testing attaching to Media Instance\n");
for (int i = 0; i < mi_events_len; i++) {
int ret;
ret = libvlc_event_attach (em, mi_events[i],
test_events_dummy_callback,
&callback_was_called);
assert(ret == 0);
}
log ("+ Testing event reception\n");
for (int i = 0; i < mi_events_len; i++)
test_event_type_reception (em, mi_events[i], &callback_was_called);
log ("+ Testing event detaching while in the event callback\n");
libvlc_event_t event;
event.type = mi_events[mi_events_len-1];
callback_was_called = false;
libvlc_event_detach (em, mi_events[mi_events_len-1], test_events_dummy_callback, &callback_was_called);
int val = libvlc_event_attach (em, mi_events[mi_events_len-1],
test_events_callback_and_detach,
&callback_was_called);
assert (val == 0);
libvlc_event_send (em, &event);
assert( callback_was_called );
callback_was_called = false;
libvlc_event_send (em, &event);
assert( !callback_was_called );
log ("+ Testing regular detach()\n");
for (int i = 0; i < mi_events_len - 1; i++)
libvlc_event_detach (em, mi_events[i], test_events_dummy_callback, &callback_was_called);
libvlc_media_player_release (mi);
libvlc_release (vlc);
}
int main (void)
{
test_init();
test_events (test_defaults_args, test_defaults_nargs);
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment