OSDN Git Service

リセット
[momiji/momiji_main.git] / Test / Momiji.Test.DeviceInfo / Momiji.Test.DeviceInfo.cpp
1 // Momiji.Test.DeviceInfo.cpp : \83\81\83C\83\93 \83v\83\8d\83W\83F\83N\83\83t\83@\83C\83\8b\82Å\82·\81B
2
3 #include "stdafx.h"
4 #using <Momiji.Core.dll>
5
6 using namespace System;
7
8 void test10()
9 {
10
11         try
12         {
13                 auto devices = 
14                         gcnew Momiji::Core::DeviceInfo::Devices(
15                                 Momiji::Interop::Ks::StaticKs::CATEGORY_AUDIO,
16                                 (
17                                                 Momiji::Interop::Setupapi::DIGCF::PRESENT 
18                                         |       Momiji::Interop::Setupapi::DIGCF::DEVICEINTERFACE
19                                 ),
20                                 nullptr
21                         );
22
23                 auto detailList = gcnew System::Collections::Generic::List<Momiji::Core::DeviceInfo::Devices::Detail^>;
24                 try
25                 {
26                         for each(Momiji::Core::DeviceInfo::Devices::Detail^ detail in devices->Enum)
27                         {
28                                 for each(Momiji::Interop::Setupapi::SPDRP spdrp in System::Enum::GetValues(Momiji::Interop::Setupapi::SPDRP::typeid)) {
29                                         detail->GetDeviceRegistryProperty(spdrp);
30                                 }
31
32                                 detail->GetDeviceRegistryProperty("FriendlyName");
33
34                                 auto alias = detail->GetAlias(Momiji::Interop::Ks::StaticKs::CATEGORY_RENDER);
35                                 if (alias == nullptr)
36                                 {
37                                         continue;
38                                 }
39
40                                 if ((alias->Flags & Momiji::Interop::Setupapi::SPINT::REMOVED) == Momiji::Interop::Setupapi::SPINT::REMOVED)
41                                 {
42                                         System::Console::WriteLine("\8dí\8f\9c\8dÏ\82Ý");
43                                         continue;
44                                 }
45                                 detailList->Add(detail);
46                         }
47
48                 }
49                 finally
50                 {
51                         delete devices;
52                 }
53
54                 for each(Momiji::Core::DeviceInfo::Devices::Detail^ detail in detailList) {
55
56                         //Momiji::Core::DeviceInfo::Devices::Detail^ detail = System::Linq::Enumerable::Last(detailList);
57
58                         //\82±\82±\82Å\8cÄ\82Ñ\8fo\82·\82Æ\81A\82¿\82á\82ñ\82Æ\83G\83\89\81[\82É\82È\82é
59                         try
60                         {
61                                 detail->GetAlias(Momiji::Interop::Ks::StaticKs::CATEGORY_CAPTURE);
62                         }
63                         catch(System::ObjectDisposedException^ e)
64                         {
65                                 System::Console::WriteLine("Devices\82ð\89ð\95ú\8cã\82Í\91\80\8dì\82Å\82«\82È\82¢ [{0}]", e);
66                         }
67
68                         auto filter = gcnew Momiji::Core::Ks::Filter(detail->DevicePath);
69                         try
70                         {
71                                 for each (auto p in filter->propertySetPin->Items)
72                                 {
73                                         try
74                                         {
75                                                 auto pin = 
76                                                         gcnew Momiji::Core::Ks::Pin<System::UInt16>(
77                                                                 p,
78                                                                 2, 
79                                                                 48000, 
80                                                                 16, 
81                                                                 (
82                                                                                 Momiji::Interop::Winmm::WaveFormatExtensiblePart::SPEAKER::FRONT_LEFT
83                                                                         |       Momiji::Interop::Winmm::WaveFormatExtensiblePart::SPEAKER::FRONT_RIGHT
84                                                                 ),
85                                                                 Momiji::Interop::Ks::StaticKs::SUBTYPE_PCM
86                                                         );
87
88                                                 try
89                                                 {
90                                                         pin->Test();
91                                                         Console::WriteLine("====================================================");
92                                                         System::Console::ReadLine();
93                                                 }
94                                                 finally
95                                                 {
96                                                         delete pin;
97                                                 }
98                                         }
99                                         catch(System::Exception^ e)
100                                         {
101                                                 Console::WriteLine("Pin Error {0}", e);
102                                                 Console::WriteLine("====================================================");
103                                                 System::Console::ReadLine();
104                                         }
105                                 }
106                         }
107                         finally
108                         {
109                                 delete filter;
110                                 Console::WriteLine("\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡");
111                                 Console::WriteLine("delete filter ====================================================");
112                                 Console::WriteLine("\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡\81¡");
113                         }
114                         System::Console::ReadLine();
115                 }
116         }
117         catch(System::Exception^ e)
118         {
119                 Console::WriteLine("ERROR:{0}", e);
120         }
121
122
123 }
124
125 int main(array<System::String ^> ^args)
126 {
127         test10();
128         System::GC::Collect();
129         System::GC::WaitForPendingFinalizers();
130         System::GC::Collect();
131
132         Console::WriteLine("====================================================");
133         System::Console::ReadLine();
134     return 0;
135 }