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.
20 #include "wCUESession.h"
21 #include <Generic/LibrarySpool.h>
22 #include <libclass/dos.h>
23 #include <Optical/IOptItem.h>
25 wCUESession::wCUESession(const char* sFileName
, const IOptItem
*it
, EDtError
&rc
)
34 rc
= DT_InvalidOperation
;
38 if (it
->getItemType() != Item_Session
)
40 rc
= DT_InvalidOperation
;
46 wCUESession::~wCUESession()
57 IFileWriter
* wCUESession::openWrite(const char* sFile
, const IOptItem
*it
, EDtError
&rc
)
59 return new wCUESession(sFile
, it
, rc
);
62 const char* wCUESession::getName()
64 return static_getName();
67 bool wCUESession::writeData(void* pBuff
, int pLen
)
70 int32 size
= pLen
* sess
->getSectorSize();
73 return (size
== DOS
->Write(fbin
, pBuff
, size
));
78 bool wCUESession::setUp()
84 fcue
= DOS
->Open(s
.Data(), MODE_NEWFILE
);
89 s
= DOS
->FilePart(name
.Data());
91 fbin
= DOS
->Open(s
.Data(), MODE_NEWFILE
);
96 DOS
->FPuts(fcue
, "REM Cue sheet generated by The Frying Pan\n\n");
97 //FPuts(fcue, "REM CATALOG xxxxxxxxxxx\n");
98 //FPuts(fcue, "REM CDTEXTFILE 'file.cdt'\n");
99 //FPuts(fcue, "REM DISC_ID id\n");
100 //FPuts(fcue, "REM UPC_EAN code\n");
103 DOS
->FPuts(fcue
, "\tFILE \"");
104 DOS
->FPuts(fcue
, s
.Data());
105 DOS
->FPuts(fcue
, "\" BINARY\n\n");
107 if (sess
->hasCDText())
109 DOS
->FPuts(fcue
, "\tARRANGER \"");
110 DOS
->FPuts(fcue
, const_cast<char*>(sess
->getCDTDirector()));
111 DOS
->FPuts(fcue
, "\"\n\tCOMPOSER \"");
112 DOS
->FPuts(fcue
, const_cast<char*>(sess
->getCDTComposer()));
113 DOS
->FPuts(fcue
, "\"\n\tMESSAGE \"");
114 DOS
->FPuts(fcue
, const_cast<char*>(sess
->getCDTMessage()));
115 DOS
->FPuts(fcue
, "\"\n\tPERFORMER \"");
116 DOS
->FPuts(fcue
, const_cast<char*>(sess
->getCDTArtist()));
117 DOS
->FPuts(fcue
, "\"\n\tSONGWRITER \"");
118 DOS
->FPuts(fcue
, const_cast<char*>(sess
->getCDTLyrics()));
119 DOS
->FPuts(fcue
, "\"\n\tTITLE \"");
120 DOS
->FPuts(fcue
, const_cast<char*>(sess
->getCDTTitle()));
121 DOS
->FPuts(fcue
, "\"\n");
122 //FPuts(fcue, "\tREM TOC_INFO t1");
123 //FPuts(fcue, "\n\tREM TOC_INFO2 t2");
124 //FPuts(fcue, "\n\tREM SIZE_INFO");
128 for (int i
=0; i
<sess
->getChildCount(); i
++)
130 const IOptItem
*it
= sess
->getChild(i
);
133 f
.FormatStr("\n\nTRACK %ld %s\n", ARRAY(it
->getItemNumber(),
134 it
->getDataType() == Data_Audio
? (int)"AUDIO" :
135 it
->getDataType() == Data_Mode1
? (int)"MODE1/2352" : (int)"MODE2/2352"));
137 DOS
->FPuts(fcue
, f
.Data());
139 for (int ix
=0; ix
<it
->getChildCount(); ix
++)
141 const IOptItem
*idx
= it
->getChild(ix
);
143 f
.FormatStr("\tINDEX %ld %ld:%02ld:%02ld\n", ARRAY(
144 idx
->getItemNumber(), // NOTE:
145 (idx
->getStartAddress()) / 75 / 60, // this is an offset within actual file!
146 (idx
->getStartAddress()) / 75 % 60, // and since we create one large file
147 (idx
->getStartAddress()) % 75)); // this is the real offset :]
148 DOS
->FPuts(fcue
, f
.Data());
151 //FPuts(fcue, "\tREM FLAGS PRE DCP 4CH SCMS\n");
152 //FPuts(fcue, "\tREM ISRC ccooooyysssss\n");
153 f
.FormatStr("\tPREGAP %ld\n", ARRAY(it
->getPreGapSize()));
154 DOS
->FPuts(fcue
, f
.Data());
155 //FPuts(fcue, "\tREM POSTGAP yyy\n");
156 //FPuts(fcue, "\tREM GENRE zzz\n");
159 DOS
->FPuts(fcue
, "\tARRANGER \"");
160 DOS
->FPuts(fcue
, const_cast<char*>(it
->getCDTDirector()));
161 DOS
->FPuts(fcue
, "\"\n\tCOMPOSER \"");
162 DOS
->FPuts(fcue
, const_cast<char*>(it
->getCDTComposer()));
163 DOS
->FPuts(fcue
, "\"\n\tMESSAGE \"");
164 DOS
->FPuts(fcue
, const_cast<char*>(it
->getCDTMessage()));
165 DOS
->FPuts(fcue
, "\"\n\tPERFORMER \"");
166 DOS
->FPuts(fcue
, const_cast<char*>(it
->getCDTArtist()));
167 DOS
->FPuts(fcue
, "\"\n\tSONGWRITER \"");
168 DOS
->FPuts(fcue
, const_cast<char*>(it
->getCDTLyrics()));
169 DOS
->FPuts(fcue
, "\"\n\tTITLE \"");
170 DOS
->FPuts(fcue
, const_cast<char*>(it
->getCDTTitle()));
171 DOS
->FPuts(fcue
, "\"\n");
172 //FPuts(fcue, "\tREM TOC_INFO t1");
173 //FPuts(fcue, "\n\tREM TOC_INFO2 t2");
174 //FPuts(fcue, "\n\tREM SIZE_INFO");
181 void wCUESession::cleanUp()
191 void wCUESession::deleteFiles()
195 void wCUESession::dispose()
200 void wCUESession::setBlockCount(unsigned long)
204 void wCUESession::setBlockSize(unsigned short)
208 const char *wCUESession::static_getName()
210 return "CUE Sheet Session";
213 bool wCUESession::static_isAudio()
218 bool wCUESession::static_isData()
223 bool wCUESession::static_isSession()