* How to stop playback on alsa synth?
@ 2008-03-16 16:53 Lukasz Pawelczyk
2008-03-16 21:48 ` Lukasz Pawelczyk
0 siblings, 1 reply; 2+ messages in thread
From: Lukasz Pawelczyk @ 2008-03-16 16:53 UTC (permalink / raw)
To: alsa-devel
Hello.
I'd like to ask how to completely stop playback using alsa synth.
Basically my program initialized output in the following way:
snd_seq_open()
snd_seq_set_client_name()
snd_seq_client_id()
snd_seq_parse_address()
snd_seq_create_simple_port()
snd_seq_connect_to()
snd_seq_alloc_named_queue()
Then I create a new thread that processes events.
It sets tempo and in infinite loop it does:
snd_seq_ev_set_fixed()
snd_seq_event_output()
This all is based on aplaymidi code.
How can I asynchronously immediately stop all the playback? Basicaly it
requires breaking snd_seq_event_output() thats locked on my thread.
I tried everything I could come up with. I know very little about alsa
synth programming and basically thats the only thing i need to do now.
Tried:
snd_seq_ev_set_queue_stop()
snd_seq_stop_queue()
snd_seq_remove_events()
or even closing the seq completely to reopen it on another file playback
with:
snd_seq_stop_queue()
snd_seq_disconnect_to()
snd_seq_delete_simple_port()
snd_seq_close()
All failed, results were very various. I simply run out of ideas. It
doesn't matter if the method would require to close seq or not. I just
need to stop the playback so i can gracefully stop the thread and play
another file (with eventual reopening ports/seq).
Would appreciate any help.
--
Regards Havner {jid,mail}:havner(at)pld-linux.org
"Quis custodiet ipsos custodes?"
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: How to stop playback on alsa synth?
2008-03-16 16:53 How to stop playback on alsa synth? Lukasz Pawelczyk
@ 2008-03-16 21:48 ` Lukasz Pawelczyk
0 siblings, 0 replies; 2+ messages in thread
From: Lukasz Pawelczyk @ 2008-03-16 21:48 UTC (permalink / raw)
To: alsa-devel
I think I've done it, just don't know how correct my solution is
I've added snd_seq_drain_output() after snd_seq_event_output() in thread
function so the events are processed more "real time" as I understand
it. I've also moved queue creation to the beginning of thread function
(because stop function deletes the queue).
Then the stop function calls:
sets a bool to break the thread loop.
snd_seq_free_queue()
snd_seq_drop_output()
This seems to work. Any comments?
One problem I got with it though is that sometimes when I stop one music
and play another one some note(s) from the old one are played
indefinitely during the new music. I suppose some 'clear' event should
be sent to remove it. I've tried MIDI_CTL_ALL_SOUNDS_OFF control one (as
pmidi does on exit) but no luck.
--
Regards Havner {jid,mail}:havner(at)pld-linux.org
"Quis custodiet ipsos custodes?"
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-03-16 21:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-16 16:53 How to stop playback on alsa synth? Lukasz Pawelczyk
2008-03-16 21:48 ` Lukasz Pawelczyk
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.