Skip to content

Commit 6cc175e

Browse files
committed
Implement CUBEB_STREAM_PREF_EXCLUSIVE
1 parent 475d97f commit 6cc175e

File tree

3 files changed

+625
-648
lines changed

3 files changed

+625
-648
lines changed

include/cubeb/cubeb.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,16 @@ typedef enum {
217217

218218
/** Miscellaneous stream preferences. */
219219
typedef enum {
220-
CUBEB_STREAM_PREF_NONE = 0x00, /**< No stream preferences are requested. */
221-
CUBEB_STREAM_PREF_LOOPBACK = 0x01 /**< Request a loopback stream. Should be
222-
specified on the input params and an
223-
output device to loopback from should
224-
be passed in place of an input device. */
220+
CUBEB_STREAM_PREF_NONE = 0x00, /**< No stream preferences are requested. */
221+
CUBEB_STREAM_PREF_LOOPBACK = 0x01, /**< Request a loopback stream. Should be
222+
specified on the input params and an
223+
output device to loopback from should
224+
be passed in place of an input device. */
225+
CUBEB_STREAM_PREF_EXCLUSIVE = 0x02 /**< (Windows / WASAPI only) Request that
226+
this stream is run in exclusive mode
227+
which results in lower latency but
228+
doesn't allow other applications to
229+
use the same device */
225230
} cubeb_stream_prefs;
226231

227232
/** Stream format initialization parameters. */

src/cubeb.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,11 @@ cubeb_stream_init(cubeb * context, cubeb_stream ** stream, char const * stream_n
318318
return r;
319319
}
320320

321+
if ((output_stream_params && output_stream_params->prefs) & CUBEB_STREAM_PREF_EXCLUSIVE || (input_stream_params && input_stream_params->prefs & CUBEB_STREAM_PREF_EXCLUSIVE)) {
322+
if (strcmp(cubeb_get_backend_id(context), "wasapi") != 0)
323+
return CUBEB_ERROR_NOT_SUPPORTED;
324+
}
325+
321326
r = context->ops->stream_init(context, stream, stream_name,
322327
input_device,
323328
input_stream_params,

0 commit comments

Comments
 (0)