- 時間撮記:
- 2013-10-22 下午03:49:35 (11 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Main/src-client/EmulatedUSBImpl.cpp
r49161 r49234 107 107 }; 108 108 109 static int emulatedWebcamInsertSettings(PCFGMNODE pConfig, EUSBSettingsMap *pSettings) 110 { 111 int rc = VINF_SUCCESS; 112 113 EUSBSettingsMap::const_iterator it; 114 for (it = pSettings->begin(); it != pSettings->end(); ++it) 115 { 116 /* Convert some well known settings for backward compatibility. */ 117 if ( RTStrCmp(it->first.c_str(), "MaxPayloadTransferSize") == 0 118 || RTStrCmp(it->first.c_str(), "MaxFramerate") == 0) 119 { 120 uint32_t u32 = 0; 121 rc = RTStrToUInt32Full(it->second.c_str(), 10, &u32); 122 if (rc == VINF_SUCCESS) 123 { 124 rc = CFGMR3InsertInteger(pConfig, it->first.c_str(), u32); 125 } 126 else 127 { 128 if (RT_SUCCESS(rc)) /* VWRN_* */ 129 { 130 rc = VERR_INVALID_PARAMETER; 131 } 132 } 133 } 134 else 135 { 136 rc = CFGMR3InsertString(pConfig, it->first.c_str(), it->second.c_str()); 137 } 138 139 if (RT_FAILURE(rc)) 140 { 141 break; 142 } 143 } 144 145 return rc; 146 } 109 147 110 148 /* static */ DECLCALLBACK(int) EUSBWEBCAM::emulatedWebcamAttach(PUVM pUVM, EUSBWEBCAM *pThis, const char *pszDriver) 111 149 { 112 EUSBSettingsMap::const_iterator it;113 114 150 PCFGMNODE pInstance = CFGMR3CreateTree(pUVM); 115 151 PCFGMNODE pConfig; 116 152 CFGMR3InsertNode(pInstance, "Config", &pConfig); 117 for (it = pThis->mDevSettings.begin(); it != pThis->mDevSettings.end(); ++it) 118 CFGMR3InsertString(pConfig, it->first.c_str(), it->second.c_str()); 153 int rc = emulatedWebcamInsertSettings(pConfig, &pThis->mDevSettings); 154 if (RT_FAILURE(rc)) 155 return rc; 119 156 PCFGMNODE pEUSB; 120 157 CFGMR3InsertNode(pConfig, "EmulatedUSB", &pEUSB); … … 129 166 CFGMR3InsertString(pConfig, "DevicePath", pThis->mPath.c_str()); 130 167 CFGMR3InsertInteger(pConfig, "Object", (uintptr_t)pThis->mpvObject); 131 for (it = pThis->mDrvSettings.begin(); it != pThis->mDrvSettings.end(); ++it) 132 CFGMR3InsertString(pConfig, it->first.c_str(), it->second.c_str()); 168 rc = emulatedWebcamInsertSettings(pConfig, &pThis->mDrvSettings); 169 if (RT_FAILURE(rc)) 170 return rc; 133 171 134 172 /* pInstance will be used by PDM and deallocated on error. */ 135 intrc = PDMR3UsbCreateEmulatedDevice(pUVM, "Webcam", pInstance, &pThis->mUuid);173 rc = PDMR3UsbCreateEmulatedDevice(pUVM, "Webcam", pInstance, &pThis->mUuid); 136 174 LogRelFlowFunc(("PDMR3UsbCreateEmulatedDevice %Rrc\n", rc)); 137 175 return rc; … … 185 223 HRESULT EUSBWEBCAM::settingsParse(void) 186 224 { 187 HRESULT hrc = S_OK; 188 189 return hrc; 225 HRESULT hr = S_OK; 226 227 /* Parse mSettings string: 228 * "[dev:|drv:]Name1=Value1;[dev:|drv:]Name2=Value2" 229 */ 230 char *pszSrc = mSettings.mutableRaw(); 231 232 if (pszSrc) 233 { 234 while (*pszSrc) 235 { 236 /* Does the setting belong to device of driver. Default is both. */ 237 bool fDev = true; 238 bool fDrv = true; 239 if (RTStrNICmp(pszSrc, "drv:", strlen("drv:")) == 0) 240 { 241 pszSrc += strlen("drv:"); 242 fDev = false; 243 } 244 else if (RTStrNICmp(pszSrc, "dev:", strlen("dev:")) == 0) 245 { 246 pszSrc += strlen("dev:"); 247 fDrv = false; 248 } 249 250 char *pszEq = RTStrStr(pszSrc, "="); 251 if (!pszEq) 252 { 253 hr = E_INVALIDARG; 254 break; 255 } 256 257 char *pszEnd = RTStrStr(pszEq, ";"); 258 if (!pszEnd) 259 { 260 pszEnd = pszEq + strlen(pszEq); 261 } 262 263 *pszEq = 0; 264 char chEnd = *pszEnd; 265 *pszEnd = 0; 266 267 /* Empty strings not allowed. */ 268 if (*pszSrc != 0 && pszEq[1] != 0) 269 { 270 if (fDev) 271 { 272 mDevSettings[pszSrc] = &pszEq[1]; 273 } 274 if (fDrv) 275 { 276 mDrvSettings[pszSrc] = &pszEq[1]; 277 } 278 } 279 280 *pszEq = '='; 281 *pszEnd = chEnd; 282 283 pszSrc = pszEnd; 284 if (*pszSrc == ';') 285 { 286 pszSrc++; 287 } 288 } 289 290 if (SUCCEEDED(hr)) 291 { 292 EUSBSettingsMap::const_iterator it; 293 for (it = mDevSettings.begin(); it != mDevSettings.end(); ++it) 294 LogRelFlowFunc(("[dev:%s] = [%s]\n", it->first.c_str(), it->second.c_str())); 295 for (it = mDrvSettings.begin(); it != mDrvSettings.end(); ++it) 296 LogRelFlowFunc(("[drv:%s] = [%s]\n", it->first.c_str(), it->second.c_str())); 297 } 298 } 299 300 return hr; 190 301 } 191 302
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器