forked from jfchapman/VUPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DlgAdvancedASIO.cpp
104 lines (95 loc) · 3.29 KB
/
DlgAdvancedASIO.cpp
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
#include "DlgAdvancedASIO.h"
#include "resource.h"
#include "Utility.h"
INT_PTR CALLBACK DlgAdvancedASIO::DialogProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch ( message ) {
case WM_INITDIALOG : {
DlgAdvancedASIO* dialog = reinterpret_cast<DlgAdvancedASIO*>( lParam );
if ( nullptr != dialog ) {
SetWindowLongPtr( hwnd, DWLP_USER, lParam );
dialog->OnInitDialog( hwnd );
return TRUE;
}
break;
}
case WM_DESTROY : {
SetWindowLongPtr( hwnd, DWLP_USER, 0 );
break;
}
case WM_COMMAND : {
switch ( LOWORD( wParam ) ) {
case IDOK : {
DlgAdvancedASIO* dialog = reinterpret_cast<DlgAdvancedASIO*>( GetWindowLongPtr( hwnd, DWLP_USER ) );
if ( nullptr != dialog ) {
dialog->SaveSettings( hwnd );
}
}
case IDCANCEL : {
EndDialog( hwnd, 0 );
return TRUE;
}
case IDC_ASIO_RESET : {
DlgAdvancedASIO* dialog = reinterpret_cast<DlgAdvancedASIO*>( GetWindowLongPtr( hwnd, DWLP_USER ) );
if ( nullptr != dialog ) {
dialog->ResetToDefaults( hwnd );
}
break;
}
}
break;
}
}
return FALSE;
}
DlgAdvancedASIO::DlgAdvancedASIO( const HINSTANCE instance, const HWND parent, Settings& settings ) :
m_Settings( settings )
{
DialogBoxParam( instance, MAKEINTRESOURCE( IDD_ADVANCED_ASIO ), parent, DialogProc, reinterpret_cast<LPARAM>( this ) );
}
DlgAdvancedASIO::~DlgAdvancedASIO()
{
}
void DlgAdvancedASIO::OnInitDialog( const HWND hwnd )
{
CentreDialog( hwnd );
bool useDefaultSamplerate = false;
int defaultSamplerate = 0;
int leadIn = 0;
m_Settings.GetAdvancedASIOSettings( useDefaultSamplerate, defaultSamplerate, leadIn );
SetDlgItemInt( hwnd, IDC_ASIO_DEFAULTRATE, static_cast<UINT>( defaultSamplerate ), FALSE );
SetDlgItemInt( hwnd, IDC_ASIO_LEADIN, static_cast<UINT>( leadIn ), FALSE );
CheckRadioButton( hwnd, IDC_ASIO_OUTPUT_DEFAULT, IDC_ASIO_OUTPUT_SOURCE,
useDefaultSamplerate ? IDC_ASIO_OUTPUT_DEFAULT : IDC_ASIO_OUTPUT_SOURCE );
}
void DlgAdvancedASIO::SaveSettings( const HWND hwnd )
{
bool useDefaultSamplerate = false;
int defaultSamplerate = 0;
int leadIn = 0;
m_Settings.GetAdvancedASIOSettings( useDefaultSamplerate, defaultSamplerate, leadIn );
useDefaultSamplerate = ( BST_CHECKED == IsDlgButtonChecked( hwnd, IDC_ASIO_OUTPUT_DEFAULT ) );
BOOL success = FALSE;
UINT value = GetDlgItemInt( hwnd, IDC_ASIO_DEFAULTRATE, &success, FALSE );
if ( success ) {
defaultSamplerate = static_cast<int>( value );
}
value = GetDlgItemInt( hwnd, IDC_ASIO_LEADIN, &success, FALSE );
if ( success ) {
leadIn = static_cast<int>( value );
}
m_Settings.SetAdvancedASIOSettings( useDefaultSamplerate, defaultSamplerate, leadIn );
}
void DlgAdvancedASIO::ResetToDefaults( const HWND hwnd )
{
bool useDefaultSamplerate = false;
int defaultSamplerate = 0;
int leadIn = 0;
int maxDefaultSamplerate = 0;
int maxLeadIn = 0;
m_Settings.GetDefaultAdvancedASIOSettings( useDefaultSamplerate, defaultSamplerate, leadIn, maxDefaultSamplerate, maxLeadIn );
SetDlgItemInt( hwnd, IDC_ASIO_DEFAULTRATE, static_cast<UINT>( defaultSamplerate ), TRUE /*signed*/ );
SetDlgItemInt( hwnd, IDC_ASIO_LEADIN, static_cast<UINT>( leadIn ), TRUE /*signed*/ );
CheckRadioButton( hwnd, IDC_ASIO_OUTPUT_DEFAULT, IDC_ASIO_OUTPUT_SOURCE,
useDefaultSamplerate ? IDC_ASIO_OUTPUT_DEFAULT : IDC_ASIO_OUTPUT_SOURCE );
}