| 7196 | |
| 7197 | |
| 7198 | bool SoundSetGet_FindComponent(IPart *aRoot, SoundComponentSearch &aSearch) |
| 7199 | { |
| 7200 | HRESULT hr; |
| 7201 | IPartsList *parts; |
| 7202 | IPart *part; |
| 7203 | UINT part_count; |
| 7204 | PartType part_type; |
| 7205 | LPWSTR part_name; |
| 7206 | |
| 7207 | bool check_name = *aSearch.target_name; |
| 7208 | |
| 7209 | if (aSearch.data_flow == In) |
| 7210 | hr = aRoot->EnumPartsIncoming(&parts); |
| 7211 | else |
| 7212 | hr = aRoot->EnumPartsOutgoing(&parts); |
| 7213 | |
| 7214 | if (FAILED(hr)) |
| 7215 | return NULL; |
| 7216 | |
| 7217 | if (FAILED(parts->GetCount(&part_count))) |
| 7218 | part_count = 0; |
| 7219 | |
| 7220 | for (UINT i = 0; i < part_count; ++i) |
| 7221 | { |
| 7222 | if (FAILED(parts->GetPart(i, &part))) |
| 7223 | continue; |
| 7224 | |
| 7225 | if (SUCCEEDED(part->GetPartType(&part_type))) |
| 7226 | { |
| 7227 | if (part_type == Connector) |
| 7228 | { |
| 7229 | if ( part_count == 1 // Ignore Connectors with no Subunits of their own. |
| 7230 | && (!check_name || (SUCCEEDED(part->GetName(&part_name)) && !_wcsicmp(part_name, aSearch.target_name))) ) |
| 7231 | { |
| 7232 | if (++aSearch.count == aSearch.target_instance) |
| 7233 | { |
| 7234 | switch (aSearch.target_control) |
| 7235 | { |
| 7236 | case SoundControlType::IID: |
| 7237 | // Permit retrieving the IPart or IConnector itself. Since there may be |
| 7238 | // multiple connected Subunits (and they can be enumerated or retrieved |
| 7239 | // via the Connector IPart), this is only done for the Connector. |
| 7240 | part->QueryInterface(aSearch.target_iid, (void **)&aSearch.control); |
| 7241 | break; |
| 7242 | case SoundControlType::Name: |
| 7243 | // check_name would typically be false in this case, since a value of true |
| 7244 | // would mean the caller already knows the component's name. |
| 7245 | part->GetName(&aSearch.name); |
| 7246 | break; |
| 7247 | } |
| 7248 | part->Release(); |
| 7249 | parts->Release(); |
| 7250 | return true; |
| 7251 | } |
| 7252 | } |
| 7253 | } |
| 7254 | else // Subunit |
| 7255 | { |
no test coverage detected