Changeset 56085 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- May 26, 2015 4:39:58 PM (10 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 19 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r55920 r56085 30 30 31 31 #include "VBoxDD.h" 32 33 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 34 # include "AudioMixer.h" 35 #else 36 extern "C" { 37 #include "audio.h" 38 } 39 #endif 32 #include "AudioMixer.h" 40 33 41 34 #ifdef LOG_GROUP … … 60 53 61 54 #ifdef VBOX 62 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER 63 # define SOFT_VOLUME /** @todo Get rid of this crap. */ 64 # else 65 # undef SOFT_VOLUME 66 # endif 55 # define SOFT_VOLUME /** @todo Get rid of this crap. */ 67 56 #else 68 # define 57 # define SOFT_VOLUME 69 58 #endif 70 59 … … 211 200 typedef AC97BusMasterRegs *PAC97BMREG; 212 201 213 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER214 202 typedef struct AC97INPUTSTREAM 215 203 { … … 264 252 AC97OUTPUTSTREAM Out; 265 253 } AC97DRIVER, *PAC97DRIVER; 266 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */267 254 268 255 typedef struct AC97STATE … … 280 267 AC97BusMasterRegs bm_regs[3]; 281 268 uint8_t mixer_data[256]; 282 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER283 269 /** The emulation timer for handling the attached 284 270 * LUN drivers. */ … … 286 272 /** Timer ticks for handling the LUN drivers. */ 287 273 uint64_t uTicks; 288 # 274 #ifdef VBOX_WITH_STATISTICS 289 275 STAMPROFILE StatTimer; 290 276 STAMCOUNTER StatBytesRead; 291 277 STAMCOUNTER StatBytesWritten; 292 # 278 #endif 293 279 /** List of associated LUN drivers. */ 294 280 RTLISTANCHOR lstDrv; … … 301 287 /** Audio sink for microphone input. */ 302 288 R3PTRTYPE(PAUDMIXSINK) pSinkMicIn; 303 #else304 QEMUSoundCard card;305 /** PCM in */306 SWVoiceIn *voice_pi;307 /** PCM out */308 SWVoiceOut *voice_po;309 /** Mic in */310 SWVoiceIn *voice_mc;311 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */312 289 uint8_t silence[128]; 313 290 int bup_flag; … … 370 347 #define GET_BM(a_idx) ( ((a_idx) >> 4) & 3 ) 371 348 372 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER373 349 static DECLCALLBACK(void) ichac97Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser); 374 350 static int ichac97TransferAudio(PAC97STATE pThis, int index, uint32_t cbElapsed); 375 #else376 static void ichac97OutputCallback(void *pvContext, int cbFree);377 static void ichac97InputCallback(void *pvContext, int cbAvail);378 static void ichac97MicInCallback(void *pvContext, int cbAvail);379 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */380 351 381 352 static void ichac97WarmReset(PAC97STATE pThis) … … 464 435 LogFlowFunc(("index=%d, on=%d\n", bm_index, on)); 465 436 466 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER467 437 PAC97DRIVER pDrv; 468 438 switch (bm_index) … … 490 460 break; 491 461 } 492 #else493 switch (bm_index)494 {495 case PI_INDEX: AUD_set_active_in( pThis->voice_pi, on); break;496 case PO_INDEX: AUD_set_active_out(pThis->voice_po, on); break;497 case MC_INDEX: AUD_set_active_in( pThis->voice_mc, on); break;498 default: AssertFailed (); break;499 }500 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */501 462 } 502 463 … … 550 511 int rc; 551 512 552 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER553 513 PAC97DRIVER pDrv; 554 514 uint8_t uLUN = 0; … … 714 674 715 675 AudioMixerInvalidate(pThis->pMixer); 716 #else717 if (freq)718 {719 audsettings_t as;720 as.freq = freq;721 as.nchannels = 2;722 as.fmt = AUD_FMT_S16;723 as.endianness = 0;724 725 switch (index)726 {727 case PI_INDEX: /* PCM in */728 pThis->voice_pi = AUD_open_in(&pThis->card, pThis->voice_pi, "ac97.pi", pThis, ichac97InputCallback, &as);729 #ifdef LOG_VOICES730 LogRel(("AC97: open PI freq=%d (%s)\n", freq, pThis->voice_pi ? "ok" : "FAIL"));731 #endif732 rc = pThis->voice_pi ? VINF_SUCCESS : VERR_GENERAL_FAILURE;733 break;734 735 case PO_INDEX: /* PCM out */736 pThis->voice_po = AUD_open_out(&pThis->card, pThis->voice_po, "ac97.po", pThis, ichac97OutputCallback, &as);737 #ifdef LOG_VOICES738 LogRel(("AC97: open PO freq=%d (%s)\n", freq, pThis->voice_po ? "ok" : "FAIL"));739 #endif740 rc = pThis->voice_po ? VINF_SUCCESS : VERR_GENERAL_FAILURE;741 break;742 743 case MC_INDEX: /* Mic in */744 pThis->voice_mc = AUD_open_in(&pThis->card, pThis->voice_mc, "ac97.mc", pThis, ichac97MicInCallback, &as);745 #ifdef LOG_VOICES746 LogRel(("AC97: open MC freq=%d (%s)\n", freq, pThis->voice_mc ? "ok" : "FAIL"));747 #endif748 rc = pThis->voice_mc ? VINF_SUCCESS : VERR_GENERAL_FAILURE;749 break;750 }751 }752 else753 {754 switch (index)755 {756 case PI_INDEX:757 AUD_close_in(&pThis->card, pThis->voice_pi);758 pThis->voice_pi = NULL;759 #ifdef LOG_VOICES760 LogRel(("AC97: Closing PCM IN\n"));761 #endif762 break;763 764 case PO_INDEX:765 AUD_close_out(&pThis->card, pThis->voice_po);766 pThis->voice_po = NULL;767 #ifdef LOG_VOICES768 LogRel(("AC97: Closing PCM OUT\n"));769 #endif770 break;771 772 case MC_INDEX:773 AUD_close_in(&pThis->card, pThis->voice_mc);774 pThis->voice_mc = NULL;775 #ifdef LOG_VOICES776 LogRel(("AC97: Closing MIC IN\n"));777 #endif778 break;779 }780 781 rc = VINF_SUCCESS;782 }783 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */784 676 785 677 LogFlowFuncLeaveRC(rc); … … 795 687 ichac97OpenStream(pThis, PI_INDEX, uFreq); 796 688 797 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER798 689 PAC97DRIVER pDrv; 799 690 RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node) 800 691 pDrv->pConnector->pfnEnableIn(pDrv->pConnector, pDrv->LineIn.pStrmIn, fEnable); 801 #else802 AUD_set_active_in(pThis->voice_pi, active[PI_INDEX]);803 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */804 692 805 693 uFreq = ichac97MixerLoad(pThis, AC97_PCM_Front_DAC_Rate); … … 809 697 ichac97OpenStream(pThis, PO_INDEX, uFreq); 810 698 811 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER812 699 RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node) 813 700 pDrv->pConnector->pfnEnableOut(pDrv->pConnector, pDrv->Out.pStrmOut, fEnable); 814 #else815 AUD_set_active_out(pThis->voice_po, active[PO_INDEX]);816 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */817 701 818 702 uFreq = ichac97MixerLoad(pThis, AC97_MIC_ADC_Rate); … … 822 706 ichac97OpenStream(pThis, MC_INDEX, uFreq); 823 707 824 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER825 708 RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node) 826 709 pDrv->pConnector->pfnEnableIn(pDrv->pConnector, pDrv->MicIn.pStrmIn, fEnable); 827 #else 828 AUD_set_active_in(pThis->voice_mc, active[MC_INDEX]); 829 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */ 830 } 831 832 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 710 } 711 833 712 static void ichac97SetVolume(PAC97STATE pThis, int index, PDMAUDIOMIXERCTL mt, uint32_t val) 834 #else835 static void ichac97SetVolume(PAC97STATE pThis, int index, audmixerctl_t mt, uint32_t val)836 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */837 713 { 838 714 int mute = (val >> MUTE_SHIFT) & 1; … … 856 732 857 733 #ifdef SOFT_VOLUME 858 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER859 734 if (pThis->pMixer) /* Device can be in reset state, so no mixer available. */ 860 735 { … … 882 757 } 883 758 } 884 # else /* !VBOX_WITH_PDM_AUDIO_DRIVER */885 if (index == AC97_Master_Volume_Mute)886 AUD_set_volume_out(pThis->voice_po, mute, lvol, rvol);887 else888 AUD_set_volume(mt, &mute, &lvol, &rvol);889 # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */890 891 #else /* !SOFT_VOLUME */892 AUD_set_volume(mt, &mute, &lvol, &rvol);893 759 #endif /* SOFT_VOLUME */ 894 760 … … 966 832 RT_ZERO(pThis->mixer_data); 967 833 968 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER969 834 PAC97DRIVER pDrv; 970 971 835 RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node) 972 836 { … … 1012 876 AssertRC(rc2); 1013 877 } 1014 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1015 878 1016 879 ichac97MixerStore(pThis, AC97_Reset , 0x0000); /* 6940 */ … … 1048 911 } 1049 912 ichac97RecordSelect(pThis, 0); 1050 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER 913 1051 914 ichac97SetVolume(pThis, AC97_Master_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME, 0x8000); 1052 915 ichac97SetVolume(pThis, AC97_PCM_Out_Volume_Mute, PDMAUDIOMIXERCTL_PCM, 0x8808); 1053 916 ichac97SetVolume(pThis, AC97_Line_In_Volume_Mute, PDMAUDIOMIXERCTL_LINE_IN, 0x8808); 1054 # else1055 ichac97SetVolume(pThis, AC97_Master_Volume_Mute, AUD_MIXER_VOLUME, 0x8000);1056 ichac97SetVolume(pThis, AC97_PCM_Out_Volume_Mute, AUD_MIXER_PCM, 0x8808);1057 ichac97SetVolume(pThis, AC97_Line_In_Volume_Mute, AUD_MIXER_LINE_IN, 0x8808);1058 # endif1059 917 1060 918 /* Reset all streams. */ … … 1104 962 PDMDevHlpPhysRead(pDevIns, addr, pThis->pvReadWriteBuf, cbToRead); /** @todo Check rc? */ 1105 963 1106 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1107 964 uint32_t cbWritten; 1108 965 … … 1121 978 LogFlowFunc(("\tLUN#%RU8: cbWritten=%RU32, cWrittenMin=%RU32\n", pDrv->uLUN, cbWritten, cbWrittenMin)); 1122 979 } 1123 #else 1124 cbWrittenMin = AUD_write(pThis->voice_po, pThis->pvReadWriteBuf, cbToRead); 1125 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */ 980 1126 981 LogFlowFunc(("\tcbToRead=%RU32, cbWrittenMin=%RU32, cbToWrite=%RU32, cbLeft=%RU32\n", 1127 982 cbToRead, cbWrittenMin, cbToWrite, cbToWrite - cbWrittenMin)); … … 1186 1041 while (cbToWrite) 1187 1042 { 1188 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1189 1043 PAC97DRIVER pDrv; 1190 1044 uint32_t cbWritten; … … 1198 1052 cbWrittenMin = RT_MIN(cbWrittenMin, cbWritten); 1199 1053 } 1200 #else1201 cbWrittenMin = AUD_write(pThis->voice_po, pThis->silence, cbToWrite);1202 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1203 1054 1204 1055 if (!cbWrittenMin) … … 1224 1075 int rc; 1225 1076 1226 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1227 1077 /* Select audio sink to process. */ 1228 1078 PAUDMIXSINK pSink = (pReg - pThis->bm_regs) == MC_INDEX ? pThis->pSinkMicIn : pThis->pSinkLineIn; … … 1263 1113 1264 1114 return rc; 1265 #else 1266 rc = VINF_SUCCESS; 1267 1268 uint32_t addr = pReg->bd.addr; 1269 uint32_t temp = pReg->picb << 1; 1270 uint32_t nread = 0; 1271 int to_copy = 0; 1272 1273 SWVoiceIn *voice = (pReg - pThis->bm_regs) == MC_INDEX ? pThis->voice_mc : pThis->voice_pi; 1274 1275 temp = audio_MIN(temp, (uint32_t)cbMax); 1276 if (!temp) 1277 { 1278 *pcbRead = 0; 1279 return VINF_EOF; 1280 } 1281 1282 uint8_t tmpbuf[4096]; 1283 while (temp) 1284 { 1285 int acquired; 1286 to_copy = audio_MIN(temp, sizeof(tmpbuf)); 1287 acquired = AUD_read(voice, tmpbuf, to_copy); 1288 if (!acquired) 1289 { 1290 rc = VERR_GENERAL_FAILURE; /* Not worth fixing anymore. */ 1291 break; 1292 } 1293 PDMDevHlpPCIPhysWrite(pDevIns, addr, tmpbuf, acquired); 1294 temp -= acquired; 1295 addr += acquired; 1296 nread += acquired; 1297 } 1298 1299 pReg->bd.addr = addr; 1300 1301 if (RT_SUCCESS(rc)) 1302 *pcbRead = nread; 1303 1304 return rc; 1305 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */ 1306 } 1307 1308 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 1115 } 1116 1309 1117 static DECLCALLBACK(void) ichac97Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 1310 1118 { … … 1382 1190 STAM_PROFILE_STOP(&pThis->StatTimer, a); 1383 1191 } 1384 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1385 1192 1386 1193 static int ichac97TransferAudio(PAC97STATE pThis, int index, uint32_t cbElapsed) … … 1517 1324 return rc; 1518 1325 } 1519 1520 #ifndef VBOX_WITH_PDM_AUDIO_DRIVER1521 static void ichac97InputCallback(void *pvContext, int cbAvail)1522 {1523 ichac97TransferAudio((AC97STATE *)pvContext, PI_INDEX, cbAvail);1524 }1525 1526 static void ichac97MicInCallback(void *pvContext, int cbAvail)1527 {1528 ichac97TransferAudio((AC97STATE *)pvContext, MC_INDEX, cbAvail);1529 }1530 1531 static void ichac97OutputCallback(void *pvContext, int cbFree)1532 {1533 ichac97TransferAudio((AC97STATE *)pvContext, PO_INDEX, cbFree);1534 }1535 #endif1536 1326 1537 1327 /** … … 1911 1701 break; 1912 1702 case AC97_Master_Volume_Mute: 1913 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1914 1703 ichac97SetVolume(pThis, index, PDMAUDIOMIXERCTL_VOLUME, u32); 1915 #else1916 ichac97SetVolume(pThis, index, AUD_MIXER_VOLUME, u32);1917 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1918 1704 break; 1919 1705 case AC97_PCM_Out_Volume_Mute: 1920 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1921 1706 ichac97SetVolume(pThis, index, PDMAUDIOMIXERCTL_PCM, u32); 1922 #else1923 ichac97SetVolume(pThis, index, AUD_MIXER_PCM, u32);1924 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1925 1707 break; 1926 1708 case AC97_Line_In_Volume_Mute: 1927 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1928 1709 ichac97SetVolume(pThis, index, PDMAUDIOMIXERCTL_LINE_IN, u32); 1929 #else1930 ichac97SetVolume(pThis, index, AUD_MIXER_LINE_IN, u32);1931 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1932 1710 break; 1933 1711 case AC97_Record_Select: … … 2070 1848 uint8_t active[LAST_INDEX]; 2071 1849 2072 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2073 1850 PAC97DRIVER pDrv; 2074 1851 RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node) … … 2080 1857 active[MC_INDEX] = pCon->pfnIsActiveIn (pCon, pDrv->MicIn.pStrmIn) ? 1 : 0; 2081 1858 } 2082 #else2083 active[PI_INDEX] = AUD_is_active_in( pThis->voice_pi) ? 1 : 0;2084 active[PO_INDEX] = AUD_is_active_out(pThis->voice_po) ? 1 : 0;2085 active[MC_INDEX] = AUD_is_active_in( pThis->voice_mc) ? 1 : 0;2086 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2087 1859 2088 1860 SSMR3PutMem(pSSM, active, sizeof(active)); … … 2127 1899 ichac97RecordSelect(pThis, ichac97MixerLoad(pThis, AC97_Record_Select)); 2128 1900 # define V_(a, b) ichac97SetVolume(pThis, a, b, ichac97MixerLoad(pThis, a)) 2129 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER2130 1901 V_(AC97_Master_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME); 2131 1902 V_(AC97_PCM_Out_Volume_Mute, PDMAUDIOMIXERCTL_PCM); 2132 1903 V_(AC97_Line_In_Volume_Mute, PDMAUDIOMIXERCTL_LINE_IN); 2133 # else2134 V_(AC97_Master_Volume_Mute, AUD_MIXER_VOLUME);2135 V_(AC97_PCM_Out_Volume_Mute, AUD_MIXER_PCM);2136 V_(AC97_Line_In_Volume_Mute, AUD_MIXER_LINE_IN);2137 # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2138 1904 # undef V_ 2139 1905 ichac97ResetStreams(pThis, active); … … 2194 1960 LogFlowFuncEnter(); 2195 1961 2196 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2197 1962 PAC97DRIVER pDrv; 2198 1963 while (!RTListIsEmpty(&pThis->lstDrv)) … … 2209 1974 pThis->pMixer = NULL; 2210 1975 } 2211 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2212 1976 2213 1977 if (pThis->pvReadWriteBuf) … … 2223 1987 2224 1988 2225 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2226 1989 /** 2227 1990 * Attach command. … … 2295 2058 return rc; 2296 2059 } 2297 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2298 2060 2299 2061 … … 2305 2067 PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE); 2306 2068 2307 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2308 2069 /* NB: This must be done *before* any possible failure (and running the destructor). */ 2309 2070 RTListInit(&pThis->lstDrv); 2310 #endif2311 2071 2312 2072 Assert(iInstance == 0); … … 2404 2164 * Attach driver. 2405 2165 */ 2406 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2407 2166 uint8_t uLUN; 2408 2167 for (uLUN = 0; uLUN < UINT8_MAX; uLUN) … … 2421 2180 2422 2181 LogFunc(("cLUNs=%RU8, rc=%Rrc\n", uLUN, rc)); 2423 #else 2424 rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "Audio Driver Port"); 2425 if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 2426 LogFunc(("ac97: No attached driver!\n")); 2427 else if (RT_FAILURE(rc)) 2428 { 2429 AssertMsgFailed(("Failed to attach AC97 LUN #0! rc=%Rrc\n", rc)); 2430 return rc; 2431 } 2432 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */ 2433 2434 #ifndef VBOX_WITH_PDM_AUDIO_DRIVER 2435 AUD_register_card("ICH0", &pThis->card); 2436 #endif 2182 2437 2183 ac97Reset(pDevIns); 2438 2184 2439 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2440 2185 PAC97DRIVER pDrv; 2441 2186 uLUN = 0; … … 2509 2254 } 2510 2255 } 2511 #else2512 if (!AUD_is_host_voice_in_ok(pThis->voice_pi))2513 LogRel(("AC97: WARNING: Unable to open PCM IN!\n"));2514 if (!AUD_is_host_voice_in_ok(pThis->voice_mc))2515 LogRel(("AC97: WARNING: Unable to open PCM MC!\n"));2516 if (!AUD_is_host_voice_out_ok(pThis->voice_po))2517 LogRel(("AC97: WARNING: Unable to open PCM OUT!\n"));2518 2519 if ( !AUD_is_host_voice_in_ok( pThis->voice_pi)2520 && !AUD_is_host_voice_out_ok(pThis->voice_po)2521 && !AUD_is_host_voice_in_ok( pThis->voice_mc))2522 {2523 AUD_close_in(&pThis->card, pThis->voice_pi);2524 AUD_close_out(&pThis->card, pThis->voice_po);2525 AUD_close_in(&pThis->card, pThis->voice_mc);2526 2527 pThis->voice_po = NULL;2528 pThis->voice_pi = NULL;2529 pThis->voice_mc = NULL;2530 AUD_init_null();2531 ac97Reset(pDevIns);2532 2533 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",2534 N_("No audio devices could be opened. Selecting the NULL audio backend "2535 "with the consequence that no sound is audible"));2536 }2537 else if ( !AUD_is_host_voice_in_ok( pThis->voice_pi)2538 || !AUD_is_host_voice_out_ok(pThis->voice_po)2539 || !AUD_is_host_voice_in_ok( pThis->voice_mc))2540 {2541 char szMissingVoices[128];2542 size_t len = 0;2543 if (!AUD_is_host_voice_in_ok(pThis->voice_pi))2544 len = RTStrPrintf(szMissingVoices, sizeof(szMissingVoices), "PCM_in");2545 if (!AUD_is_host_voice_out_ok(pThis->voice_po))2546 len += RTStrPrintf(szMissingVoices + len, sizeof(szMissingVoices) - len, len ? ", PCM_out" : "PCM_out");2547 if (!AUD_is_host_voice_in_ok(pThis->voice_mc))2548 len += RTStrPrintf(szMissingVoices + len, sizeof(szMissingVoices) - len, len ? ", PCM_mic" : "PCM_mic");2549 2550 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",2551 N_("Some audio devices (%s) could not be opened. Guest applications generating audio "2552 "output or depending on audio input may hang. Make sure your host audio device "2553 "is working properly. Check the logfile for error messages of the audio "2554 "subsystem"), szMissingVoices);2555 }2556 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2557 2256 2558 2257 if (RT_SUCCESS(rc)) … … 2564 2263 } 2565 2264 2566 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2567 2265 if (RT_SUCCESS(rc)) 2568 2266 { … … 2595 2293 } 2596 2294 # endif 2597 2598 #endif2599 2295 2600 2296 return VINF_SUCCESS; -
trunk/src/VBox/Devices/Audio/DevIchHda.cpp
r55920 r56085 45 45 #include "VBoxDD.h" 46 46 47 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 48 # include "AudioMixer.h" 49 #else 50 extern "C" { 51 #include "audio.h" 52 } 53 #endif 47 #include "AudioMixer.h" 54 48 #include "DevIchHdaCodec.h" 55 49 … … 551 545 } HDASTREAMTRANSFERDESC, *PHDASTREAMTRANSFERDESC; 552 546 553 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER554 547 typedef struct HDAINPUTSTREAM 555 548 { … … 608 601 HDAOUTPUTSTREAM Out; 609 602 } HDADRIVER, *PHDADRIVER; 610 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */611 603 612 604 /** … … 655 647 /** Flag whether the RC part is enabled. */ 656 648 bool fRCEnabled; 657 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER658 649 /** The emulation timer for handling the attached 659 650 * LUN drivers. */ … … 686 677 /** Audio mixer sink for microphone input. */ 687 678 R3PTRTYPE(PAUDMIXSINK) pSinkMicIn; 688 #else /* !VBOX_WITH_PDM_AUDIO_DRIVER */689 /** The HDA codec to use. */690 R3PTRTYPE(PHDACODEC) pCodec;691 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */692 679 uint64_t u64BaseTS; 693 680 /** 1.2.3.4.5.6.7. - someone please tell me what I'm counting! - .8.9.10... */ 694 681 uint8_t u8Counter; 695 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER696 682 uint8_t au8Padding[7]; 697 #else698 uint8_t au8Padding[7];699 #endif700 683 } HDASTATE; 701 684 /** Pointer to the ICH Intel HD Audio Controller state. */ … … 749 732 static int hdaRegWriteU8(PHDASTATE pThis, uint32_t iReg, uint32_t pu32Value); 750 733 751 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER752 734 static DECLCALLBACK(void) hdaTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser); 753 735 static int hdaTransfer(PHDASTATE pThis, ENMSOUNDSOURCE enmSrc, uint32_t cbAvail); 754 #else755 static int hdaTransfer(PHDACODEC pCodec, ENMSOUNDSOURCE enmSource, int cbAvail);756 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */757 736 758 737 #ifdef IN_RING3 … … 1531 1510 pBdle = &pThis->StInBdle; 1532 1511 break; 1533 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 1534 # ifdef VBOX_WITH_HDA_MIC_IN 1512 #ifdef VBOX_WITH_HDA_MIC_IN 1535 1513 case HDA_REG_SD2CTL: 1536 1514 u8Strm = 2; 1537 1515 pBdle = &pThis->StMicBdle; 1538 1516 break; 1539 # endif1540 1517 #endif 1541 1518 case HDA_REG_SD4CTL: … … 1563 1540 Assert((!fReset && !fInReset)); 1564 1541 1565 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER1566 1542 PHDADRIVER pDrv; 1567 # endif1568 1543 switch (iReg) 1569 1544 { 1570 1545 case HDA_REG_SD0CTL: 1571 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER 1546 { 1572 1547 RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node) 1573 1548 pDrv->pConnector->pfnEnableIn(pDrv->pConnector, 1574 1549 pDrv->LineIn.pStrmIn, fRun); 1575 # else1576 AUD_set_active_in(pThis->pCodec->SwVoiceIn, fRun);1577 # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1578 1550 break; 1579 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER 1580 # 1551 } 1552 # ifdef VBOX_WITH_HDA_MIC_IN 1581 1553 case HDA_REG_SD2CTL: 1554 { 1582 1555 RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node) 1583 1556 pDrv->pConnector->pfnEnableIn(pDrv->pConnector, 1584 1557 pDrv->MicIn.pStrmIn, fRun); 1585 # endif1586 # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1587 1558 break; 1559 } 1560 # endif 1588 1561 case HDA_REG_SD4CTL: 1589 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER 1562 { 1590 1563 RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node) 1591 1564 pDrv->pConnector->pfnEnableOut(pDrv->pConnector, 1592 1565 pDrv->Out.pStrmOut, fRun); 1593 # else1594 AUD_set_active_out(pThis->pCodec->SwVoiceOut, fRun);1595 # endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1596 1566 break; 1567 } 1597 1568 default: 1598 1569 AssertMsgFailed(("Changing RUN bit on non-attached stream, register %RU32\n", iReg)); … … 1682 1653 1683 1654 #ifdef IN_RING3 1684 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1685 1655 static int hdaSdFmtToAudSettings(uint32_t u32SdFmt, PPDMAUDIOSTREAMCFG pCfg) 1686 #else1687 static int hdaSdFmtToAudSettings(uint32_t u32SdFmt, audsettings_t *pCfg)1688 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1689 1656 { 1690 1657 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); … … 1727 1694 } 1728 1695 1729 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1730 1696 PDMAUDIOFMT enmFmt = AUD_FMT_S16; /* Default to 16-bit signed. */ 1731 #else1732 audfmt_e enmFmt = AUD_FMT_S16; /* Default to 16-bit signed. */1733 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1734 1735 1697 switch (EXTRACT_VALUE(u32SdFmt, HDA_SDFMT_BITS_MASK, HDA_SDFMT_BITS_SHIFT)) 1736 1698 { 1737 1699 case 0: 1738 LogFunc(("%s requested 8-bit\n", __FUNCTION__)); 1739 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 1700 LogFunc(("Requested 8-bit\n")); 1740 1701 enmFmt = AUD_FMT_S8; 1741 #else1742 enmFmt = AUD_FMT_S8;1743 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1744 1702 break; 1745 1703 case 1: 1746 LogFunc(("%s requested 16-bit\n", __FUNCTION__)); 1747 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 1704 LogFunc(("Requested 16-bit\n")); 1748 1705 enmFmt = AUD_FMT_S16; 1749 #else1750 enmFmt = AUD_FMT_S16;1751 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1752 1706 break; 1753 1707 case 2: 1754 LogFunc((" %s requested 20-bit\n", __FUNCTION__));1708 LogFunc(("Requested 20-bit\n")); 1755 1709 break; 1756 1710 case 3: 1757 LogFunc((" %s requested 24-bit\n", __FUNCTION__));1711 LogFunc(("Requested 24-bit\n")); 1758 1712 break; 1759 1713 case 4: 1760 LogFunc(("%s requested 32-bit\n", __FUNCTION__)); 1761 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 1714 LogFunc(("Requested 32-bit\n")); 1762 1715 enmFmt = AUD_FMT_S32; 1763 #else1764 enmFmt = AUD_FMT_S32;1765 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1766 1716 break; 1767 1717 default: … … 1774 1724 if (RT_SUCCESS(rc)) 1775 1725 { 1776 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1777 1726 pCfg->uHz = u32Hz * u32HzMult / u32HzDiv; 1778 1727 pCfg->cChannels = (u32SdFmt & 0xf) + 1; 1779 1728 pCfg->enmFormat = enmFmt; 1780 1729 pCfg->enmEndianness = PDMAUDIOHOSTENDIANNESS; 1781 #else1782 pCfg->nchannels = (u32SdFmt & 0xf) + 1;1783 pCfg->fmt = enmFmt;1784 pCfg->endianness = 0;1785 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1786 1730 } 1787 1731 … … 1812 1756 rc = hdaCodecOpenStream(pThis->pCodec, PI_INDEX, &as); 1813 1757 break; 1814 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 1815 # ifdef VBOX_WITH_HDA_MIC_IN 1758 # ifdef VBOX_WITH_HDA_MIC_IN 1816 1759 case HDA_REG_SD2FMT: 1817 1760 RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node) 1818 1761 rc = hdaCodecOpenStream(pThis->pCodec, MC_INDEX, &as); 1819 1762 break; 1820 # endif 1821 #endif 1763 # endif 1822 1764 default: 1823 1765 LogFunc(("Warning: Attempt to change format on register %d\n", iReg)); … … 1827 1769 /** @todo r=andy rc gets lost; needs fixing. */ 1828 1770 return hdaRegWriteU16(pThis, iReg, u32Value); 1829 # else 1771 # else /* !VBOX_WITH_HDA_CODEC_EMU */ 1830 1772 return hdaRegWriteU16(pThis, iReg, u32Value); 1831 1773 # endif 1832 #else 1774 #else /* !IN_RING3 */ 1833 1775 return VINF_IOM_R3_MMIO_WRITE; 1834 1776 #endif … … 2184 2126 } 2185 2127 2186 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2187 2128 /** 2188 2129 * hdaReadAudio - copies samples from audio backend to DMA. … … 2244 2185 return rc; 2245 2186 } 2246 #else2247 static int hdaReadAudio(PHDASTATE pThis, PHDASTREAMTRANSFERDESC pStreamDesc,2248 uint32_t u32CblLimit, uint32_t *pu32Avail, uint32_t *pcbRead)2249 {2250 PHDABDLEDESC pBdle = &pThis->StInBdle;2251 2252 uint32_t cbTransferred = 0;2253 uint32_t cb2Copy = 0;2254 uint32_t cbBackendCopy = 0;2255 2256 int rc;2257 2258 Log(("hda:ra: CVI(pos:%d, len:%d)\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen));2259 2260 cb2Copy = hdaCalculateTransferBufferLength(pBdle, pStreamDesc, *pu32Avail, u32CblLimit);2261 if (!cb2Copy)2262 {2263 /* if we enter here we can't report "unreported bits" */2264 rc = VINF_EOF;2265 }2266 else2267 {2268 /*2269 * read from backend input line to the last unreported position or at the begining.2270 */2271 cbBackendCopy = AUD_read(pThis->pCodec->SwVoiceIn, pBdle->au8HdaBuffer, cb2Copy);2272 2273 /*2274 * write the HDA DMA buffer2275 */2276 PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns), pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, pBdle->au8HdaBuffer,2277 cbBackendCopy);2278 2279 /* Don't see any reason why cb2Copy would differ from cbBackendCopy */2280 Assert((cbBackendCopy == cb2Copy && (*pu32Avail) >= cb2Copy)); /* sanity */2281 2282 if (pBdle->cbUnderFifoW + cbBackendCopy > hdaFifoWToSz(pThis, 0))2283 {2284 hdaBackendReadTransferReported(pBdle, cb2Copy, cbBackendCopy, &cbTransferred, pu32Avail);2285 rc = VINF_SUCCESS;2286 }2287 else2288 {2289 hdaBackendTransferUnreported(pThis, pBdle, pStreamDesc, cbBackendCopy, pu32Avail);2290 rc = VINF_EOF;2291 }2292 }2293 2294 Assert((cbTransferred <= (SDFIFOS(pThis, 0) + 1)));2295 Log(("hda:ra: CVI(pos:%d, len:%d) cbTransferred: %d\n", pBdle->u32BdleCviPos, pBdle->u32BdleCviLen, cbTransferred));2296 2297 if (pcbRead)2298 *pcbRead = cbTransferred;2299 2300 return rc;2301 }2302 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2303 2187 2304 2188 static int hdaWriteAudio(PHDASTATE pThis, PHDASTREAMTRANSFERDESC pStreamDesc, uint32_t u32CblLimit, … … 2330 2214 pBdle->u64BdleCviAddr + pBdle->u32BdleCviPos, 2331 2215 pBdle->au8HdaBuffer + pBdle->cbUnderFifoW, cb2Copy); 2332 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 2216 2217 #ifdef VBOX_WITH_STATISTICS 2333 2218 STAM_COUNTER_ADD(&pThis->StatBytesRead, cb2Copy); 2334 2219 #endif … … 2339 2224 if (cb2Copy + pBdle->cbUnderFifoW >= hdaFifoWToSz(pThis, pStreamDesc)) 2340 2225 { 2341 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2342 2226 uint32_t cbWritten; 2343 2227 cbWrittenMin = UINT32_MAX; … … 2363 2247 if (cbWrittenMin == UINT32_MAX) 2364 2248 cbWrittenMin = 0; 2365 #else2366 cbWrittenMin = AUD_write (pThis->pCodec->SwVoiceOut, pBdle->au8HdaBuffer, cb2Copy + pBdle->cbUnderFifoW);2367 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2368 2249 2369 2250 hdaBackendWriteTransferReported(pBdle, cb2Copy, cbWrittenMin, &cbTransferred, pcbAvail); … … 2437 2318 } 2438 2319 2439 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2440 2320 static DECLCALLBACK(int) hdaOpenIn(PHDASTATE pThis, 2441 2321 const char *pszName, PDMAUDIORECSOURCE enmRecSource, … … 2548 2428 return rc; 2549 2429 } 2550 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */ 2551 2552 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 2430 2553 2431 static DECLCALLBACK(void) hdaTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 2554 2432 { … … 2629 2507 2630 2508 LogFlowFunc(("pThis=%p, cbAvail=%RU32\n", pThis, cbAvail)); 2631 #else2632 static DECLCALLBACK(int) hdaTransfer(PHDACODEC pCodec, ENMSOUNDSOURCE enmSrc, uint32_t cbAvail)2633 {2634 AssertPtrReturn(pCodec, VERR_INVALID_POINTER);2635 PHDASTATE pThis = pCodec->pHDAState;2636 AssertPtrReturn(pThis, VERR_INVALID_POINTER);2637 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2638 2509 2639 2510 uint8_t u8Strm; … … 2690 2561 LogFunc(("CBL=%RU32, LPIB=%RU32\n", StreamDesc.u32Cbl, *StreamDesc.pu32Lpib)); 2691 2562 2692 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2693 2563 PAUDMIXSINK pSink; 2694 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2695 2564 uint32_t cbWritten = 0; 2696 2565 switch (enmSrc) 2697 2566 { 2698 2567 case PI_INDEX: 2699 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2700 2568 pSink = pThis->pSinkLineIn; 2701 2569 rc = hdaReadAudio(pThis, pSink, &StreamDesc, u32CblLimit, &cbAvail, &cbWritten); 2702 #else2703 rc = hdaReadAudio(pThis, &StreamDesc, u32CblLimit, (uint32_t *)&cbAvail, &cbWritten);2704 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2705 2570 break; 2706 2571 case PO_INDEX: 2707 2572 rc = hdaWriteAudio(pThis, &StreamDesc, u32CblLimit, &cbAvail, &cbWritten); 2708 2573 break; 2709 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 2710 # ifdef VBOX_WITH_HDA_MIC_IN 2574 #ifdef VBOX_WITH_HDA_MIC_IN 2711 2575 case MC_INDEX: 2712 2576 pSink = pThis->pSinkMicIn; 2713 2577 rc = hdaReadAudio(pThis, pSink, &StreamDesc, u32CblLimit, &cbAvail, &cbWritten); 2714 2578 break; 2715 # endif 2716 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */ 2579 #endif 2717 2580 default: 2718 2581 AssertMsgFailed(("Unsupported source index %ld\n", enmSrc)); … … 3247 3110 bool fEnableOut = RT_BOOL(SDCTL(pThis, 4) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN)); 3248 3111 3249 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER3250 3112 PHDADRIVER pDrv; 3251 3113 RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node) … … 3261 3123 break; 3262 3124 } 3263 #else3264 AUD_set_active_in(pThis->pCodec->SwVoiceIn, SDCTL(pThis, 0) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));3265 AUD_set_active_out(pThis->pCodec->SwVoiceOut, SDCTL(pThis, 4) & HDA_REG_FIELD_FLAG_MASK(SDCTL, RUN));3266 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */3267 3125 3268 3126 if (RT_SUCCESS(rc)) … … 3508 3366 LogFunc(("Resetting ...\n")); 3509 3367 3510 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER3511 3368 /* Stop any audio currently playing. */ 3512 3369 PHDADRIVER pDrv; … … 3520 3377 /* Ditto. */ 3521 3378 } 3522 #else3523 AUD_set_active_in(pThis->pCodec->SwVoiceIn, false);3524 AUD_set_active_out(pThis->pCodec->SwVoiceOut, false);3525 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */3526 3379 3527 3380 pThis->cbCorbBuf = 256 * sizeof(uint32_t); … … 3577 3430 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 3578 3431 3579 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER3580 3432 PHDADRIVER pDrv; 3581 3433 while (!RTListIsEmpty(&pThis->lstDrv)) … … 3592 3444 pThis->pMixer = NULL; 3593 3445 } 3594 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */3595 3446 3596 3447 if (pThis->pCodec) … … 3612 3463 } 3613 3464 3614 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER3615 3465 /** 3616 3466 * Attach command. … … 3692 3542 LogFlowFuncEnter(); 3693 3543 } 3694 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */3695 3544 3696 3545 /** … … 3835 3684 return rc; 3836 3685 3837 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER3838 3686 RTListInit(&pThis->lstDrv); 3839 3687 … … 3892 3740 3893 3741 LogFunc(("cLUNs=%RU8, rc=%Rrc\n", uLUN, rc)); 3894 #else3895 /*3896 * Attach driver.3897 */3898 rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "Audio Driver Port");3899 if (rc == VERR_PDM_NO_ATTACHED_DRIVER)3900 Log(("hda: No attached driver!\n"));3901 else if (RT_FAILURE(rc))3902 {3903 AssertMsgFailed(("Failed to attach Intel HDA LUN #0! rc=%Rrc\n", rc));3904 return rc;3905 }3906 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */3907 3742 3908 3743 if (RT_SUCCESS(rc)) … … 3913 3748 return PDMDEV_SET_ERROR(pDevIns, VERR_NO_MEMORY, N_("Out of memory allocating HDA codec state")); 3914 3749 3915 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER3916 3750 /* Audio driver callbacks for multiplexing. */ 3917 3751 pThis->pCodec->pfnCloseIn = hdaCloseIn; … … 3919 3753 pThis->pCodec->pfnOpenIn = hdaOpenIn; 3920 3754 pThis->pCodec->pfnOpenOut = hdaOpenOut; 3755 pThis->pCodec->pfnReset = hdaCodecReset; 3921 3756 pThis->pCodec->pfnSetVolume = hdaSetVolume; 3922 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */3923 3757 3924 3758 pThis->pCodec->pHDAState = pThis; /* Assign HDA controller state to codec. */ … … 3935 3769 PCIDevSetSubSystemVendorId(&pThis->PciDev, pThis->pCodec->u16VendorId); /* 2c ro - intel.) */ 3936 3770 PCIDevSetSubSystemId( &pThis->PciDev, pThis->pCodec->u16DeviceId); /* 2e ro. */ 3937 3938 #ifndef VBOX_WITH_PDM_AUDIO_DRIVER3939 pThis->pCodec->pfnTransfer = hdaTransfer;3940 #endif3941 pThis->pCodec->pfnReset = hdaCodecReset;3942 3771 } 3943 3772 … … 4022 3851 } 4023 3852 4024 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER4025 3853 if (RT_SUCCESS(rc)) 4026 3854 { … … 4055 3883 } 4056 3884 # endif 4057 4058 #endif4059 3885 4060 3886 LogFlowFuncLeaveRC(rc); -
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 -
trunk/src/VBox/Devices/Audio/DevIchHdaCodec.h
r55404 r56085 110 110 const uint8_t u8DacLineOut; 111 111 #endif 112 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER113 112 /* Callbacks to the HDA controller, mostly used for multiplexing to the various host backends. */ 114 113 DECLR3CALLBACKMEMBER(void, pfnCloseIn, (PHDASTATE pThis, PDMAUDIORECSOURCE enmRecSource)); … … 117 116 DECLR3CALLBACKMEMBER(int, pfnOpenOut, (PHDASTATE pThis, const char *pszName, PPDMAUDIOSTREAMCFG pCfg)); 118 117 DECLR3CALLBACKMEMBER(int, pfnSetVolume, (PHDASTATE pThis, ENMSOUNDSOURCE enmSource, bool fMute, uint8_t uVolLeft, uint8_t uVolRight)); 119 #else120 QEMUSoundCard card;121 /** PCM in */122 SWVoiceIn *SwVoiceIn;123 /** PCM out */124 SWVoiceOut *SwVoiceOut;125 /* Callbacks for host driver backends. */126 DECLR3CALLBACKMEMBER(int, pfnTransfer, (PHDACODEC pCodec, ENMSOUNDSOURCE enmSource, uint32_t cbAvail));127 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */128 118 /* Callbacks by codec implementation. */ 129 119 DECLR3CALLBACKMEMBER(int, pfnLookup, (PHDACODEC pThis, uint32_t verb, PPFNHDACODECVERBPROCESSOR)); … … 139 129 int hdaCodecSaveState(PHDACODEC pThis, PSSMHANDLE pSSM); 140 130 int hdaCodecLoadState(PHDACODEC pThis, PSSMHANDLE pSSM, uint32_t uVersion); 141 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER142 131 int hdaCodecOpenStream(PHDACODEC pThis, PDMAUDIORECSOURCE enmRecSource, PDMAUDIOSTREAMCFG *pAudioSettings); 143 #else144 int hdaCodecOpenVoice(PHDACODEC pThis, ENMSOUNDSOURCE enmSoundSource, audsettings_t *pAudioSettings);145 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */146 132 147 133 #define HDA_SSM_VERSION 4 -
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r55920 r56085 60 60 #include <VBox/log.h> 61 61 62 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 63 # include "AudioMixer.h" 64 #else 65 extern "C" { 66 #include "audio.h" 67 } 68 #endif 62 #include "AudioMixer.h" 69 63 70 64 /** Current saved state version. */ … … 83 77 static const char e3[] = "COPYRIGHT (C) CREATIVE TECHNOLOGY LTD, 1992."; 84 78 85 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER86 79 typedef struct SB16OUTPUTSTREAM 87 80 { … … 124 117 SB16OUTPUTSTREAM Out; 125 118 } SB16DRIVER, *PSB16DRIVER; 126 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */127 119 128 120 typedef struct SB16STATE … … 150 142 int fmt_signed; 151 143 int fmt_bits; 152 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER153 144 PDMAUDIOFMT fmt; 154 #else155 audfmt_e fmt;156 QEMUSoundCard card;157 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */158 145 int dma_auto; 159 146 int block_size; … … 191 178 int align; 192 179 193 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER194 180 RTLISTANCHOR lstDrv; 195 181 /** The device' software mixer. */ … … 201 187 /** Timer ticks for handling the LUN drivers. */ 202 188 uint64_t uTicksIO; 203 #else204 uint32_t audio_free;205 SWVoiceOut *voice;206 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */207 189 208 190 PTMTIMER pTimerIRQ; … … 216 198 } SB16STATE, *PSB16STATE; 217 199 218 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER219 200 static int sb16OpenOut(PSB16STATE pThis, PPDMAUDIOSTREAMCFG pCfg); 220 #endif 221 222 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 201 223 202 /** 224 203 * Attach command. … … 292 271 return rc; 293 272 } 294 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */ 295 296 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 273 297 274 static void sb16AudioCallback(void *pvContext, uint32_t cbFree); 298 #else299 static void sb16AudioCallback(void *pvContext, int cbFree);300 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */301 275 302 276 static int magic_of_irq(int irq) … … 368 342 LogFlowFunc(("hold %d high %d dma %d\n", hold, pThis->use_hdma, dma)); 369 343 370 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER371 344 PSB16DRIVER pDrv; 372 # endif373 345 if (hold) 374 346 { 375 347 PDMDevHlpDMASetDREQ (pThis->pDevIns, dma, 1); 376 348 PDMDevHlpDMASchedule (pThis->pDevIns); 377 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER378 349 RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node) 379 350 pDrv->pConnector->pfnEnableOut(pDrv->pConnector, 380 351 pDrv->Out.pStrmOut, true /* fEnable */); 381 # else382 AUD_set_active_out (pThis->voice, 1);383 # endif384 352 } 385 353 else 386 354 { 387 355 PDMDevHlpDMASetDREQ (pThis->pDevIns, dma, 0); 388 # ifdef VBOX_WITH_PDM_AUDIO_DRIVER389 356 RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node) 390 357 pDrv->pConnector->pfnEnableOut(pDrv->pConnector, 391 358 pDrv->Out.pStrmOut, false /* fEnable */); 392 # else393 AUD_set_active_out (pThis->voice, 0);394 # endif395 359 } 396 360 } … … 410 374 if (pThis->freq > 0) 411 375 { 412 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER413 376 PDMAUDIOSTREAMCFG streamCfg; 414 377 streamCfg.uHz = pThis->freq; … … 419 382 int rc = sb16OpenOut(pThis, &streamCfg); 420 383 AssertRC(rc); 421 #else422 pThis->audio_free = 0;423 424 audsettings_t streamCfg;425 streamCfg.freq = pThis->freq;426 streamCfg.nchannels = 1 << pThis->fmt_stereo;427 streamCfg.fmt = pThis->fmt;428 streamCfg.endianness = 0;429 pThis->voice = AUD_open_out (430 &pThis->card,431 pThis->voice,432 "sb16",433 pThis,434 sb16AudioCallback,435 &streamCfg436 );437 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */438 384 } 439 385 … … 563 509 if (pThis->freq) 564 510 { 565 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER566 511 PDMAUDIOSTREAMCFG streamCfg; 567 512 streamCfg.uHz = pThis->freq; … … 572 517 int rc = sb16OpenOut(pThis, &streamCfg); 573 518 AssertRC(rc); 574 #else575 pThis->audio_free = 0;576 577 audsettings_t streamCfg;578 streamCfg.freq = pThis->freq;579 streamCfg.nchannels = 1 << pThis->fmt_stereo;580 streamCfg.fmt = pThis->fmt;581 streamCfg.endianness = 0;582 pThis->voice = AUD_open_out (583 &pThis->card,584 pThis->voice,585 "sb16",586 pThis,587 sb16AudioCallback,588 &streamCfg589 );590 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */591 519 } 592 520 … … 1070 998 static void sb16SetMasterVolume(PSB16STATE pThis) 1071 999 { 1072 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1073 1000 /* There's no mute switch, only volume controls. */ 1074 1001 uint8_t lvol = sb16MixRegToVol(pThis, 0x30); … … 1076 1003 PDMAUDIOVOLUME vol = { false, lvol, rvol }; 1077 1004 AudioMixerSetMasterVolume(pThis->pMixer, &vol); 1078 #else1079 int mute = 0;1080 uint8_t lvol = pThis->mixer_regs[0x30];1081 uint8_t rvol = pThis->mixer_regs[0x31];1082 1083 AUD_set_volume(AUD_MIXER_VOLUME, &mute, &lvol, &rvol);1084 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1085 1005 } 1086 1006 1087 1007 static void sb16SetPcmOutVolume(PSB16STATE pThis) 1088 1008 { 1089 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1090 1009 /* There's no mute switch, only volume controls. */ 1091 1010 uint8_t lvol = sb16MixRegToVol(pThis, 0x32); … … 1093 1012 PDMAUDIOVOLUME vol = { false, lvol, rvol }; 1094 1013 AudioMixerSetSinkVolume(pThis->pSinkOutput, &vol); 1095 #else1096 int mute = 0;1097 uint8_t lvol = pThis->mixer_regs[0x32];1098 uint8_t rvol = pThis->mixer_regs[0x33];1099 1100 AUD_set_volume(AUD_MIXER_PCM, &mute, &lvol, &rvol);1101 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1102 1014 } 1103 1015 … … 1109 1021 pThis->fmt_stereo = 0; 1110 1022 1111 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1112 1023 PDMAUDIOSTREAMCFG streamCfg; 1113 1024 streamCfg.uHz = pThis->freq; … … 1116 1027 streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS; 1117 1028 1118 int rc = sb16OpenOut(pThis, &streamCfg); 1119 AssertRC(rc); 1120 #else 1121 audsettings_t streamCfg; 1122 streamCfg.freq = pThis->freq; 1123 streamCfg.nchannels = 1; 1124 streamCfg.fmt = AUD_FMT_U8; 1125 streamCfg.endianness = 0; 1126 pThis->voice = AUD_open_out ( 1127 &pThis->card, 1128 pThis->voice, 1129 "sb16", 1130 pThis, 1131 sb16AudioCallback, 1132 &streamCfg 1133 ); 1134 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */ 1135 1136 /* Not sure about that... */ 1137 /* AUD_set_active_out (pThis->voice, 1); */ 1029 int rc2 = sb16OpenOut(pThis, &streamCfg); 1030 AssertRC(rc2); 1138 1031 } 1139 1032 … … 1338 1231 static void sb16MixerReset(PSB16STATE pThis) 1339 1232 { 1340 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1341 1233 PSB16DRIVER pDrv; 1342 1234 … … 1351 1243 pThis->pMixer = NULL; 1352 1244 } 1353 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */ 1354 1355 memset (pThis->mixer_regs, 0xff, 0x7f); 1356 memset (pThis->mixer_regs + 0x83, 0xff, sizeof (pThis->mixer_regs) - 0x83); 1245 1246 memset(pThis->mixer_regs, 0xff, 0x7f); 1247 memset(pThis->mixer_regs + 0x83, 0xff, sizeof (pThis->mixer_regs) - 0x83); 1357 1248 1358 1249 pThis->mixer_regs[0x02] = 4; /* master volume 3bits */ … … 1382 1273 pThis->mixer_regs[i] = 0x80; 1383 1274 1384 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1385 1275 int rc2 = AudioMixerCreate("SB16 Mixer", 0 /* uFlags */, &pThis->pMixer); 1386 1276 if (RT_SUCCESS(rc2)) … … 1401 1291 AssertRC(rc2); 1402 1292 } 1403 #endif1404 1293 1405 1294 /* Update the master (mixer) and PCM out volumes. */ … … 1417 1306 } 1418 1307 1419 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 1420 uint32_t popcount (uint32_t u) /** @todo r=andy WTF? */ 1308 uint32_t popcount(uint32_t u) /** @todo r=andy WTF? */ 1421 1309 { 1422 1310 u = ((u&0x55555555) + ((u>>1)&0x55555555)); … … 1428 1316 } 1429 1317 1430 uint32_t lsbindex (uint32_t u) 1431 { 1432 return popcount ((u & -(int32_t)u) - 1); 1433 } 1434 #endif 1318 uint32_t lsbindex(uint32_t u) 1319 { 1320 return popcount((u & -(int32_t)u) - 1); 1321 } 1435 1322 1436 1323 /* Convert SB16 to SB Pro mixer volume (left). */ … … 1656 1543 AssertMsgRC(rc, ("DMAReadMemory -> %Rrc\n", rc)); 1657 1544 1658 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1659 1545 uint32_t cbWritten; 1660 1546 … … 1673 1559 LogFlowFunc(("\tLUN#%RU8: cbWritten=%RU32, cWrittenMin=%RU32\n", pDrv->uLUN, cbWritten, cbWrittenMin)); 1674 1560 } 1675 #else1676 cbWrittenMin = AUD_write (pThis->voice, tmpbuf, cbToRead);1677 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1678 1561 1679 1562 Assert(cbToWrite >= cbWrittenMin); … … 1704 1587 pThis->left_till_irq = pThis->block_size; 1705 1588 1706 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1707 1589 PSB16DRIVER pDrv; 1708 1590 … … 1728 1610 return dma_pos; 1729 1611 } 1730 #else1731 if (pThis->voice)1732 {1733 free = pThis->audio_free & ~pThis->align;1734 if ((free <= 0) || !dma_len)1735 return dma_pos;1736 }1737 else1738 free = dma_len;1739 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1740 1612 1741 1613 copy = free; … … 1786 1658 } 1787 1659 1788 #ifndef VBOX_WITH_PDM_AUDIO_DRIVER1789 static void sb16AudioCallback(void *pvContext, int cbFree)1790 {1791 PSB16STATE pState = (PSB16STATE)pvContext;1792 AssertPtrReturnVoid(pState);1793 pState->audio_free = cbFree;1794 /* New space available, see if we can transfer more. There is no cyclic DMA timer in VBox. */1795 PDMDevHlpDMASchedule(pState->pDevIns);1796 }1797 #else1798 1660 static DECLCALLBACK(void) sb16TimerIO(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser) 1799 1661 { … … 1862 1724 TMTimerSet(pThis->pTimerIO, TMTimerGet(pThis->pTimerIO) + pThis->uTicksIO); 1863 1725 } 1864 #endif /* !VBOX_WITH_PDM_AUDIO_DRIVER */1865 1726 1866 1727 static void sb16Save(PSSMHANDLE pSSM, PSB16STATE pThis) … … 1970 1831 SSMR3GetMem(pSSM, pThis->mixer_regs, 256); 1971 1832 1972 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1973 1833 #if 0 1974 1834 PSB16DRIVER pDrv; … … 1982 1842 } 1983 1843 #endif 1984 #else1985 AUD_close_out (&pThis->card, pThis->voice);1986 pThis->voice = NULL;1987 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */1988 1844 1989 1845 if (pThis->dma_running) … … 1991 1847 if (pThis->freq) 1992 1848 { 1993 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER1994 1849 PDMAUDIOSTREAMCFG streamCfg; 1995 1850 streamCfg.uHz = pThis->freq; … … 2000 1855 int rc = sb16OpenOut(pThis, &streamCfg); 2001 1856 AssertRC(rc); 2002 #else2003 pThis->audio_free = 0;2004 2005 audsettings_t as;2006 as.freq = pThis->freq;2007 as.nchannels = 1 << pThis->fmt_stereo;2008 as.fmt = pThis->fmt;2009 as.endianness = 0;2010 pThis->voice = AUD_open_out (2011 &pThis->card,2012 pThis->voice,2013 "sb16",2014 pThis,2015 sb16AudioCallback,2016 &as2017 );2018 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2019 1857 } 2020 1858 … … 2096 1934 } 2097 1935 2098 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2099 1936 static int sb16OpenOut(PSB16STATE pThis, PPDMAUDIOSTREAMCFG pCfg) 2100 1937 { … … 2142 1979 return rc; 2143 1980 } 2144 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2145 1981 2146 1982 /** … … 2196 2032 PSB16STATE pThis = PDMINS_2_DATA(pDevIns, PSB16STATE); 2197 2033 2198 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2199 2034 PSB16DRIVER pDrv; 2200 2035 … … 2209 2044 pThis->pMixer = NULL; 2210 2045 } 2211 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2212 2046 2213 2047 return VINF_SUCCESS; … … 2284 2118 pThis->csp_regs[9] = 0xf8; 2285 2119 2286 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2287 2120 RTListInit(&pThis->lstDrv); 2288 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2289 2121 2290 2122 sb16MixerReset(pThis); … … 2323 2155 * Attach driver. 2324 2156 */ 2325 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER2326 2157 uint8_t uLUN; 2327 2158 for (uLUN = 0; uLUN < UINT8_MAX; uLUN) … … 2340 2171 2341 2172 LogFunc(("cLUNs=%RU8, rc=%Rrc\n", uLUN, rc)); 2342 #else 2343 rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "Audio Driver Port"); 2344 if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 2345 LogFunc(("SB16: No attached driver!\n")); 2346 else if (RT_FAILURE(rc)) 2347 { 2348 AssertMsgFailed(("Failed to attach SB16 LUN #0! rc=%Rrc\n", rc)); 2349 return rc; 2350 } 2351 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */ 2352 2353 #ifdef VBOX_WITH_PDM_AUDIO_DRIVER 2173 2354 2174 sb16ResetLegacy(pThis); 2355 2175 … … 2409 2229 } 2410 2230 } 2411 #else2412 AUD_register_card("sb16", &pThis->card);2413 sb16ResetLegacy(pThis);2414 2415 if (!AUD_is_host_voice_out_ok(pThis->voice))2416 {2417 LogRel (("SB16: WARNING: Unable to open PCM OUT!\n"));2418 AUD_close_out (&pThis->card, pThis->voice);2419 pThis->voice = NULL;2420 2421 AUD_init_null();2422 2423 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",2424 N_("No audio devices could be opened. Selecting the NULL audio backend "2425 "with the consequence that no sound is audible"));2426 }2427 #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */2428 2231 2429 2232 return VINF_SUCCESS; -
trunk/src/VBox/Devices/Audio/testcase/Makefile.kmk
r53442 r56085 5 5 6 6 # 7 # Copyright (C) 2014 Oracle Corporation7 # Copyright (C) 2014-2015 Oracle Corporation 8 8 # 9 9 # This file is part of VirtualBox Open Source Edition (OSE), as … … 19 19 include $(KBUILD_PATH)/subheader.kmk 20 20 21 if defined(VBOX_WITH_TESTCASES) && !defined(VBOX_ONLY_ADDITIONS) && !defined(VBOX_ONLY_SDK) && defined(VBOX_WITH_PDM_AUDIO_DRIVER)21 if defined(VBOX_WITH_TESTCASES) && !defined(VBOX_ONLY_ADDITIONS) && !defined(VBOX_ONLY_SDK) 22 22 23 23 PROGRAMS += tstAudioMixBuffer … … 25 25 26 26 tstAudioMixBuffer_TEMPLATE = VBOXR3TSTEXE 27 tstAudioMixBuffer_DEFS += TESTCASE VBOX_WITH_PDM_AUDIO_DRIVER27 tstAudioMixBuffer_DEFS += TESTCASE 28 28 tstAudioMixBuffer_SOURCES = \ 29 29 tstAudioMixBuffer.cpp \
Note:
See TracChangeset
for help on using the changeset viewer.