Bringing ChocolateCaste-0.7 into the main branch.
[AROS-Contrib.git] / FryingPan / Optical / Disc_DVD_MinusR.cpp
bloba4a469ac7d87ede1a95f3b44b4228978ead9652e
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_MinusR.h"
23 Disc_DVD_MinusR::Disc_DVD_MinusR(Drive *d) : Disc_DVD_ROM(d)
27 void Disc_DVD_MinusR::Init(void)
29 Disc_DVD_ROM::Init();
30 information = rdvd.ReadStructure(cmd_ReadDVDStructure::DVD_PreRecordedLeadIn, 0, 0);
33 Disc_DVD_MinusR::~Disc_DVD_MinusR(void)
37 int Disc_DVD_MinusR::OnChangeWriteMethod()
39 DiscWriteMethod dwm = GetWriteMethod();
41 if (dwm == DRT_WriteMethod_Default)
43 return SetWriteMethod(DRT_WriteMethod_Packet); // a small loopback
45 else if (dwm != DRT_WriteMethod_Packet)
47 SetWriteMethod(DRT_WriteMethod_Packet); // reject
48 return ODE_IllegalType;
51 Page<Page_Write> &pw = drive->GetWritePage();
52 if (!pw.IsValid()) return ODE_NoModePage;
53 _D(Lvl_Debug, "Setting up DVD-R/RW parameters: packet writing enabled");
54 pw->SetSessionFormat(Page_Write::Session_Data);
55 pw->SetPacketSize(16);
56 pw->SetDataMode(Page_Write::DataMode_Mode1);
57 pw->SetWriteType(Page_Write::WriteType_Packet);
58 pw->SetTrackMode(Page_Write::TrackMode_Data_Incremental);
59 pw->SetMultisession(1);
60 pw->SetLinkSize(0);
61 return drive->SetPage(pw);
64 int Disc_DVD_MinusR::CloseDisc(int type, int lTrackNo)
66 cmd_Close *cl = new cmd_Close(dio);
68 _D(Lvl_Info, "Closing DVD-R media");
69 cl->setType(cmd_Close::Close_FlushBuffers, 0);
71 * do not let immediate go up here. immediate flush causes problems.
73 //cl->setImmediate(true);
74 cl->Go();
75 WaitOpComplete();
77 if (type == DRT_Close_Track) {
78 cl->setType(cmd_Close::Close_DVDMinusR_Track, lTrackNo);
79 } else if (type == DRT_Close_Session) {
80 cl->setType(cmd_Close::Close_DVDMinusR_LastSession, 0);
81 } else if (type == DRT_Close_Finalize) {
82 cl->setType(cmd_Close::Close_DVDMinusR_LastSession, 0);
85 * do not let immediate go up here. immediate flush causes problems.
87 //cl->setImmediate(true);
88 int error = cl->Go();
89 WaitOpComplete();
90 delete cl;
92 // Init();
93 RequestUpdate();
95 return error;
98 bool Disc_DVD_MinusR::IsWritable()
100 if (GetNextWritableTrack(0))
101 return true;
102 return false;
105 int Disc_DVD_MinusR::CheckItemData(const IOptItem *pDI)
107 const_cast<IOptItem*>(pDI)->setIncremental(true);
109 if (pDI->hasCDText())
111 _D(Lvl_Error, "CD-Text allowed only on CD media");
112 return ODE_BadLayout;
114 if (pDI->isPreemphasized())
116 _D(Lvl_Error, "Preemphasy allowed only on CD media");
117 return ODE_BadLayout;
119 if (pDI->getPreGapSize())
121 _D(Lvl_Error, "Pad size other than 0 not allowed");
122 return ODE_BadLayout;
125 if (pDI->getItemType() == Item_Disc)
127 if (pDI->getFlags() & DIF_Disc_MasterizeCD)
129 _D(Lvl_Error, "DVD discs can not be masterized");
130 return ODE_BadLayout;
132 const_cast<IOptItem*>(pDI)->setSectorSize(2048);
134 else if (pDI->getItemType() == Item_Session)
136 const_cast<IOptItem*>(pDI)->setSectorSize(2048);
138 else if (pDI->getItemType() == Item_Track)
140 if (pDI->getDataType() != Data_Mode1)
142 _D(Lvl_Error, "Only Data/Mode1 tracks allowed on DVD media");
143 return ODE_BadTrackMode;
145 const_cast<IOptItem*>(pDI)->setSectorSize(2048);
146 const_cast<IOptItem*>(pDI)->setIncremental(true);
148 else if (pDI->getItemType() == Item_Index)
150 _D(Lvl_Error, "Indices allowed only on CD media");
151 return ODE_BadLayout;
154 return Disc::CheckItemData(pDI);