-
Notifications
You must be signed in to change notification settings - Fork 8
/
CDDAExtract.h
154 lines (108 loc) · 3.69 KB
/
CDDAExtract.h
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#pragma once
#include "stdafx.h"
#include "DiscManager.h"
#include "Handlers.h"
#include "Playlist.h"
#include "Settings.h"
#include <atomic>
class WndTaskbar;
// CD audio extractor.
class CDDAExtract
{
public:
// 'instance' - module instance handle.
// 'hwnd' - application window handle.
// 'library' - media library.
// 'settings' - application settings.
// 'handlers' - audio format handlers.
// 'discManager' - optical disc manager.
// 'tracks' - tracks to extract.
// 'encoderHandler' - encoder handler to use.
// 'joinFilename' - output filename, when joining tracks into a single file.
// 'taskbar' - taskbar control.
CDDAExtract( const HINSTANCE instance, const HWND hwnd, Library& library, Settings& settings, Handlers& handlers, DiscManager& discManager, const Playlist::Items& tracks, const Handler::Ptr encoderHandler, const std::wstring& joinFilename, WndTaskbar& taskbar );
virtual ~CDDAExtract();
private:
// CD audio data.
typedef std::shared_ptr<CDDAMedia::Data> DataPtr;
// Maps media information to CD audio data.
typedef std::map<MediaInfo,DataPtr> MediaData;
// Dialog box procedure.
static INT_PTR CALLBACK DialogProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam );
// Read thread procedure.
static DWORD WINAPI ReadThreadProc( LPVOID lpParam );
// Encode thread procedure.
static DWORD WINAPI EncodeThreadProc( LPVOID lpParam );
// Called when the dialog is initialised.
// 'hwnd' - dialog window handle.
void OnInitDialog( const HWND hwnd );
// Closes the dialog.
void Close();
// Read thread handler.
void ReadHandler();
// Encode thread handler.
void EncodeHandler();
// Returns whether extraction has been cancelled.
bool Cancelled() const;
// Updates the status of the progress bars.
void UpdateStatus();
// Called if there was an error during the extraction process.
// 'errorID' - error resource ID.
void Error( const WORD errorID );
// Writes track specific tags to 'filename' based on the 'mediaInfo'.
void WriteTrackTags( const std::wstring& filename, const MediaInfo& mediaInfo );
// Writes album specific tags to 'filename' based on the 'mediaInfo'.
void WriteAlbumTags( const std::wstring& filename, const MediaInfo& mediaInfo );
// Module instance handle.
HINSTANCE m_hInst;
// Dialog window handle.
HWND m_hWnd;
// Media library.
Library& m_Library;
// Application settings.
Settings& m_Settings;
// Audio format handlers.
Handlers& m_Handlers;
// Optical disc manager.
DiscManager& m_DiscManager;
// Taskbar control.
WndTaskbar& m_Taskbar;
// Tracks to extract.
const Playlist::Items m_Tracks;
// Cancel event handle.
HANDLE m_CancelEvent;
// Pending encode event handle.
HANDLE m_PendingEncodeEvent;
// Read thread handle.
HANDLE m_ReadThread;
// Encode thread handle.
HANDLE m_EncodeThread;
// Pending tracks to encode.
MediaData m_PendingEncode;
// Pending tracks mutex.
std::mutex m_PendingEncodeMutex;
// Read track status.
std::atomic<long> m_StatusTrack;
// Read pass status.
std::atomic<long> m_StatusPass;
// Read progress, in the range 0.0 to 1.0.
std::atomic<float> m_ProgressRead;
// Encode progress, in the range 0.0 to 1.0.
std::atomic<float> m_ProgressEncode;
// Progress bar range.
long m_ProgressRange;
// The currently displayed read track status.
long m_DisplayedTrack;
// The currently displayed read pass status.
long m_DisplayedPass;
// The total number of samples to extract.
long m_TotalSamples;
// The encoder handler to use.
Handler::Ptr m_EncoderHandler;
// The encoder to use.
Encoder::Ptr m_Encoder;
// The encoder settings to use.
std::string m_EncoderSettings;
// The output filename, when joining tracks into a single file.
std::wstring m_JoinFilename;
};