47 |
|
|
48 |
hr = glue (IFACE, _Unlock) (buf, p1, blen1, p2, blen2); |
hr = glue (IFACE, _Unlock) (buf, p1, blen1, p2, blen2); |
49 |
if (FAILED (hr)) { |
if (FAILED (hr)) { |
50 |
dsound_logerr (hr, "Can not unlock " NAME "\n"); |
dsound_logerr (hr, "Could not unlock " NAME "\n"); |
51 |
return -1; |
return -1; |
52 |
} |
} |
53 |
|
|
93 |
#ifndef DSBTYPE_IN |
#ifndef DSBTYPE_IN |
94 |
if (hr == DSERR_BUFFERLOST) { |
if (hr == DSERR_BUFFERLOST) { |
95 |
if (glue (dsound_restore_, TYPE) (buf)) { |
if (glue (dsound_restore_, TYPE) (buf)) { |
96 |
dsound_logerr (hr, "Can not lock " NAME "\n"); |
dsound_logerr (hr, "Could not lock " NAME "\n"); |
97 |
goto fail; |
goto fail; |
98 |
} |
} |
99 |
continue; |
continue; |
100 |
} |
} |
101 |
#endif |
#endif |
102 |
dsound_logerr (hr, "Can not lock " NAME "\n"); |
dsound_logerr (hr, "Could not lock " NAME "\n"); |
103 |
goto fail; |
goto fail; |
104 |
} |
} |
105 |
|
|
158 |
if (ds->FIELD) { |
if (ds->FIELD) { |
159 |
hr = glue (IFACE, _Stop) (ds->FIELD); |
hr = glue (IFACE, _Stop) (ds->FIELD); |
160 |
if (FAILED (hr)) { |
if (FAILED (hr)) { |
161 |
dsound_logerr (hr, "Can not stop " NAME "\n"); |
dsound_logerr (hr, "Could not stop " NAME "\n"); |
162 |
} |
} |
163 |
|
|
164 |
hr = glue (IFACE, _Release) (ds->FIELD); |
hr = glue (IFACE, _Release) (ds->FIELD); |
165 |
if (FAILED (hr)) { |
if (FAILED (hr)) { |
166 |
dsound_logerr (hr, "Can not release " NAME "\n"); |
dsound_logerr (hr, "Could not release " NAME "\n"); |
167 |
} |
} |
168 |
ds->FIELD = NULL; |
ds->FIELD = NULL; |
169 |
} |
} |
170 |
} |
} |
171 |
|
|
172 |
#ifdef DSBTYPE_IN |
#ifdef DSBTYPE_IN |
173 |
static int dsound_init_in ( |
static int dsound_init_in (HWVoiceIn *hw, audsettings_t *as) |
|
HWVoiceIn *hw, |
|
|
int freq, |
|
|
int nchannels, |
|
|
audfmt_e fmt |
|
|
) |
|
174 |
#else |
#else |
175 |
static int dsound_init_out ( |
static int dsound_init_out (HWVoiceOut *hw, audsettings_t *as) |
|
HWVoiceOut *hw, |
|
|
int freq, |
|
|
int nchannels, |
|
|
audfmt_e fmt |
|
|
) |
|
176 |
#endif |
#endif |
177 |
{ |
{ |
178 |
int err; |
int err; |
179 |
HRESULT hr; |
HRESULT hr; |
180 |
dsound *s = &glob_dsound; |
dsound *s = &glob_dsound; |
181 |
WAVEFORMATEX wfx; |
WAVEFORMATEX wfx; |
182 |
struct full_fmt full_fmt; |
audsettings_t obt_as; |
183 |
#ifdef DSBTYPE_IN |
#ifdef DSBTYPE_IN |
184 |
const char *typ = "ADC"; |
const char *typ = "ADC"; |
185 |
DSoundVoiceIn *ds = (DSoundVoiceIn *) hw; |
DSoundVoiceIn *ds = (DSoundVoiceIn *) hw; |
192 |
DSBCAPS bc; |
DSBCAPS bc; |
193 |
#endif |
#endif |
194 |
|
|
195 |
full_fmt.freq = freq; |
err = waveformat_from_audio_settings (&wfx, as); |
|
full_fmt.nchannels = nchannels; |
|
|
full_fmt.fmt = fmt; |
|
|
err = waveformat_from_full_fmt (&wfx, &full_fmt); |
|
196 |
if (err) { |
if (err) { |
197 |
return -1; |
return -1; |
198 |
} |
} |
220 |
#endif |
#endif |
221 |
|
|
222 |
if (FAILED (hr)) { |
if (FAILED (hr)) { |
223 |
dsound_logerr2 (hr, typ, "Can not create " NAME "\n"); |
dsound_logerr2 (hr, typ, "Could not create " NAME "\n"); |
224 |
return -1; |
return -1; |
225 |
} |
} |
226 |
|
|
227 |
hr = glue (IFACE, _GetFormat) ( |
hr = glue (IFACE, _GetFormat) (ds->FIELD, &wfx, sizeof (wfx), NULL); |
|
ds->FIELD, |
|
|
&wfx, |
|
|
sizeof (wfx), |
|
|
NULL |
|
|
); |
|
228 |
if (FAILED (hr)) { |
if (FAILED (hr)) { |
229 |
dsound_logerr2 (hr, typ, "Can not get " NAME " format\n"); |
dsound_logerr2 (hr, typ, "Could not get " NAME " format\n"); |
230 |
goto fail0; |
goto fail0; |
231 |
} |
} |
232 |
|
|
240 |
|
|
241 |
hr = glue (IFACE, _GetCaps) (ds->FIELD, &bc); |
hr = glue (IFACE, _GetCaps) (ds->FIELD, &bc); |
242 |
if (FAILED (hr)) { |
if (FAILED (hr)) { |
243 |
dsound_logerr2 (hr, typ, "Can not get " NAME " format\n"); |
dsound_logerr2 (hr, typ, "Could not get " NAME " format\n"); |
244 |
goto fail0; |
goto fail0; |
245 |
} |
} |
246 |
|
|
247 |
err = waveformat_to_full_fmt (&wfx, &full_fmt); |
err = waveformat_to_audio_settings (&wfx, &obt_as); |
248 |
if (err) { |
if (err) { |
249 |
goto fail0; |
goto fail0; |
250 |
} |
} |
251 |
|
|
252 |
ds->first_time = 1; |
ds->first_time = 1; |
253 |
hw->bufsize = bc.dwBufferBytes; |
|
254 |
audio_pcm_init_info ( |
audio_pcm_init_info (&hw->info, &obt_as, audio_need_to_swap_endian (0)); |
255 |
&hw->info, |
|
256 |
full_fmt.freq, |
if (bc.dwBufferBytes & hw->info.align) { |
257 |
full_fmt.nchannels, |
dolog ( |
258 |
full_fmt.fmt, |
"GetCaps returned misaligned buffer size %ld, alignment %d\n", |
259 |
audio_need_to_swap_endian (0) |
bc.dwBufferBytes, hw->info.align + 1 |
260 |
); |
); |
261 |
|
} |
262 |
|
hw->samples = bc.dwBufferBytes >> hw->info.shift; |
263 |
|
|
264 |
#ifdef DEBUG_DSOUND |
#ifdef DEBUG_DSOUND |
265 |
dolog ("caps %ld, desc %ld\n", |
dolog ("caps %ld, desc %ld\n", |
266 |
bc.dwBufferBytes, bd.dwBufferBytes); |
bc.dwBufferBytes, bd.dwBufferBytes); |
267 |
|
|
268 |
dolog ("bufsize %d, freq %d, chan %d, fmt %d\n", |
dolog ("bufsize %d, freq %d, chan %d, fmt %d\n", |
269 |
hw->bufsize, full_fmt.freq, full_fmt.nchannels, full_fmt.fmt); |
hw->bufsize, settings.freq, settings.nchannels, settings.fmt); |
270 |
#endif |
#endif |
271 |
return 0; |
return 0; |
272 |
|
|