Changeset 56085 in vbox for trunk/src/VBox/Devices/Audio/DevIchHdaCodec.cpp
- Timestamp:
- May 26, 2015 4:39:58 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchHdaCodec.cpp
r55521 r56085 35 35 36 36 #include "VBoxDD.h" 37 #ifndef VBOX_WITH_PDM_AUDIO_DRIVER38 extern "C" {39 #include "audio.h"40 }41 #endif42 37 #include "DevIchHdaCodec.h" 43 38 … … 1167 1162 * Misc helpers. 1168 1163 */ 1169 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1170 1164 static int hdaCodecToAudVolume(PHDACODEC pThis, AMPLIFIER *pAmp, PDMAUDIOMIXERCTL mt) 1171 #else1172 static int hdaCodecToAudVolume(AMPLIFIER *pAmp, audmixerctl_t mt)1173 #endif1174 1165 { 1175 1166 uint32_t dir = AMPLIFIER_OUT; … … 1177 1168 switch (mt) 1178 1169 { 1179 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1180 1170 case PDMAUDIOMIXERCTL_PCM: 1181 1171 enmSrc = PO_INDEX; 1182 #else1183 case AUD_MIXER_VOLUME:1184 case AUD_MIXER_PCM:1185 #endif1186 1172 dir = AMPLIFIER_OUT; 1187 1173 break; 1188 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1189 1174 case PDMAUDIOMIXERCTL_LINE_IN: 1190 1175 enmSrc = PI_INDEX; 1191 #else1192 case AUD_MIXER_LINE_IN:1193 #endif1194 1176 dir = AMPLIFIER_IN; 1195 1177 break; … … 1214 1196 rVol = (rVol + 1) * (2 * 255) / 256; 1215 1197 1216 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 1217 /** @todo In SetVolume no passing audmixerctl_in as its not used in DrvAudio.cpp. */ 1218 pThis->pfnSetVolume(pThis->pHDAState, enmSrc, RT_BOOL(mute), lVol, rVol); 1219 #else 1220 AUD_set_volume(mt, &mute, &lVol, &rVol); 1221 #endif 1222 return VINF_SUCCESS; 1198 return pThis->pfnSetVolume(pThis->pHDAState, enmSrc, RT_BOOL(mute), lVol, rVol); 1223 1199 } 1224 1200 … … 1360 1336 1361 1337 /** @todo Fix ID of u8AdcVolsLineIn! */ 1362 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1363 1338 hdaCodecToAudVolume(pThis, pAmplifier, PDMAUDIOMIXERCTL_LINE_IN); 1364 #else1365 hdaCodecToAudVolume(pAmplifier, AUD_MIXER_LINE_IN);1366 #endif1367 1339 } 1368 1340 if (fIsOut) … … 1374 1346 1375 1347 /** @todo Fix ID of u8DacLineOut! */ 1376 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1377 1348 hdaCodecToAudVolume(pThis, pAmplifier, PDMAUDIOMIXERCTL_PCM); 1378 #else1379 hdaCodecToAudVolume(pAmplifier, AUD_MIXER_VOLUME);1380 #endif1381 1349 } 1382 1350 … … 2275 2243 } 2276 2244 2277 #ifndef VBOX_WITH_PDM_AUDIO_DRIVER2278 static void pi_callback(void *opaque, int avail)2279 {2280 PHDACODEC pThis = (PHDACODEC)opaque;2281 pThis->pfnTransfer(pThis, PI_INDEX, avail);2282 }2283 2284 static void po_callback(void *opaque, int avail)2285 {2286 PHDACODEC pThis = (PHDACODEC)opaque;2287 pThis->pfnTransfer(pThis, PO_INDEX, avail);2288 }2289 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2290 2291 2245 /* 2292 2246 * APIs exposed to DevHDA. 2293 2247 */ 2294 2295 2248 2296 2249 /** … … 2302 2255 * format) before enabling. 2303 2256 */ 2304 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2305 2257 int hdaCodecOpenStream(PHDACODEC pThis, ENMSOUNDSOURCE enmSoundSource, PPDMAUDIOSTREAMCFG pCfg) 2306 #else 2307 int hdaCodecOpenStream(PHDACODEC pThis, ENMSOUNDSOURCE enmSoundSource, audsettings_t *pAudioSettings) 2258 { 2259 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 2260 2261 int rc; 2262 2263 switch (enmSoundSource) 2264 { 2265 case PI_INDEX: 2266 rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.in", PDMAUDIORECSOURCE_LINE_IN, pCfg); 2267 break; 2268 2269 case PO_INDEX: 2270 rc = pThis->pfnOpenOut(pThis->pHDAState, "hda.out", pCfg); 2271 break; 2272 2273 #ifdef VBOX_WITH_HDA_MIC_IN 2274 case MC_INDEX: 2275 rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.mc", PDMAUDIORECSOURCE_MIC, pCfg); 2276 break; 2308 2277 #endif 2309 {2310 AssertPtrReturn(pThis, VERR_INVALID_POINTER);2311 2312 int rc;2313 2314 switch (enmSoundSource)2315 {2316 case PI_INDEX:2317 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2318 rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.in",2319 PDMAUDIORECSOURCE_LINE_IN, pCfg);2320 #else2321 pThis->SwVoiceIn = AUD_open_in(&pThis->card, pThis->SwVoiceIn, "hda.in", pThis, pi_callback, pAudioSettings);2322 rc = pThis->SwVoiceIn ? VINF_SUCCESS : VERR_GENERAL_FAILURE;2323 #endif2324 break;2325 2326 case PO_INDEX:2327 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2328 rc = pThis->pfnOpenOut(pThis->pHDAState, "hda.out", pCfg);2329 #else2330 pThis->SwVoiceOut = AUD_open_out(&pThis->card, pThis->SwVoiceOut, "hda.out", pThis, po_callback, pAudioSettings);2331 rc = pThis->SwVoiceOut ? VINF_SUCCESS : VERR_GENERAL_FAILURE;2332 #endif2333 break;2334 2335 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2336 # ifdef VBOX_WITH_HDA_MIC_IN2337 case MC_INDEX:2338 rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.mc",2339 PDMAUDIORECSOURCE_MIC, pCfg);2340 break;2341 # endif2342 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2343 2344 2278 default: 2345 2279 AssertMsgFailed(("Index %ld not implemented\n", enmSoundSource)); … … 2416 2350 */ 2417 2351 if (hdaCodecIsDacNode(pThis, pThis->u8DacLineOut)) 2418 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2419 2352 hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8DacLineOut].dac.B_params, PDMAUDIOMIXERCTL_PCM); 2420 #else2421 hdaCodecToAudVolume(&pThis->paNodes[pThis->u8DacLineOut].dac.B_params, AUD_MIXER_VOLUME);2422 #endif2423 2353 else if (hdaCodecIsSpdifOutNode(pThis, pThis->u8DacLineOut)) 2424 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2425 2354 hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8DacLineOut].spdifout.B_params, PDMAUDIOMIXERCTL_PCM); 2426 2355 hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8AdcVolsLineIn].adcvol.B_params, PDMAUDIOMIXERCTL_LINE_IN); 2427 #else2428 hdaCodecToAudVolume(&pThis->paNodes[pThis->u8DacLineOut].spdifout.B_params, AUD_MIXER_VOLUME);2429 hdaCodecToAudVolume(&pThis->paNodes[pThis->u8AdcVolsLineIn].adcvol.B_params, AUD_MIXER_LINE_IN);2430 #endif2431 2356 2432 2357 return VINF_SUCCESS; … … 2468 2393 pThis->paNodes[1].afg.u32F20_param = CODEC_MAKE_F20(pThis->u16VendorId, pThis->u8BSKU, pThis->u8AssemblyId); 2469 2394 2470 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2471 2395 /* 44.1 kHz. */ 2472 2396 PDMAUDIOSTREAMCFG as; … … 2475 2399 as.enmFormat = AUD_FMT_S16; 2476 2400 as.enmEndianness = PDMAUDIOHOSTENDIANNESS; 2477 #else2478 AUD_register_card("ICH0", &pThis->card);2479 2480 /* 44.1 kHz */2481 audsettings_t as;2482 as.freq = 44100;2483 as.nchannels = 2;2484 as.fmt = AUD_FMT_S16;2485 as.endianness = 0;2486 #endif2487 2401 2488 2402 pThis->paNodes[1].node.au32F00_param[0xA] = CODEC_F00_0A_16_BIT; … … 2490 2404 hdaCodecOpenStream(pThis, PI_INDEX, &as); 2491 2405 hdaCodecOpenStream(pThis, PO_INDEX, &as); 2492 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 2493 # ifdef VBOX_WITH_HDA_MIC_IN 2406 #ifdef VBOX_WITH_HDA_MIC_IN 2494 2407 hdaCodecOpenStream(pThis, MC_INDEX, &as); 2495 # endif 2496 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */ 2408 #endif 2497 2409 2498 2410 pThis->paNodes[1].node.au32F00_param[0xA] |= CODEC_F00_0A_44_1KHZ; … … 2505 2417 pThis->pfnCodecNodeReset(pThis, i, &pThis->paNodes[i]); 2506 2418 2507 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2508 2419 hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8DacLineOut].dac.B_params, PDMAUDIOMIXERCTL_PCM); 2509 2420 hdaCodecToAudVolume(pThis, &pThis->paNodes[pThis->u8AdcVolsLineIn].adcvol.B_params, PDMAUDIOMIXERCTL_LINE_IN); 2510 2421 2511 2512 #else 2513 hdaCodecToAudVolume(&pThis->paNodes[pThis->u8DacLineOut].dac.B_params, AUD_MIXER_VOLUME); 2514 hdaCodecToAudVolume(&pThis->paNodes[pThis->u8AdcVolsLineIn].adcvol.B_params, AUD_MIXER_LINE_IN); 2515 2516 if (!AUD_is_host_voice_in_ok(pThis->SwVoiceIn)) 2517 LogRel (("HDA: WARNING: Unable to open PCM IN!\n")); 2518 if (!AUD_is_host_voice_out_ok(pThis->SwVoiceOut)) 2519 LogRel (("HDA: WARNING: Unable to open PCM OUT!\n")); 2520 2521 if ( !AUD_is_host_voice_in_ok(pThis->SwVoiceIn) 2522 && !AUD_is_host_voice_out_ok(pThis->SwVoiceOut)) 2523 { 2524 AUD_close_in(&pThis->card, pThis->SwVoiceIn); 2525 AUD_close_out(&pThis->card, pThis->SwVoiceOut); 2526 2527 pThis->SwVoiceOut = NULL; 2528 pThis->SwVoiceIn = NULL; 2529 2530 AUD_init_null (); 2531 2532 PDMDevHlpVMSetRuntimeError (pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", 2533 N_ ("No audio devices could be opened. Selecting the NULL audio backend " 2534 "with the consequence that no sound is audible")); 2535 } 2536 else if ( !AUD_is_host_voice_in_ok(pThis->SwVoiceIn) 2537 || !AUD_is_host_voice_out_ok(pThis->SwVoiceOut)) 2538 { 2539 char szMissingVoices[128]; 2540 size_t len = 0; 2541 2542 if (!AUD_is_host_voice_in_ok(pThis->SwVoiceIn)) 2543 len = RTStrPrintf (szMissingVoices, sizeof(szMissingVoices), "PCM_in"); 2544 if (!AUD_is_host_voice_out_ok(pThis->SwVoiceOut)) 2545 len += RTStrPrintf (szMissingVoices + len, sizeof(szMissingVoices) - len, len ? ", PCM_out" : "PCM_out"); 2546 2547 PDMDevHlpVMSetRuntimeError (pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", 2548 N_ ("Some audio devices (%s) could not be opened. Guest applications generating audio " 2549 "output or depending on audio input may hang. Make sure your host audio device " 2550 "is working properly. Check the logfile for error messages of the audio " 2551 "subsystem"), szMissingVoices); 2552 } 2553 #endif 2554 2555 return VINF_SUCCESS; 2556 } 2557 2422 return VINF_SUCCESS; 2423 } 2424
Note:
See TracChangeset
for help on using the changeset viewer.