1 /* PipeWire 2 * 3 * Copyright © 2018 Wim Taymans 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the next 13 * paragraph) shall be included in all copies or substantial portions of the 14 * Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 * DEALINGS IN THE SOFTWARE. 23 */ 24 25 #ifndef PIPEWIRE_MAIN_LOOP_H 26 #define PIPEWIRE_MAIN_LOOP_H 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 /** \defgroup pw_main_loop Main Loop 33 * 34 * A main loop object 35 */ 36 37 /** 38 * \addtogroup pw_main_loop 39 * \{ 40 */ 41 42 /** A main loop object */ 43 struct pw_main_loop; 44 45 #include <pipewire/loop.h> 46 47 /** Events of the main loop */ 48 struct pw_main_loop_events { 49 #define PW_VERSION_MAIN_LOOP_EVENTS 0 50 uint32_t version; 51 52 /** Emitted when the main loop is destroyed */ 53 void (*destroy) (void *data); 54 }; 55 56 /** Create a new main loop. */ 57 struct pw_main_loop * 58 pw_main_loop_new(const struct spa_dict *props); 59 60 /** Add an event listener */ 61 void pw_main_loop_add_listener(struct pw_main_loop *loop, 62 struct spa_hook *listener, 63 const struct pw_main_loop_events *events, 64 void *data); 65 66 /** Get the loop implementation */ 67 struct pw_loop * pw_main_loop_get_loop(struct pw_main_loop *loop); 68 69 /** Destroy a loop */ 70 void pw_main_loop_destroy(struct pw_main_loop *loop); 71 72 /** Run a main loop. This blocks until \ref pw_main_loop_quit is called */ 73 int pw_main_loop_run(struct pw_main_loop *loop); 74 75 /** Quit a main loop */ 76 int pw_main_loop_quit(struct pw_main_loop *loop); 77 78 /** 79 * \} 80 */ 81 82 #ifdef __cplusplus 83 } 84 #endif 85 86 #endif /* PIPEWIRE_MAIN_LOOP_H */ 87