📄 thread.h
字号:
//// Copyright (c) 2003 by Istv醤 V醨adi//// This file is part of dxr3Player, a DVD player written specifically // for the DXR3 (aka Hollywood+) decoder card.// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either 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, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA#ifndef DXR3PLAYER_DVD_READER_THREAD_H#define DXR3PLAYER_DVD_READER_THREAD_H//------------------------------------------------------------------------------#include "dvd/File.h"#include "dvd/SectorPosition.h"#include "sched/Thread.h"//------------------------------------------------------------------------------namespace dvd {class DVD;namespace demux {class Sector;}}//------------------------------------------------------------------------------namespace dvd { namespace reader {//------------------------------------------------------------------------------/** * The DVD reader thread. */class Thread : public sched::Thread{public: /** * The type of the commands the thread can perform. */ typedef enum command_t { /// No command given NONE, /// Check if there is a disk in the driver CHECK, /// Open the DVD OPEN, /// Read from the DVD READ, /// Close the DVD CLOSE, /// Eject the DVD EJECT };private: /** * The DVD to work with. */ DVD& dvd; /** * The VTS number of the file. */ unsigned fileVTSNumber; /** * Indicate if the file belongs to a menu or not. */ bool menuFile; /** * The file currently opened. */ File file; /** * The parameters of a read command */ struct { /** * The address of the sector to read into. */ dvd::demux::Sector* destination; /** * The position to read from. */ SectorPosition source; /** * The number of sectors to read. */ size_t numSectors; } readParameters; /** * The result of a check operation. */ volatile bool checkResult; /** * The command to perform. */ volatile command_t command;public: /** * Construct the thread. */ Thread(DVD& dvd); /** * Get the DVD. */ DVD& getDVD() const; /** * Get the command last given. If the thread is busy, it is being * executed, otherwise it was the last command performed. */ command_t getLastCommand() const; /** * Check if there is a disk in the driver. */ bool check(); /** * Try opening the DVD. Should be called only if it is not opened. */ void open(); /** * Start reading the given number of sectors into the given * address. */ void read(dvd::demux::Sector* destination, const SectorPosition& source, size_t numSectors); /** * Discard the given number of read sectors starting with the * first sector. New reading can start only if all sectors are * discarded. * * @param numSectors the number of sectors to discard, or 0 to * discard all sectors. * * @return the number of sectors discarded */ size_t discardRead(size_t numSectors = 0); /** * Get the point of the last destination sector. */ dvd::demux::Sector* getReadDestination() const; /** * Get the starting position of the last reading. */ const SectorPosition& getReadSource() const; /** * Get the number of sectors read by the last reading. */ size_t getNumberOfSectorsRead() const; /** * Close the DVD. Should be called only if it is opened. */ void close(); /** * Eject the DVD. Should be called only if it is closed. */ void eject();private: /** * Perform the current command. * * @see sched::Thread::perform */ virtual void perform(); /** * Open the file belonging to the given VTS. */ void openFile(unsigned vtsNo, bool isMenu);};//------------------------------------------------------------------------------// Inline definitions//------------------------------------------------------------------------------inline DVD& Thread::getDVD() const{ return dvd;}//------------------------------------------------------------------------------inline Thread::command_t Thread::getLastCommand() const{ return command;}//------------------------------------------------------------------------------inline dvd::demux::Sector* Thread::getReadDestination() const{ assert(command==READ); return readParameters.destination;}//------------------------------------------------------------------------------inline const SectorPosition& Thread::getReadSource() const{ assert(command==READ); return readParameters.source;}//------------------------------------------------------------------------------inline size_t Thread::getNumberOfSectorsRead() const{ assert(command==READ); return readParameters.numSectors;}//------------------------------------------------------------------------------} /* namespace dvd::reader */ } /* namespace dvd *///------------------------------------------------------------------------------#endif // DXR3PLAYER_DVD_READER_THREAD_H// Local variables:// mode: c++// End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -