Changeset 390 for GPL/trunk/lib32/sound.c
- Timestamp:
- Oct 8, 2008, 7:52:36 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk/lib32/sound.c
r345 r390 206 206 int ALSAToOSSDataType(ULONG ALSADataType) 207 207 { 208 switch(ALSADataType) 208 switch(ALSADataType) 209 209 { 210 210 case SNDRV_PCM_FORMAT_S8: … … 341 341 342 342 //query wave in & out caps 343 for(i=0;i<2;i++) 343 for(i=0;i<2;i++) 344 344 { 345 345 PWAVE_CAPS pWaveCaps = (i == 0) ? &pDevCaps->waveOutCaps : &pDevCaps->waveInCaps; 346 346 347 347 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) 349 349 { 350 350 printk("OSS32_QueryDevCaps: wave open error %i\n", ret); … … 360 360 //set operation to non-blocking 361 361 pHandle->file.f_flags = O_NONBLOCK; 362 362 363 363 ret = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_INFO, (ULONG)pcminfo); 364 364 if(ret != 0) { … … 375 375 printk("Device name: %s\n", pDevCaps->szDeviceName); 376 376 pWaveCaps->nrStreams = pcminfo->subdevices_count; 377 377 378 378 //get all hardware parameters 379 379 _snd_pcm_hw_params_any(params); … … 415 415 mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 416 416 format_mask = mask->bits[0]; 417 for(fmt=0;fmt<32;fmt++) 417 for(fmt=0;fmt<32;fmt++) 418 418 { 419 if(format_mask & (1 << fmt)) 419 if(format_mask & (1 << fmt)) 420 420 { 421 421 int f = ALSAToOSSDataType(fmt); … … 430 430 } 431 431 //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) 433 433 { 434 434 pDevCaps->ulCaps |= OSS32_CAPS_MPU401_PLAYBACK; … … 436 436 streamid = 0; 437 437 } 438 if(OSS32_MidiOpen(deviceid, OSS32_STREAM_MPU401_MIDIIN, &streamid) == OSSERR_SUCCESS) 438 if(OSS32_MidiOpen(deviceid, OSS32_STREAM_MPU401_MIDIIN, &streamid) == OSSERR_SUCCESS) 439 439 { 440 440 pDevCaps->ulCaps |= OSS32_CAPS_MPU401_CAPTURE; … … 442 442 streamid = 0; 443 443 } 444 if(OSS32_MidiOpen(deviceid, OSS32_STREAM_FM_MIDIOUT, &streamid) == OSSERR_SUCCESS) 444 if(OSS32_MidiOpen(deviceid, OSS32_STREAM_FM_MIDIOUT, &streamid) == OSSERR_SUCCESS) 445 445 { 446 446 pDevCaps->ulCaps |= OSS32_CAPS_FMSYNTH_PLAYBACK; … … 448 448 streamid = 0; 449 449 } 450 if(OSS32_MidiOpen(deviceid, OSS32_STREAM_WAVETABLE_MIDIOUT, &streamid) == OSSERR_SUCCESS) 450 if(OSS32_MidiOpen(deviceid, OSS32_STREAM_WAVETABLE_MIDIOUT, &streamid) == OSSERR_SUCCESS) 451 451 { 452 452 pDevCaps->ulCaps |= OSS32_CAPS_WAVETABLE_PLAYBACK; … … 986 986 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_RATE, 987 987 pHwParams->ulSampleRate, 0); 988 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 988 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 989 989 periodsize, 0); 990 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 990 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 991 991 periodbytes, 0); 992 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_PERIODS, 992 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_PERIODS, 993 993 nrperiods, 0); 994 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 994 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 995 995 periodsize*nrperiods, 0); 996 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 996 _snd_pcm_hw_param_set(¶ms, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 997 997 periodbytes*nrperiods, 0); 998 998 //#ifdef DEBUG_PK … … 1032 1032 1033 1033 //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) 1035 1035 { 1036 1036 swparams.avail_min = periodsize; … … 1119 1119 #endif 1120 1120 1121 if (size == 0) 1121 if (size == 0) 1122 1122 { 1123 1123 #ifdef DEBUG_PK … … 1139 1139 // size should be aligned to channels number * samplesize //PS+++ what is it and why?!?!?! 1140 1140 j = 10; // 10 try if error 1141 while (size && j && ret) 1141 while (size && j && ret) 1142 1142 { 1143 1143 for (i=0; i < 1000; i++) … … 1147 1147 if ((status.state != SNDRV_PCM_STATE_XRUN ) && samples_to_bytes(status.avail) ) 1148 1148 break; 1149 if (i > 998) 1149 if (i > 998) 1150 1150 { 1151 1151 // 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)); … … 1162 1162 ret = pHandle->file.f_op->write(&pHandle->file, (char *)buffer, size, &pHandle->file.f_pos); 1163 1163 1164 if (ret < 0 ) 1164 if (ret < 0 ) 1165 1165 { // We have any error, don't try more 1166 1166 j--; … … 1168 1168 ret1 = pHandle->file.f_op->ioctl(&pHandle->inode, &pHandle->file, SNDRV_PCM_IOCTL_PREPARE, 0); 1169 1169 // printk("Error ret:%i ret1:%i trans: %d need %d tot:%d\n",ret,ret1,transferred, size,size1); 1170 continue; 1170 continue; 1171 1171 } 1172 1172 if (ret == 0) continue; … … 1266 1266 //****************************************************************************** 1267 1267 //****************************************************************************** 1268 OSSRET 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 //****************************************************************************** 1268 1302 OSSRET OSS32_WaveSetVolume(OSSSTREAMID streamid, ULONG volume) 1269 1303 {
Note:
See TracChangeset
for help on using the changeset viewer.