10 #ifdef SUPPORT_OS2AUDIO 38 #define MIX_BUFFER_EOS 1 42 static ULONG ulMCIBuffers;
44 static MCI_AMP_OPEN_PARMS maop;
45 static MCI_MIXSETUP_PARMS mmp;
46 static MCI_BUFFER_PARMS mbp;
47 static MCI_GENERIC_PARMS mgp = {0};
48 static MCI_MIX_BUFFER MixBuffers[NUM_BUFFERS];
49 static unsigned char *wave, *startwave, *endwave;
50 static ULONG sizewave;
52 static HEV dataplayed;
55 static void MciError(ULONG ulError)
57 unsigned char buffer[128];
58 unsigned char string[128];
61 rc = mciGetErrorString(ulError, buffer,
sizeof(buffer));
63 if (rc == MCIERR_SUCCESS)
64 sprintf(
string,
"MCI Error %d: %s",ULONG_LOWD(ulError),buffer);
66 sprintf(
string,
"MCI Error %d: Cannot query error message.",ULONG_LOWD(rc));
68 cerr <<
string << endl;
72 static LONG APIENTRY MyEvent(ULONG ulStatus, PMCI_MIX_BUFFER PlayedBuffer, ULONG ulFlags)
74 if(PlayedBuffer->ulFlags == MIX_BUFFER_EOS)
75 DosPostEventSem(dataplayed);
79 case MIX_STREAM_ERROR | MIX_WRITE_COMPLETE:
81 if ( ulStatus == ERROR_DEVICE_UNDERRUN)
83 mmp.pmixWrite( mmp.ulMixHandle,
88 case MIX_WRITE_COMPLETE:
93 if(wave + PlayedBuffer->ulBufferLength >= endwave)
95 PlayedBuffer->ulFlags = MIX_BUFFER_EOS;
96 PlayedBuffer->ulBufferLength = (ULONG) (endwave - wave);
98 memcpy(PlayedBuffer->pBuffer, wave, PlayedBuffer->ulBufferLength);
99 wave += PlayedBuffer->ulBufferLength;
101 mmp.pmixWrite( mmp.ulMixHandle,
121 endwave = startwave + sizewave;
125 memset (&maop, 0,
sizeof(maop));
127 maop.pszDeviceType = (PSZ) MAKEULONG(MCI_DEVTYPE_AUDIO_AMPMIX, DeviceID);
129 rc = mciSendCommand(0,
131 MCI_WAIT | MCI_OPEN_TYPE_ID | MCI_OPEN_SHAREABLE,
135 if (rc != MCIERR_SUCCESS)
143 memset(&mmp, 0,
sizeof(mmp));
145 mmp.ulBitsPerSample = 16;
146 mmp.ulFormatTag = MCI_WAVE_FORMAT_PCM;
151 mmp.ulFormatMode = MCI_PLAY;
152 mmp.ulDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO;
153 mmp.pmixEvent = MyEvent;
155 rc = mciSendCommand( maop.usDeviceID,
157 MCI_WAIT | MCI_MIXSETUP_INIT,
161 if ( rc != MCIERR_SUCCESS )
170 ulMCIBuffers = NUM_BUFFERS;
171 mbp.ulNumBuffers = ulMCIBuffers;
172 mbp.ulBufferSize = mmp.ulBufferSize;
173 memset(MixBuffers, 0,
sizeof(MixBuffers[0])*NUM_BUFFERS);
174 mbp.pBufList = MixBuffers;
176 rc = mciSendCommand( maop.usDeviceID,
178 MCI_WAIT | MCI_ALLOCATE_MEMORY,
182 if ( ULONG_LOWD(rc) != MCIERR_SUCCESS )
188 ulMCIBuffers = mbp.ulNumBuffers;
192 for(i = 0; i < ulMCIBuffers; i++)
196 MixBuffers[i].ulFlags = 0;
197 MixBuffers[i].ulBufferLength = mbp.ulBufferSize;
198 if(wave + MixBuffers[i].ulBufferLength >= endwave)
200 MixBuffers[i].ulFlags = MIX_BUFFER_EOS;
201 MixBuffers[i].ulBufferLength = (ULONG) (endwave - wave);
203 memcpy(MixBuffers[i].pBuffer, wave, MixBuffers[i].ulBufferLength);
204 wave += MixBuffers[i].ulBufferLength;
209 DosCreateEventSem(
NULL,&dataplayed,0,
FALSE);
212 rc = mmp.pmixWrite( mmp.ulMixHandle,
216 if ( rc != MCIERR_SUCCESS )
222 DosWaitEventSem(dataplayed, -1);
223 DosCloseEventSem(dataplayed);
225 rc = mciSendCommand( maop.usDeviceID,
227 MCI_WAIT | MCI_DEALLOCATE_MEMORY,
231 if ( rc != MCIERR_SUCCESS )
237 rc = mciSendCommand( maop.usDeviceID,
243 if ( rc != MCIERR_SUCCESS )
264 std::cerr <<
"OS/2 16bit realtime DART playback not supported." << std::endl;
A class for storing digital waveforms. The waveform is stored as an array of 16 bit shorts...
Utility IO Function header file.
ssize_t num_samples() const
return the number of samples in the waveform
const EST_SMatrix & values() const
int play_os2audio_wave(EST_Wave &inwave, EST_Option &al)
int sample_rate() const
return the sampling rate (frequency)
ssize_t num_channels() const
return the number of channels in the waveform