Files
recycled-ni-neutrino/lib/libtuxtxt/libtuxtxt.cpp
nightshad c31fb2e397 Check passed pid. Prevents invalid use and possible corruption
of the 'state'.


git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@1394 e54a6e83-5905-42d5-8d5c-058d10e6a962


Origin commit data
------------------
Branch: ni/coolstream
Commit: c042af61d7
Author: nightshad <nightshad@e54a6e83-5905-42d5-8d5c-058d10e6a962>
Date: 2011-04-12 (Tue, 12 Apr 2011)



------------------
This commit was generated by Migit
2011-04-12 09:29:46 +00:00

102 lines
2.7 KiB
C++

/******************************************************************************
* <<< TuxTxt - Teletext Plugin >>> *
* *
* (c) Thomas "LazyT" Loewe 2002-2003 (LazyT@gmx.net) *
* *
* TOP-Text Support 2004 by Roland Meier <RolandMeier@Siemens.com> *
* Info entnommen aus videotext-0.6.19991029, *
* Copyright (c) 1994-96 Martin Buck <martin-2.buck@student.uni-ulm.de> *
* *
******************************************************************************/
#define TUXTXT_DEBUG 0
#include <sys/ioctl.h>
#include <fcntl.h>
#include "tuxtxt_def.h"
#include "tuxtxt_common.h"
/******************************************************************************
* Initialize *
******************************************************************************/
static int tuxtxt_initialized=0;
int tuxtxt_init()
{
if ( tuxtxt_initialized )
return 0;
tuxtxt_initialized=1;
/* init data */
memset(&tuxtxt_cache.astCachetable, 0, sizeof(tuxtxt_cache.astCachetable));
memset(&tuxtxt_cache.astP29, 0, sizeof(tuxtxt_cache.astP29));
tuxtxt_clear_cache();
tuxtxt_cache.receiving = 0;
tuxtxt_cache.thread_starting = 0;
tuxtxt_cache.vtxtpid = -1;
tuxtxt_cache.thread_id = 0;
tuxtxt_cache.dmx = -1;
return 1;//tuxtxt_init_demuxer();
}
/******************************************************************************
* Interface to caller *
******************************************************************************/
int tuxtxt_stop()
{
if (!tuxtxt_cache.receiving) return 1;
tuxtxt_cache.receiving = 0;
return tuxtxt_stop_thread();
}
void tuxtxt_start(int tpid, int source)
{
if (tpid == -1)
{
printf("tuxtxt: invalid PID!\n");
return;
}
if (tuxtxt_cache.vtxtpid != tpid)
{
tuxtxt_stop();
tuxtxt_clear_cache();
tuxtxt_cache.page = 0x100;
tuxtxt_cache.vtxtpid = tpid;
tuxtxt_start_thread(source);
}
else if (!tuxtxt_cache.thread_starting && !tuxtxt_cache.receiving)
{
tuxtxt_start_thread(source);
}
}
void tuxtxt_close()
{
#if TUXTXT_DEBUG
printf ("libtuxtxt: cleaning up\n");
#endif
tuxtxt_stop();
#if 0
if (tuxtxt_cache.dmx != -1)
close(tuxtxt_cache.dmx);
#endif
tuxtxt_cache.dmx = -1;
tuxtxt_clear_cache();
tuxtxt_initialized=0;
}
/* Local Variables: */
/* indent-tabs-mode:t */
/* tab-width:3 */
/* c-basic-offset:3 */
/* comment-column:0 */
/* fill-column:120 */
/* End: */