VirtualBox

Changeset 7525 in vbox


Ignore:
Timestamp:
Mar 25, 2008 10:17:49 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
28995
Message:

Solaris host audio: fixes and integrated into Main. Needs more
rigorous testing, only tested locally here. BFE still acts weird.

Location:
trunk/src/VBox
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/audio.c

    r6598 r7525  
    18701870        case AUD_MIXER_PCM:
    18711871            name = "PCM_OUT";
     1872            vol  = &pcm_out_volume;
    18721873            break;
    18731874        case AUD_MIXER_LINE_IN:
  • trunk/src/VBox/Devices/Audio/solaudio.c

    r7454 r7525  
    5959} conf =
    6060{
    61     INIT_FIELD (cbBuffer =) 8912,
     61    INIT_FIELD (cbBuffer =) 4352,
    6262};
    6363
     
    123123
    124124
    125 static char *solaudio_getdevice ()
     125static char *solaudio_getdevice (void)
    126126{
    127127    /* This is for multiple audio devices where env. var determines current one,
    128128     * otherwise else we fallback to default.
    129129     */
    130     char *pszAudioDev = RTEnvGet("AUDIODEV");
     130    const char *pszAudioDev = RTEnvGet("AUDIODEV");
    131131    if (pszAudioDev)
    132132        return RTStrDup(pszAudioDev);
     
    141141    int AudioCtl;
    142142    struct stat FileStat;
    143     const char *pszAudioDev = NULL;
    144     const char *pszAudioCtl = "/dev/audioctl";
     143    char *pszAudioDev = NULL;
     144    char *pszAudioCtl = NULL;
    145145    audio_info_t AudioInfo;
    146146
     
    149149    {
    150150        LogRel(("solaudio: solaudio_getdevice() failed to return a valid device.\n"));
    151         goto err;
     151        return -1;
    152152    }
    153153
     
    155155    {
    156156        LogRel(("solaudio: failed to stat %s\n", pszAudioDev));
    157         goto err;
     157        goto err2;
    158158    }
    159159
     
    161161    {
    162162        LogRel(("solaudio: invalid mode for %s\n", pszAudioDev));
    163         goto err;
     163        goto err2;
    164164    }
    165165
     
    168168    {
    169169        LogRel(("solaudio: failed to open %s\n", pszAudioDev));
    170         goto err;
    171     }
    172 
     170        goto err2;
     171    }
     172
     173    RTStrAPrintf(&pszAudioCtl, "%sctl", pszAudioDev);
    173174    AudioCtl = open(pszAudioCtl, O_WRONLY | O_NONBLOCK);
    174175    if (AudioCtl < 0)
     
    193194    AudioInfo.play.buffer_size = info->play.buffer_size;
    194195    AudioInfo.play.gain = AUDIO_MAX_GAIN;
    195     AudioInfo.play.balance = AUDIO_MID_BALANCE;
    196196    if (ioctl(AudioDev, AUDIO_SETINFO, &AudioInfo) < 0)
    197197    {
     
    204204    *pfd = AudioDev;
    205205    *pctl_fd = AudioCtl;
     206    RTStrFree(pszAudioDev);
     207    RTStrFree(pszAudioCtl);
    206208    return 0;
    207209
    208210err:
     211    RTStrFree(pszAudioCtl);
     212err2:
    209213    RTStrFree(pszAudioDev);
    210214    return -1;
     
    224228    AudioInfo.play.channels = as->nchannels;
    225229    AudioInfo.play.precision = aud_to_solfmt(as->fmt);
     230#if 0
     231    /* Not really needed. */
     232    int cbPerSample = (AudioInfo.play.channels * AudioInfo.play.precision) / 8;
     233    int cbPerSecond = cbPerSample * AudioInfo.play.sample_rate;
     234    AudioInfo.play.buffer_size = cbPerSecond > 131072 ? conf.cbBuffer : conf.cbBuffer / 2;
     235#endif
    226236    AudioInfo.play.buffer_size = conf.cbBuffer;
     237
    227238    if (as->fmt == AUD_FMT_U8)
    228239        AudioInfo.play.encoding = AUDIO_ENCODING_LINEAR8;
     
    260271static void solaudio_stop (solaudioVoiceOut *sol)
    261272{
     273    audio_info_t AudioInfo;
    262274    LogFlow(("solaudio: stop\n"));
    263275    if (sol->AudioDev < 0 || sol->AudioCtl < 0)
     
    269281    if (ioctl(sol->AudioCtl, I_SETSIG, 0) < 0)
    270282    {
    271         LogRel(("solaudio: failed to stop signalling\n"));
     283        Log(("solaudio: failed to stop signalling\n"));
    272284        return;
    273285    }
     
    275287    if (ioctl(sol->AudioDev, I_FLUSH, FLUSHW) < 0)
    276288    {
    277         Log(("solaudio: failed to drop unplayed buffers\n"));
     289        LogRel(("solaudio: failed to drop unplayed buffers\n"));
    278290        return;
    279291    }
     292
     293    AUDIO_INITINFO(&AudioInfo);
     294    AudioInfo.play.samples = 0;
     295    AudioInfo.play.pause = 0;
     296    AudioInfo.play.eof = 0;
     297    AudioInfo.play.error = 0;
     298    sol->cBuffersPlayed = 0;
     299    if (ioctl(sol->AudioDev, AUDIO_SETINFO, &AudioInfo) < 0)
     300    {
     301        LogRel(("solaudio: AUDIO_SETINFO failed during stop.\n"));
     302        return;
     303    }
     304}
     305
     306
     307static void solaudio_fini_out (HWVoiceOut *hw)
     308{
     309    solaudioVoiceOut *sol = (solaudioVoiceOut *) hw;
     310    solaudio_stop (sol);
    280311
    281312    close(sol->AudioDev);
     
    283314    close(sol->AudioCtl);
    284315    sol->AudioCtl = -1;
    285     sol->cBuffersPlayed = 0;
    286316    if (sol->pPCMBuf)
    287317    {
     
    289319        sol->pPCMBuf = NULL;
    290320    }
    291 }
    292 
    293 
    294 static void solaudio_fini_out (HWVoiceOut *hw)
    295 {
    296     solaudioVoiceOut *sol = (solaudioVoiceOut *) hw;
    297     solaudio_stop (sol);
     321
    298322    LogFlow(("solaudio: fini_out done\n"));
    299323}
     
    312336    }
    313337
    314     cbBuffer = AudioInfo.play.buffer_size * (2 + AudioInfo.play.eof - sol->cBuffersPlayed);
     338    if (sol->cBuffersPlayed - AudioInfo.play.eof <= 2)
     339        cbBuffer = AudioInfo.play.buffer_size;
    315340
    316341    LogFlow(("avail: eof=%d samples=%d bufsize=%d bufplayed=%d avail=%d\n", AudioInfo.play.eof, AudioInfo.play.samples,
     
    328353
    329354    WaitTimeSpec.tv_sec = 0;
    330     WaitTimeSpec.tv_nsec = 1000000;
    331 
    332     while (AudioInfo.play.eof < pSol->cBuffersPlayed - 2)
     355    WaitTimeSpec.tv_nsec = 100000000;
     356
     357    while (AudioInfo.play.eof + 10 < pSol->cBuffersPlayed)
    333358    {
    334359        nanosleep(&WaitTimeSpec, NULL);
     
    373398            break;
    374399
     400        /* Increment eof marker for synchronous buffer processed */
     401        write (pSol->AudioDev, NULL, 0);
     402        pSol->cBuffersPlayed++;
     403
    375404        hw->rpos   = (hw->rpos + csToWrite) % hw->samples;
    376405        csSamples -= csToWrite;
    377406    }
    378     /* Increment eof marker for synchronous buffer processed */
    379     write (pSol->AudioDev, NULL, 0);
    380     pSol->cBuffersPlayed++;
    381407    return csDecr;
    382408}
     
    392418            /* reset the eof marker and samples markers */
    393419            audio_info_t AudioInfo;
     420            LogFlow(("solaudio: voice_enable\n"));
    394421            AUDIO_INITINFO(&AudioInfo);
    395422            ioctl(pSol->AudioDev, AUDIO_GETINFO, &AudioInfo);
     
    400427
    401428            audio_pcm_info_clear_buf(&hw->info, pSol->pPCMBuf, hw->samples);
    402             LogFlow(("solaudio: voice_enable\n"));
    403429            break;
    404430        }
     
    429455static void solaudio_audio_fini (void *opaque)
    430456{
    431     (void) opaque;
    432 }
    433 
    434 
    435 static struct audio_pcm_ops solaudio_pcm_ops = {
     457    NOREF(opaque);
     458}
     459
     460
     461static struct audio_pcm_ops solaudio_pcm_ops =
     462{
    436463    solaudio_init_out,
    437464    solaudio_fini_out,
     
    447474};
    448475
    449 static struct audio_option solaudio_options[] = {
     476static struct audio_option solaudio_options[] =
     477{
    450478    {"BUFFER_SIZE", AUD_OPT_INT, &conf.cbBuffer,
    451479     "Size of the buffer in bytes", NULL, 0},
     
    453481};
    454482
    455 struct audio_driver solaudio_audio_driver = {
     483struct audio_driver solaudio_audio_driver =
     484{
    456485    INIT_FIELD (name           = ) "solaudio",
    457486    INIT_FIELD (descr          = ) "SolarisAudio http://sun.com",
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r7466 r7525  
    234234#else
    235235    bool fWin = false;
     236#endif
     237#ifdef RT_OS_SOLARIS
     238    bool fSolaris = true;
     239#else
     240    bool fSolaris = false;
    236241#endif
    237242#ifdef RT_OS_DARWIN
     
    371376#endif
    372377        }
     378        if (fSolaris)
     379        {
     380            RTPrintf(                        "|solaudio");
     381        }
    373382        if (fLinux)
    374383        {
     
    14351444                        pszDrv = "CoreAudio";
    14361445                    break;
     1446                case AudioDriverType_SolAudio:
     1447                    if (details == VMINFO_MACHINEREADABLE)
     1448                        pszDrv = "solaudio";
     1449                    else
     1450                        pszDrv = "SolAudio";
     1451                    break;
    14371452                default:
    14381453                    if (details == VMINFO_MACHINEREADABLE)
     
    49234938# endif
    49244939#endif /* !RT_OS_LINUX */
     4940#ifdef RT_OS_SOLARIS
     4941                else if (strcmp(audio, "solaudio") == 0)
     4942                {
     4943                    CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_SolAudio));
     4944                    CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
     4945                }
     4946
     4947#endif /* !RT_OS_SOLARIS */
    49254948#ifdef RT_OS_DARWIN
    49264949                else if (strcmp(audio, "coreaudio") == 0)
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r7466 r7525  
    23532353    audioDriverTypes [KAudioDriverType_WinMM] =
    23542354        tr ("Windows Multimedia", "AudioDriverType");
     2355    audioDriverTypes [KAudioDriverType_SolAudio] =
     2356        tr ("Solaris Audio", "AudioDriverType");
    23552357    audioDriverTypes [KAudioDriverType_OSS] =
    23562358        tr ("OSS Audio Driver", "AudioDriverType");
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMSettingsDlg.ui.h

    r7466 r7525  
    863863    cbAudioDriver->insertItem (vboxGlobal().toString (KAudioDriverType_WinMM));
    864864# endif
     865#elif defined Q_OS_SOLARIS
     866    cbAudioDriver->insertItem (vboxGlobal().toString (KAudioDriverType_SolAudio));
    865867#elif defined Q_OS_LINUX
    866868    cbAudioDriver->insertItem (vboxGlobal().toString (KAudioDriverType_OSS));
  • trunk/src/VBox/Main/AudioAdapterImpl.cpp

    r7466 r7525  
    232232            case AudioDriverType_DirectSound:
    233233#endif /* RT_OS_WINDOWS */
     234#ifdef RT_OS_SOLARIS
     235            case AudioDriverType_SolAudio:
     236#endif
    234237#ifdef RT_OS_LINUX
    235238            case AudioDriverType_OSS:
     
    383386        mData->mAudioDriver = AudioDriverType_DirectSound;
    384387#endif // RT_OS_WINDOWS
     388#ifdef RT_OS_SOLARIS
     389    else if (strcmp (driver, "SolAudio") == 0)
     390        mData->mAudioDriver = AudioDriverType_SolAudio;
     391#endif // RT_OS_SOLARIS
    385392#ifdef RT_OS_LINUX
    386393    else if (strcmp (driver, "OSS") == 0)
     
    473480            }
    474481#endif /* RT_OS_WINDOWS */
     482#ifdef RT_OS_SOLARIS
     483            case AudioDriverType_SolAudio:
     484            {
     485                driverStr = "SolAudio";
     486                break;
     487            }
     488#endif
    475489#ifdef RT_OS_LINUX
    476490            case AudioDriverType_ALSA:
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r7466 r7525  
    14041404            }
    14051405#endif /* RT_OS_WINDOWS */
     1406#ifdef RT_OS_SOLARIS
     1407            case AudioDriverType_SolAudio:
     1408            {
     1409                rc = CFGMR3InsertString(pCfg, "AudioDriver", "solaudio");               RC_CHECK();           
     1410                break;
     1411            }
     1412#endif
    14061413#ifdef RT_OS_LINUX
    14071414            case AudioDriverType_OSS:
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r7466 r7525  
    92529252    <const name="MMPM"          value="6"/>
    92539253    <const name="Pulse"         value="7"/>
    9254     <const name="ESD"           value="8"/>
     9254    <const name="SolAudio"      value="8"/>
    92559255  </enum>
    92569256
  • trunk/src/VBox/Main/xml/SettingsConverter.xsl

    r7492 r7525  
    306306        <xsl:when test="@driver='winmm'">WinMM</xsl:when>
    307307        <xsl:when test="@driver='dsound'">DirectSound</xsl:when>
    308         <xsl:when test="@driver='esd'">ESD</xsl:when>
     308        <xsl:when test="@driver='solaudio'">SolAudio</xsl:when>
    309309        <xsl:when test="@driver='mmpm'">MMPM</xsl:when>
    310310        <xsl:otherwise>
  • trunk/src/VBox/Main/xml/VirtualBox-settings-solaris.xsd

    r7466 r7525  
    9999          <xsd:restriction base="xsd:token">
    100100            <xsd:enumeration value="Null"/>
    101             <xsd:enumeration value="ESD"/>
     101            <xsd:enumeration value="SolAudio"/>
    102102          </xsd:restriction>
    103103        </xsd:simpleType>
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette