forgotten commit. disabled until egl is adapted.
[AROS-Contrib.git] / FryingPan / Optical / Disc_DVD_PlusRW.cpp
blob23778ca86cf81f6a45212cf0ede83cba2729a356
1 /*
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
4 *
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.
9 *
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.
20 #include "Headers.h"
21 #include "Disc_DVD_PlusRW.h"
23 Disc_DVD_PlusRW::Disc_DVD_PlusRW(Drive *d) : Disc_DVD_PlusR(d)
25 readfmtcaps = 0;
26 meas = 0;
29 Disc_DVD_PlusRW::~Disc_DVD_PlusRW(void)
31 delete readfmtcaps;
34 void Disc_DVD_PlusRW::Init(void)
36 Disc_DVD_PlusR::Init();
38 if (readfmtcaps) delete readfmtcaps;
40 readfmtcaps = new cmd_ReadFormatCapacities(dio);
41 readfmtcaps->Go();
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)
56 cmd_Format *fmt;
57 int err;
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);
71 Calibrate();
73 if (meas != 0)
74 meas->begin();
75 err = fmt->Go();
76 WaitOpComplete();
77 if (meas != 0)
78 meas->end();
79 meas = 0;
80 // if (err == ODE_OK) Init();
81 RequestUpdate();
82 delete fmt;
83 return err;
86 int Disc_DVD_PlusRW::StructureDisc(void)
88 int err;
89 err = FormatDisc(DRT_Format_Fast);
90 if (err) return err;
91 return ODE_OK;
94 bool Disc_DVD_PlusRW::IsFormatted(void)
96 if (NULL == readfmtcaps)
97 return false;
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);
107 cl->Go();
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();
117 delete cl;
119 // Init();
120 RequestUpdate();
122 return error;
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);
137 if (di == 0)
138 return trak;
139 if (di == trak)
140 di = 0;
144 return 0;
147 int Disc_DVD_PlusRW::DiscSubType()
149 cmd_GetConfiguration::Feature *x;
151 x = drive->GetDriveFeature(cmd_GetConfiguration::Feature_DVD_PlusRW_DualLayer);
152 if (x == 0)
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;
160 } else {
161 _D(Lvl_Debug, "Got SingleLayer DVD+RW media..");
162 return DRT_SubType_Unknown;
166 int16 Disc_DVD_PlusRW::GetOperationProgress()
168 if (meas != 0)
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();