1 /* -*- Mode: C ; c-basic-offset: 4 -*- */ 2 /* 3 JACK control API 4 5 Copyright (C) 2008 Nedko Arnaudov 6 Copyright (C) 2008 GRAME 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; version 2 of the License. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 21 */ 22 /** 23 * @file jack/control.h 24 * @ingroup publicheader 25 * @brief JACK control API 26 * 27 */ 28 29 module jack.c.control; 30 public import jack.c.systemdeps; 31 public import jack.c.jslist; 32 33 extern(C) 34 { 35 36 /** Parameter types, intentionally similar to jack_driver_param_type_t */ 37 enum jackctl_param_type_t 38 { 39 JackParamInt = 1, /**< @brief value type is a signed integer */ 40 JackParamUInt, /**< @brief value type is an unsigned integer */ 41 JackParamChar, /**< @brief value type is a char */ 42 JackParamString, /**< @brief value type is a string with max size of ::JACK_PARAM_STRING_MAX+1 chars */ 43 JackParamBool, /**< @brief value type is a boolean */ 44 }; 45 46 /** Driver types */ 47 enum jackctl_driver_type_t 48 { 49 JackMaster = 1, /**< @brief master driver */ 50 JackSlave /**< @brief slave driver */ 51 }; 52 53 /** @brief Max value that jackctl_param_type_t type can have */ 54 enum JACK_PARAM_MAX = jackctl_param_type_t.JackParamBool + 1; 55 56 /** @brief Max length of string parameter value, excluding terminating null char */ 57 enum JACK_PARAM_STRING_MAX = 127; 58 59 /** @brief Type for parameter value */ 60 /* intentionally similar to jack_driver_param_value_t */ 61 union jackctl_parameter_value 62 { 63 uint32_t ui; /**< @brief member used for ::JackParamUInt */ 64 int32_t i; /**< @brief member used for ::JackParamInt */ 65 char c; /**< @brief member used for ::JackParamChar */ 66 char[JACK_PARAM_STRING_MAX + 1] str; /**< @brief member used for ::JackParamString */ 67 bool b; /**< @brief member used for ::JackParamBool */ 68 }; 69 70 /** opaque type for server object */ 71 struct jackctl_server_t; 72 73 /** opaque type for driver object */ 74 struct jackctl_driver_t; 75 76 /** opaque type for internal client object */ 77 struct jackctl_internal_t; 78 79 /** opaque type for parameter object */ 80 struct jackctl_parameter_t; 81 82 /** opaque type for sigmask object */ 83 struct jackctl_sigmask_t; 84 85 /** 86 * @defgroup ControlAPI The API for starting and controlling a JACK server 87 * @{ 88 */ 89 90 /** 91 * Call this function to setup process signal handling. As a general 92 * rule, it is required for proper operation for the server object. 93 * 94 * @param flags signals setup flags, use 0 for none. Currently no 95 * flags are defined 96 * 97 * @return the configurated signal set. 98 */ 99 jackctl_sigmask_t * 100 jackctl_setup_signals( 101 uint flags); 102 103 /** 104 * Call this function to wait on a signal set. 105 * 106 * @param signals signals set to wait on 107 */ 108 void 109 jackctl_wait_signals( 110 jackctl_sigmask_t * signals); 111 112 /** 113 * Call this function to create server object. 114 * 115 * @param on_device_acquire - Optional callback to be called before device is acquired. If false is returned, device usage will fail 116 * @param on_device_release - Optional callback to be called after device is released. 117 * 118 * @return server object handle, NULL if creation of server object 119 * failed. Successfully created server object must be destroyed with 120 * paired call to ::jackctl_server_destroy 121 */ 122 jackctl_server_t * 123 jackctl_server_create( 124 bool function(const(char) * device_name) on_device_acquire, 125 void function(const(char) * device_name) on_device_release); 126 127 /** 128 * Call this function to destroy server object. 129 * 130 * @param server server object handle to destroy 131 */ 132 void 133 jackctl_server_destroy( 134 jackctl_server_t * server); 135 136 /** 137 * Call this function to open JACK server 138 * 139 * @param server server object handle 140 * @param driver driver to use 141 * 142 * @return success status: true - success, false - fail 143 */ 144 bool 145 jackctl_server_open( 146 jackctl_server_t * server, 147 jackctl_driver_t * driver); 148 149 /** 150 * Call this function to start JACK server 151 * 152 * @param server server object handle 153 * 154 * @return success status: true - success, false - fail 155 */ 156 bool 157 jackctl_server_start( 158 jackctl_server_t * server); 159 160 /** 161 * Call this function to stop JACK server 162 * 163 * @param server server object handle 164 * 165 * @return success status: true - success, false - fail 166 */ 167 bool 168 jackctl_server_stop( 169 jackctl_server_t * server); 170 171 /** 172 * Call this function to close JACK server 173 * 174 * @param server server object handle 175 * 176 * @return success status: true - success, false - fail 177 */ 178 bool 179 jackctl_server_close( 180 jackctl_server_t * server); 181 182 /** 183 * Call this function to get list of available drivers. List node data 184 * pointers is a driver object handle (::jackctl_driver_t). 185 * 186 * @param server server object handle to get drivers for 187 * 188 * @return Single linked list of driver object handles. Must not be 189 * modified. Always same for same server object. 190 */ 191 const(JSList) * 192 jackctl_server_get_drivers_list( 193 jackctl_server_t * server); 194 195 /** 196 * Call this function to get list of server parameters. List node data 197 * pointers is a parameter object handle (::jackctl_parameter_t). 198 * 199 * @param server server object handle to get parameters for 200 * 201 * @return Single linked list of parameter object handles. Must not be 202 * modified. Always same for same server object. 203 */ 204 const(JSList) * 205 jackctl_server_get_parameters( 206 jackctl_server_t * server); 207 208 /** 209 * Call this function to get list of available internal clients. List node data 210 * pointers is a internal client object handle (::jackctl_internal_t). 211 * 212 * @param server server object handle to get internal clients for 213 * 214 * @return Single linked list of internal client object handles. Must not be 215 * modified. Always same for same server object. 216 */ 217 const(JSList) * 218 jackctl_server_get_internals_list( 219 jackctl_server_t * server); 220 221 /** 222 * Call this function to load one internal client. 223 * (can be used when the server is running) 224 * 225 * @param server server object handle 226 * @param internal internal to use 227 * 228 * @return success status: true - success, false - fail 229 */ 230 bool 231 jackctl_server_load_internal( 232 jackctl_server_t * server, 233 jackctl_internal_t * internal); 234 235 /** 236 * Call this function to unload one internal client. 237 * (can be used when the server is running) 238 * 239 * @param server server object handle 240 * @param internal internal to unload 241 * 242 * @return success status: true - success, false - fail 243 */ 244 bool 245 jackctl_server_unload_internal( 246 jackctl_server_t * server, 247 jackctl_internal_t * internal); 248 249 /** 250 * Call this function to add a slave in the driver slave list. 251 * (cannot be used when the server is running that is between 252 * jackctl_server_start and jackctl_server_stop) 253 * 254 * @param server server object handle 255 * @param driver driver to add in the driver slave list. 256 * 257 * @return success status: true - success, false - fail 258 */ 259 bool 260 jackctl_server_add_slave(jackctl_server_t * server, 261 jackctl_driver_t * driver); 262 263 /** 264 * Call this function to remove a slave from the driver slave list. 265 * (cannot be used when the server is running that is between 266 * jackctl_server_start and jackctl_server_stop) 267 * 268 * @param server server object handle 269 * @param driver driver to remove from the driver slave list. 270 * 271 * @return success status: true - success, false - fail 272 */ 273 bool 274 jackctl_server_remove_slave(jackctl_server_t * server, 275 jackctl_driver_t * driver); 276 277 /** 278 * Call this function to switch master driver. 279 * 280 * @param server server object handle 281 * @param driver driver to switch to 282 * 283 * @return success status: true - success, false - fail 284 */ 285 bool 286 jackctl_server_switch_master(jackctl_server_t * server, 287 jackctl_driver_t * driver); 288 289 290 /** 291 * Call this function to get name of driver. 292 * 293 * @param driver driver object handle to get name of 294 * 295 * @return driver name. Must not be modified. Always same for same 296 * driver object. 297 */ 298 const(char) * 299 jackctl_driver_get_name( 300 jackctl_driver_t * driver); 301 302 /** 303 * Call this function to get type of driver. 304 * 305 * @param driver driver object handle to get name of 306 * 307 * @return driver type. Must not be modified. Always same for same 308 * driver object. 309 */ 310 jackctl_driver_type_t 311 jackctl_driver_get_type( 312 jackctl_driver_t * driver); 313 314 /** 315 * Call this function to get list of driver parameters. List node data 316 * pointers is a parameter object handle (::jackctl_parameter_t). 317 * 318 * @param driver driver object handle to get parameters for 319 * 320 * @return Single linked list of parameter object handles. Must not be 321 * modified. Always same for same driver object. 322 */ 323 const(JSList) * 324 jackctl_driver_get_parameters( 325 jackctl_driver_t * driver); 326 327 /** 328 * Call this function to parse parameters for a driver. 329 * 330 * @param driver driver object handle 331 * @param argc parameter list len 332 * @param argv parameter list, as an array of char* 333 * 334 * @return success status: true - success, false - fail 335 */ 336 int 337 jackctl_driver_params_parse( 338 jackctl_driver_t * driver, 339 int argc, 340 char*[] argv); 341 342 /** 343 * Call this function to get name of internal client. 344 * 345 * @param internal internal object handle to get name of 346 * 347 * @return internal name. Must not be modified. Always same for same 348 * internal object. 349 */ 350 const(char) * 351 jackctl_internal_get_name( 352 jackctl_internal_t * internal); 353 354 /** 355 * Call this function to get list of internal parameters. List node data 356 * pointers is a parameter object handle (::jackctl_parameter_t). 357 * 358 * @param internal internal object handle to get parameters for 359 * 360 * @return Single linked list of parameter object handles. Must not be 361 * modified. Always same for same internal object. 362 */ 363 const(JSList) * 364 jackctl_internal_get_parameters( 365 jackctl_internal_t * internal); 366 367 /** 368 * Call this function to get parameter name. 369 * 370 * @param parameter parameter object handle to get name of 371 * 372 * @return parameter name. Must not be modified. Always same for same 373 * parameter object. 374 */ 375 const(char) * 376 jackctl_parameter_get_name( 377 jackctl_parameter_t * parameter); 378 379 /** 380 * Call this function to get parameter short description. 381 * 382 * @param parameter parameter object handle to get short description of 383 * 384 * @return parameter short description. Must not be modified. Always 385 * same for same parameter object. 386 */ 387 const(char) * 388 jackctl_parameter_get_short_description( 389 jackctl_parameter_t * parameter); 390 391 /** 392 * Call this function to get parameter long description. 393 * 394 * @param parameter parameter object handle to get long description of 395 * 396 * @return parameter long description. Must not be modified. Always 397 * same for same parameter object. 398 */ 399 const(char) * 400 jackctl_parameter_get_long_description( 401 jackctl_parameter_t * parameter); 402 403 /** 404 * Call this function to get parameter type. 405 * 406 * @param parameter parameter object handle to get type of 407 * 408 * @return parameter type. Always same for same parameter object. 409 */ 410 jackctl_param_type_t 411 jackctl_parameter_get_type( 412 jackctl_parameter_t * parameter); 413 414 /** 415 * Call this function to get parameter character. 416 * 417 * @param parameter parameter object handle to get character of 418 * 419 * @return character. 420 */ 421 char 422 jackctl_parameter_get_id( 423 jackctl_parameter_t * parameter); 424 425 /** 426 * Call this function to check whether parameter has been set, or its 427 * default value is being used. 428 * 429 * @param parameter parameter object handle to check 430 * 431 * @return true - parameter is set, false - parameter is using default 432 * value. 433 */ 434 bool 435 jackctl_parameter_is_set( 436 jackctl_parameter_t * parameter); 437 438 /** 439 * Call this function to reset parameter to its default value. 440 * 441 * @param parameter parameter object handle to reset value of 442 * 443 * @return success status: true - success, false - fail 444 */ 445 bool 446 jackctl_parameter_reset( 447 jackctl_parameter_t * parameter); 448 449 /** 450 * Call this function to get parameter value. 451 * 452 * @param parameter parameter object handle to get value of 453 * 454 * @return parameter value. 455 */ 456 jackctl_parameter_value 457 jackctl_parameter_get_value( 458 jackctl_parameter_t * parameter); 459 460 /** 461 * Call this function to set parameter value. 462 * 463 * @param parameter parameter object handle to get value of 464 * @param value_ptr pointer to variable containing parameter value 465 * 466 * @return success status: true - success, false - fail 467 */ 468 bool 469 jackctl_parameter_set_value( 470 jackctl_parameter_t * parameter, 471 const(jackctl_parameter_value) * value_ptr); 472 473 /** 474 * Call this function to get parameter default value. 475 * 476 * @param parameter parameter object handle to get default value of 477 * 478 * @return parameter default value. 479 */ 480 jackctl_parameter_value 481 jackctl_parameter_get_default_value( 482 jackctl_parameter_t * parameter); 483 484 /** 485 * Call this function check whether parameter has range constraint. 486 * 487 * @param parameter object handle of parameter to check 488 * 489 * @return whether parameter has range constraint. 490 */ 491 bool 492 jackctl_parameter_has_range_constraint( 493 jackctl_parameter_t * parameter); 494 495 /** 496 * Call this function check whether parameter has enumeration constraint. 497 * 498 * @param parameter object handle of parameter to check 499 * 500 * @return whether parameter has enumeration constraint. 501 */ 502 bool 503 jackctl_parameter_has_enum_constraint( 504 jackctl_parameter_t * parameter); 505 506 /** 507 * Call this function get how many enumeration values parameter has. 508 * 509 * @param parameter object handle of parameter 510 * 511 * @return number of enumeration values 512 */ 513 uint32_t 514 jackctl_parameter_get_enum_constraints_count( 515 jackctl_parameter_t * parameter); 516 517 /** 518 * Call this function to get parameter enumeration value. 519 * 520 * @param parameter object handle of parameter 521 * @param index index of parameter enumeration value 522 * 523 * @return enumeration value. 524 */ 525 jackctl_parameter_value 526 jackctl_parameter_get_enum_constraint_value( 527 jackctl_parameter_t * parameter, 528 uint32_t index); 529 530 /** 531 * Call this function to get parameter enumeration value description. 532 * 533 * @param parameter object handle of parameter 534 * @param index index of parameter enumeration value 535 * 536 * @return enumeration value description. 537 */ 538 const(char) * 539 jackctl_parameter_get_enum_constraint_description( 540 jackctl_parameter_t * parameter, 541 uint32_t index); 542 543 /** 544 * Call this function to get parameter range. 545 * 546 * @param parameter object handle of parameter 547 * @param min_ptr pointer to variable receiving parameter minimum value 548 * @param max_ptr pointer to variable receiving parameter maximum value 549 */ 550 void 551 jackctl_parameter_get_range_constraint( 552 jackctl_parameter_t * parameter, 553 jackctl_parameter_value * min_ptr, 554 jackctl_parameter_value * max_ptr); 555 556 /** 557 * Call this function to check whether parameter constraint is strict, 558 * i.e. whether supplying non-matching value will not work for sure. 559 * 560 * @param parameter parameter object handle to check 561 * 562 * @return whether parameter constraint is strict. 563 */ 564 bool 565 jackctl_parameter_constraint_is_strict( 566 jackctl_parameter_t * parameter); 567 568 /** 569 * Call this function to check whether parameter has fake values, 570 * i.e. values have no user meaningful meaning and only value 571 * description is meaningful to user. 572 * 573 * @param parameter parameter object handle to check 574 * 575 * @return whether parameter constraint is strict. 576 */ 577 bool 578 jackctl_parameter_constraint_is_fake_value( 579 jackctl_parameter_t * parameter); 580 581 /** 582 * Call this function to log an error message. 583 * 584 * @param format string 585 */ 586 void 587 jack_error( 588 const(char) *format, 589 ...); 590 591 /** 592 * Call this function to log an information message. 593 * 594 * @param format string 595 */ 596 void 597 jack_info( 598 const(char) *format, 599 ...); 600 601 /** 602 * Call this function to log an information message but only when 603 * verbose mode is enabled. 604 * 605 * @param format string 606 */ 607 void 608 jack_log( 609 const(char) *format, 610 ...); 611 612 /* @} */ 613 614 } /* extern(C) */