@@ -147,20 +147,6 @@ struct auto_lock {
147
147
owned_critical_section * lock;
148
148
};
149
149
150
- struct auto_unlock {
151
- auto_unlock (owned_critical_section * lock)
152
- : lock(lock)
153
- {
154
- lock->leave ();
155
- }
156
- ~auto_unlock ()
157
- {
158
- lock->enter ();
159
- }
160
- private:
161
- owned_critical_section * lock;
162
- };
163
-
164
150
struct auto_com {
165
151
auto_com () {
166
152
result = CoInitializeEx (NULL , COINIT_MULTITHREADED);
@@ -984,7 +970,7 @@ int setup_wasapi_stream(cubeb_stream * stm)
984
970
hr = get_default_endpoint (&device);
985
971
if (FAILED (hr)) {
986
972
LOG (" Could not get default endpoint, error: %x\n " , hr);
987
- auto_unlock unlock ( stm->stream_reset_lock );
973
+ stm->stream_reset_lock -> leave ( );
988
974
wasapi_stream_destroy (stm);
989
975
return CUBEB_ERROR;
990
976
}
@@ -997,7 +983,7 @@ int setup_wasapi_stream(cubeb_stream * stm)
997
983
SafeRelease (device);
998
984
if (FAILED (hr)) {
999
985
LOG (" Could not activate the device to get an audio client: error: %x\n " , hr);
1000
- auto_unlock unlock ( stm->stream_reset_lock );
986
+ stm->stream_reset_lock -> leave ( );
1001
987
wasapi_stream_destroy (stm);
1002
988
return CUBEB_ERROR;
1003
989
}
@@ -1007,7 +993,7 @@ int setup_wasapi_stream(cubeb_stream * stm)
1007
993
hr = stm->client ->GetMixFormat (&mix_format);
1008
994
if (FAILED (hr)) {
1009
995
LOG (" Could not fetch current mix format from the audio client: error: %x\n " , hr);
1010
- auto_unlock unlock ( stm->stream_reset_lock );
996
+ stm->stream_reset_lock -> leave ( );
1011
997
wasapi_stream_destroy (stm);
1012
998
return CUBEB_ERROR;
1013
999
}
@@ -1032,15 +1018,15 @@ int setup_wasapi_stream(cubeb_stream * stm)
1032
1018
1033
1019
if (FAILED (hr)) {
1034
1020
LOG (" Unable to initialize audio client: %x.\n " , hr);
1035
- auto_unlock unlock ( stm->stream_reset_lock );
1021
+ stm->stream_reset_lock -> leave ( );
1036
1022
wasapi_stream_destroy (stm);
1037
1023
return CUBEB_ERROR;
1038
1024
}
1039
1025
1040
1026
hr = stm->client ->GetBufferSize (&stm->buffer_frame_count );
1041
1027
if (FAILED (hr)) {
1042
1028
LOG (" Could not get the buffer size from the client %x.\n " , hr);
1043
- auto_unlock unlock ( stm->stream_reset_lock );
1029
+ stm->stream_reset_lock -> leave ( );
1044
1030
wasapi_stream_destroy (stm);
1045
1031
return CUBEB_ERROR;
1046
1032
}
@@ -1052,7 +1038,7 @@ int setup_wasapi_stream(cubeb_stream * stm)
1052
1038
hr = stm->client ->SetEventHandle (stm->refill_event );
1053
1039
if (FAILED (hr)) {
1054
1040
LOG (" Could set the event handle for the client %x.\n " , hr);
1055
- auto_unlock unlock ( stm->stream_reset_lock );
1041
+ stm->stream_reset_lock -> leave ( );
1056
1042
wasapi_stream_destroy (stm);
1057
1043
return CUBEB_ERROR;
1058
1044
}
@@ -1061,7 +1047,7 @@ int setup_wasapi_stream(cubeb_stream * stm)
1061
1047
(void **)&stm->render_client );
1062
1048
if (FAILED (hr)) {
1063
1049
LOG (" Could not get the render client %x.\n " , hr);
1064
- auto_unlock unlock ( stm->stream_reset_lock );
1050
+ stm->stream_reset_lock -> leave ( );
1065
1051
wasapi_stream_destroy (stm);
1066
1052
return CUBEB_ERROR;
1067
1053
}
@@ -1070,7 +1056,7 @@ int setup_wasapi_stream(cubeb_stream * stm)
1070
1056
(void **)&stm->audio_stream_volume );
1071
1057
if (FAILED (hr)) {
1072
1058
LOG (" Could not get the IAudioStreamVolume %x.\n " , hr);
1073
- auto_unlock unlock ( stm->stream_reset_lock );
1059
+ stm->stream_reset_lock -> leave ( );
1074
1060
wasapi_stream_destroy (stm);
1075
1061
return CUBEB_ERROR;
1076
1062
}
@@ -1087,7 +1073,7 @@ int setup_wasapi_stream(cubeb_stream * stm)
1087
1073
CUBEB_RESAMPLER_QUALITY_DESKTOP);
1088
1074
if (!stm->resampler ) {
1089
1075
LOG (" Could not get a resampler\n " );
1090
- auto_unlock unlock ( stm->stream_reset_lock );
1076
+ stm->stream_reset_lock -> leave ( );
1091
1077
wasapi_stream_destroy (stm);
1092
1078
return CUBEB_ERROR;
1093
1079
}
@@ -1249,8 +1235,9 @@ int stream_stop(cubeb_stream * stm, bool * was_running)
1249
1235
}
1250
1236
1251
1237
{
1252
- auto_unlock lock ( stm->stream_reset_lock );
1238
+ stm->stream_reset_lock -> leave ( );
1253
1239
stop_and_join_render_thread (stm);
1240
+ stm->stream_reset_lock ->enter ();
1254
1241
}
1255
1242
1256
1243
if (SUCCEEDED (hr)) {
0 commit comments