-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwinemultimedia_1.7.4_20131011.patch
6468 lines (6263 loc) · 212 KB
/
winemultimedia_1.7.4_20131011.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/configure b/configure
index 683043c..bf5e7f9 100755
--- a/configure
+++ b/configure
@@ -658,6 +658,8 @@ OSS4INCL
ALSALIBS
GSTREAMER_LIBS
GSTREAMER_CFLAGS
+PULSEINCL
+PULSELIBS
LIBGETTEXTPO
ZLIB
FREETYPE_LIBS
@@ -834,6 +836,7 @@ with_osmesa
with_oss
with_png
with_pthread
+with_pulse
with_sane
with_tiff
with_v4l
@@ -2044,6 +2047,7 @@ Optional Packages:
--without-oss do not use the OSS sound support
--without-png do not use PNG
--without-pthread do not use the pthread library
+ --without-pulse do not use PulseAudio sound support
--without-sane do not use SANE (scanner support)
--without-tiff do not use TIFF
--without-v4l do not use v4l1 (v4l support)
@@ -3273,6 +3277,12 @@ if test "${with_pthread+set}" = set; then :
fi
+# Check whether --with-pulse was given.
+if test "${with_pulse+set}" = set; then :
+ withval=$with_pulse;
+fi
+
+
# Check whether --with-sane was given.
if test "${with_sane+set}" = set; then :
withval=$with_sane;
@@ -11710,6 +11720,87 @@ esac
fi
fi
+PULSELIBS=""
+
+PULSEINCL=""
+
+if test "x$with_pulse" != "xno";
+then
+ ac_save_CPPFLAGS="$CPPFLAGS"
+ if test "$PKG_CONFIG" != "false";
+ then
+ ac_pulse_libs="`$PKG_CONFIG --libs libpulse 2>/dev/null`"
+ ac_pulse_cflags="`$PKG_CONFIG --cflags-only-I libpulse 2>/dev/null`"
+
+ CPPFLAGS="$CPPFLAGS $ac_pulse_cflags"
+ for ac_header in pulse/pulseaudio.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "pulse/pulseaudio.h" "ac_cv_header_pulse_pulseaudio_h" "$ac_includes_default"
+if test "x$ac_cv_header_pulse_pulseaudio_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_PULSE_PULSEAUDIO_H 1
+_ACEOF
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pa_stream_is_corked in -lpulse" >&5
+$as_echo_n "checking for pa_stream_is_corked in -lpulse... " >&6; }
+if ${ac_cv_lib_pulse_pa_stream_is_corked+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpulse $ac_pulse_libs $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pa_stream_is_corked ();
+int
+main ()
+{
+return pa_stream_is_corked ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_pulse_pa_stream_is_corked=yes
+else
+ ac_cv_lib_pulse_pa_stream_is_corked=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pulse_pa_stream_is_corked" >&5
+$as_echo "$ac_cv_lib_pulse_pa_stream_is_corked" >&6; }
+if test "x$ac_cv_lib_pulse_pa_stream_is_corked" = xyes; then :
+
+$as_echo "#define HAVE_PULSEAUDIO 1" >>confdefs.h
+
+ PULSELIBS="$ac_pulse_libs"
+ PULSEINCL="$ac_pulse_cflags"
+fi
+
+
+fi
+
+done
+
+ fi
+ CPPFLAGS="$ac_save_CPPFLAGS"
+fi
+if test "$ac_cv_lib_pulse_pa_stream_is_corked" != "yes"; then :
+ case "x$with_pulse" in
+ x) as_fn_append wine_warnings "|libpulse ${notice_platform}development files not found or too old, Pulse won't be supported." ;;
+ xno) ;;
+ *) as_fn_error $? "libpulse ${notice_platform}development files not found or too old, Pulse won't be supported.
+This is an error since --with-pulse was requested." "$LINENO" 5 ;;
+esac
+fi
+
if test "x$with_gstreamer" != "xno"
then
if test -n "$GSTREAMER_CFLAGS"; then :
@@ -12987,12 +13078,13 @@ fi
test -n "$ALSALIBS" || enable_winealsa_drv=${enable_winealsa_drv:-no}
test -n "$COREAUDIO" || enable_winecoreaudio_drv=${enable_winecoreaudio_drv:-no}
+test -n "$PULSELIBS" || enable_winepulse_drv=${enable_winepulse_drv:-no}
test "x$ac_cv_member_oss_sysinfo_numaudioengines" = xyes || enable_wineoss_drv=${enable_wineoss_drv:-no}
test "$ac_cv_header_linux_joystick_h" = "yes" || enable_winejoystick_drv=${enable_winejoystick_drv:-no}
-if test "x$ALSALIBS$COREAUDIO" = "x" -a \
+if test "x$ALSALIBS$COREAUDIO$PULSELIBS" = "x" -a \
"x$ac_cv_member_oss_sysinfo_numaudioengines" != xyes -a \
- "x$with_alsa$with_coreaudio$with_oss" != xnonono
+ "x$with_alsa$with_coreaudio$with_oss$with_pulse" != xnononono
then
as_fn_append wine_warnings "|No sound system was found. Windows applications will be silent."
fi
@@ -17205,6 +17297,7 @@ wine_fn_config_dll winemp3.acm enable_winemp3_acm
wine_fn_config_dll wineoss.drv enable_wineoss_drv
wine_fn_config_dll wineps.drv enable_wineps_drv po
wine_fn_config_dll wineps16.drv16 enable_win16
+wine_fn_config_dll winepulse.drv enable_winepulse_drv
wine_fn_config_dll wineqtdecoder enable_wineqtdecoder
wine_fn_config_dll winex11.drv enable_winex11_drv
wine_fn_config_dll wing.dll16 enable_win16
diff --git a/configure.ac b/configure.ac
index fc68e1d..4252e05 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,6 +67,7 @@ AC_ARG_WITH(oss, AS_HELP_STRING([--without-oss],[do not use the OSS sound
AC_ARG_WITH(png, AS_HELP_STRING([--without-png],[do not use PNG]))
AC_ARG_WITH(pthread, AS_HELP_STRING([--without-pthread],[do not use the pthread library]),
[if test "x$withval" = "xno"; then ac_cv_header_pthread_h=no; fi])
+AC_ARG_WITH(pulse, AC_HELP_STRING([--without-pulse],[do not use PulseAudio sound support]))
AC_ARG_WITH(sane, AS_HELP_STRING([--without-sane],[do not use SANE (scanner support)]))
AC_ARG_WITH(tiff, AS_HELP_STRING([--without-tiff],[do not use TIFF]))
AC_ARG_WITH(v4l, AS_HELP_STRING([--without-v4l],[do not use v4l1 (v4l support)]))
@@ -1540,6 +1541,30 @@ then
[GetText ${notice_platform}development files not found (or too old), po files can't be rebuilt.])
fi
+dnl **** Check for PulseAudio ****
+AC_SUBST(PULSELIBS,"")
+AC_SUBST(PULSEINCL,"")
+if test "x$with_pulse" != "xno";
+then
+ ac_save_CPPFLAGS="$CPPFLAGS"
+ if test "$PKG_CONFIG" != "false";
+ then
+ ac_pulse_libs="`$PKG_CONFIG --libs libpulse 2>/dev/null`"
+ ac_pulse_cflags="`$PKG_CONFIG --cflags-only-I libpulse 2>/dev/null`"
+
+ CPPFLAGS="$CPPFLAGS $ac_pulse_cflags"
+ AC_CHECK_HEADERS(pulse/pulseaudio.h,
+ [AC_CHECK_LIB(pulse, pa_stream_is_corked,
+ [AC_DEFINE(HAVE_PULSEAUDIO, 1, [Define if you have pulseaudio])
+ PULSELIBS="$ac_pulse_libs"
+ PULSEINCL="$ac_pulse_cflags"],,$ac_pulse_libs)
+ ])
+ fi
+ CPPFLAGS="$ac_save_CPPFLAGS"
+fi
+WINE_WARNING_WITH(pulse, [test "$ac_cv_lib_pulse_pa_stream_is_corked" != "yes"],
+ [libpulse ${notice_platform}development files not found or too old, Pulse won't be supported.])
+
dnl **** Check for gstreamer ****
if test "x$with_gstreamer" != "xno"
then
@@ -1758,13 +1783,14 @@ WINE_CHECK_SONAME(odbc,SQLConnect,,[AC_DEFINE_UNQUOTED(SONAME_LIBODBC,["libodbc.
dnl **** Disable unsupported winmm drivers ****
test -n "$ALSALIBS" || enable_winealsa_drv=${enable_winealsa_drv:-no}
test -n "$COREAUDIO" || enable_winecoreaudio_drv=${enable_winecoreaudio_drv:-no}
+test -n "$PULSELIBS" || enable_winepulse_drv=${enable_winepulse_drv:-no}
test "x$ac_cv_member_oss_sysinfo_numaudioengines" = xyes || enable_wineoss_drv=${enable_wineoss_drv:-no}
test "$ac_cv_header_linux_joystick_h" = "yes" || enable_winejoystick_drv=${enable_winejoystick_drv:-no}
dnl **** Check for any sound system ****
-if test "x$ALSALIBS$COREAUDIO" = "x" -a \
+if test "x$ALSALIBS$COREAUDIO$PULSELIBS" = "x" -a \
"x$ac_cv_member_oss_sysinfo_numaudioengines" != xyes -a \
- "x$with_alsa$with_coreaudio$with_oss" != xnonono
+ "x$with_alsa$with_coreaudio$with_oss$with_pulse" != xnononono
then
WINE_WARNING([No sound system was found. Windows applications will be silent.])
fi
@@ -3242,6 +3268,7 @@ WINE_CONFIG_DLL(winemp3.acm)
WINE_CONFIG_DLL(wineoss.drv)
WINE_CONFIG_DLL(wineps.drv,,[po])
WINE_CONFIG_DLL(wineps16.drv16,enable_win16)
+WINE_CONFIG_DLL(winepulse.drv)
WINE_CONFIG_DLL(wineqtdecoder)
WINE_CONFIG_DLL(winex11.drv)
WINE_CONFIG_DLL(wing.dll16,enable_win16)
diff --git a/dlls/avrt/main.c b/dlls/avrt/main.c
index 5c9ef4a..9f79e7d 100644
--- a/dlls/avrt/main.c
+++ b/dlls/avrt/main.c
@@ -80,6 +80,7 @@ HANDLE WINAPI AvSetMmThreadCharacteristicsW(LPCWSTR TaskName, LPDWORD TaskIndex)
SetLastError(ERROR_INVALID_HANDLE);
return NULL;
}
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL-1);
return (HANDLE)0x12345678;
}
diff --git a/dlls/dsound/capture.c b/dlls/dsound/capture.c
index 40f1702..0fe300c 100644
--- a/dlls/dsound/capture.c
+++ b/dlls/dsound/capture.c
@@ -51,7 +51,7 @@ typedef struct IDirectSoundCaptureBufferImpl
IDirectSoundCaptureBuffer8 IDirectSoundCaptureBuffer8_iface;
IDirectSoundNotify IDirectSoundNotify_iface;
LONG numIfaces; /* "in use interfaces" refcount */
- LONG ref, refn;
+ LONG ref, refn, has_dsc8;
/* IDirectSoundCaptureBuffer fields */
DirectSoundCaptureDevice *device;
DSCBUFFERDESC *pdscbd;
@@ -241,8 +241,9 @@ static HRESULT WINAPI IDirectSoundCaptureBufferImpl_QueryInterface(IDirectSoundC
*ppobj = NULL;
- if ( IsEqualGUID( &IID_IDirectSoundCaptureBuffer, riid ) ||
- IsEqualGUID( &IID_IDirectSoundCaptureBuffer8, riid ) ) {
+ if ( IsEqualIID( &IID_IUnknown, riid ) ||
+ IsEqualIID( &IID_IDirectSoundCaptureBuffer, riid ) ||
+ (This->has_dsc8 && IsEqualIID( &IID_IDirectSoundCaptureBuffer8, riid )) ) {
IDirectSoundCaptureBuffer8_AddRef(iface);
*ppobj = iface;
return S_OK;
@@ -1239,6 +1240,8 @@ static HRESULT WINAPI IDirectSoundCaptureImpl_CreateCaptureBuffer(IDirectSoundCa
if (hr != DS_OK)
WARN("IDirectSoundCaptureBufferImpl_Create failed\n");
+ else
+ This->device->capture_buffer->has_dsc8 = This->has_dsc8;
return hr;
}
diff --git a/dlls/dsound/dsound.c b/dlls/dsound/dsound.c
index 986168b..a6fc671 100644
--- a/dlls/dsound/dsound.c
+++ b/dlls/dsound/dsound.c
@@ -306,7 +306,6 @@ static HRESULT WINAPI IDirectSound8Impl_SetCooperativeLevel(IDirectSound8 *iface
{
IDirectSoundImpl *This = impl_from_IDirectSound8(iface);
DirectSoundDevice *device = This->device;
- DWORD oldlevel;
HRESULT hr = S_OK;
TRACE("(%p,%p,%s)\n", This, hwnd, dumpCooperativeLevel(level));
@@ -323,15 +322,10 @@ static HRESULT WINAPI IDirectSound8Impl_SetCooperativeLevel(IDirectSound8 *iface
RtlAcquireResourceExclusive(&device->buffer_list_lock, TRUE);
EnterCriticalSection(&device->mixlock);
- oldlevel = device->priolevel;
- device->priolevel = level;
- if ((level == DSSCL_WRITEPRIMARY) != (oldlevel == DSSCL_WRITEPRIMARY)) {
+ if ((level == DSSCL_WRITEPRIMARY) != (device->priolevel == DSSCL_WRITEPRIMARY))
hr = DSOUND_ReopenDevice(device, level == DSSCL_WRITEPRIMARY);
- if (FAILED(hr))
- device->priolevel = oldlevel;
- else
- DSOUND_PrimaryOpen(device);
- }
+ if (SUCCEEDED(hr))
+ device->priolevel = level;
LeaveCriticalSection(&device->mixlock);
RtlReleaseResource(&device->buffer_list_lock);
return hr;
@@ -602,7 +596,7 @@ static HRESULT DirectSoundDevice_Create(DirectSoundDevice ** ppDevice)
device->ref = 1;
device->priolevel = DSSCL_NORMAL;
- device->state = STATE_STOPPED;
+ device->stopped = 1;
device->speaker_config = DSSPEAKER_COMBINED(DSSPEAKER_STEREO, DSSPEAKER_GEOMETRY_WIDE);
/* 3D listener initial parameters */
@@ -623,28 +617,23 @@ static HRESULT DirectSoundDevice_Create(DirectSoundDevice ** ppDevice)
device->ds3dl.flRolloffFactor = DS3D_DEFAULTROLLOFFFACTOR;
device->ds3dl.flDopplerFactor = DS3D_DEFAULTDOPPLERFACTOR;
- device->prebuf = ds_snd_queue_max;
device->guid = GUID_NULL;
/* Set default wave format (may need it for waveOutOpen) */
- device->pwfx = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(WAVEFORMATEXTENSIBLE));
device->primary_pwfx = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(WAVEFORMATEXTENSIBLE));
- if (!device->pwfx || !device->primary_pwfx) {
+ if (!device->primary_pwfx) {
WARN("out of memory\n");
- HeapFree(GetProcessHeap(),0,device->primary_pwfx);
- HeapFree(GetProcessHeap(),0,device->pwfx);
HeapFree(GetProcessHeap(),0,device);
return DSERR_OUTOFMEMORY;
}
- device->pwfx->wFormatTag = WAVE_FORMAT_PCM;
- device->pwfx->nSamplesPerSec = 22050;
- device->pwfx->wBitsPerSample = 8;
- device->pwfx->nChannels = 2;
- device->pwfx->nBlockAlign = device->pwfx->wBitsPerSample * device->pwfx->nChannels / 8;
- device->pwfx->nAvgBytesPerSec = device->pwfx->nSamplesPerSec * device->pwfx->nBlockAlign;
- device->pwfx->cbSize = 0;
- memcpy(device->primary_pwfx, device->pwfx, sizeof(*device->pwfx));
+ device->primary_pwfx->wFormatTag = WAVE_FORMAT_PCM;
+ device->primary_pwfx->nSamplesPerSec = 22050;
+ device->primary_pwfx->wBitsPerSample = 8;
+ device->primary_pwfx->nChannels = 2;
+ device->primary_pwfx->nBlockAlign = 2;
+ device->primary_pwfx->nAvgBytesPerSec = 44100;
+ device->primary_pwfx->cbSize = 0;
InitializeCriticalSection(&(device->mixlock));
device->mixlock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": DirectSoundDevice.mixlock");
@@ -693,17 +682,17 @@ ULONG DirectSoundDevice_Release(DirectSoundDevice * device)
if (hr != DS_OK)
WARN("DSOUND_PrimaryDestroy failed\n");
- if(device->client)
+ if(device->client) {
+ IAudioClient_Stop(device->client);
IAudioClient_Release(device->client);
+ }
if(device->render)
IAudioRenderClient_Release(device->render);
- if(device->clock)
- IAudioClock_Release(device->clock);
if(device->volume)
IAudioStreamVolume_Release(device->volume);
HeapFree(GetProcessHeap(), 0, device->tmp_buffer);
- HeapFree(GetProcessHeap(), 0, device->mix_buffer);
+ HeapFree(GetProcessHeap(), 0, device->cp_buffer);
HeapFree(GetProcessHeap(), 0, device->buffer);
RtlDeleteResource(&device->buffer_list_lock);
device->mixlock.DebugInfo->Spare[0] = 0;
@@ -789,6 +778,7 @@ HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGUID lpcG
device->mmdevice = mmdevice;
device->guid = devGUID;
device->sleepev = CreateEventW(0, 0, 0, 0);
+ device->buflen = ds_hel_buflen;
hr = DSOUND_ReopenDevice(device, FALSE);
if (FAILED(hr))
@@ -844,12 +834,8 @@ HRESULT DirectSoundDevice_Initialize(DirectSoundDevice ** ppDevice, LPCGUID lpcG
ZeroMemory(&device->volpan, sizeof(device->volpan));
- hr = DSOUND_PrimaryCreate(device);
- if (hr == DS_OK) {
- device->thread = CreateThread(0, 0, DSOUND_mixthread, device, 0, 0);
- SetThreadPriority(device->thread, THREAD_PRIORITY_TIME_CRITICAL);
- } else
- WARN("DSOUND_PrimaryCreate failed: %08x\n", hr);
+ device->thread = CreateThread(0, 0, DSOUND_mixthread, device, 0, 0);
+ SetThreadPriority(device->thread, THREAD_PRIORITY_TIME_CRITICAL);
*ppDevice = device;
list_add_tail(&DSOUND_renderers, &device->entry);
diff --git a/dlls/dsound/dsound_convert.c b/dlls/dsound/dsound_convert.c
index d3d686a..d410d5e 100644
--- a/dlls/dsound/dsound_convert.c
+++ b/dlls/dsound/dsound_convert.c
@@ -222,27 +222,9 @@ static void norm32(float *src, INT *dst, unsigned len)
}
}
-static void normieee32(float *src, float *dst, unsigned len)
-{
- TRACE("%p - %p %d\n", src, dst, len);
- len /= 4;
- while (len--)
- {
- if(*src > 1)
- *dst = 1;
- else if(*src < -1)
- *dst = -1;
- else
- *dst = *src;
- ++dst;
- ++src;
- }
-}
-
const normfunc normfunctions[5] = {
(normfunc)norm8,
(normfunc)norm16,
(normfunc)norm24,
(normfunc)norm32,
- (normfunc)normieee32
};
diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c
index 7a16366..4f533b4 100644
--- a/dlls/dsound/dsound_main.c
+++ b/dlls/dsound/dsound_main.c
@@ -91,8 +91,7 @@ GUID DSOUND_capture_guids[MAXWAVEDRIVERS];
WCHAR wine_vxd_drv[] = { 'w','i','n','e','m','m','.','v','x','d', 0 };
/* All default settings, you most likely don't want to touch these, see wiki on UsefulRegistryKeys */
-int ds_hel_buflen = 32768 * 2;
-int ds_snd_queue_max = 10;
+int ds_hel_buflen = 32768;
static HINSTANCE instance;
/*
@@ -145,15 +144,10 @@ void setup_dsound_options(void)
if (!get_config_key( hkey, appkey, "HelBuflen", buffer, MAX_PATH ))
ds_hel_buflen = atoi(buffer);
- if (!get_config_key( hkey, appkey, "SndQueueMax", buffer, MAX_PATH ))
- ds_snd_queue_max = atoi(buffer);
-
-
if (appkey) RegCloseKey( appkey );
if (hkey) RegCloseKey( hkey );
TRACE("ds_hel_buflen = %d\n", ds_hel_buflen);
- TRACE("ds_snd_queue_max = %d\n", ds_snd_queue_max);
}
static const char * get_device_id(LPCGUID pGuid)
diff --git a/dlls/dsound/dsound_private.h b/dlls/dsound/dsound_private.h
index a8f5f42..b2342e3 100644
--- a/dlls/dsound/dsound_private.h
+++ b/dlls/dsound/dsound_private.h
@@ -31,7 +31,6 @@
#include "wine/list.h"
extern int ds_hel_buflen DECLSPEC_HIDDEN;
-extern int ds_snd_queue_max DECLSPEC_HIDDEN;
/*****************************************************************************
* Predeclare the interface implementation structures
@@ -70,18 +69,16 @@ struct DirectSoundDevice
DSCAPS drvcaps;
DWORD priolevel, sleeptime;
PWAVEFORMATEX pwfx, primary_pwfx;
- UINT playing_offs_bytes, in_mmdev_bytes, prebuf;
- DWORD fraglen;
LPBYTE buffer;
- DWORD writelead, buflen, state, playpos, mixpos;
+ DWORD writelead, buflen, aclen, fraglen, playpos, pad, stopped;
int nrofbuffers;
IDirectSoundBufferImpl** buffers;
RTL_RWLOCK buffer_list_lock;
CRITICAL_SECTION mixlock;
IDirectSoundBufferImpl *primary;
DWORD speaker_config;
- float *mix_buffer, *tmp_buffer;
- DWORD tmp_buffer_len, mix_buffer_len;
+ float *tmp_buffer, *cp_buffer;
+ DWORD tmp_buffer_len, mix_buffer_len, cp_buffer_len;
DSVOLUMEPAN volpan;
@@ -93,7 +90,6 @@ struct DirectSoundDevice
IMMDevice *mmdevice;
IAudioClient *client;
- IAudioClock *clock;
IAudioStreamVolume *volume;
IAudioRenderClient *render;
@@ -202,14 +198,11 @@ HRESULT IDirectSoundImpl_Create(IUnknown *outer_unk, REFIID riid, void **ppv, BO
/* primary.c */
-HRESULT DSOUND_PrimaryCreate(DirectSoundDevice *device) DECLSPEC_HIDDEN;
HRESULT DSOUND_PrimaryDestroy(DirectSoundDevice *device) DECLSPEC_HIDDEN;
HRESULT DSOUND_PrimaryPlay(DirectSoundDevice *device) DECLSPEC_HIDDEN;
HRESULT DSOUND_PrimaryStop(DirectSoundDevice *device) DECLSPEC_HIDDEN;
-HRESULT DSOUND_PrimaryGetPosition(DirectSoundDevice *device, LPDWORD playpos, LPDWORD writepos) DECLSPEC_HIDDEN;
LPWAVEFORMATEX DSOUND_CopyFormat(LPCWAVEFORMATEX wfex) DECLSPEC_HIDDEN;
HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave) DECLSPEC_HIDDEN;
-HRESULT DSOUND_PrimaryOpen(DirectSoundDevice *device) DECLSPEC_HIDDEN;
HRESULT primarybuffer_create(DirectSoundDevice *device, IDirectSoundBufferImpl **ppdsb,
const DSBUFFERDESC *dsbd) DECLSPEC_HIDDEN;
void primarybuffer_destroy(IDirectSoundBufferImpl *This) DECLSPEC_HIDDEN;
diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c
index 282808e..007180c 100644
--- a/dlls/dsound/mixer.c
+++ b/dlls/dsound/mixer.c
@@ -251,7 +251,8 @@ static UINT cp_fields_resample(IDirectSoundBufferImpl *dsb, UINT count, float *f
{
UINT i, channel;
UINT istride = dsb->pwfx->nBlockAlign;
- UINT ostride = dsb->device->pwfx->nChannels * sizeof(float);
+ DirectSoundDevice *dev = dsb->device;
+ UINT ostride = dev->pwfx->nChannels * sizeof(float);
float freqAdjust = dsb->freqAdjust;
float freqAcc_start = *freqAcc;
@@ -262,18 +263,29 @@ static UINT cp_fields_resample(IDirectSoundBufferImpl *dsb, UINT count, float *f
UINT fir_cachesize = (fir_len + dsbfirstep - 2) / dsbfirstep;
UINT required_input = max_ipos + fir_cachesize;
+ float *intermediate, *fir_copy, *itmp;
+
+ DWORD len = required_input * channels;
+ len += fir_cachesize;
+ len *= sizeof(float);
+
+ if (!dev->cp_buffer) {
+ dev->cp_buffer = HeapAlloc(GetProcessHeap(), 0, len);
+ dev->cp_buffer_len = len;
+ } else if (len > dev->cp_buffer_len) {
+ dev->cp_buffer = HeapReAlloc(GetProcessHeap(), 0, dev->cp_buffer, len);
+ dev->cp_buffer_len = len;
+ }
- float* intermediate = HeapAlloc(GetProcessHeap(), 0,
- sizeof(float) * required_input * channels);
+ fir_copy = dev->cp_buffer;
+ intermediate = fir_copy + fir_cachesize;
- float* fir_copy = HeapAlloc(GetProcessHeap(), 0,
- sizeof(float) * fir_cachesize);
/* Important: this buffer MUST be non-interleaved
* if you want -msse3 to have any effect.
* This is good for CPU cache effects, too.
*/
- float* itmp = intermediate;
+ itmp = intermediate;
for (channel = 0; channel < channels; channel++)
for (i = 0; i < required_input; i++)
*(itmp++) = get_current_sample(dsb,
@@ -309,9 +321,6 @@ static UINT cp_fields_resample(IDirectSoundBufferImpl *dsb, UINT count, float *f
freqAcc_end -= (int)freqAcc_end;
*freqAcc = freqAcc_end;
- HeapFree(GetProcessHeap(), 0, fir_copy);
- HeapFree(GetProcessHeap(), 0, intermediate);
-
return max_ipos;
}
@@ -427,7 +436,7 @@ static void DSOUND_MixerVol(const IDirectSoundBufferImpl *dsb, INT frames)
* writepos = position (offset) in device buffer to write at
* fraglen = number of bytes to mix
*/
-static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD fraglen)
+static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, float *mix_buffer, DWORD writepos, DWORD fraglen)
{
INT len = fraglen;
float *ibuf;
@@ -452,7 +461,7 @@ static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, DWORD writepos, DWO
/* Apply volume if needed */
DSOUND_MixerVol(dsb, frames);
- mixieee32(ibuf, dsb->device->mix_buffer, frames * dsb->device->pwfx->nChannels);
+ mixieee32(ibuf, mix_buffer, frames * dsb->device->pwfx->nChannels);
/* check for notification positions */
if (dsb->dsbd.dwFlags & DSBCAPS_CTRLPOSITIONNOTIFY &&
@@ -476,7 +485,7 @@ static DWORD DSOUND_MixInBuffer(IDirectSoundBufferImpl *dsb, DWORD writepos, DWO
*
* Returns: the number of bytes beyond the writepos that were mixed.
*/
-static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mixlen)
+static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, float *mix_buffer, DWORD writepos, DWORD mixlen)
{
DWORD primary_done = 0;
@@ -503,7 +512,7 @@ static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mi
/* First try to mix to the end of the buffer if possible
* Theoretically it would allow for better optimization
*/
- primary_done += DSOUND_MixInBuffer(dsb, writepos, mixlen);
+ primary_done += DSOUND_MixInBuffer(dsb, mix_buffer, writepos, mixlen);
TRACE("total mixed data=%d\n", primary_done);
@@ -518,14 +527,12 @@ static DWORD DSOUND_MixOne(IDirectSoundBufferImpl *dsb, DWORD writepos, DWORD mi
* writepos = the current safe-to-write position in the primary buffer
* mixlen = the maximum amount to mix into the primary buffer
* (beyond the current writepos)
- * recover = true if the sound device may have been reset and the write
- * position in the device buffer changed
* all_stopped = reports back if all buffers have stopped
*
* Returns: the length beyond the writepos that was mixed to.
*/
-static void DSOUND_MixToPrimary(const DirectSoundDevice *device, DWORD writepos, DWORD mixlen, BOOL recover, BOOL *all_stopped)
+static void DSOUND_MixToPrimary(const DirectSoundDevice *device, float *mix_buffer, DWORD writepos, DWORD mixlen, BOOL *all_stopped)
{
INT i;
IDirectSoundBufferImpl *dsb;
@@ -533,7 +540,7 @@ static void DSOUND_MixToPrimary(const DirectSoundDevice *device, DWORD writepos,
/* unless we find a running buffer, all have stopped */
*all_stopped = TRUE;
- TRACE("(%d,%d,%d)\n", writepos, mixlen, recover);
+ TRACE("(%d,%d)\n", writepos, mixlen);
for (i = 0; i < device->nrofbuffers; i++) {
dsb = device->buffers[i];
@@ -553,7 +560,7 @@ static void DSOUND_MixToPrimary(const DirectSoundDevice *device, DWORD writepos,
dsb->state = STATE_PLAYING;
/* mix next buffer into the main buffer */
- DSOUND_MixOne(dsb, writepos, mixlen);
+ DSOUND_MixOne(dsb, mix_buffer, writepos, mixlen);
*all_stopped = FALSE;
}
@@ -572,85 +579,29 @@ static void DSOUND_MixToPrimary(const DirectSoundDevice *device, DWORD writepos,
* Returns: None
*/
-static void DSOUND_WaveQueue(DirectSoundDevice *device, BOOL force)
+static void DSOUND_WaveQueue(DirectSoundDevice *device, LPBYTE pos, DWORD bytes)
{
- DWORD prebuf_frames, prebuf_bytes, read_offs_bytes;
BYTE *buffer;
HRESULT hr;
TRACE("(%p)\n", device);
- read_offs_bytes = (device->playing_offs_bytes + device->in_mmdev_bytes) % device->buflen;
-
- TRACE("read_offs_bytes = %u, playing_offs_bytes = %u, in_mmdev_bytes: %u, prebuf = %u\n",
- read_offs_bytes, device->playing_offs_bytes, device->in_mmdev_bytes, device->prebuf);
-
- if (!force)
- {
- if(device->mixpos < device->playing_offs_bytes)
- prebuf_bytes = device->mixpos + device->buflen - device->playing_offs_bytes;
- else
- prebuf_bytes = device->mixpos - device->playing_offs_bytes;
- }
- else
- /* buffer the maximum amount of frags */
- prebuf_bytes = device->prebuf * device->fraglen;
-
- /* limit to the queue we have left */
- if(device->in_mmdev_bytes + prebuf_bytes > device->prebuf * device->fraglen)
- prebuf_bytes = device->prebuf * device->fraglen - device->in_mmdev_bytes;
-
- TRACE("prebuf_bytes = %u\n", prebuf_bytes);
-
- if(!prebuf_bytes)
- return;
-
- device->in_mmdev_bytes += prebuf_bytes;
-
- if(prebuf_bytes + read_offs_bytes > device->buflen){
- DWORD chunk_bytes = device->buflen - read_offs_bytes;
- prebuf_frames = chunk_bytes / device->pwfx->nBlockAlign;
- prebuf_bytes -= chunk_bytes;
- }else{
- prebuf_frames = prebuf_bytes / device->pwfx->nBlockAlign;
- prebuf_bytes = 0;
- }
-
- hr = IAudioRenderClient_GetBuffer(device->render, prebuf_frames, &buffer);
+ hr = IAudioRenderClient_GetBuffer(device->render, bytes / device->pwfx->nBlockAlign, &buffer);
if(FAILED(hr)){
WARN("GetBuffer failed: %08x\n", hr);
return;
}
- memcpy(buffer, device->buffer + read_offs_bytes,
- prebuf_frames * device->pwfx->nBlockAlign);
+ memcpy(buffer, pos, bytes);
- hr = IAudioRenderClient_ReleaseBuffer(device->render, prebuf_frames, 0);
- if(FAILED(hr)){
- WARN("ReleaseBuffer failed: %08x\n", hr);
+ hr = IAudioRenderClient_ReleaseBuffer(device->render, bytes / device->pwfx->nBlockAlign, 0);
+ if(FAILED(hr)) {
+ ERR("ReleaseBuffer failed: %08x\n", hr);
+ IAudioRenderClient_ReleaseBuffer(device->render, 0, 0);
return;
}
- /* check if anything wrapped */
- if(prebuf_bytes > 0){
- prebuf_frames = prebuf_bytes / device->pwfx->nBlockAlign;
-
- hr = IAudioRenderClient_GetBuffer(device->render, prebuf_frames, &buffer);
- if(FAILED(hr)){
- WARN("GetBuffer failed: %08x\n", hr);
- return;
- }
-
- memcpy(buffer, device->buffer, prebuf_frames * device->pwfx->nBlockAlign);
-
- hr = IAudioRenderClient_ReleaseBuffer(device->render, prebuf_frames, 0);
- if(FAILED(hr)){
- WARN("ReleaseBuffer failed: %08x\n", hr);
- return;
- }
- }
-
- TRACE("in_mmdev_bytes now = %i\n", device->in_mmdev_bytes);
+ device->pad += bytes;
}
/**
@@ -663,12 +614,12 @@ static void DSOUND_WaveQueue(DirectSoundDevice *device, BOOL force)
* secondary->buffer (secondary format)
* =[Resample]=> device->tmp_buffer (float format)
* =[Volume]=> device->tmp_buffer (float format)
- * =[Mix]=> device->mix_buffer (float format)
- * =[Reformat]=> device->buffer (device format)
+ * =[Reformat]=> device->buffer (device format, skipped on float)
*/
static void DSOUND_PerformMix(DirectSoundDevice *device)
{
- UINT32 pad, to_mix_frags, to_mix_bytes;
+ UINT32 pad, maxq, writepos;
+ DWORD block;
HRESULT hr;
TRACE("(%p)\n", device);
@@ -682,161 +633,68 @@ static void DSOUND_PerformMix(DirectSoundDevice *device)
LeaveCriticalSection(&device->mixlock);
return;
}
-
- to_mix_frags = device->prebuf - (pad * device->pwfx->nBlockAlign + device->fraglen - 1) / device->fraglen;
-
- to_mix_bytes = to_mix_frags * device->fraglen;
-
- if(device->in_mmdev_bytes > 0){
- DWORD delta_bytes = min(to_mix_bytes, device->in_mmdev_bytes);
- device->in_mmdev_bytes -= delta_bytes;
- device->playing_offs_bytes += delta_bytes;
- device->playing_offs_bytes %= device->buflen;
+ block = device->pwfx->nBlockAlign;
+ pad *= block;
+ device->playpos += device->pad - pad;
+ device->playpos %= device->buflen;
+ device->pad = pad;
+
+ maxq = device->aclen - pad;
+ if(!maxq){
+ /* nothing to do! */
+ LeaveCriticalSection(&device->mixlock);
+ return;
}
+ if (maxq > device->fraglen * 3)
+ maxq = device->fraglen * 3;
+
+ writepos = (device->playpos + pad) % device->buflen;
if (device->priolevel != DSSCL_WRITEPRIMARY) {
- BOOL recover = FALSE, all_stopped = FALSE;
- DWORD playpos, writepos, writelead, maxq, prebuff_max, prebuff_left, size1, size2;
- LPVOID buf1, buf2;
+ BOOL all_stopped = FALSE;
int nfiller;
+ void *buffer = NULL;
/* the sound of silence */
nfiller = device->pwfx->wBitsPerSample == 8 ? 128 : 0;
- /* get the position in the primary buffer */
- if (DSOUND_PrimaryGetPosition(device, &playpos, &writepos) != 0){
- LeaveCriticalSection(&(device->mixlock));
- return;
- }
-
- TRACE("primary playpos=%d, writepos=%d, clrpos=%d, mixpos=%d, buflen=%d\n",
- playpos,writepos,device->playpos,device->mixpos,device->buflen);
- assert(device->playpos < device->buflen);
-
- /* calc maximum prebuff */
- prebuff_max = (device->prebuf * device->fraglen);
-
- /* check how close we are to an underrun. It occurs when the writepos overtakes the mixpos */
- prebuff_left = DSOUND_BufPtrDiff(device->buflen, device->mixpos, playpos);
- writelead = DSOUND_BufPtrDiff(device->buflen, writepos, playpos);
-
/* check for underrun. underrun occurs when the write position passes the mix position
* also wipe out just-played sound data */
- if((prebuff_left > prebuff_max) || (device->state == STATE_STOPPED) || (device->state == STATE_STARTING)){
- if (device->state == STATE_STOPPING || device->state == STATE_PLAYING)
- WARN("Probable buffer underrun\n");
- else TRACE("Buffer starting or buffer underrun\n");
-
- /* recover mixing for all buffers */
- recover = TRUE;
-
- /* reset mix position to write position */
- device->mixpos = writepos;
-
- ZeroMemory(device->buffer, device->buflen);
- } else if (playpos < device->playpos) {
- buf1 = device->buffer + device->playpos;
- buf2 = device->buffer;
- size1 = device->buflen - device->playpos;
- size2 = playpos;
- FillMemory(buf1, size1, nfiller);
- if (playpos && (!buf2 || !size2))
- FIXME("%d: (%d, %d)=>(%d, %d) There should be an additional buffer here!!\n", __LINE__, device->playpos, device->mixpos, playpos, writepos);
- FillMemory(buf2, size2, nfiller);
- } else {
- buf1 = device->buffer + device->playpos;
- buf2 = NULL;
- size1 = playpos - device->playpos;
- size2 = 0;
- FillMemory(buf1, size1, nfiller);
- }
- device->playpos = playpos;
-
- /* find the maximum we can prebuffer from current write position */
- maxq = (writelead < prebuff_max) ? (prebuff_max - writelead) : 0;
-
- TRACE("prebuff_left = %d, prebuff_max = %dx%d=%d, writelead=%d\n",
- prebuff_left, device->prebuf, device->fraglen, prebuff_max, writelead);
-
- ZeroMemory(device->mix_buffer, device->mix_buffer_len);
+ if (!pad)
+ WARN("Probable buffer underrun\n");
- /* do the mixing */
- DSOUND_MixToPrimary(device, writepos, maxq, recover, &all_stopped);
-
- if (maxq + writepos > device->buflen)
- {
- DWORD todo = device->buflen - writepos;
- DWORD offs_float = (todo / device->pwfx->nBlockAlign) * device->pwfx->nChannels;
- device->normfunction(device->mix_buffer, device->buffer + writepos, todo);
- device->normfunction(device->mix_buffer + offs_float, device->buffer, maxq - todo);
- }
- else
- device->normfunction(device->mix_buffer, device->buffer + writepos, maxq);
-
- /* update the mix position, taking wrap-around into account */
- device->mixpos = writepos + maxq;
- device->mixpos %= device->buflen;
-
- /* update prebuff left */
- prebuff_left = DSOUND_BufPtrDiff(device->buflen, device->mixpos, playpos);
-
- /* check if have a whole fragment */
- if (prebuff_left >= device->fraglen){
-
- /* update the wave queue */
- DSOUND_WaveQueue(device, FALSE);
-
- /* buffers are full. start playing if applicable */
- if(device->state == STATE_STARTING){
- TRACE("started primary buffer\n");
- if(DSOUND_PrimaryPlay(device) != DS_OK){
- WARN("DSOUND_PrimaryPlay failed\n");
- }
- else{
- /* we are playing now */
- device->state = STATE_PLAYING;
- }
- }
-
- /* buffers are full. start stopping if applicable */
- if(device->state == STATE_STOPPED){
- TRACE("restarting primary buffer\n");
- if(DSOUND_PrimaryPlay(device) != DS_OK){
- WARN("DSOUND_PrimaryPlay failed\n");
- }
- else{
- /* start stopping again. as soon as there is no more data, it will stop */
- device->state = STATE_STOPPING;
- }
- }
+ hr = IAudioRenderClient_GetBuffer(device->render, maxq / block, (void*)&buffer);
+ if(FAILED(hr)){
+ WARN("GetBuffer failed: %08x\n", hr);
+ LeaveCriticalSection(&device->mixlock);
+ return;
}
- /* if device was stopping, its for sure stopped when all buffers have stopped */
- else if((all_stopped == TRUE) && (device->state == STATE_STOPPING)){
- TRACE("All buffers have stopped. Stopping primary buffer\n");
- device->state = STATE_STOPPED;
-
- /* stop the primary buffer now */
- DSOUND_PrimaryStop(device);
- }
+ memset(buffer, nfiller, maxq);
- } else if (device->state != STATE_STOPPED) {
+ if (!device->normfunction)
+ DSOUND_MixToPrimary(device, buffer, writepos, maxq, &all_stopped);
+ else {
- DSOUND_WaveQueue(device, TRUE);
+ /* do the mixing */
+ DSOUND_MixToPrimary(device, (float*)device->buffer, writepos, maxq, &all_stopped);
- /* in the DSSCL_WRITEPRIMARY mode, the app is totally in charge... */
- if (device->state == STATE_STARTING) {
- if (DSOUND_PrimaryPlay(device) != DS_OK)
- WARN("DSOUND_PrimaryPlay failed\n");
- else
- device->state = STATE_PLAYING;
- }
- else if (device->state == STATE_STOPPING) {
- if (DSOUND_PrimaryStop(device) != DS_OK)
- WARN("DSOUND_PrimaryStop failed\n");
- else
- device->state = STATE_STOPPED;
+ device->normfunction(device->buffer, buffer, maxq);
}
+
+ hr = IAudioRenderClient_ReleaseBuffer(device->render, maxq / block, 0);
+ if(FAILED(hr))
+ ERR("ReleaseBuffer failed: %08x\n", hr);
+
+ device->pad += maxq;
+ } else if (!device->stopped) {
+ if (maxq > device->buflen)
+ maxq = device->buflen;
+ if (writepos + maxq > device->buflen) {
+ DSOUND_WaveQueue(device, device->buffer + writepos, device->buflen - writepos);
+ DSOUND_WaveQueue(device, device->buffer, writepos + maxq - device->buflen);
+ } else
+ DSOUND_WaveQueue(device, device->buffer + writepos, maxq);
}
LeaveCriticalSection(&(device->mixlock));
diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c
index a824477..8f3580a 100644
--- a/dlls/dsound/primary.c
+++ b/dlls/dsound/primary.c
@@ -40,24 +40,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(dsound);
-static DWORD DSOUND_fraglen(DirectSoundDevice *device)
-{
- REFERENCE_TIME period;
- HRESULT hr;
- DWORD ret;
-
- hr = IAudioClient_GetDevicePeriod(device->client, &period, NULL);
- if(FAILED(hr)){
- /* just guess at 10ms */
- WARN("GetDevicePeriod failed: %08x\n", hr);
- ret = MulDiv(device->pwfx->nBlockAlign, device->pwfx->nSamplesPerSec, 100);
- }else
- ret = MulDiv(device->pwfx->nSamplesPerSec * device->pwfx->nBlockAlign, period, 10000000);
-
- ret -= ret % device->pwfx->nBlockAlign;
- return ret;
-}
-
static HRESULT DSOUND_WaveFormat(DirectSoundDevice *device, IAudioClient *client,
BOOL forcewave, WAVEFORMATEX **wfx)
{
@@ -146,17 +128,8 @@ static HRESULT DSOUND_WaveFormat(DirectSoundDevice *device, IAudioClient *client
return S_OK;
}
-HRESULT DSOUND_ReopenDevice(DirectSoundDevice *device, BOOL forcewave)
+static void DSOUND_ReleaseDevice(DirectSoundDevice *device)
{
- UINT prebuf_frames;
- REFERENCE_TIME prebuf_rt;
- WAVEFORMATEX *wfx = NULL;
- HRESULT hres;
- REFERENCE_TIME period;
- DWORD period_ms;
-
- TRACE("(%p, %d)\n", device, forcewave);
-