diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Plugins/SDK/burner/ISOBurner.cpp | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/Plugins/SDK/burner/ISOBurner.cpp')
-rw-r--r-- | Src/Plugins/SDK/burner/ISOBurner.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/Src/Plugins/SDK/burner/ISOBurner.cpp b/Src/Plugins/SDK/burner/ISOBurner.cpp new file mode 100644 index 00000000..84d45f62 --- /dev/null +++ b/Src/Plugins/SDK/burner/ISOBurner.cpp @@ -0,0 +1,67 @@ +#include "ISOBurner.h" +#include "../nu/AutoChar.h" +#include "ifc_burner_writecallback.h" + +ISOBurner::ISOBurner(obj_primo *_primo) : BurnerCommon(_primo) +{ +} + +int ISOBurner::Open() +{ + if (!primo) + return 1; + + return 0; +} + +int ISOBurner::Write(wchar_t driveLetter, const wchar_t *isoFile, int flags, unsigned int speed, ifc_burner_writecallback *callback) +{ + DWORD unit[] = {driveLetter, 0xFFFFFFFF}; + DWORD ret = primo->WriteOtherCDImage(unit, (PBYTE)(char *)AutoChar(isoFile), flags, speed); + if (ret != PRIMOSDK_OK) + return 1; + + while (1) + { + DWORD cursec = 0, totsec = 0; + ret = primo->RunningStatus(PRIMOSDK_GETSTATUS, &cursec, &totsec); + + if (ret == PRIMOSDK_RUNNING) + { + if (callback) + { + int abort = callback->OnStatus(cursec, totsec); + if (abort) + { + ret = primo->RunningStatus(PRIMOSDK_ABORT, 0, 0); + callback = 0; // cheap way to prevent making further callbacks + } + } + WaitForSingleObject(triggerEvent, 500); + } + else if (ret == PRIMOSDK_OK) + { + DWORD unit = driveLetter; + ret = primo->UnitStatus(&unit, NULL, NULL, NULL, NULL); + + if (ret == PRIMOSDK_OK && callback) + callback->Finished(); + break; + } + else + break; + } + + if (ret != PRIMOSDK_OK) + return 1; + + return 0; +} + +#define CBCLASS ISOBurner +START_DISPATCH; +CB(ISOBURNER_OPEN, Open) +CB(ISOBURNER_WRITE, Write) +VCB(ISOBURNER_FORCECALLBACK, ForceCallback) +END_DISPATCH; +#undef CBCLASS |