@@ -1264,34 +1264,37 @@ impl Stream {
1264
1264
1265
1265
/// Pauses playback of this stream temporarily.
1266
1266
///
1267
- /// Available on both playback and recording streams.
1268
- ///
1269
- /// The pause operation is executed as quickly as possible. If a cork is very quickly followed
1270
- /// by an uncork, this might not actually have any effect on the stream that is output. You can
1271
- /// use [`is_corked()`] to find out whether the stream is currently paused or not. Normally a
1272
- /// stream will be created in uncorked state. If you pass [`FlagSet::START_CORKED`] as a flag
1273
- /// when connecting the stream, it will be created in corked state.
1274
- ///
1275
- /// The optional callback must accept a `bool`, which indicates success.
1276
- ///
1277
- /// Panics if the underlying C function returns a null pointer.
1267
+ /// This simply calls [`set_corked_state()`] with a value of `true`.
1278
1268
///
1279
- /// [`is_corked()`]: Self::is_corked
1269
+ /// [`set_corked_state()`]: Self::set_corked_state
1270
+ #[ inline( always) ]
1280
1271
pub fn cork ( & mut self , callback : Option < Box < dyn FnMut ( bool ) + ' static > > )
1281
1272
-> Operation < dyn FnMut ( bool ) >
1282
1273
{
1283
- let ( cb_fn, cb_data) : ( Option < extern "C" fn ( _, _, _) > , _ ) =
1284
- get_su_capi_params :: < _ , _ > ( callback, success_cb_proxy) ;
1285
- let ptr = unsafe { capi:: pa_stream_cork ( self . ptr , true as i32 , cb_fn, cb_data) } ;
1286
- Operation :: from_raw ( ptr, cb_data as * mut Box < dyn FnMut ( bool ) > )
1274
+ self . set_corked_state ( true , callback)
1287
1275
}
1288
1276
1289
1277
/// Resumes playback of this stream.
1290
1278
///
1279
+ /// This simply calls [`set_corked_state()`] with a value of `false`.
1280
+ ///
1281
+ /// [`set_corked_state()`]: Self::set_corked_state
1282
+ #[ inline( always) ]
1283
+ pub fn uncork ( & mut self , callback : Option < Box < dyn FnMut ( bool ) + ' static > > )
1284
+ -> Operation < dyn FnMut ( bool ) >
1285
+ {
1286
+ self . set_corked_state ( false , callback)
1287
+ }
1288
+
1289
+ /// Pauses or resumes playback of this stream.
1290
+ ///
1291
1291
/// Available on both playback and recording streams.
1292
1292
///
1293
- /// The un-pause operation is executed as quickly as possible. If an uncork is very quickly
1294
- /// followed by a cork, this might not actually have any effect on the stream that is output.
1293
+ /// Set state to `true` to cork (pause) the stream. Set state to `false` to uncork (resume) the
1294
+ /// stream. Alternatively [`cork()`] and [`uncork()`] helper functions can be used.
1295
+ ///
1296
+ /// The operation is executed as quickly as possible. If a cork is very quickly followed by an
1297
+ /// uncork, or vice versa, this might not actually have any effect on the stream that is output.
1295
1298
/// You can use [`is_corked()`] to find out whether the stream is currently paused or not.
1296
1299
/// Normally a stream will be created in uncorked state. If you pass [`FlagSet::START_CORKED`]
1297
1300
/// as a flag when connecting the stream, it will be created in corked state.
@@ -1301,12 +1304,14 @@ impl Stream {
1301
1304
/// Panics if the underlying C function returns a null pointer.
1302
1305
///
1303
1306
/// [`is_corked()`]: Self::is_corked
1304
- pub fn uncork ( & mut self , callback : Option < Box < dyn FnMut ( bool ) + ' static > > )
1307
+ /// [`cork()`]: Self::cork
1308
+ /// [`uncork()`]: Self::uncork
1309
+ pub fn set_corked_state ( & mut self , state : bool , callback : Option < Box < dyn FnMut ( bool ) + ' static > > )
1305
1310
-> Operation < dyn FnMut ( bool ) >
1306
1311
{
1307
1312
let ( cb_fn, cb_data) : ( Option < extern "C" fn ( _, _, _) > , _ ) =
1308
1313
get_su_capi_params :: < _ , _ > ( callback, success_cb_proxy) ;
1309
- let ptr = unsafe { capi:: pa_stream_cork ( self . ptr , false as i32 , cb_fn, cb_data) } ;
1314
+ let ptr = unsafe { capi:: pa_stream_cork ( self . ptr , state as i32 , cb_fn, cb_data) } ;
1310
1315
Operation :: from_raw ( ptr, cb_data as * mut Box < dyn FnMut ( bool ) > )
1311
1316
}
1312
1317
0 commit comments