From e2de64d6f1beb9e492daf5b886e19933c1fa41dd Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- mpeglib/example/yaf/yafcore/multiReader.h | 88 +++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 mpeglib/example/yaf/yafcore/multiReader.h (limited to 'mpeglib/example/yaf/yafcore/multiReader.h') diff --git a/mpeglib/example/yaf/yafcore/multiReader.h b/mpeglib/example/yaf/yafcore/multiReader.h new file mode 100644 index 00000000..79f7dd8b --- /dev/null +++ b/mpeglib/example/yaf/yafcore/multiReader.h @@ -0,0 +1,88 @@ +/* + This class can waits for input on different istreams + Copyright (C) 1998 Martin Vogt + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Library General Public License as published by + the Free Software Foundation. + + For more information look at the file COPYRIGHT in this package + + */ + + + + +#ifndef __MULTIREADER_H +#define __MULTIREADER_H + +#include "lineStack.h" +#include "buffer.h" + +extern "C" { +#include +#include +#include +#include +#include +#include + } + +/** + The purpose of this class is to have a thread safe input method + for yaf command. +

+ Sometime the decoder thread must send data to the control thread. + E.g. the Stream has ended. The decoder thread must inform the + control thread that the player should go into the "off" state. + A direct call is not thread safe and this is why the decoder + thread must use this class. For the control thread it looks + like the user has typed "off". + +*/ + +#define _MAX_INPUT 5 + +typedef struct { + LineStack* tmpLineStack; // owned by class + int fd; // filedescriptor for input + int empty; +} LineInput; + + +class MultiReader { + + Buffer* buffer; + LineInput* lineInputArray[_MAX_INPUT]; + LineStack* script; + + public: + MultiReader(); + ~MultiReader(); + + int add(int fd); + void add(LineStack* aScript); + void add(Buffer* aScript); + void remove (int fd); + + void waitForLine(); + void poll(struct timeval* timeout); + + int hasLine(); + void getLine(Buffer* buffer); + + private: + + void doSelect(struct timeval *timeout); + + int getEmptySlot(); + int getSlot(int fd); + + +}; + + + + + +#endif -- cgit v1.2.1