📄 thread.cc
字号:
//// 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//------------------------------------------------------------------------------#include "Thread.h"#include "dvd/demux/Sector.h"#include "dvd/DVD.h"#include "util/Log.h"#include <cassert>//------------------------------------------------------------------------------using dvd::reader::Thread;using dvd::demux::Sector;//------------------------------------------------------------------------------Thread::Thread(DVD& dvd) : sched::Thread("dvd::reader::Thread"), dvd(dvd), checkResult(false), command(NONE){ readParameters.numSectors = 0;}//------------------------------------------------------------------------------bool Thread::check(){ if (dvd.isOpen()) return true; checkResult = false; command = CHECK; trigger(); return checkResult;}//------------------------------------------------------------------------------void Thread::open(){ assert(!dvd.isOpen()); command = OPEN; trigger();}//------------------------------------------------------------------------------void Thread::read(Sector* destination, const SectorPosition& source, size_t numSectors){ assert(dvd.isOpen()); assert(destination!=0); assert(numSectors!=0); assert(readParameters.numSectors==0);// Log::debug("dvd::reader::Thread::read: Reading %u sectors from VTS %u (%sin menu) from sector %u\n",// numSectors, source.getVTSNumber(),// source.isInMenu() ? "" : "not ",// source.getSectorNumber()); readParameters.destination = destination; readParameters.source = source; readParameters.numSectors = numSectors; command = READ; trigger();}//------------------------------------------------------------------------------size_t Thread::discardRead(size_t numSectors){ assert(numSectors<=readParameters.numSectors); if (numSectors==0) numSectors = readParameters.numSectors; readParameters.destination += numSectors; readParameters.source.setSectorNumber(readParameters.source.getSectorNumber() + numSectors); readParameters.numSectors -= numSectors; if (readParameters.numSectors==0) command = NONE; return numSectors;}//------------------------------------------------------------------------------void Thread::close(){ assert(dvd.isOpen()); command = CLOSE; trigger();}//------------------------------------------------------------------------------void Thread::eject(){ assert(!dvd.isOpen()); command = EJECT; trigger();}//------------------------------------------------------------------------------void Thread::perform(){ switch(command) { case CHECK: checkResult = dvd.hasDisk(); break; case OPEN: dvd.open(); break; case READ: openFile(readParameters.source.getVTSNumber(), readParameters.source.isInMenu()); file.readSectors(readParameters.destination, readParameters.source.getSectorNumber(), readParameters.numSectors); break; case CLOSE: file.close(); dvd.close(); break; case EJECT: dvd.eject(); break; case NONE: default: break; }}//------------------------------------------------------------------------------void Thread::openFile(unsigned vtsNo, bool isMenu){ if (!file || vtsNo!=fileVTSNumber || isMenu!=menuFile) { const IFO* ifo = (vtsNo==0) ? (const IFO*)dvd.getVMG() : (const IFO*)dvd.getVTS(vtsNo); assert(ifo!=0); file = isMenu ? dvd.openMenuFile(ifo) : dvd.openTitleFile(ifo); assert(file); fileVTSNumber = vtsNo; menuFile = isMenu; }}//------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -