Ignore:
Timestamp:
Oct 8, 2008, 7:52:36 PM (17 years ago)
Author:
rjerant
Message:

Port OSS32_WaveGetHwPtr() to Uniaud32 1.1.4 from Uniaud32 2.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk/lib32/sound.c

    r345 r390  
    206206int ALSAToOSSDataType(ULONG ALSADataType)
    207207{
    208     switch(ALSADataType) 
     208    switch(ALSADataType)
    209209    {
    210210    case SNDRV_PCM_FORMAT_S8:
     
    341341
    342342    //query wave in & out caps
    343     for(i=0;i<2;i++) 
     343    for(i=0;i<2;i++)
    344344    {
    345345        PWAVE_CAPS pWaveCaps = (i == 0) ? &pDevCaps->waveOutCaps : &pDevCaps->waveInCaps;
    346346
    347347        ret = OSS32_WaveOpen(deviceid, (i == 0) ? OSS32_STREAM_WAVEOUT : OSS32_STREAM_WAVEIN, &streamid, 0, 0);
    348         if(ret != OSSERR_SUCCESS) 
     348        if(ret != OSSERR_SUCCESS)
    349349        {
    350350            printk("OSS32_QueryDevCaps: wave open error %i\n", ret);
     
    360360        //set operation to non-blocking
    361361        pHandle->file.f_flags = O_NONBLOCK;
    362    
     362
    363363        ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_INFO, (ULONG)pcminfo);
    364364        if(ret != 0) {
     
    375375        printk("Device name: %s\n", pDevCaps->szDeviceName);
    376376        pWaveCaps->nrStreams = pcminfo->subdevices_count;
    377    
     377
    378378        //get all hardware parameters
    379379        _snd_pcm_hw_params_any(params);
     
    415415        mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
    416416        format_mask = mask->bits[0];
    417         for(fmt=0;fmt<32;fmt++) 
     417        for(fmt=0;fmt<32;fmt++)
    418418        {
    419             if(format_mask & (1 << fmt)) 
     419            if(format_mask & (1 << fmt))
    420420            {
    421421                int f = ALSAToOSSDataType(fmt);
     
    430430    }
    431431    //Check support for MPU401, FM & Wavetable MIDI
    432     if(OSS32_MidiOpen(deviceid, OSS32_STREAM_MPU401_MIDIOUT, &streamid) == OSSERR_SUCCESS) 
     432    if(OSS32_MidiOpen(deviceid, OSS32_STREAM_MPU401_MIDIOUT, &streamid) == OSSERR_SUCCESS)
    433433    {
    434434        pDevCaps->ulCaps |= OSS32_CAPS_MPU401_PLAYBACK;
     
    436436        streamid = 0;
    437437    }
    438     if(OSS32_MidiOpen(deviceid, OSS32_STREAM_MPU401_MIDIIN, &streamid) == OSSERR_SUCCESS) 
     438    if(OSS32_MidiOpen(deviceid, OSS32_STREAM_MPU401_MIDIIN, &streamid) == OSSERR_SUCCESS)
    439439    {
    440440        pDevCaps->ulCaps |= OSS32_CAPS_MPU401_CAPTURE;
     
    442442        streamid = 0;
    443443    }
    444     if(OSS32_MidiOpen(deviceid, OSS32_STREAM_FM_MIDIOUT, &streamid) == OSSERR_SUCCESS) 
     444    if(OSS32_MidiOpen(deviceid, OSS32_STREAM_FM_MIDIOUT, &streamid) == OSSERR_SUCCESS)
    445445    {
    446446        pDevCaps->ulCaps |= OSS32_CAPS_FMSYNTH_PLAYBACK;
     
    448448        streamid = 0;
    449449    }
    450     if(OSS32_MidiOpen(deviceid, OSS32_STREAM_WAVETABLE_MIDIOUT, &streamid) == OSSERR_SUCCESS) 
     450    if(OSS32_MidiOpen(deviceid, OSS32_STREAM_WAVETABLE_MIDIOUT, &streamid) == OSSERR_SUCCESS)
    451451    {
    452452        pDevCaps->ulCaps |= OSS32_CAPS_WAVETABLE_PLAYBACK;
     
    986986    _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_RATE,
    987987                          pHwParams->ulSampleRate, 0);
    988     _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 
     988    _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
    989989                          periodsize, 0);
    990     _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 
     990    _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_PERIOD_BYTES,
    991991                          periodbytes, 0);
    992     _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_PERIODS, 
     992    _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_PERIODS,
    993993                          nrperiods, 0);
    994     _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 
     994    _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
    995995                          periodsize*nrperiods, 0);
    996     _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 
     996    _snd_pcm_hw_param_set(&params, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
    997997                          periodbytes*nrperiods, 0);
    998998//#ifdef DEBUG_PK
     
    10321032
    10331033    //set silence threshold (all sizes in frames) (only needed for playback)
    1034     if(pHandle->file.f_mode == FMODE_WRITE) 
     1034    if(pHandle->file.f_mode == FMODE_WRITE)
    10351035    {
    10361036        swparams.avail_min         = periodsize;
     
    11191119#endif
    11201120
    1121     if (size == 0) 
     1121    if (size == 0)
    11221122    {
    11231123#ifdef DEBUG_PK
     
    11391139        // size should be aligned to channels number * samplesize  //PS+++ what is it and why?!?!?!
    11401140        j = 10;            // 10 try if error
    1141         while (size && j && ret) 
     1141        while (size && j && ret)
    11421142        {
    11431143               for (i=0; i < 1000; i++)
     
    11471147                     if ((status.state != SNDRV_PCM_STATE_XRUN ) && samples_to_bytes(status.avail) )
    11481148                         break;
    1149                      if (i > 998) 
     1149                     if (i > 998)
    11501150                     {
    11511151//                         printk("timeout stat %x avail:%d hw:%d app:%d\n",status.state,samples_to_bytes(status.avail),samples_to_bytes(status.hw_ptr), samples_to_bytes(status.appl_ptr));
     
    11621162               ret = pHandle->file.f_op->write(&pHandle->file, (char *)buffer, size, &pHandle->file.f_pos);
    11631163
    1164                if (ret < 0 ) 
     1164               if (ret < 0 )
    11651165               {  // We have any error, don't try more
    11661166                  j--;
     
    11681168                      ret1 = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0);
    11691169//                  printk("Error ret:%i ret1:%i trans: %d need %d tot:%d\n",ret,ret1,transferred, size,size1);
    1170                   continue; 
     1170                  continue;
    11711171               }
    11721172               if (ret == 0)  continue;
     
    12661266//******************************************************************************
    12671267//******************************************************************************
     1268OSSRET OSS32_WaveGetHwPtr(ULONG streamid, ULONG *pPosition)
     1269{
     1270    soundhandle        *pHandle = (soundhandle *)streamid;
     1271    struct snd_pcm_status    status;
     1272    int                 ret;
     1273    ULONG               delta;
     1274
     1275    if(pHandle == NULL || pHandle->magic != MAGIC_WAVE_ALSA32) {
     1276        DebugInt3();
     1277        return OSSERR_INVALID_STREAMID;
     1278    }
     1279    if(pPosition == NULL) {
     1280        DebugInt3();
     1281        return OSSERR_INVALID_PARAMETER;
     1282    }
     1283
     1284    //set operation to non-blocking
     1285    pHandle->file.f_flags = O_NONBLOCK;
     1286
     1287    //Get the status of the stream
     1288    ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_STATUS, (ULONG)__Stack32ToFlat(&status));
     1289
     1290    if(ret) {
     1291        DebugInt3();
     1292        return UNIXToOSSError(ret);
     1293    }
     1294
     1295    dprintf(("OSS32_WaveGetHwPtr: %lx", samples_to_bytes(status.appl_ptr)));
     1296    *pPosition = samples_to_bytes(status.appl_ptr);  //return new hardware position
     1297    return OSSERR_SUCCESS;
     1298}
     1299
     1300//******************************************************************************
     1301//******************************************************************************
    12681302OSSRET OSS32_WaveSetVolume(OSSSTREAMID streamid, ULONG volume)
    12691303{
Note: See TracChangeset for help on using the changeset viewer.