本文整理汇总了C++中snd_seq_close函数的典型用法代码示例。如果您正苦于以下问题:C++ snd_seq_close函数的具体用法?C++ snd_seq_close怎么用?C++ snd_seq_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了snd_seq_close函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printf
bool Midi2UdpThread::initSeq()
{
if(snd_seq_open(&seq_handle, "default", SND_SEQ_OPEN_INPUT, 0) < 0) {
printf("midi2udp: Error opening ALSA sequencer.\n");
return false;
}
snd_seq_set_client_name(seq_handle, "DSMIDIWIFI MIDI2UDP");
char portname[64] = "DSMIDIWIFI MIDI2UDP IN";
int res = midi_in_port = snd_seq_create_simple_port(seq_handle, portname, SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE,
SND_SEQ_PORT_TYPE_APPLICATION);
if(res < 0) {
printf("midi2udp: Error creating MIDI port!\n");
snd_seq_close(seq_handle);
return false;
}
res = snd_midi_event_new(MAX_MIDI_MESSAGE_LENGTH, &eventparser);
if(res != 0) {
printf("midi2udp: Error making midi event parser!\n");
snd_seq_close(seq_handle);
return false;
}
snd_midi_event_init(eventparser);
midi_event = (snd_seq_event_t*)malloc(sizeof(snd_seq_event_t));
return true;
}
示例2: stop_midireceiver
void stop_midireceiver (JackVST *jvst)
{
int err;
snd_seq_event_t event;
snd_seq_t *seq2 = create_sequencer ("jfstquit", true);
jvst->midiquit = 1;
snd_seq_connect_to (seq2, 0, snd_seq_client_id (jvst->seq),0);
snd_seq_ev_clear (&event);
snd_seq_ev_set_direct (&event);
snd_seq_ev_set_subs (&event);
snd_seq_ev_set_source (&event, 0);
snd_seq_ev_set_controller (&event,1,0x80,50);
if ((err = snd_seq_event_output (seq2, &event)) < 0) {
fst_error ("cannot send stop event to midi thread: %s\n",
snd_strerror (err));
}
snd_seq_drain_output (seq2);
snd_seq_close (seq2);
pthread_join (jvst->midi_thread,NULL);
snd_seq_close (jvst->seq);
}
示例3: seq_open
int seq_open() {
unsigned int caps;
if (!seq_opened) {
/* sequencer opening */
if (snd_seq_open(&seq_handle, "hw", SND_SEQ_OPEN_OUTPUT, 0)) {
fprintf(stderr, "Error opening ALSA sequencer.\n");
return(-1);
}
/* our client id */
my_client = snd_seq_client_id(seq_handle);
/* set client info */
snd_seq_set_client_name(seq_handle, DEFAULT_NAME);
/* create port */
caps = SND_SEQ_PORT_CAP_READ;
if (seq_client == SND_SEQ_ADDRESS_SUBSCRIBERS)
caps |= SND_SEQ_PORT_CAP_SUBS_READ;
my_port = snd_seq_create_simple_port(seq_handle, DEFAULT_NAME, caps,SND_SEQ_PORT_TYPE_MIDI_GENERIC | SND_SEQ_PORT_TYPE_APPLICATION);
if (my_port < 0) {
fprintf(stderr, "can't create port\n");
snd_seq_close(seq_handle);
return 0;
}
/* subscribe to MIDI port */
if (seq_client != SND_SEQ_ADDRESS_SUBSCRIBERS) {
if (snd_seq_connect_to(seq_handle, my_port, seq_client, seq_port) < 0) {
fprintf(stderr, "can't subscribe to MIDI port (%d:%d)\n", seq_client, seq_port);
snd_seq_close(seq_handle);
return 0;
}
}
}
seq_opened = 1;
return 1;
}
示例4: getConfigSetting
int ALSAMidiDriver::open() {
std::string arg;
unsigned int caps;
if (isOpen)
return -1;
arg = getConfigSetting("alsa_port", ALSA_PORT);
if (parse_addr(arg, &seq_client, &seq_port) < 0) {
perr << "ALSAMidiDriver: Invalid port: " << arg << std::endl;
return -1;
}
if (my_snd_seq_open(&seq_handle)) {
perr << "ALSAMidiDriver: Can't open sequencer" << std::endl;
return -1;
}
isOpen = true;
my_client = snd_seq_client_id(seq_handle);
snd_seq_set_client_name(seq_handle, "PENTAGRAM");
snd_seq_set_client_group(seq_handle, "input");
caps = SND_SEQ_PORT_CAP_READ;
if (seq_client == SND_SEQ_ADDRESS_SUBSCRIBERS)
caps = ~SND_SEQ_PORT_CAP_SUBS_READ;
my_port =
snd_seq_create_simple_port(seq_handle, "PENTAGRAM", caps,
SND_SEQ_PORT_TYPE_MIDI_GENERIC | SND_SEQ_PORT_TYPE_APPLICATION);
if (my_port < 0) {
snd_seq_close(seq_handle);
isOpen = false;
perr << "ALSAMidiDriver: Can't create port" << std::endl;
return -1;
}
if (seq_client != SND_SEQ_ADDRESS_SUBSCRIBERS) {
/* subscribe to MIDI port */
if (snd_seq_connect_to(seq_handle, my_port, seq_client, seq_port) < 0) {
snd_seq_close(seq_handle);
isOpen = false;
perr << "ALSAMidiDriver: "
<< "Can't subscribe to MIDI port (" << seq_client
<< ":" << seq_port << ")" << std::endl;
return -1;
}
}
pout << "ALSA client initialised [" << seq_client << ":"
<< seq_port << "]" << std::endl;
return 0;
}
示例5: createDevice
static snd_seq_t* createDevice (const bool forInput,
const String& deviceNameToOpen)
{
snd_seq_t* seqHandle = 0;
if (snd_seq_open (&seqHandle, "default", forInput ? SND_SEQ_OPEN_INPUT
: SND_SEQ_OPEN_OUTPUT, 0) == 0)
{
snd_seq_set_client_name (seqHandle,
(const char*) (forInput ? (deviceNameToOpen + T(" Input"))
: (deviceNameToOpen + T(" Output"))));
const int portId
= snd_seq_create_simple_port (seqHandle,
forInput ? "in"
: "out",
forInput ? (SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE)
: (SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ),
forInput ? SND_SEQ_PORT_TYPE_APPLICATION
: SND_SEQ_PORT_TYPE_MIDI_GENERIC);
if (portId < 0)
{
snd_seq_close (seqHandle);
seqHandle = 0;
}
}
return seqHandle;
}
示例6: snd_seq_open
static snd_seq_t *create_alsa_seq(const char *client_name,bool isinput){
snd_seq_t * seq;
int err;
err = snd_seq_open(&seq, "default", SND_SEQ_OPEN_DUPLEX, 0);
if (err){
printf( "Could not open ALSA sequencer, aborting\n\n%s\n\n"
"Make sure you have configure ALSA properly and that\n"
"/proc/asound/seq/clients exists and contains relevant\n"
"devices.\n", snd_strerror (err));
return NULL;
}
snd_seq_set_client_name (seq, client_name);
err = snd_seq_create_simple_port (seq, isinput==true?"Input":"Output",
(isinput==true?SND_SEQ_PORT_CAP_WRITE:SND_SEQ_PORT_CAP_READ)|SND_SEQ_PORT_CAP_DUPLEX|
SND_SEQ_PORT_CAP_SUBS_READ|SND_SEQ_PORT_CAP_SUBS_WRITE,
SND_SEQ_PORT_TYPE_APPLICATION|SND_SEQ_PORT_TYPE_SPECIFIC);
if (err){
printf ( "Could not create ALSA port, aborting\n\n%s\n", snd_strerror (err));
snd_seq_close(seq);
return NULL;
}
return seq;
}
示例7: snd_seq_close
void Udp2MidiThread::freeSeq()
{
int res = snd_seq_close(seq_handle);
if( res < 0 ) {
printf("udp2midi: Error closing socket!\n");
}
}
示例8: jack_finish
void
jack_finish (void *arg)
{
struct a2j* self = (struct a2j*) arg;
void* thread_status;
self->finishing = 1;
a2j_debug("midi: delete");
g_keep_alsa_walking = false; /* tell alsa io thread to stop, whenever they wake up */
/* do something that we need to do anyway and will wake the io thread, then join */
snd_seq_disconnect_from (self->seq, self->port_id, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_ANNOUNCE);
a2j_debug ("wait for ALSA io thread\n");
pthread_join (self->alsa_io_thread, &thread_status);
a2j_debug ("thread done\n");
jack_ringbuffer_reset (self->port_add);
a2j_stream_detach (&self->stream);
snd_seq_close(self->seq);
self->seq = NULL;
a2j_stream_close (self);
jack_ringbuffer_free(self->port_add);
jack_ringbuffer_free(self->port_del);
free (self);
}
示例9: snd_seq_client_info_alloca
AlsaDevices AlsaMusicPlugin::getAlsaDevices() const {
AlsaDevices devices;
snd_seq_t *seq_handle;
if (my_snd_seq_open(&seq_handle) < 0)
return devices; // can't open sequencer
snd_seq_client_info_t *cinfo;
snd_seq_client_info_alloca(&cinfo);
snd_seq_port_info_t *pinfo;
snd_seq_port_info_alloca(&pinfo);
snd_seq_client_info_set_client(cinfo, -1);
while (snd_seq_query_next_client(seq_handle, cinfo) >= 0) {
bool found_valid_port = false;
/* reset query info */
snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo));
snd_seq_port_info_set_port(pinfo, -1);
while (!found_valid_port && snd_seq_query_next_port(seq_handle, pinfo) >= 0) {
if (check_permission(pinfo)) {
found_valid_port = true;
const char *name = snd_seq_client_info_get_name(cinfo);
// TODO: Can we figure out the appropriate music type?
MusicType type = MT_GM;
int client = snd_seq_client_info_get_client(cinfo);
devices.push_back(AlsaDevice(name, type, client));
}
}
}
snd_seq_close(seq_handle);
return devices;
}
示例10: snd_seq_close
void MIDIOut::initALSA()
{
snd_seq_client_info_t* client = NULL;
/* Destroy the old handle */
if (m_alsa != NULL)
snd_seq_close(m_alsa);
m_alsa = NULL;
/* Destroy the plugin's own address */
if (m_address != NULL)
delete m_address;
m_address = NULL;
/* Open the sequencer interface */
if (snd_seq_open(&m_alsa, "default", SND_SEQ_OPEN_DUPLEX, 0) != 0)
{
qWarning() << "Unable to open ALSA interface!";
m_alsa = NULL;
return;
}
/* Set current client information */
snd_seq_client_info_alloca(&client);
snd_seq_set_client_name(m_alsa, name().toAscii());
snd_seq_get_client_info(m_alsa, client);
/* Create an application-level port */
m_address = new snd_seq_addr_t;
m_address->port = snd_seq_create_simple_port(m_alsa, "__QLC__output",
SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ,
SND_SEQ_PORT_TYPE_MIDI_GENERIC);
m_address->client = snd_seq_client_info_get_client(client);
}
示例11: snd_seq_close
void Midi2UdpThread::freeSeq()
{
int res = snd_seq_close(seq_handle);
if( res < 0 ) {
printf("midi2udp: Error closing socket!\n");
}
}
示例12: snd_seq_poll_descriptors_count
void DeviceManager::loop()
{
struct pollfd *pfds;
int npfds;
int c, err;
npfds = snd_seq_poll_descriptors_count(handle, POLLIN);
D("npfds: %d", npfds);
pfds = (struct pollfd *)alloca(sizeof(*pfds) * npfds);
for (;;) {
snd_seq_poll_descriptors(handle, pfds, npfds, POLLIN);
if (poll(pfds, npfds, -1) < 0)
break;
do {
snd_seq_event_t *event;
err = snd_seq_event_input(handle, &event);
if (err < 0)
break;
if (event){
list[0]->processEvent(event);
}
} while (err > 0);
fflush(stdout);
// if (stop)
// break;
}
snd_seq_close(handle);
}
示例13: del_aubio_alsa_seq_driver
/** del_aubio_alsa_seq_driver */
int del_aubio_alsa_seq_driver(aubio_midi_driver_t* p)
{
aubio_alsa_seq_driver_t* dev;
dev = (aubio_alsa_seq_driver_t*) p;
if (dev == NULL) {
return AUBIO_OK;
}
dev->status = AUBIO_MIDI_DONE;
/* cancel the thread and wait for it before cleaning up */
if (dev->thread) {
if (pthread_cancel(dev->thread)) {
AUBIO_ERR( "Failed to cancel the midi thread");
return AUBIO_FAIL;
}
if (pthread_join(dev->thread, NULL)) {
AUBIO_ERR( "Failed to join the midi thread");
return AUBIO_FAIL;
}
}
if (dev->seq_port >= 0) {
snd_seq_delete_simple_port (dev->seq_handle, dev->seq_port);
}
if (dev->seq_handle) {
snd_seq_drain_output(dev->seq_handle);
snd_seq_close(dev->seq_handle);
}
AUBIO_FREE(dev);
return AUBIO_OK;
}
示例14: snd_seq_delete_simple_port
qxgeditMidiDevice::~qxgeditMidiDevice (void)
{
// Reset pseudo-singleton reference.
g_pMidiDevice = NULL;
// Last but not least, delete input thread...
if (m_pInputThread) {
// Try to terminate executive thread,
// but give it a bit of time to cleanup...
if (m_pInputThread->isRunning()) {
m_pInputThread->setRunState(false);
// m_pInputThread->terminate();
m_pInputThread->wait();
}
delete m_pInputThread;
m_pInputThread = NULL;
}
if (m_pAlsaSeq) {
snd_seq_delete_simple_port(m_pAlsaSeq, m_iAlsaPort);
m_iAlsaPort = -1;
snd_seq_close(m_pAlsaSeq);
m_iAlsaClient = -1;
m_pAlsaSeq = NULL;
}
}
示例15: test_teardown
static void
test_teardown (void)
{
ck_g_object_final_unref (registry);
if (seq) {
snd_seq_close (seq);
}
}