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_PlusRW.h"
23 Disc_DVD_PlusRW::Disc_DVD_PlusRW(Drive
*d
) : Disc_DVD_PlusR(d
)
29 Disc_DVD_PlusRW::~Disc_DVD_PlusRW(void)
34 void Disc_DVD_PlusRW::Init(void)
36 Disc_DVD_PlusR::Init();
38 if (readfmtcaps
) delete readfmtcaps
;
40 readfmtcaps
= new cmd_ReadFormatCapacities(dio
);
43 Page
<Page_Write
> &pw
= drive
->GetWritePage();
44 pw
->SetWriteType(Page_Write::WriteType_Packet
);
45 if (drive
->SetPage(pw
))
47 _D(Lvl_Error
, "Unable to set up packet writing for DVD+RW/-RAM media!!!");
50 _D(Lvl_Info
, "Disc formatted? : %ld", readfmtcaps
->IsFormatted());
51 _D(Lvl_Info
, "Max capacity : %ld blocks", readfmtcaps
->GetMaxCapacity());
54 int Disc_DVD_PlusRW::FormatDisc(int met
)
59 Page
<Page_Write
> &pw
= drive
->GetWritePage();
60 pw
->SetWriteType(Page_Write::WriteType_Packet
);
61 pw
->SetPacketSize(16);
62 if (drive
->SetPage(pw
))
63 return ODE_CommandError
;
65 meas
= drive
->GetHardwareConfig()->DVDPlusInfo()->getCFormatMeas(GetDiscSize(), GetWriteSpeed());
66 // all methods work same here.
67 fmt
= new cmd_Format(dio
);
68 fmt
->setImmediate(true);
69 fmt
->setType(cmd_Format::Format_DVDP_FullFormat
, readfmtcaps
->GetMaxCapacity(), 0);
80 // if (err == ODE_OK) Init();
86 int Disc_DVD_PlusRW::StructureDisc(void)
89 err
= FormatDisc(DRT_Format_Fast
);
94 bool Disc_DVD_PlusRW::IsFormatted(void)
96 if (NULL
== readfmtcaps
)
99 return readfmtcaps
->IsFormatted();
102 int Disc_DVD_PlusRW::CloseDisc(int type
, int)
104 cmd_Close
*cl
= new cmd_Close(dio
);
106 cl
->setType(cmd_Close::Close_FlushBuffers
, 0);
109 if (type
== DRT_Close_Track
) {
110 cl
->setType(cmd_Close::Close_DVDPlusRW_DeIcing
, 0);
111 } else if (type
== DRT_Close_Session
) {
112 cl
->setType(cmd_Close::Close_DVDPlusRW_FinalizeCompatible
, 0);
113 } else if (type
== DRT_Close_Finalize
) {
114 cl
->setType(cmd_Close::Close_DVDPlusRW_FinalizeCompatible
, 0);
116 int error
= cl
->Go();
125 const IOptItem
*Disc_DVD_PlusRW::GetNextWritableTrack(const IOptItem
*di
)
127 _D(Lvl_Info
, "DVD+RW/RAM Querying next writable track after %08lx", (int)di
);
129 const IOptItem
*disc
= GetContents();
130 for (int i
=0; i
<disc
->getChildCount(); i
++)
132 const IOptItem
*sess
= disc
->getChild(i
);
133 for (int j
=0; j
<sess
->getChildCount(); j
++)
135 const IOptItem
*trak
= sess
->getChild(j
);
147 int Disc_DVD_PlusRW::DiscSubType()
149 cmd_GetConfiguration::Feature
*x
;
151 x
= drive
->GetDriveFeature(cmd_GetConfiguration::Feature_DVD_PlusRW_DualLayer
);
154 return DRT_SubType_Unknown
;
157 if (x
->IsCurrent()) {
158 _D(Lvl_Debug
, "Got DualLayer DVD+RW media! Yuppie!");
159 return DRT_SubType_DVD_DualLayer
;
161 _D(Lvl_Debug
, "Got SingleLayer DVD+RW media..");
162 return DRT_SubType_Unknown
;
166 int16
Disc_DVD_PlusRW::GetOperationProgress()
170 return meas
->getProgress();
172 return Disc::GetOperationProgress();
175 uint32
Disc_DVD_PlusRW::GetDiscSize()
177 if (0 != readfmtcaps
)
178 return readfmtcaps
->GetMaxCapacity();
179 return Disc_DVD_PlusR::GetDiscSize();