drumstick 2.9.0
C++ MIDI libraries using Qt objects, idioms, and style.
subscription.cpp
Go to the documentation of this file.
1/*
2 MIDI Sequencer C++ library
3 Copyright (C) 2006-2023, Pedro Lopez-Cabanillas <plcl@users.sf.net>
4
5 This library is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#include "errorcheck.h"
27namespace drumstick {
28namespace ALSA {
29
55{
56 snd_seq_query_subscribe_malloc(&m_Info);
57}
58
64{
65 snd_seq_query_subscribe_malloc(&m_Info);
66 snd_seq_query_subscribe_copy(m_Info, other.m_Info);
67}
68
73Subscriber::Subscriber(snd_seq_query_subscribe_t* other)
74{
75 snd_seq_query_subscribe_malloc(&m_Info);
76 snd_seq_query_subscribe_copy(m_Info, other);
77}
78
83{
84 snd_seq_query_subscribe_free(m_Info);
85}
86
92{
93 return new Subscriber(m_Info);
94}
95
102{
103 if (this == &other)
104 return *this;
105 snd_seq_query_subscribe_copy(m_Info, other.m_Info);
106 return *this;
107}
108
113int
115{
116 return snd_seq_query_subscribe_get_client(m_Info);
117}
118
123int
125{
126 return snd_seq_query_subscribe_get_port(m_Info);
127}
128
133const snd_seq_addr_t*
135{
136 return snd_seq_query_subscribe_get_root(m_Info);
137}
138
147snd_seq_query_subs_type_t
149{
150 return snd_seq_query_subscribe_get_type(m_Info);
151}
152
157int
159{
160 return snd_seq_query_subscribe_get_index(m_Info);
161}
162
167int
169{
170 return snd_seq_query_subscribe_get_num_subs(m_Info);
171}
172
177const snd_seq_addr_t*
179{
180 return snd_seq_query_subscribe_get_addr(m_Info);
181}
182
187int
189{
190 return snd_seq_query_subscribe_get_queue(m_Info);
191}
192
197bool
199{
200 return (snd_seq_query_subscribe_get_exclusive(m_Info) != 0);
201}
202
207bool
209{
210 return (snd_seq_query_subscribe_get_time_update(m_Info) != 0);
211}
212
217bool
219{
220 return (snd_seq_query_subscribe_get_time_real(m_Info) != 0);
221}
222
227void
229{
230 snd_seq_query_subscribe_set_client(m_Info, client);
231}
232
237void
239{
240 snd_seq_query_subscribe_set_port(m_Info, port);
241}
242
247void
248Subscriber::setRoot(snd_seq_addr_t* addr)
249{
250 snd_seq_query_subscribe_set_root(m_Info, addr);
251}
252
261void
262Subscriber::setType(snd_seq_query_subs_type_t type)
263{
264 snd_seq_query_subscribe_set_type(m_Info, type);
265}
266
271void
273{
274 snd_seq_query_subscribe_set_index(m_Info, index);
275}
276
281int
283{
284 return snd_seq_query_subscribe_sizeof();
285}
286
291{
292 snd_seq_port_subscribe_malloc(&m_Info);
293}
294
300{
301 snd_seq_port_subscribe_malloc(&m_Info);
302 snd_seq_port_subscribe_copy(m_Info, other.m_Info);
303}
304
309Subscription::Subscription(snd_seq_port_subscribe_t* other)
310{
311 snd_seq_port_subscribe_malloc(&m_Info);
312 snd_seq_port_subscribe_copy(m_Info, other);
313}
314
320{
321 snd_seq_port_subscribe_malloc(&m_Info);
322 DRUMSTICK_ALSA_CHECK_WARNING(snd_seq_get_port_subscription(seq->getHandle(), m_Info));
323}
324
329{
330 snd_seq_port_subscribe_free(m_Info);
331}
332
339{
340 return new Subscription(m_Info);
341}
342
350{
351 if (this == &other)
352 return *this;
353 snd_seq_port_subscribe_copy(m_Info, other.m_Info);
354 return *this;
355}
356
361const snd_seq_addr_t*
363{
364 return snd_seq_port_subscribe_get_sender(m_Info);
365}
366
371const snd_seq_addr_t*
373{
374 return snd_seq_port_subscribe_get_dest(m_Info);
375}
376
381int
383{
384 return snd_seq_port_subscribe_get_queue(m_Info);
385}
386
391bool
393{
394 return (snd_seq_port_subscribe_get_exclusive(m_Info) != 0);
395}
396
401bool
403{
404 return (snd_seq_port_subscribe_get_time_update(m_Info) != 0);
405}
406
411bool
413{
414 return (snd_seq_port_subscribe_get_time_real(m_Info) != 0);
415}
416
421void
422Subscription::setSender(const snd_seq_addr_t* addr)
423{
424 snd_seq_port_subscribe_set_sender(m_Info, addr);
425}
426
431void
432Subscription::setDest(const snd_seq_addr_t* addr)
433{
434 snd_seq_port_subscribe_set_dest(m_Info, addr);
435}
436
441void
443{
444 snd_seq_port_subscribe_set_queue(m_Info, q);
445}
446
451void
453{
454 snd_seq_port_subscribe_set_exclusive(m_Info, val?1:0);
455}
456
461void
463{
464 snd_seq_port_subscribe_set_time_update(m_Info, val?1:0);
465}
466
471void
473{
474 snd_seq_port_subscribe_set_time_real(m_Info, val?1:0);
475}
476
482void
483Subscription::setSender(unsigned char client, unsigned char port)
484{
485 snd_seq_addr_t addr;
486 addr.client = client;
487 addr.port = port;
488 setSender(&addr);
489}
490
496void
497Subscription::setDest(unsigned char client, unsigned char port)
498{
499 snd_seq_addr_t addr;
500 addr.client = client;
501 addr.port = port;
502 setDest(&addr);
503}
504
511void
513{
514 if ((m_Info == nullptr) || (seq == nullptr) || !(seq->isOpened()))
515 {
516 return;
517 }
518 DRUMSTICK_ALSA_CHECK_WARNING(snd_seq_subscribe_port(seq->getHandle(), m_Info));
519}
520
527void
529{
530 if ((m_Info == nullptr) || (seq == nullptr) || !(seq->isOpened()))
531 {
532 return;
533 }
534 DRUMSTICK_ALSA_CHECK_WARNING(snd_seq_unsubscribe_port(seq->getHandle(), m_Info));
535}
536
541int
543{
544 return snd_seq_port_subscribe_sizeof();
545}
546
547} // namespace ALSA
548} // namespace drumstick
549
Classes managing ALSA Sequencer clients.
Client management.
Definition: alsaclient.h:219
Subscriber container class.
Definition: subscription.h:58
Subscriber()
Default constructor.
Subscriber & operator=(const Subscriber &other)
Assignment operator.
int getSizeOfInfo() const
Gets the size of the ALSA query subscriber object.
const snd_seq_addr_t * getRoot()
Gets the subscriber's root address.
void setType(snd_seq_query_subs_type_t type)
Sets the subscription type.
bool getExclusive()
Gets the subscriber's exclusive flag.
void setRoot(snd_seq_addr_t *addr)
Sets the subscriber's root address.
void setIndex(int index)
Sets the index of the subscriber.
int getIndex()
Gets the index of the subscriber container.
int getClient()
Gets the subscriber's client number.
const snd_seq_addr_t * getAddr()
Gets the subscriber's address.
int getQueue()
Gets the subscriber's queue number.
int getPort()
Gets the subscriober's port number.
int getNumSubs()
Gets the number of subscribers returned by a query operation.
void setClient(int client)
Sets the subscriber's client number.
virtual ~Subscriber()
Destructor.
snd_seq_query_subs_type_t getType()
Gets the subscription type (read or write).
bool getTimeUpdate()
Gets the susbcriber's time-update flag.
Subscriber * clone()
Copy the current object.
void setPort(int port)
Sets the subscriber's port number.
bool getTimeReal()
Gets the subscriber's time real time-stamp flag.
Subscription management.
Definition: subscription.h:97
virtual ~Subscription()
Destructor.
Subscription()
Default constructor.
const snd_seq_addr_t * getSender()
Gets the sender address of the subscription (MIDI OUT port)
void setExclusive(bool val)
Sets the subscription's exclusive flag.
int getSizeOfInfo() const
Gets the size of the ALSA subscription object.
bool getExclusive()
Gets the subscription's exclusive flag.
void setSender(unsigned char client, unsigned char port)
Sets the Subscription's sender (MIDI OUT) port.
void unsubscribe(MidiClient *seq)
Breaks the subscription in the ALSA sequencer subsystem.
Subscription * clone()
Copy the current object.
void setDest(unsigned char client, unsigned char port)
Sets the Subscription's destination (MIDI IN) port.
int getQueue()
Gets the susbcription's queue number.
void setQueue(int queue)
Sets the Subscription's Queue number.
void setTimeUpdate(bool val)
Sets the susbcription's time-update flag.
Subscription & operator=(const Subscription &other)
Assignment operator.
bool getTimeUpdate()
Gets the susbcription's time-update flag.
void setTimeReal(bool val)
Sets the subscription's time real (time-stamping) flag.
const snd_seq_addr_t * getDest()
Gets the destination address of the subscription (MIDI IN port)
void subscribe(MidiClient *seq)
Performs the subscription in the ALSA sequencer subsystem.
bool getTimeReal()
Gets the susbcription's time-real (time-stamping) flag.
Error checking functions and macros.
snd_seq_t * getHandle()
Returns the sequencer handler managed by ALSA.
Definition: alsaclient.cpp:286
bool isOpened()
Returns true if the sequencer is opened.
Definition: alsaclient.cpp:295
#define DRUMSTICK_ALSA_CHECK_WARNING(x)
This macro calls the check warning function.
Definition: errorcheck.h:86
Drumstick common.
Definition: alsaclient.cpp:68