drumstick 0.5.0
subscription.cpp
Go to the documentation of this file.
1/*
2 MIDI Sequencer C++ library
3 Copyright (C) 2006-2010, 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 2 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 along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18*/
19
20#include "alsaclient.h"
21
27namespace drumstick {
28
54{
55 snd_seq_query_subscribe_malloc(&m_Info);
56}
57
63{
64 snd_seq_query_subscribe_malloc(&m_Info);
65 snd_seq_query_subscribe_copy(m_Info, other.m_Info);
66}
67
72Subscriber::Subscriber(snd_seq_query_subscribe_t* other)
73{
74 snd_seq_query_subscribe_malloc(&m_Info);
75 snd_seq_query_subscribe_copy(m_Info, other);
76}
77
82{
83 snd_seq_query_subscribe_free(m_Info);
84}
85
91{
92 return new Subscriber(m_Info);
93}
94
101{
102 snd_seq_query_subscribe_copy(m_Info, other.m_Info);
103 return *this;
104}
105
110int
112{
113 return snd_seq_query_subscribe_get_client(m_Info);
114}
115
120int
122{
123 return snd_seq_query_subscribe_get_port(m_Info);
124}
125
130const snd_seq_addr_t*
132{
133 return snd_seq_query_subscribe_get_root(m_Info);
134}
135
144snd_seq_query_subs_type_t
146{
147 return snd_seq_query_subscribe_get_type(m_Info);
148}
149
154int
156{
157 return snd_seq_query_subscribe_get_index(m_Info);
158}
159
164int
166{
167 return snd_seq_query_subscribe_get_num_subs(m_Info);
168}
169
174const snd_seq_addr_t*
176{
177 return snd_seq_query_subscribe_get_addr(m_Info);
178}
179
184int
186{
187 return snd_seq_query_subscribe_get_queue(m_Info);
188}
189
194bool
196{
197 return (snd_seq_query_subscribe_get_exclusive(m_Info) != 0);
198}
199
204bool
206{
207 return (snd_seq_query_subscribe_get_time_update(m_Info) != 0);
208}
209
214bool
216{
217 return (snd_seq_query_subscribe_get_time_real(m_Info) != 0);
218}
219
224void
226{
227 snd_seq_query_subscribe_set_client(m_Info, client);
228}
229
234void
236{
237 snd_seq_query_subscribe_set_port(m_Info, port);
238}
239
244void
245Subscriber::setRoot(snd_seq_addr_t* addr)
246{
247 snd_seq_query_subscribe_set_root(m_Info, addr);
248}
249
258void
259Subscriber::setType(snd_seq_query_subs_type_t type)
260{
261 snd_seq_query_subscribe_set_type(m_Info, type);
262}
263
268void
270{
271 snd_seq_query_subscribe_set_index(m_Info, index);
272}
273
278int
280{
281 return snd_seq_query_subscribe_sizeof();
282}
283
288{
289 snd_seq_port_subscribe_malloc(&m_Info);
290}
291
297{
298 snd_seq_port_subscribe_malloc(&m_Info);
299 snd_seq_port_subscribe_copy(m_Info, other.m_Info);
300}
301
306Subscription::Subscription(snd_seq_port_subscribe_t* other)
307{
308 snd_seq_port_subscribe_malloc(&m_Info);
309 snd_seq_port_subscribe_copy(m_Info, other);
310}
311
317{
318 snd_seq_port_subscribe_malloc(&m_Info);
319 CHECK_WARNING(snd_seq_get_port_subscription(seq->getHandle(), m_Info));
320}
321
327{
328 snd_seq_port_subscribe_free(m_Info);
329}
330
337{
338 return new Subscription(m_Info);
339}
340
348{
349 snd_seq_port_subscribe_copy(m_Info, other.m_Info);
350 return *this;
351}
352
357const snd_seq_addr_t*
359{
360 return snd_seq_port_subscribe_get_sender(m_Info);
361}
362
367const snd_seq_addr_t*
369{
370 return snd_seq_port_subscribe_get_dest(m_Info);
371}
372
377int
379{
380 return snd_seq_port_subscribe_get_queue(m_Info);
381}
382
387bool
389{
390 return (snd_seq_port_subscribe_get_exclusive(m_Info) != 0);
391}
392
397bool
399{
400 return (snd_seq_port_subscribe_get_time_update(m_Info) != 0);
401}
402
407bool
409{
410 return (snd_seq_port_subscribe_get_time_real(m_Info) != 0);
411}
412
417void
418Subscription::setSender(const snd_seq_addr_t* addr)
419{
420 snd_seq_port_subscribe_set_sender(m_Info, addr);
421}
422
427void
428Subscription::setDest(const snd_seq_addr_t* addr)
429{
430 snd_seq_port_subscribe_set_dest(m_Info, addr);
431}
432
437void
439{
440 snd_seq_port_subscribe_set_queue(m_Info, q);
441}
442
447void
449{
450 snd_seq_port_subscribe_set_exclusive(m_Info, val?1:0);
451}
452
457void
459{
460 snd_seq_port_subscribe_set_time_update(m_Info, val?1:0);
461}
462
467void
469{
470 snd_seq_port_subscribe_set_time_real(m_Info, val?1:0);
471}
472
478void
479Subscription::setSender(unsigned char client, unsigned char port)
480{
481 snd_seq_addr_t addr;
482 addr.client = client;
483 addr.port = port;
484 setSender(&addr);
485}
486
492void
493Subscription::setDest(unsigned char client, unsigned char port)
494{
495 snd_seq_addr_t addr;
496 addr.client = client;
497 addr.port = port;
498 setDest(&addr);
499}
500
507void
509{
510 if ((m_Info == NULL) || (seq == NULL) || !(seq->isOpened()))
511 {
512 return;
513 }
514 CHECK_WARNING(snd_seq_subscribe_port(seq->getHandle(), m_Info));
515}
516
523void
525{
526 if ((m_Info == NULL) || (seq == NULL) || !(seq->isOpened()))
527 {
528 return;
529 }
530 CHECK_WARNING(snd_seq_unsubscribe_port(seq->getHandle(), m_Info));
531}
532
537int
539{
540 return snd_seq_port_subscribe_sizeof();
541}
542
543} /* namespace drumstick */
544
Classes managing ALSA Sequencer clients.
Client management.
Definition: alsaclient.h:199
snd_seq_t * getHandle()
Returns the sequencer handler managed by ALSA.
Definition: alsaclient.h:235
bool isOpened()
Returns true if the sequencer is opened.
Definition: alsaclient.h:237
Subscriber container class.
Definition: subscription.h:44
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:83
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.
#define CHECK_WARNING(x)
This macro calls the check warning function.