Beispiel #1
0
gSDLDC::gSDLDC()
{
	if (SDL_Init(SDL_INIT_VIDEO) < 0)
	{
		eWarning("Could not initialize SDL: %s", SDL_GetError());
		return;
	}
	
	m_screen = SDL_SetVideoMode(720, 576, 32, SDL_HWSURFACE);
	if (!m_screen)
	{
		eWarning("Could not create SDL surface: %s", SDL_GetError());
		return;
	}

	m_instance=this;
	
	m_surface.type = 0;
	m_surface.x = m_screen->w;
	m_surface.y = m_screen->h;
	m_surface.bpp = m_screen->format->BitsPerPixel;
	m_surface.bypp = m_screen->format->BytesPerPixel;
	m_surface.stride = m_screen->pitch;
	m_surface.data = m_screen->pixels;
	m_surface.clut.colors=256;
	m_surface.clut.data=new gRGB[m_surface.clut.colors];
	
	m_pixmap = new gPixmap(&m_surface);
	
	memset(m_surface.clut.data, 0, sizeof(*m_surface.clut.data)*m_surface.clut.colors);
}
Beispiel #2
0
RESULT eServiceXine::start()
{
	if (m_state == stError)
		return -1;

	ASSERT(m_state == stIdle);
	ASSERT(stream);

	if (!xine_open(stream, m_filename.c_str()))
	{
		eWarning("xine_open failed!");
		return -1;
	}

	if (!xine_play(stream, 0, 0))
	{
		eWarning("xine_play failed!");
		return -1;
	}

	m_state = stRunning;

	m_event(this, evStart);
	return 0;
}
Beispiel #3
0
void eDVBPESReader::data(int)
{
	while (1)
	{
		uint8_t buffer[16384];
		int r;
		r = ::read(m_fd, buffer, 16384);
		if (!r)
			return;
		if(r < 0)
		{
			if (errno == EAGAIN || errno == EINTR) /* ok */
				return;
			eWarning("ERROR reading PES (fd=%d) - %m", m_fd);
			return;
		}

		if (m_active)
			m_read(buffer, r);
		else
			eWarning("PES reader not active");
		if (r != 16384)
			break;
	}
}
Beispiel #4
0
eServiceXine::eServiceXine(const char *filename): m_filename(filename), m_pump(eApp, 1)
{
	m_state = stError;
	stream = 0;
	event_queue = 0;
	ao_port = 0;
	vo_port = 0;


//	if ((vo_port = xine_open_video_driver(xine, "fb", XINE_VISUAL_TYPE_FB, NULL)) == NULL)
	if ((vo_port = xine_open_video_driver(xine, "none", XINE_VISUAL_TYPE_NONE, NULL)) == NULL)
	{
		eWarning("cannot open xine video driver");
	}

	if ((ao_port = xine_open_audio_driver(xine , "alsa", NULL)) == NULL)
	{
		eWarning("cannot open xine audio driver");
	}
	stream = xine_stream_new(xine, ao_port, vo_port);
	event_queue = xine_event_new_queue(stream);
	xine_event_create_listener_thread(event_queue, eventListenerWrap, this);

//	CONNECT(m_pump.recv_msg, eServiceXine::gstPoll);
	m_state = stIdle;
}
Beispiel #5
0
	eXine()
	{
			/* this should be done once. */

		if(!xine_check_version(1, 1, 0))
		{
			int major, minor, sub;
			xine_get_version (&major, &minor, &sub);
			eWarning("Require xine library version 1.1.0, found %d.%d.%d.\n",
						major, minor,sub);
			return;
		} else {
			int major, minor, sub;
			eDebug("Built with xine library %d.%d.%d (%s)\n",
						 XINE_MAJOR_VERSION, XINE_MINOR_VERSION, XINE_SUB_VERSION, XINE_VERSION);

			xine_get_version (&major, &minor, &sub);

			eDebug("Found xine library version: %d.%d.%d (%s).\n",
						 major, minor, sub, xine_get_version_string());
		}

		xine = xine_new();
		xine_engine_set_param(xine, XINE_ENGINE_PARAM_VERBOSITY, 1);
		xine_init(xine);
	}
