-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadCDSectorThreadUnit.pas
More file actions
116 lines (101 loc) · 3.48 KB
/
Copy pathReadCDSectorThreadUnit.pas
File metadata and controls
116 lines (101 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
unit ReadCDSectorThreadUnit;
interface
uses
Classes,
Tools_Unit,
MMC1Unit,
SPC_Unit,
CommonCDSettingsUnit;
Type
T_Method=procedure(s : String) of object;
type
T_ReadCDSectorThread=
class(TThread)
private
{ Private declarations }
sender_method : T_Method;
StartSect : LongInt;
SubChSelMode : Byte;
is_TEB : Boolean;
is_no_ErrMsg : Boolean;
err_msg : String;
Procedure ShowErrMsg;
protected
procedure Execute; override;
public
Constructor Create(thread_done_proc : TNotifyEvent;
in_method : T_Method;
in_StartSect : LongInt;
in_SubChSelMode : Byte;
in_is_TEB : Boolean;
in_is_no_ErrMsg : Boolean);
Procedure ReadCDSector;
end;
implementation
Uses
MainFormUnit;
Constructor T_ReadCDSectorThread.Create(thread_done_proc : TNotifyEvent;
in_method : T_Method;
in_StartSect : LongInt;
in_SubChSelMode : Byte;
in_is_TEB : Boolean;
in_is_no_ErrMsg : Boolean);
Begin
sender_method:=in_method;
StartSect:=in_StartSect;
SubChSelMode:=in_SubChSelMode;
is_TEB:=in_is_TEB;
is_no_ErrMsg:=in_is_no_ErrMsg;
OnTerminate:=thread_done_proc;
FreeOnTerminate := True;
Inherited Create(False);
End;
Procedure T_ReadCDSectorThread.ShowErrMsg;
Begin
sender_method(err_msg);
End;
Procedure T_ReadCDSectorThread.ReadCDSector;
Var
Data_1block_size : Word;
Sector_block_size : Word;
SubCh_block_size : Byte;
HSA_sector : LongInt;
SubCh_buf : ^Byte;
sub_int_PW_96 : T_sub_int_PW_96;
Begin
Sector_block_size:=Form1.SCSI.MMC1_any_link.Get_MMC1.GetBlockSizeFromFilterReadFormat(MMC_SECTORTYPE_ANY,
MMC_READCD_SYNC_ALLHDR_USERDATA_EDCECC);
SubCh_block_size:=Form1.SCSI.MMC1_any_link.Get_MMC1.GetBlockSizeFromSubCh(SubChSelMode);
Data_1block_size:=SubCh_block_size+Sector_block_size;
Form1.SCSI.SPC_any_link.Zero_data_buf;
{
//Convert positive LBA sector to MMCLBA (MMC style LBA) sector
If StartSect>=404850 Then
HSA_sector:=StartSect-450000
else
HSA_sector:=StartSect;
}
HSA_sector:=StartSect;
Form1.SCSI.MMC1_any_link.Do_readCD_byFormat_CDB12(HSA_sector,
1,
MMC_SECTORTYPE_ANY,
MMC_READCD_SYNC_ALLHDR_USERDATA_EDCECC,
SubChSelMode);
If Not (Form1.SCSI.SPC_any_link.Get_is_sendcmd_OK OR
(is_TEB AND
((Form1.SCSI.SPC_any_link.Get_sense_key=SEN_KEY_MEDIUM_ERR) OR
(Form1.SCSI.SPC_any_link.Get_sense_key=SEN_KEY_RECV_ERR)))) Then
Begin
If (NOT is_no_ErrMsg) Then
Begin
err_msg:='Error while processing ReadCD command.' + Chr(10) + Chr(13) +
Form1.SCSI.MMC1_any_link.Get_err_msg;
Synchronize(ShowErrMsg);
End;
End;
End;
procedure T_ReadCDSectorThread.Execute;
begin
ReadCDSector;
end;
end.