add new code to disable dvdcss caching
This commit is contained in:
parent
ed3801ab02
commit
83d91b6a73
|
@ -268,7 +268,7 @@ namespace Li::Dvd {
|
|||
this->sectorsReadSoFar = 0;
|
||||
this->fileReadSoFar = 0;
|
||||
this->keepRunning = false;
|
||||
this->ripinThread->join();
|
||||
this->ripinThread->detach();
|
||||
|
||||
delete this->driveIoCtl;
|
||||
delete this->ripinThread;
|
||||
|
|
|
@ -36,18 +36,24 @@ namespace Li::Gui {
|
|||
}
|
||||
|
||||
DumpDVD::~DumpDVD() {
|
||||
this->keepPolling = false;
|
||||
this->pollDrives->join();
|
||||
if (this->imRippinIt) {
|
||||
this->endRipNow();
|
||||
std::filesystem::remove(std::string(this->outputFile));
|
||||
}
|
||||
else {
|
||||
this->keepPolling = false;
|
||||
this->pollDrives->detach();
|
||||
delete this->pollDrives;
|
||||
}
|
||||
|
||||
delete this->lock;
|
||||
delete this->pollDrives;
|
||||
freeOldDriveList();
|
||||
}
|
||||
|
||||
void DumpDVD::pollDrivesThread() {
|
||||
while (this->keepPolling) {
|
||||
if ( (this->counter % (60 * 10)) == 0) {
|
||||
this->refreshDriveList();
|
||||
}
|
||||
this->refreshDriveList();
|
||||
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +109,7 @@ namespace Li::Gui {
|
|||
void DumpDVD::startRip() {
|
||||
if (this->GetCurrentSelectedDrive()->DiscInDrive()) {
|
||||
this->keepPolling = false;
|
||||
this->pollDrives->join();
|
||||
this->pollDrives->detach();
|
||||
delete this->pollDrives;
|
||||
|
||||
std::vector<uint32_t>* speeds = this->GetCurrentSelectedDrive()->SupportedSpeeds();
|
||||
|
@ -119,11 +125,15 @@ namespace Li::Gui {
|
|||
}
|
||||
}
|
||||
|
||||
void DumpDVD::endRipAndGoBackToMenu() {
|
||||
void DumpDVD::endRipNow() {
|
||||
this->dvdRipper->EndRip();
|
||||
delete this->dvdRipper;
|
||||
|
||||
this->imRippinIt = false;
|
||||
}
|
||||
|
||||
void DumpDVD::endRipAndGoBackToMenu() {
|
||||
this->endRipNow();
|
||||
|
||||
this->reset();
|
||||
|
||||
this->keepPolling = true;
|
||||
|
@ -177,7 +187,7 @@ namespace Li::Gui {
|
|||
|
||||
if (this->dvdRipper->Done()) {
|
||||
if (!this->dvdRipper->Error()) {
|
||||
ImGui::Begin("Complete", &this->imRippinIt, ImGuiWindowFlags_NoCollapse);
|
||||
ImGui::Begin("Complete", &this->imRippinIt, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize);
|
||||
ImGui::Text("ISO file was created successfully.");
|
||||
if (ImGui::Button("OK")) {
|
||||
this->endRipAndGoBackToMenu();
|
||||
|
@ -185,7 +195,7 @@ namespace Li::Gui {
|
|||
ImGui::End();
|
||||
}
|
||||
else {
|
||||
ImGui::Begin("Error", &this->imRippinIt, ImGuiWindowFlags_NoCollapse);
|
||||
ImGui::Begin("Error", &this->imRippinIt, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize);
|
||||
ImGui::Text("Error occured when creating an ISO\n\"%s\"", this->dvdRipper->ErrorMessage().c_str());
|
||||
if (ImGui::Button("OK")) {
|
||||
this->endRipAndGoBackToMenu();
|
||||
|
@ -284,7 +294,7 @@ namespace Li::Gui {
|
|||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize, ImGuiCond_Always);
|
||||
|
||||
ImGui::Begin("DVD Dumper", NULL, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove |
|
||||
ImGui::Begin("DVD Dumper", NULL, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing);
|
||||
|
||||
if (this->imRippinIt)
|
||||
|
|
|
@ -41,6 +41,7 @@ namespace Li::Gui {
|
|||
void reset();
|
||||
|
||||
void startRip();
|
||||
void endRipNow();
|
||||
void endRipAndGoBackToMenu();
|
||||
|
||||
void showRipMenu();
|
||||
|
|
|
@ -1,38 +1,25 @@
|
|||
#include "MainWindow.hpp"
|
||||
#ifdef _WIN32
|
||||
#include "D3D.hpp"
|
||||
#include <imgui_impl_dx11.cpp>
|
||||
#endif
|
||||
#include "SDL.hpp"
|
||||
#include "DumpDVD.hpp"
|
||||
|
||||
#include <imgui_impl_sdl2.h>
|
||||
#include <imgui.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "SDL.hpp"
|
||||
#include "DumpDVD.hpp"
|
||||
|
||||
namespace Li::Gui {
|
||||
MainWindow::MainWindow() {
|
||||
this->sdl = new SDL("DumpDVD", 800, 400);
|
||||
this->sdl->SetMaxFPS(24.0);
|
||||
|
||||
DumpDVD* dumpDvdMenu = new DumpDVD();
|
||||
uint32_t lastRenderTime = SDL_GetTicks();
|
||||
while (!this->sdl->IsExiting()) {
|
||||
uint32_t curRenderTime = SDL_GetTicks();
|
||||
uint32_t delta = curRenderTime - lastRenderTime;
|
||||
if (delta > 1000 / 60.0)
|
||||
{
|
||||
this->sdl->PollEvent();
|
||||
this->sdl->NewFrame();
|
||||
this->sdl->PollEvent();
|
||||
this->sdl->NewFrame();
|
||||
|
||||
dumpDvdMenu->RenderUI();
|
||||
dumpDvdMenu->RenderUI();
|
||||
|
||||
this->sdl->Render();
|
||||
|
||||
lastRenderTime = curRenderTime;
|
||||
}
|
||||
this->sdl->Render();
|
||||
}
|
||||
|
||||
delete dumpDvdMenu;
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
#include <imgui_impl_dx11.h>
|
||||
#endif
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <imgui_impl_sdl2.h>
|
||||
#include <imgui.h>
|
||||
|
@ -50,7 +53,9 @@ namespace Li::Gui {
|
|||
#else
|
||||
#error No imgui renderer backend provided for this platform
|
||||
#endif
|
||||
isExiting = false;
|
||||
this->isExiting = false;
|
||||
this->SetMaxFPS(24.0);
|
||||
this->lastRenderTime = SDL_GetTicks();
|
||||
}
|
||||
bool SDL::IsExiting() {
|
||||
return this->isExiting;
|
||||
|
@ -77,16 +82,31 @@ namespace Li::Gui {
|
|||
}
|
||||
}
|
||||
void SDL::NewFrame() {
|
||||
this->curRenderTime = SDL_GetTicks();
|
||||
|
||||
this->renderer->ImGuiNewFrame();
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
}
|
||||
|
||||
void SDL::SetMaxFPS(float fpsLimit) {
|
||||
this->maxFps = fpsLimit;
|
||||
this->limit = (1000 / this->maxFps);
|
||||
}
|
||||
|
||||
void SDL::Render() {
|
||||
ImGui::Render();
|
||||
ImVec4 clearColor = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||
this->renderer->Render(clearColor);
|
||||
|
||||
this->lastRenderTime = this->curRenderTime;
|
||||
this->delta = (this->curRenderTime - this->lastRenderTime);
|
||||
|
||||
if (this->delta < this->limit)
|
||||
{
|
||||
uint32_t remain = (this->limit - this->delta);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(remain));
|
||||
}
|
||||
}
|
||||
|
||||
SDL::~SDL() {
|
||||
|
|
|
@ -11,12 +11,22 @@ namespace Li::Gui {
|
|||
SDL_WindowFlags windowFlags;
|
||||
SDL_SysWMinfo wmInfo;
|
||||
SDL_Window* window;
|
||||
|
||||
|
||||
float maxFps;
|
||||
uint32_t limit;
|
||||
|
||||
uint32_t lastRenderTime;
|
||||
uint32_t curRenderTime;
|
||||
uint32_t delta;
|
||||
|
||||
Renderer* renderer;
|
||||
bool isExiting;
|
||||
|
||||
public:
|
||||
bool IsExiting();
|
||||
void NewFrame();
|
||||
void SetMaxFPS(float fpsLimit);
|
||||
void PollEvent();
|
||||
void Render();
|
||||
SDL(std::string windowTitle, int windowWidth, int windowHeight);
|
||||
|
|
Binary file not shown.
|
@ -200,7 +200,7 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_CACHE
|
||||
/* Check if we've already cracked this key */
|
||||
p_title = dvdcss->p_titles;
|
||||
while( p_title != NULL
|
||||
|
@ -253,7 +253,7 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
|
|||
close( i_fd );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
/* Crack or decrypt Content Scrambling System (CSS) title key
|
||||
* for current Video Title Set (VTS). */
|
||||
if( i_ret < 0 )
|
||||
|
@ -273,7 +273,7 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
|
|||
/* We cache this anyway, so we don't need to check again. */
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_CACHE
|
||||
/* Key is valid, we store it on disk. */
|
||||
if( dvdcss->psz_cachefile[0] && b_cache )
|
||||
{
|
||||
|
@ -294,7 +294,6 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
|
|||
close( i_fd );
|
||||
}
|
||||
}
|
||||
|
||||
/* Find our spot in the list */
|
||||
p_newtitle = NULL;
|
||||
p_title = dvdcss->p_titles;
|
||||
|
@ -329,6 +328,7 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
|
|||
p_title->p_next = p_newtitle;
|
||||
}
|
||||
|
||||
#endif
|
||||
memcpy( dvdcss->css.p_title_key, p_title_key, DVD_KEY_SIZE );
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
* "C:\Documents and Settings\$USER\Application Data\dvdcss\" under Win32.
|
||||
* The special value "off" disables caching.
|
||||
*/
|
||||
|
||||
//#define ENABLE_CACHE 1
|
||||
/*
|
||||
* Preamble
|
||||
*/
|
||||
|
@ -204,6 +204,7 @@ static int set_access_method( dvdcss_t dvdcss )
|
|||
|
||||
static int set_cache_directory( dvdcss_t dvdcss )
|
||||
{
|
||||
#ifdef ENABLE_CACHE
|
||||
char *psz_cache = getenv( "DVDCSS_CACHE" );
|
||||
|
||||
if( psz_cache && !strcmp( psz_cache, "off" ) )
|
||||
|
@ -299,11 +300,13 @@ static int set_cache_directory( dvdcss_t dvdcss )
|
|||
print_error( dvdcss, "cache directory name is too long" );
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int init_cache_dir( dvdcss_t dvdcss )
|
||||
{
|
||||
#ifdef ENABLE_CACHE
|
||||
static const char psz_tag[] =
|
||||
"Signature: 8a477f597d28d172789f06886806bc55\r\n"
|
||||
"# This file is a cache directory tag created by libdvdcss.\r\n"
|
||||
|
@ -344,11 +347,13 @@ static int init_cache_dir( dvdcss_t dvdcss )
|
|||
}
|
||||
close( i_fd );
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void create_cache_subdir( dvdcss_t dvdcss )
|
||||
{
|
||||
#ifdef ENABLE_CACHE
|
||||
uint8_t p_sector[DVDCSS_BLOCK_SIZE];
|
||||
char psz_key[STRING_KEY_SIZE + 1];
|
||||
char *psz_title;
|
||||
|
@ -465,10 +470,12 @@ static void create_cache_subdir( dvdcss_t dvdcss )
|
|||
|
||||
error:
|
||||
dvdcss->psz_cachefile[0] = '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
static void init_cache( dvdcss_t dvdcss )
|
||||
{
|
||||
#ifdef ENABLE_CACHE
|
||||
/* Set CSS key cache directory. */
|
||||
int i_ret = set_cache_directory( dvdcss );
|
||||
if ( i_ret < 0 )
|
||||
|
@ -485,6 +492,7 @@ static void init_cache( dvdcss_t dvdcss )
|
|||
|
||||
/* If the cache is enabled, create a DVD-specific subdirectory. */
|
||||
create_cache_subdir( dvdcss );
|
||||
#endif
|
||||
}
|
||||
|
||||
LIBDVDCSS_EXPORT char* dvdcss_get_cur_disckey(dvdcss_t dvdcss) {
|
||||
|
@ -628,9 +636,9 @@ static dvdcss_t dvdcss_open_common ( const char *psz_target, void *p_stream,
|
|||
print_debug( dvdcss, "could not get disc key" );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_CACHE
|
||||
init_cache( dvdcss );
|
||||
|
||||
#endif
|
||||
/* Seek to the beginning, just for safety. */
|
||||
dvdcss->pf_seek( dvdcss, 0 );
|
||||
|
||||
|
|
Loading…
Reference in New Issue