[4314] | 1 | //notify_proxy.c: |
---|
| 2 | |
---|
| 3 | /* |
---|
[4708] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2011 |
---|
[4314] | 5 | * |
---|
| 6 | * This file is part of libroar a part of RoarAudio, |
---|
| 7 | * a cross-platform sound system for both, home and professional use. |
---|
| 8 | * See README for details. |
---|
| 9 | * |
---|
| 10 | * This file is free software; you can redistribute it and/or modify |
---|
| 11 | * it under the terms of the GNU General Public License version 3 |
---|
| 12 | * as published by the Free Software Foundation. |
---|
| 13 | * |
---|
| 14 | * libroar is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this software; see the file COPYING. If not, write to |
---|
| 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
| 23 | * |
---|
| 24 | * NOTE for everyone want's to change something and send patches: |
---|
| 25 | * read README and HACKING! There a addition information on |
---|
| 26 | * the license of this document you need to read before you send |
---|
| 27 | * any patches. |
---|
| 28 | * |
---|
| 29 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
| 30 | * or libpulse*: |
---|
| 31 | * The libs libroaresd, libroararts and libroarpulse link this lib |
---|
| 32 | * and are therefore GPL. Because of this it may be illigal to use |
---|
| 33 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
| 34 | */ |
---|
| 35 | |
---|
| 36 | #include "libroar.h" |
---|
| 37 | |
---|
[4315] | 38 | #define MAX_EVENTS_PER_GROUP 4 |
---|
| 39 | #define EOL ROAR_NOTIFY_SPECIAL |
---|
| 40 | |
---|
[4397] | 41 | // TODO: FIXME: ROAR_NOTIFY_EGRP2EVENT() on _OE_ events? |
---|
| 42 | // TODO: refthink design of this proxy. |
---|
| 43 | |
---|
[4315] | 44 | void roar_notify_proxy_std(struct roar_notify_core * core, struct roar_event * event, void * userdata) { |
---|
| 45 | struct { |
---|
| 46 | uint32_t event_min, event_max; |
---|
| 47 | uint32_t events[MAX_EVENTS_PER_GROUP]; |
---|
| 48 | } * ptr, list[] = { |
---|
[4415] | 49 | {.event_min = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_CLIENTS), |
---|
| 50 | .event_max = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_CLIENTS + 0xff), |
---|
[4319] | 51 | .events = { |
---|
| 52 | ROAR_EGRP_ANY_CLIENT_EVENT, |
---|
| 53 | EOL |
---|
| 54 | } |
---|
| 55 | }, |
---|
[4415] | 56 | {.event_min = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_STREAMS), |
---|
| 57 | .event_max = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_STREAMS + 0xff), |
---|
[4315] | 58 | .events = { |
---|
[4319] | 59 | ROAR_EGRP_ANY_STREAM_EVENT, |
---|
| 60 | EOL |
---|
| 61 | } |
---|
| 62 | }, |
---|
[4415] | 63 | {.event_min = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_SOURCES), |
---|
| 64 | .event_max = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_SOURCES + 0xff), |
---|
[4319] | 65 | .events = { |
---|
| 66 | ROAR_EGRP_ANY_SOURCE_EVENT, |
---|
| 67 | EOL |
---|
| 68 | } |
---|
| 69 | }, |
---|
[4415] | 70 | {.event_min = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_SAMPLES), |
---|
| 71 | .event_max = ROAR_NOTIFY_OE2EVENT(ROAR_NOTIFY_OE_GROUP_SAMPLES + 0xff), |
---|
[4319] | 72 | .events = { |
---|
| 73 | ROAR_EGRP_ANY_SAMPLE_EVENT, |
---|
[4315] | 74 | EOL |
---|
| 75 | } |
---|
| 76 | } |
---|
| 77 | }; |
---|
| 78 | struct roar_event locevent; |
---|
| 79 | size_t i, e; |
---|
| 80 | register uint32_t oe = event->event; |
---|
| 81 | |
---|
| 82 | (void)userdata; |
---|
| 83 | |
---|
| 84 | memcpy(&locevent, event, sizeof(locevent)); |
---|
| 85 | |
---|
| 86 | locevent.event_proxy = locevent.event; |
---|
| 87 | locevent.flags |= ROAR_EVENT_FLAG_PROXYEVENT; |
---|
| 88 | |
---|
| 89 | locevent.event = ROAR_EGRP_ANY_EVENT; |
---|
| 90 | |
---|
| 91 | roar_notify_core_emit(core, &locevent); |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | for (i = 0; i < sizeof(list)/sizeof(*list); i++) { |
---|
| 95 | ptr = &(list[i]); |
---|
| 96 | if ( ptr->event_min <= oe && ptr->event_max >= oe ) { |
---|
| 97 | for (e = 0; ptr->events[e] != EOL; e++) { |
---|
| 98 | locevent.event = ptr->events[e]; |
---|
| 99 | roar_notify_core_emit(core, &locevent); |
---|
| 100 | } |
---|
| 101 | } |
---|
| 102 | } |
---|
| 103 | } |
---|
[4314] | 104 | |
---|
| 105 | //ll |
---|