2 ==============================================================================
\r
4 Copyright 2005-11 by Satoshi Fujiwara.
\r
6 async can be redistributed and/or modified under the terms of the
\r
7 GNU General Public License, as published by the Free Software Foundation;
\r
8 either version 2 of the License, or (at your option) any later version.
\r
10 async is distributed in the hope that it will be useful,
\r
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 GNU General Public License for more details.
\r
15 You should have received a copy of the GNU General Public License
\r
16 along with async; if not, visit www.gnu.org/licenses or write to the
\r
17 Free Software Foundation, Inc., 59 Temple Place, Suite 330,
\r
18 Boston, MA 02111-1307 USA
\r
20 ==============================================================================
\r
29 #include "resource.h"
\r
30 #define BOOST_ASSIGN_MAX_PARAMS 7
\r
31 #include <boost/assign.hpp>
\r
32 #include <boost/assign/ptr_list_of.hpp>
\r
33 #include <boost/assign/ptr_list_inserter.hpp>
\r
34 #include <boost/foreach.hpp>
\r
37 #define _CRTDBG_MAP_ALLOC
\r
39 #define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
\r
42 #include "sf_windows.h"
\r
43 #include "CommDlg.h"
\r
46 #include "exception.h"
\r
47 #include "application.h"
\r
48 #include "config_tab_dialog.h"
\r
50 #define THROW_IFERR(hres) \
\r
51 if (FAILED(hres)) { throw sf::win32_error_exception(hres); }
\r
53 #ifndef HINST_THISCOMPONENT
\r
54 EXTERN_C IMAGE_DOS_HEADER __ImageBase;
\r
55 #define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
\r
60 config_tab_dialog::config_tab_dialog(sf::base_window& parent_window,HWND tab_hwnd,int tab_id,const std::wstring& menu_name,const std::wstring& name,HINSTANCE inst,LPCTSTR temp)
\r
61 : tab_dialog_base(parent_window,tab_hwnd,tab_id,menu_name,name,inst,temp)
\r
62 ,update_config_dialog_(false)
\r
63 ,edit_output_config_(false)
\r
64 ,edit_input_config_(false)
\r
70 LRESULT config_tab_dialog::window_proc(HWND hwnd,uint32_t message, WPARAM wParam, LPARAM lParam)
\r
75 init_config_dialog();
\r
79 switch(LOWORD(wParam)){
\r
80 // ---------------------------------
\r
82 // ---------------------------------
\r
83 case IDC_ENDPOINT_DEVICE:
\r
85 if(HIWORD(wParam) == CBN_SELCHANGE && !update_config_dialog_)
\r
87 edit_output_config_ = true;
\r
88 current_output_driver_index_ = SendMessage(GetDlgItem(hwnd,IDC_ENDPOINT_DEVICE),CB_GETITEMDATA,SendMessage(GetDlgItem(hwnd,IDC_ENDPOINT_DEVICE),CB_GETCURSEL,0,0),0);
\r
89 update_config_dialog();
\r
92 case IDC_SAMPLE_BIT:
\r
94 if(HIWORD(wParam) == CBN_SELCHANGE && !update_config_dialog_)
\r
96 edit_output_config_ = true;
\r
97 editing_output_params_.bits = SendMessage(GetDlgItem(hwnd,IDC_SAMPLE_BIT),CB_GETITEMDATA,SendMessage(GetDlgItem(hwnd,IDC_SAMPLE_BIT),CB_GETCURSEL,0,0),0);
\r
98 update_config_dialog();
\r
101 case IDC_VALID_SAMPLE_BITS:
\r
103 if(HIWORD(wParam) == CBN_SELCHANGE && !update_config_dialog_)
\r
105 edit_output_config_ = true;
\r
106 editing_output_params_.valid_bits = SendMessage(GetDlgItem(hwnd,IDC_VALID_SAMPLE_BITS),CB_GETITEMDATA,SendMessage(GetDlgItem(hwnd,IDC_VALID_SAMPLE_BITS),CB_GETCURSEL,0,0),0);
\r
107 update_config_dialog();
\r
110 case IDC_SAMPLE_RATE:
\r
112 if(HIWORD(wParam) == CBN_SELCHANGE && !update_config_dialog_)
\r
114 edit_output_config_ = true;
\r
115 editing_output_params_.sample_rate = SendMessage(GetDlgItem(hwnd,IDC_SAMPLE_RATE),CB_GETITEMDATA,SendMessage(GetDlgItem(hwnd,IDC_SAMPLE_RATE),CB_GETCURSEL,0,0),0);
\r
116 update_config_dialog();
\r
122 if(!update_config_dialog_){
\r
123 edit_output_config_ = true;
\r
125 //application::instance()->exclusive_mode(::SendMessage(GetDlgItem(hwnd,IDC_EXC_MODE),BM_GETCHECK,0,0) == BST_CHECKED);
\r
126 editing_output_params_.exclusive_mode = ::SendMessage(GetDlgItem(hwnd,IDC_EXC_MODE),BM_GETCHECK,0,0) == BST_CHECKED;
\r
127 update_config_dialog();
\r
131 case IDC_EVENT_MODE:
\r
134 if(!update_config_dialog_){
\r
135 //application::instance()->exclusive_mode(::SendMessage(GetDlgItem(hwnd,IDC_EXC_MODE),BM_GETCHECK,0,0) == BST_CHECKED);
\r
136 editing_output_params_.event_mode = ::SendMessage(GetDlgItem(hwnd,IDC_EVENT_MODE),BM_GETCHECK,0,0) == BST_CHECKED;
\r
137 edit_output_config_ = true;
\r
138 update_config_dialog();
\r
145 if(HIWORD(wParam) == EN_UPDATE && !update_config_dialog_)
\r
147 edit_output_config_ = true;
\r
148 enable_control(hwnd_,IDC_APPLY,true);
\r
149 enable_control(hwnd_,IDC_CANCEL,true);
\r
150 //BOOL success = FALSE;
\r
152 //res = GetDlgItemInt(hwnd_,IDC_LATENCY,&success,TRUE);
\r
155 // editing_output_params_.latency = res;
\r
157 // message_box(L"不正な値が設定されています。",L"エラー",MB_OK);
\r
161 // ---------------------------------
\r
163 // ---------------------------------
\r
164 case IDC_INPUT_ENDPOINT_DEVICE:
\r
165 if(HIWORD(wParam) == CBN_SELCHANGE && !update_config_dialog_)
\r
167 edit_input_config_ = true;
\r
168 current_input_driver_index_
\r
170 GetDlgItem(hwnd,IDC_INPUT_ENDPOINT_DEVICE),
\r
172 SendMessage(GetDlgItem(hwnd,IDC_INPUT_ENDPOINT_DEVICE),CB_GETCURSEL,0,0),
\r
174 update_config_dialog();
\r
177 case IDC_INPUT_SAMPLE_BIT:
\r
178 if(HIWORD(wParam) == CBN_SELCHANGE && !update_config_dialog_)
\r
180 edit_input_config_ = true;
\r
181 editing_input_params_.bits
\r
183 GetDlgItem(hwnd,IDC_INPUT_SAMPLE_BIT),
\r
185 SendMessage(GetDlgItem(hwnd,IDC_INPUT_SAMPLE_BIT),CB_GETCURSEL,0,0)
\r
187 update_config_dialog();
\r
190 case IDC_INPUT_VALID_SAMPLE_BITS:
\r
191 if(HIWORD(wParam) == CBN_SELCHANGE && !update_config_dialog_)
\r
193 edit_input_config_ = true;
\r
194 editing_input_params_.valid_bits
\r
196 GetDlgItem(hwnd,IDC_INPUT_VALID_SAMPLE_BITS),
\r
198 SendMessage(GetDlgItem(hwnd,IDC_INPUT_VALID_SAMPLE_BITS),CB_GETCURSEL,0,0),
\r
200 update_config_dialog();
\r
203 case IDC_INPUT_SAMPLE_RATE:
\r
204 if(HIWORD(wParam) == CBN_SELCHANGE && !update_config_dialog_)
\r
206 edit_input_config_ = true;
\r
207 editing_input_params_.sample_rate
\r
209 GetDlgItem(hwnd,IDC_INPUT_SAMPLE_RATE),
\r
211 SendMessage(GetDlgItem(hwnd,IDC_INPUT_SAMPLE_RATE),CB_GETCURSEL,0,0),
\r
213 update_config_dialog();
\r
216 case IDC_INPUT_EXC_MODE:
\r
218 if(!update_config_dialog_){
\r
219 edit_input_config_ = true;
\r
221 //application::instance()->exclusive_mode(::SendMessage(GetDlgItem(hwnd,IDC_INPUT_EXC_MODE),BM_GETCHECK,0,0) == BST_CHECKED);
\r
222 editing_input_params_.exclusive_mode
\r
223 = ::SendMessage(GetDlgItem(hwnd,IDC_INPUT_EXC_MODE),BM_GETCHECK,0,0)
\r
225 update_config_dialog();
\r
229 case IDC_INPUT_EVENT_MODE:
\r
231 if(!update_config_dialog_){
\r
232 //application::instance()->exclusive_mode(::SendMessage(GetDlgItem(hwnd,IDC_INPUT_EXC_MODE),BM_GETCHECK,0,0) == BST_CHECKED);
\r
233 editing_input_params_.event_mode
\r
234 = ::SendMessage(GetDlgItem(hwnd,IDC_INPUT_EVENT_MODE),BM_GETCHECK,0,0)
\r
236 edit_input_config_ = true;
\r
237 update_config_dialog();
\r
241 case IDC_INPUT_LATENCY:
\r
242 if(HIWORD(wParam) == EN_UPDATE && !update_config_dialog_)
\r
244 edit_input_config_ = true;
\r
245 enable_control(hwnd_,IDC_APPLY,true);
\r
246 enable_control(hwnd_,IDC_CANCEL,true);
\r
247 //BOOL success = FALSE;
\r
249 //res = GetDlgItemInt(hwnd_,IDC_INPUT_LATENCY,&success,TRUE);
\r
252 // editing_input_params_.latency = res;
\r
254 // message_box(L"不正な値が設定されています。",L"エラー",MB_OK);
\r
258 // ---------------------------------
\r
260 // ---------------------------------
\r
263 BOOL success = FALSE;
\r
264 REFERENCE_TIME res(0);
\r
268 if(edit_output_config_){
\r
269 res = GetDlgItemInt(hwnd_,IDC_LATENCY,&success,TRUE);
\r
272 editing_output_params_.latency = res * 10000;
\r
274 message_box(L"レイテンシに不正な値が設定されています。",L"エラー",MB_OK);
\r
277 application::instance()->apply_output_device_config
\r
278 (current_output_driver_index_,editing_output_params_);
\r
279 edit_output_config_ = false;
\r
282 application::instance()->apply_output_device_config
\r
283 (wasapi_device_manager::instance()->current_output_device_index(),
\r
284 wasapi_device_manager::instance()->current_output_device().params);
\r
285 edit_output_config_ = true;
\r
291 if(edit_input_config_){
\r
292 res = GetDlgItemInt(hwnd_,IDC_INPUT_LATENCY,&success,TRUE);
\r
295 editing_input_params_.latency = res * 10000;
\r
297 message_box(L"レイテンシに不正な値が設定されています。",L"エラー",MB_OK);
\r
300 application::instance()->apply_input_device_config
\r
301 (current_input_driver_index_,editing_input_params_);
\r
302 edit_input_config_ = false;
\r
305 application::instance()->apply_input_device_config
\r
306 (wasapi_device_manager::instance()->current_input_device_index(),
\r
307 wasapi_device_manager::instance()->current_input_device().params);
\r
308 edit_input_config_ = true;
\r
311 update_config_dialog();
\r
314 // ---------------------------------
\r
316 // ---------------------------------
\r
319 wasapi_device_manager::ptr m(sf::wasapi_device_manager::instance());
\r
321 if(edit_output_config_){
\r
322 editing_output_params_ = m->current_output_device().params;
\r
323 edit_output_config_ = false;
\r
326 if(edit_input_config_){
\r
327 editing_input_params_ = m->current_input_device().params;
\r
328 edit_input_config_ = false;
\r
331 update_config_dialog();
\r
337 case WM_CTLCOLORDLG:
\r
338 case WM_CTLCOLORSTATIC:
\r
339 case WM_CTLCOLORBTN:
\r
341 SetBkMode((HDC)wParam,TRANSPARENT);
\r
342 return (LRESULT)GetStockObject( /* NULL_BRUSH */WHITE_BRUSH );
\r
343 case WM_ERASEBKGND:
\r
349 void config_tab_dialog::init_config_dialog()
\r
352 wasapi_device_manager::ptr m(sf::wasapi_device_manager::instance());
\r
357 editing_output_params_ = m->current_output_device().params;
\r
358 wasapi_device_manager::device_infos_t& i(m->output_device_infos());
\r
360 for(int c = 0;c < i.size();++c)
\r
362 if(i[c].is_selected){
\r
363 current_output_driver_index_ = c;
\r
370 editing_input_params_ = m->current_input_device().params;
\r
371 wasapi_device_manager::device_infos_t& i(m->input_device_infos());
\r
372 for(int c = 0;c < i.size();++c)
\r
374 if(i[c].is_selected){
\r
375 current_input_driver_index_ = c;
\r
379 edit_output_config_ = false;
\r
380 edit_input_config_ = false;
\r
381 update_config_dialog();
\r
382 //i[current_index].support_formats
\r
386 void config_tab_dialog::update_config_dialog()
\r
388 update_config_dialog_ = true;
\r
389 application::ptr app(application::instance());
\r
391 // ----------------------------------------
\r
392 enable_control(hwnd_,IDC_APPLY,edit_output_config_ || edit_input_config_);
\r
393 enable_control(hwnd_,IDC_CANCEL,edit_output_config_ || edit_input_config_);
\r
396 // デバイスコンボボックスのセットアップ
\r
397 wasapi_device_manager::ptr m(sf::wasapi_device_manager::instance());
\r
399 // ==========================================
\r
401 // ==========================================
\r
403 wasapi_device_manager::device_infos_t& i(m->output_device_infos());
\r
405 HWND hwnd_endp = GetDlgItem(hwnd_,IDC_ENDPOINT_DEVICE);
\r
406 SendMessage(hwnd_endp,CB_RESETCONTENT,0,0);
\r
408 for(int c = 0,e = i.size(); c < e;++c)
\r
410 SendMessage(hwnd_endp,CB_ADDSTRING,0,(LPARAM)i[c].device_friendly_name.c_str());
\r
411 SendMessage(hwnd_endp,CB_SETITEMDATA,c,c);
\r
412 if(c == current_output_driver_index_)
\r
414 SendMessage(hwnd_endp,CB_SETCURSEL,c,0);
\r
418 typedef wasapi_device_manager::format_map_type fmts_t;
\r
419 fmts_t& fmts = i[current_output_driver_index_].support_formats;
\r
421 HWND hwnd_smp_bits = GetDlgItem(hwnd_,IDC_SAMPLE_BIT);
\r
423 SendMessage(hwnd_smp_bits,CB_RESETCONTENT,0,0);
\r
424 uint32_t share_mode = AUDCLNT_SHAREMODE_SHARED;
\r
425 if(editing_output_params_.exclusive_mode)
\r
427 share_mode = AUDCLNT_SHAREMODE_EXCLUSIVE;
\r
428 ::SendDlgItemMessage(hwnd_,IDC_EXC_MODE,BM_SETCHECK,BST_CHECKED ,0);
\r
430 ::SendDlgItemMessage(hwnd_,IDC_EXC_MODE,BM_SETCHECK,BST_UNCHECKED ,0);
\r
433 if(editing_output_params_.event_mode)
\r
435 ::SendDlgItemMessage(hwnd_,IDC_EVENT_MODE,BM_SETCHECK,BST_CHECKED ,0);
\r
437 ::SendDlgItemMessage(hwnd_,IDC_EVENT_MODE,BM_SETCHECK,BST_UNCHECKED ,0);
\r
440 typedef fmts_t::mapped_type fsmpbits_t;
\r
441 fsmpbits_t& fsmpbits = fmts[share_mode];
\r
444 std::for_each(fsmpbits.begin(),fsmpbits.end(),
\r
445 [&](fsmpbits_t::value_type & pair)
\r
447 SendMessage(hwnd_smp_bits,CB_ADDSTRING,0,(LPARAM)(boost::lexical_cast<std::wstring>(pair.first).c_str()));
\r
448 SendMessage(hwnd_smp_bits,CB_SETITEMDATA,c,pair.first);
\r
449 if(editing_output_params_.bits == pair.first)
\r
451 SendMessage(hwnd_smp_bits,CB_SETCURSEL,c,0);
\r
458 // ----------------------------------------
\r
459 // ----------------------------------------
\r
461 typedef wasapi_device_manager::format_map_type::mapped_type::mapped_type fmts_vbits_t;
\r
463 fmts_vbits_t& fmts_vbits = fmts[share_mode][editing_output_params_.bits];
\r
465 HWND hwnd_valid_bits = GetDlgItem(hwnd_,IDC_VALID_SAMPLE_BITS);
\r
466 SendMessage(hwnd_valid_bits,CB_RESETCONTENT,0,0);
\r
467 std::for_each(fmts_vbits.begin(),fmts_vbits.end(),
\r
468 [&](fmts_vbits_t::value_type& pair_vbits)
\r
470 SendMessage(hwnd_valid_bits,CB_ADDSTRING,0,(LPARAM)(boost::lexical_cast<std::wstring>(pair_vbits.first).c_str()));
\r
471 SendMessage(hwnd_valid_bits,CB_SETITEMDATA,cnt_vbits,pair_vbits.first);
\r
472 if(pair_vbits.first == editing_output_params_.valid_bits)
\r
474 SendMessage(hwnd_valid_bits,CB_SETCURSEL,cnt_vbits,0);
\r
480 // ----------------------------------------
\r
481 // ----------------------------------------
\r
482 typedef wasapi_device_manager::format_map_type::mapped_type::mapped_type::mapped_type fmts_channels_t;
\r
484 fmts_channels = fmts[share_mode][editing_output_params_.bits][editing_output_params_.valid_bits];
\r
485 //typedef decltype(fmts_channels) fmts_channels_t;
\r
486 int cnt_channels = 0;
\r
487 HWND hwnd_channels = GetDlgItem(hwnd_,IDC_CHANNEL);
\r
488 SendMessage(hwnd_channels,CB_RESETCONTENT,0,0);
\r
489 std::for_each(fmts_channels.begin(),fmts_channels.end(),
\r
490 [&](fmts_channels_t::value_type & pair_channel)
\r
492 SendMessage(hwnd_channels,CB_ADDSTRING,0,(LPARAM)(boost::lexical_cast<std::wstring>(pair_channel.first).c_str()));
\r
493 SendMessage(hwnd_channels,CB_SETITEMDATA,cnt_channels,pair_channel.first);
\r
494 if(pair_channel.first == editing_output_params_.channel)
\r
496 SendMessage(hwnd_channels,CB_SETCURSEL,cnt_channels,0);
\r
502 // ----------------------------------------
\r
503 // ----------------------------------------
\r
505 typedef wasapi_device_manager::format_map_type::mapped_type::mapped_type::mapped_type::mapped_type fmts_sample_rates_t;
\r
506 fmts_sample_rates_t& fmts_sample_rates
\r
507 = fmts[share_mode][editing_output_params_.bits][editing_output_params_.valid_bits][editing_output_params_.channel];
\r
508 int cnt_samples = 0;
\r
509 HWND hwnd_sample = GetDlgItem(hwnd_,IDC_SAMPLE_RATE);
\r
510 SendMessage(hwnd_sample,CB_RESETCONTENT,0,0);
\r
511 std::for_each(fmts_sample_rates.begin(),fmts_sample_rates.end(),
\r
512 [&](fmts_sample_rates_t::value_type & pair_sample)
\r
514 SendMessage(hwnd_sample,CB_ADDSTRING,0,(LPARAM)(boost::lexical_cast<std::wstring>(pair_sample.first).c_str()));
\r
515 SendMessage(hwnd_sample,CB_SETITEMDATA,cnt_samples,pair_sample.first);
\r
516 if(pair_sample.first == editing_output_params_.sample_rate)
\r
518 SendMessage(hwnd_sample,CB_SETCURSEL,cnt_samples,0);
\r
525 // ----------------------------------------
\r
526 // ----------------------------------------
\r
527 SetDlgItemInt(hwnd_,IDC_LATENCY,editing_output_params_.latency/10000,TRUE);
\r
528 SetDlgItemText(hwnd_,IDC_MIN_MAX_LATENCY,(boost::wformat(L"(%dms ~ %dms)")
\r
529 % (i[current_output_driver_index_].latency_minimum / 10000)
\r
530 % (i[current_output_driver_index_].latency_default / 10000)).str().c_str());
\r
533 // ===================================================================
\r
535 // ===================================================================
\r
537 wasapi_device_manager::device_infos_t& i(m->input_device_infos());
\r
539 HWND hwnd_endp = GetDlgItem(hwnd_,IDC_INPUT_ENDPOINT_DEVICE);
\r
540 SendMessage(hwnd_endp,CB_RESETCONTENT,0,0);
\r
542 for(int c = 0,e = i.size(); c < e;++c)
\r
544 SendMessage(hwnd_endp,CB_ADDSTRING,0,(LPARAM)i[c].device_friendly_name.c_str());
\r
545 SendMessage(hwnd_endp,CB_SETITEMDATA,c,c);
\r
546 if(c == current_input_driver_index_)
\r
548 SendMessage(hwnd_endp,CB_SETCURSEL,c,0);
\r
552 typedef wasapi_device_manager::format_map_type fmts_t;
\r
553 fmts_t& fmts = i[current_input_driver_index_].support_formats;
\r
555 HWND hwnd_smp_bits = GetDlgItem(hwnd_,IDC_INPUT_SAMPLE_BIT);
\r
557 SendMessage(hwnd_smp_bits,CB_RESETCONTENT,0,0);
\r
558 uint32_t share_mode = AUDCLNT_SHAREMODE_SHARED;
\r
559 if(editing_input_params_.exclusive_mode)
\r
561 share_mode = AUDCLNT_SHAREMODE_EXCLUSIVE;
\r
562 ::SendDlgItemMessage(hwnd_,IDC_INPUT_EXC_MODE,BM_SETCHECK,BST_CHECKED ,0);
\r
564 ::SendDlgItemMessage(hwnd_,IDC_INPUT_EXC_MODE,BM_SETCHECK,BST_UNCHECKED ,0);
\r
567 if(editing_input_params_.event_mode)
\r
569 ::SendDlgItemMessage(hwnd_,IDC_INPUT_EVENT_MODE,BM_SETCHECK,BST_CHECKED ,0);
\r
571 ::SendDlgItemMessage(hwnd_,IDC_INPUT_EVENT_MODE,BM_SETCHECK,BST_UNCHECKED ,0);
\r
574 typedef fmts_t::mapped_type fsmpbits_t;
\r
575 fsmpbits_t& fsmpbits = fmts[share_mode];
\r
578 std::for_each(fsmpbits.begin(),fsmpbits.end(),
\r
579 [&](fsmpbits_t::value_type & pair)
\r
581 SendMessage(hwnd_smp_bits,CB_ADDSTRING,0,(LPARAM)(boost::lexical_cast<std::wstring>(pair.first).c_str()));
\r
582 SendMessage(hwnd_smp_bits,CB_SETITEMDATA,c,pair.first);
\r
583 if(editing_input_params_.bits == pair.first)
\r
585 SendMessage(hwnd_smp_bits,CB_SETCURSEL,c,0);
\r
592 // ----------------------------------------
\r
593 // ----------------------------------------
\r
595 typedef wasapi_device_manager::format_map_type::mapped_type::mapped_type fmts_vbits_t;
\r
597 fmts_vbits_t& fmts_vbits = fmts[share_mode][editing_input_params_.bits];
\r
599 HWND hwnd_valid_bits = GetDlgItem(hwnd_,IDC_INPUT_VALID_SAMPLE_BITS);
\r
600 SendMessage(hwnd_valid_bits,CB_RESETCONTENT,0,0);
\r
601 std::for_each(fmts_vbits.begin(),fmts_vbits.end(),
\r
602 [&](fmts_vbits_t::value_type& pair_vbits)
\r
604 SendMessage(hwnd_valid_bits,CB_ADDSTRING,0,(LPARAM)(boost::lexical_cast<std::wstring>(pair_vbits.first).c_str()));
\r
605 SendMessage(hwnd_valid_bits,CB_SETITEMDATA,cnt_vbits,pair_vbits.first);
\r
606 if(pair_vbits.first == editing_input_params_.valid_bits)
\r
608 SendMessage(hwnd_valid_bits,CB_SETCURSEL,cnt_vbits,0);
\r
614 // ----------------------------------------
\r
615 // ----------------------------------------
\r
616 typedef wasapi_device_manager::format_map_type::mapped_type::mapped_type::mapped_type fmts_channels_t;
\r
618 fmts_channels = fmts[share_mode][editing_input_params_.bits][editing_input_params_.valid_bits];
\r
619 //typedef decltype(fmts_channels) fmts_channels_t;
\r
620 int cnt_channels = 0;
\r
621 HWND hwnd_channels = GetDlgItem(hwnd_,IDC_INPUT_CHANNEL);
\r
622 SendMessage(hwnd_channels,CB_RESETCONTENT,0,0);
\r
623 std::for_each(fmts_channels.begin(),fmts_channels.end(),
\r
624 [&](fmts_channels_t::value_type & pair_channel)
\r
626 SendMessage(hwnd_channels,CB_ADDSTRING,0,(LPARAM)(boost::lexical_cast<std::wstring>(pair_channel.first).c_str()));
\r
627 SendMessage(hwnd_channels,CB_SETITEMDATA,cnt_channels,pair_channel.first);
\r
628 if(pair_channel.first == editing_input_params_.channel)
\r
630 SendMessage(hwnd_channels,CB_SETCURSEL,cnt_channels,0);
\r
636 // ----------------------------------------
\r
637 // ----------------------------------------
\r
639 typedef wasapi_device_manager::format_map_type::mapped_type::mapped_type::mapped_type::mapped_type fmts_sample_rates_t;
\r
640 fmts_sample_rates_t& fmts_sample_rates
\r
641 = fmts[share_mode][editing_input_params_.bits][editing_input_params_.valid_bits][editing_input_params_.channel];
\r
642 int cnt_samples = 0;
\r
643 HWND hwnd_sample = GetDlgItem(hwnd_,IDC_INPUT_SAMPLE_RATE);
\r
644 SendMessage(hwnd_sample,CB_RESETCONTENT,0,0);
\r
645 std::for_each(fmts_sample_rates.begin(),fmts_sample_rates.end(),
\r
646 [&](fmts_sample_rates_t::value_type & pair_sample)
\r
648 SendMessage(hwnd_sample,CB_ADDSTRING,0,(LPARAM)(boost::lexical_cast<std::wstring>(pair_sample.first).c_str()));
\r
649 SendMessage(hwnd_sample,CB_SETITEMDATA,cnt_samples,pair_sample.first);
\r
650 if(pair_sample.first == editing_input_params_.sample_rate)
\r
652 SendMessage(hwnd_sample,CB_SETCURSEL,cnt_samples,0);
\r
659 // ----------------------------------------
\r
660 // ----------------------------------------
\r
661 SetDlgItemInt(hwnd_,IDC_INPUT_LATENCY,editing_input_params_.latency/10000,TRUE);
\r
662 SetDlgItemText(hwnd_,IDC_INPUT_MIN_MAX_LATENCY,(boost::wformat(L"(%dms ~ %dms)")
\r
663 % (i[current_input_driver_index_].latency_minimum / 10000)
\r
664 % (i[current_input_driver_index_].latency_default / 10000)).str().c_str());
\r
667 update_config_dialog_ = false;
\r
670 void config_tab_dialog::enable_config_dialog(bool value)
\r
673 enable_control(hwnd_,IDC_EXC_MODE,value);
\r
674 enable_control(hwnd_,IDC_EVENT_MODE,value);
\r
675 enable_control(hwnd_,IDC_ENDPOINT_DEVICE,value);
\r
676 enable_control(hwnd_,IDC_SAMPLE_BIT,value);
\r
677 enable_control(hwnd_,IDC_VALID_SAMPLE_BITS,value);
\r
678 enable_control(hwnd_,IDC_SAMPLE_RATE,value);
\r
679 enable_control(hwnd_,IDC_LATENCY,value);
\r
680 enable_control(hwnd_,IDC_CHANNEL,value);
\r
682 enable_control(hwnd_,IDC_INPUT_EXC_MODE,value);
\r
683 enable_control(hwnd_,IDC_INPUT_EVENT_MODE,value);
\r
684 enable_control(hwnd_,IDC_INPUT_ENDPOINT_DEVICE,value);
\r
685 enable_control(hwnd_,IDC_INPUT_SAMPLE_BIT,value);
\r
686 enable_control(hwnd_,IDC_INPUT_VALID_SAMPLE_BITS,value);
\r
687 enable_control(hwnd_,IDC_INPUT_SAMPLE_RATE,value);
\r
688 enable_control(hwnd_,IDC_INPUT_LATENCY,value);
\r
689 enable_control(hwnd_,IDC_INPUT_CHANNEL,value);
\r
692 enable_control(hwnd_,IDC_APPLY,edit_output_config_ || edit_input_config_);
\r
693 enable_control(hwnd_,IDC_CANCEL,edit_output_config_ || edit_input_config_);
\r
695 enable_control(hwnd_,IDC_APPLY,false);
\r
696 enable_control(hwnd_,IDC_CANCEL,false);
\r
701 void config_tab_dialog::enable()
\r
703 enable_config_dialog(true);
\r
706 void config_tab_dialog::disable()
\r
708 enable_config_dialog(false);
\r