| 162 | } |
| 163 | |
| 164 | void print_device(device_t &device) { |
| 165 | audio::wstring_t wstring; |
| 166 | DWORD device_state; |
| 167 | |
| 168 | device->GetState(&device_state); |
| 169 | device->GetId(&wstring); |
| 170 | |
| 171 | audio::prop_t prop; |
| 172 | device->OpenPropertyStore(STGM_READ, &prop); |
| 173 | |
| 174 | prop_var_t adapter_friendly_name; |
| 175 | prop_var_t device_friendly_name; |
| 176 | prop_var_t device_desc; |
| 177 | |
| 178 | prop->GetValue(PKEY_Device_FriendlyName, &device_friendly_name.prop); |
| 179 | prop->GetValue(PKEY_DeviceInterface_FriendlyName, &adapter_friendly_name.prop); |
| 180 | prop->GetValue(PKEY_Device_DeviceDesc, &device_desc.prop); |
| 181 | |
| 182 | if (!(device_state & device_state_filter)) { |
| 183 | return; |
| 184 | } |
| 185 | |
| 186 | std::wstring device_state_string = L"Unknown"s; |
| 187 | switch (device_state) { |
| 188 | case DEVICE_STATE_ACTIVE: |
| 189 | device_state_string = L"Active"s; |
| 190 | break; |
| 191 | case DEVICE_STATE_DISABLED: |
| 192 | device_state_string = L"Disabled"s; |
| 193 | break; |
| 194 | case DEVICE_STATE_UNPLUGGED: |
| 195 | device_state_string = L"Unplugged"s; |
| 196 | break; |
| 197 | case DEVICE_STATE_NOTPRESENT: |
| 198 | device_state_string = L"Not present"s; |
| 199 | break; |
| 200 | } |
| 201 | |
| 202 | std::wstring current_format = L"Unknown"s; |
| 203 | for (const auto &format : formats) { |
| 204 | // This will fail for any format that's not the mix format for this device, |
| 205 | // so we can take the first match as the current format to display. |
| 206 | auto audio_client = make_audio_client(device, format); |
| 207 | if (audio_client) { |
| 208 | current_format = from_utf8(format.name); |
| 209 | break; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | wprintf( |
| 214 | L"===== Device =====\n" |
| 215 | L"Device ID : %ls\n" |
| 216 | L"Device name : %ls\n" |
| 217 | L"Adapter name : %ls\n" |
| 218 | L"Device description : %ls\n" |
| 219 | L"Device state : %ls\n" |
| 220 | L"Current format : %ls\n\n", |
| 221 | wstring.get(), |
no test coverage detected