Beispiel #6
0
RESULT eDVBPESReader::start(int pid)
{
	RESULT res;
	if (m_fd < 0)
		return -ENODEV;

	m_notifier->start();

#if HAVE_DVB_API_VERSION < 3
	dmxPesFilterParams flt;
	
	flt.pesType = DMX_PES_OTHER;
#else
	dmx_pes_filter_params flt;
	
	flt.pes_type = DMX_PES_OTHER;
#endif

	flt.pid     = pid;
	flt.input   = DMX_IN_FRONTEND;
	flt.output  = DMX_OUT_TAP;
	
	flt.flags   = DMX_IMMEDIATE_START;

	res = ::ioctl(m_fd, DMX_SET_PES_FILTER, &flt);
	
	if (res)
		eWarning("PES filter: DMX_SET_PES_FILTER - %m");
	if (!res)
		m_active = 1;
	return res;
}
Beispiel #7
0
void eDVBSectionReader::data(int)
{
	__u8 data[4096]; // max. section size
	int r;
	r = ::read(fd, data, 4096);
#if FUZZING
	int j;
	for (j = 0; j < r; ++j)
	{
		if (!(rand()%FUZZING_PROPABILITY))
			data[j] ^= rand();
	}
#endif	
	if(r < 0)
	{
		eWarning("ERROR reading section - %m\n");
		return;
	}
	if (checkcrc)
	{
			// this check should never happen unless the driver is crappy!
		unsigned int c;
		if ((c = crc32((unsigned)-1, data, r)))
		{
			eDebug("crc32 failed! is %x\n", c);
			return;
		}
	}
	if (active)
		read(data);
	else
		eDebug("data.. but not active");
}
Beispiel #8
0
void eWidgetDesktop::makeCompatiblePixmap(gPixmap &pm)
{
	if (m_comp_mode != cmImmediate)
		return;

//	eDebug("[widgetDesktop] make compatible pixmap of %p", &pm);
	if (!m_screen.m_dc)
	{
		eWarning("[eWidgetDesktop] no DC to make pixmap compatible with!");
		return;
	}

	ePtr<gPixmap> target_pixmap;
	m_screen.m_dc->getPixmap(target_pixmap);

	if (!target_pixmap) {
		eDebug("[eWidgetDesktop] no target pixmap! assuming bpp > 8 for accelerated graphics.");
		return;
	}

	if (target_pixmap->surface && target_pixmap->surface->bpp > 8)
		return;

	ePtr<gDC> pixmap_dc = new gDC(&pm);
	gPainter pixmap_painter(pixmap_dc);

	pixmap_painter.mergePalette(target_pixmap);
}
Beispiel #9
0
static void avahi_client_callback(AvahiClient *client, AvahiClientState state, void *d)
{
	eDebug("[Avahi] client state: %d", state);
	switch(state)
	{
		case AVAHI_CLIENT_S_RUNNING:
			/* The server has startup successfully and registered its host
			 * name on the network, register all our services */
			avahi_client_try_register_all();
			break;
		case AVAHI_CLIENT_FAILURE:
			/* Problem? Maybe we have to re-register everything? */
			eWarning("[Avahi] Client failure: %s\n", avahi_strerror(avahi_client_errno(client)));
			break;
		case AVAHI_CLIENT_S_COLLISION:
			/* Let's drop our registered services. When the server is back
			 * in AVAHI_SERVER_RUNNING state we will register them
			 * again with the new host name. */
		case AVAHI_CLIENT_S_REGISTERING:
			/* The server records are now being established. This
			 * might be caused by a host name change. We need to wait
			 * for our own records to register until the host name is
			 * properly esatblished. */
			avahi_client_reset_all();
			break;
		case AVAHI_CLIENT_CONNECTING:
			/* No action... */
			break;
	}
}
Beispiel #10
0
RESULT eDVBPESReader::start(int pid)
{
	RESULT res;
	if (m_fd < 0)
		return -ENODEV;

	m_notifier->start();

	dmx_pes_filter_params flt;
	memset(&flt, 0, sizeof(flt));

	flt.pes_type = DMX_PES_OTHER;
	flt.pid     = pid;
	flt.input   = DMX_IN_FRONTEND;
	flt.output  = DMX_OUT_TAP;

	flt.flags   = DMX_IMMEDIATE_START;

	res = ::ioctl(m_fd, DMX_SET_PES_FILTER, &flt);

	if (res)
		eWarning("PES filter: DMX_SET_PES_FILTER - %m");
	if (!res)
		m_active = 1;
	return res;
}
Beispiel #11
0
void gPixmap::fill(const gRegion &region, const gRGB &color)
{
	unsigned int i;
	for (i=0; i<region.rects.size(); ++i)
	{
		const eRect &area = region.rects[i];
		if ((area.height()<=0) || (area.width()<=0))
			continue;

		if (surface->bpp == 32)
		{
			__u32 col;

			col = color.argb();
#if defined(__sh__) 
if((col&0xFF000000) == 0xFF000000)
col = 0xFF000000;
#endif
			col^=0xFF000000;

			if (surface->data_phys && gAccel::getInstance())
				if (!gAccel::getInstance()->fill(surface,  area, col))
					continue;

			for (int y=area.top(); y<area.bottom(); y++)
			{
				__u32 *dst=(__u32*)(((__u8*)surface->data)+y*surface->stride+area.left()*surface->bypp);
				int x=area.width();
				while (x--)
					*dst++=col;
			}
		}	else
			eWarning("couldn't rgbfill %d bpp", surface->bpp);
	}
}
Beispiel #12
0
void eDVBSectionReader::data(int)
{
	uint8_t data[4096]; // max. section size
	int r;
	r = ::read(fd, data, 4096);
	if(r < 0)
	{
		eWarning("ERROR reading section - %m\n");
		return;
	}
	if (checkcrc)
	{
		// this check should never happen unless the driver is crappy!
		unsigned int c;
		if ((c = crc32((unsigned)-1, data, r)))
		{
			//eDebug("[eDVBSectionReader] section crc32 failed! is %x\n", c);
			return;
		}
	}
	if (active)
		read(data);
	else
		eDebug("data.. but not active");
}
Beispiel #13
0
RESULT eDVBPESReader::start(int pid)
{
	RESULT res;
	if (m_fd < 0)
		return -ENODEV;

	eDebug("[eDVBPESReader] DMX_SET_PES_FILTER pid=%04x", pid);
	m_notifier->start();

	dmx_pes_filter_params flt;
	flt.pes_type = DMX_PES_OTHER;
	flt.pid     = pid;
	flt.input   = DMX_IN_FRONTEND;
	flt.output  = DMX_OUT_TAP;

	flt.flags   = DMX_IMMEDIATE_START;

	res = ::ioctl(m_fd, DMX_SET_PES_FILTER, &flt);

	if (res)
		eWarning("[eDVBPESReader] DMX_SET_PES_FILTER pid=%04x:  %m", pid);
	if (!res)
		m_active = 1;
	return res;
}
Beispiel #14
0
void eWidgetDesktop::makeCompatiblePixmap(gPixmap &pm)
{
	if (m_comp_mode != cmImmediate)
		return;
	
//	eDebug("widgetDesktop: make compatible pixmap of %p", &pm);
	if (!m_screen.m_dc)
	{
		eWarning("eWidgetDesktop: no DC to make pixmap compatible with!");
		return;
	}

	ePtr<gPixmap> target_pixmap;
	m_screen.m_dc->getPixmap(target_pixmap);
	
	ASSERT(target_pixmap);
	
	if (target_pixmap->surface && target_pixmap->surface->bpp > 8)
		return;

	ePtr<gDC> pixmap_dc = new gDC(&pm);
	gPainter pixmap_painter(pixmap_dc);
	
	pixmap_painter.mergePalette(target_pixmap);
}
Beispiel #15
0
static void peer_remove(const char *name)
{
	eWarning("REMOVE Peer %s", name);
	PeerMapping::iterator it = peers.find(std::string(name));
	if (it != peers.end())
		peers.erase(it);
}
Beispiel #16
0
static void peer_register(const char *name,	const char *host_name, uint16_t port)
{
	eWarning("ADD Peer %s=%s:%u", name, host_name, port);
	std::ostringstream url;
	url << "http://" << host_name << ":" << port;
	peers[std::string(name)] = url.str();
}
Beispiel #17
0
void eFilePushThreadRecorder::thread()
{
	setIoPrio(IOPRIO_CLASS_RT, 7);

	eDebug("[eFilePushThreadRecorder] THREAD START");

	/* we set the signal to not restart syscalls, so we can detect our signal. */
	struct sigaction act;
	act.sa_handler = signal_handler; // no, SIG_IGN doesn't do it. we want to receive the -EINTR
	act.sa_flags = 0;
	sigaction(SIGUSR1, &act, 0);

	hasStarted();

	/* m_stop must be evaluated after each syscall. */
	while (!m_stop)
	{
		ssize_t bytes = ::read(m_fd_source, m_buffer, m_buffersize);
		if (bytes < 0)
		{
			bytes = 0;
			/* Check m_stop after interrupted syscall. */
			if (m_stop) {
				break;
			}
			if (errno == EINTR || errno == EBUSY || errno == EAGAIN)
				continue;
			if (errno == EOVERFLOW)
			{
				eWarning("[eFilePushThreadRecorder] OVERFLOW while recording");
				++m_overflow_count;
				continue;
			}
			eDebug("[eFilePushThreadRecorder] *read error* (%m) - aborting thread because i don't know what else to do.");
			sendEvent(evtReadError);
			break;
		}

#ifdef SHOW_WRITE_TIME
		struct timeval starttime;
		struct timeval now;
		gettimeofday(&starttime, NULL);
#endif
		int w = writeData(bytes);
#ifdef SHOW_WRITE_TIME
		gettimeofday(&now, NULL);
		suseconds_t diff = (1000000 * (now.tv_sec - starttime.tv_sec)) + now.tv_usec - starttime.tv_usec;
		eDebug("[eFilePushThreadRecorder] write %d bytes time: %9u us", bytes, (unsigned int)diff);
#endif
		if (w < 0)
		{
			eDebug("[eFilePushThreadRecorder] WRITE ERROR, aborting thread: %m");
			sendEvent(evtWriteError);
			break;
		}
	}
	flush();
	sendEvent(evtStopped);
	eDebug("[eFilePushThreadRecorder] THREAD STOP");
}
Beispiel #18
0
eDVBPESReader::eDVBPESReader(eDVBDemux *demux, eMainloop *context, RESULT &res): m_demux(demux), m_active(0)
{
	eWarning("[eDVBPESReader] Created. Opening demux");
	m_fd = m_demux->openDemux();
	if (m_fd >= 0)
	{
		setBufferSize(64*1024);
		::fcntl(m_fd, F_SETFL, O_NONBLOCK);
		m_notifier = eSocketNotifier::create(context, m_fd, eSocketNotifier::Read, false);
		CONNECT(m_notifier->activated, eDVBPESReader::data);
		res = 0;
	} else
	{
		eWarning("[eDVBPESReader] openDemux failed: %m");
		res = errno;
	}
}
Beispiel #19
0
eThread::~eThread()
{
	if (the_thread)
	{
		/* Warn about this class' design being borked */
		eWarning("Destroyed thread without joining it, this usually means your thread is now running with a halfway destroyed object");
		kill();
	}
}
Beispiel #20
0
RESULT eDVBTSRecorder::stop()
{
	int state=3;

	for (std::map<int,int>::iterator i(m_pids.begin()); i != m_pids.end(); ++i)
		stopPID(i->first);

	if (!m_running)
		return -1;

	/* workaround for record thread stop */
	if (m_source_fd >= 0)
	{
		if (::ioctl(m_source_fd, DMX_STOP) < 0)
			eWarning("[eDVBTSRecorder] DMX_STOP: %m");
		else
			state &= ~1;

		if (::close(m_source_fd) < 0)
			eWarning("[eDVBTSRecorder] close: %m");
		else
			state &= ~2;
		m_source_fd = -1;
	}

	m_thread->stop();

	if (state & 3)
	{
		if (m_source_fd >= 0)
		{
			::close(m_source_fd);
			m_source_fd = -1;
		}
	}

	m_running = 0;

	m_thread->stopSaveMetaInformation();
	return 0;
}
Beispiel #21
0
void eThread::kill()
{
	/* FIXME: Allthough in Linux we seem to get away with it, there is no
	 * guarantee that "0" is an invalid value for pthread_t */
	if (!the_thread) /* already joined */
		return;

	int ret = pthread_join(the_thread, NULL);
	the_thread = 0;
	if (ret)
		eWarning("pthread_join failed, code: %d", ret);
}
Beispiel #22
0
void eDVBServiceRecord::recordEvent(int event)
{
	switch (event)
	{
	case iDVBTSRecorder::eventWriteError:
		eWarning("[eDVBServiceRecord] record write error");
		stop();
		m_event((iRecordableService*)this, evRecordWriteError);
		return;
	default:
		eDebug("unhandled record event %d", event);
	}
}
Beispiel #23
0
void eFilePushThread::resume()
{
	if (m_stop != 2)
	{
		eWarning("eFilePushThread::resume called while not paused");
		return;
	}
	/* Resume the paused thread by resetting the flag and
	 * signal the thread to release it */
	eSingleLocker lock(m_run_mutex);
	m_stop = 0;
	m_run_cond.signal(); /* Tell we're ready to resume */
}
Beispiel #24
0
void eDVBServiceStream::recordEvent(int event)
{
	switch (event)
	{
	case iDVBTSRecorder::eventWriteError:
		eWarning("[eDVBServiceStream] stream write error");
		streamStopped();
		break;
	default:
		eDebug("unhandled record event %d", event);
		break;
	}
}
Beispiel #25
0
eDVBSectionReader::eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESULT &res): demux(demux), active(0)
{
	fd = demux->openDemux();

	if (fd >= 0)
	{
		notifier=eSocketNotifier::create(context, fd, eSocketNotifier::Read, false);
		CONNECT(notifier->activated, eDVBSectionReader::data);
		res = 0;
	} else
	{
		eWarning("[eDVBSectionReader] demux->openDemux failed: %m");
		res = errno;
	}
}
Beispiel #26
0
void e2avahi_resolve_cancel(const char* service_type, E2AvahiResolveCallback callback, void *userdata)
{
	AvahiBrowserEntry entry(service_type, callback, userdata);
	AvahiBrowserEntryList::iterator it = std::find(avahi_browsers.begin(), avahi_browsers.end(), entry);
	if (it == avahi_browsers.end()) {
		eWarning("[Avahi] Cannot remove resolver for %s, not found", service_type);
		return;
	}
	if (it->browser)
	{
		avahi_service_browser_free(it->browser);
		it->browser = NULL;
	}
	avahi_browsers.erase(it);
}
Beispiel #27
0
RESULT eDVBTSRecorder::startPID(int pid)
{
	while(true) {
		uint16_t p = pid;
		if (::ioctl(m_source_fd, DMX_ADD_PID, &p) < 0) {
			eWarning("[eDVBTSRecorder] DMX_ADD_PID pid=%04x: %m", pid);
			if (errno == EAGAIN || errno == EINTR) {
				eDebug("[eDVBTSRecorder] retry!");
				continue;
			}
		} else
			m_pids[pid] = 1;
		break;
	}
	return 0;
}
Beispiel #28
0
void eDVBTSRecorder::stopPID(int pid)
{
	if (m_pids[pid] != -1)
	{
		while(true) {
			uint16_t p = pid;
			if (::ioctl(m_source_fd, DMX_REMOVE_PID, &p) < 0) {
				eWarning("[eDVBTSRecorder] DMX_REMOVE_PID pid=%04x: %m", pid);
				if (errno == EAGAIN || errno == EINTR) {
					eDebug("[eDVBTSRecorder] retry!");
					continue;
				}
			}
			break;
		}
	}
	m_pids[pid] = -1;
}
Beispiel #29
0
void eFilePushThread::pause()
{
	if (m_stop == 1)
	{
		eWarning("eFilePushThread::pause called while not running");
		return;
	}
	/* Set thread into a paused state by setting m_stop to 2 and wait
	 * for the thread to acknowledge that */
	eSingleLocker lock(m_run_mutex);
	m_stop = 2;
	sendSignal(SIGUSR1);
	m_run_cond.signal(); /* Trigger if in weird state */
	while (m_run_state) {
		eDebug("FILEPUSH waiting for pause");
		m_run_cond.wait(m_run_mutex);
	}
}
Beispiel #30
0
void gPixmap::fill(const gRegion &region, const gColor &color)
{
	unsigned int i;
	for (i=0; i<region.rects.size(); ++i)
	{
		const eRect &area = region.rects[i];
		if ((area.height()<=0) || (area.width()<=0))
			continue;

		if (surface->bpp == 8)
		{
			for (int y=area.top(); y<area.bottom(); y++)
		 		memset(((__u8*)surface->data)+y*surface->stride+area.left(), color.color, area.width());
		} else if (surface->bpp == 32)
		{
			__u32 col;

			if (surface->clut.data && color < surface->clut.colors)
				col=(surface->clut.data[color].a<<24)|(surface->clut.data[color].r<<16)|(surface->clut.data[color].g<<8)|(surface->clut.data[color].b);
			else
				col=0x10101*color;
		
#if defined(__sh__) 
if((col&0xFF000000) == 0xFF000000)
col = 0xFF000000;
#endif
			col^=0xFF000000;
	

			if (surface->data_phys && gAccel::getInstance())
				if (!gAccel::getInstance()->fill(surface,  area, col))
					continue;

			for (int y=area.top(); y<area.bottom(); y++)
			{
				__u32 *dst=(__u32*)(((__u8*)surface->data)+y*surface->stride+area.left()*surface->bypp);
				int x=area.width();
				while (x--)
					*dst++=col;
			}
		}	else
			eWarning("couldn't fill %d bpp", surface->bpp);
	}
}