2 * FryingPan - Amiga CD/DVD Recording Software (User Interface and supporting Libraries only)
3 * Copyright (C) 2001-2011 Tomasz Wiszkowski Tomasz.Wiszkowski at gmail.com
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "Disc_DVD_MinusRW.h"
23 Disc_DVD_MinusRW::Disc_DVD_MinusRW(Drive
*d
) : Disc_DVD_MinusR(d
)
29 void Disc_DVD_MinusRW::Init(void)
31 Disc_DVD_MinusR::Init(); // MUSI BYC W TEJ KOLEJNOSCI
32 readfmtcaps
= new cmd_ReadFormatCapacities(dio
);
36 Disc_DVD_MinusRW::~Disc_DVD_MinusRW(void)
41 bool Disc_DVD_MinusRW::IsFormatted(void)
43 if (NULL
== readfmtcaps
)
45 if (readfmtcaps
->IsFormatted())
50 bool Disc_DVD_MinusRW::IsOverwritable(void)
52 cmd_GetConfiguration::Feature
*x
;
54 if (DiscType() != DRT_Profile_DVD_MinusRW_Restricted
)
57 x
= drive
->GetDriveFeature(cmd_GetConfiguration::Feature_RigidOverwrite
);
59 if (x
->IsCurrent()) return 1;
61 x
= drive
->GetDriveFeature(cmd_GetConfiguration::Feature_RestrictedOverwrite
);
63 if (x
->IsCurrent()) return 1;
68 int Disc_DVD_MinusRW::EraseDisc(int met
)
70 cmd_Blank::BlankType type
;
72 cmd_StartStopUnit
ssu(dio
);
74 ssu
.setType(cmd_StartStopUnit::StartStop_Start
);
78 Page
<Page_Write
> &pw
= drive
->GetWritePage();
79 pw
->SetWriteType(Page_Write::WriteType_SessionAtOnce
);
80 if (drive
->SetPage(pw
))
81 return ODE_CommandError
;
84 case DRT_Blank_Complete
:
86 type
= cmd_Blank::Blank_All
;
87 meas
= drive
->GetHardwareConfig()->DVDMinusInfo()->getCBlankMeas(GetDiscSize(), GetWriteSpeed());
92 type
= cmd_Blank::Blank_Minimal
;
93 meas
= drive
->GetHardwareConfig()->DVDMinusInfo()->getQBlankMeas(GetDiscSize(), GetWriteSpeed());
97 return ODE_IllegalParameter
;
102 cmd_Blank
*blk
= new cmd_Blank(dio
);
103 blk
->setType(type
, 0);
104 blk
->setImmediate(true);
113 // if (err == ODE_OK) Init();
119 int Disc_DVD_MinusRW::FormatDisc(int met
)
123 cmd_StartStopUnit
ssu(dio
);
125 ssu
.setType(cmd_StartStopUnit::StartStop_Start
);
128 Page
<Page_Write
> &pw
= drive
->GetWritePage();
129 pw
->SetWriteType(Page_Write::WriteType_Packet
);
130 pw
->SetPacketSize(16);
131 if (drive
->SetPage(pw
))
132 return ODE_CommandError
;
136 fmt
= new cmd_Format(dio
);
137 fmt
->setImmediate(true);
141 case DRT_Format_Complete
:
143 _D(Lvl_Info
, "Complete format of dvd-rw media requested");
144 fmt
->setType(cmd_Format::Format_FullFormat
, readfmtcaps
->GetMaxCapacity(), 16);
145 meas
= drive
->GetHardwareConfig()->DVDMinusInfo()->getCFormatMeas(GetDiscSize(), GetWriteSpeed());
148 case DRT_Format_Fast
:
150 _D(Lvl_Info
, "Quick format of dvd-rw media requested");
151 fmt
->setType(cmd_Format::Format_DVDM_QuickFormat
, 0, 16);
152 meas
= drive
->GetHardwareConfig()->DVDMinusInfo()->getQFormatMeas(GetDiscSize(), GetWriteSpeed());
164 // if (err == ODE_OK) Init();
170 int Disc_DVD_MinusRW::StructureDisc(void)
173 err
= EraseDisc(DRT_Blank_Fast
);
175 err
= FormatDisc(DRT_Format_Fast
);
180 int Disc_DVD_MinusRW::DiscType()
182 if (NULL
== readfmtcaps
)
183 return DRT_Profile_DVD_MinusRW_Sequential
; // we dont know if it can be formatted
185 if (readfmtcaps
->IsFormatted()) {
186 return DRT_Profile_DVD_MinusRW_Restricted
;
188 return DRT_Profile_DVD_MinusRW_Sequential
;
192 bool Disc_DVD_MinusRW::IsWritable()
194 // _D("Checking whether disc is formatted...");
195 // if (!IsFormatted())
197 _D(Lvl_Info
, "Checking for writable tracks...");
198 if (GetNextWritableTrack(0))
203 int16
Disc_DVD_MinusRW::GetOperationProgress()
207 return meas
->getProgress();
209 return Disc::GetOperationProgress();
212 uint32
Disc_DVD_MinusRW::GetDiscSize()
214 if (0 != readfmtcaps
)
215 return readfmtcaps
->GetMaxCapacity();
216 return Disc_DVD_MinusR::GetDiscSize();