[alsa-devel] How to stop playback on alsa synth?

Lukasz Pawelczyk havner at pld-linux.org
Sun Mar 16 17:53:39 CET 2008


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?"


More information about the Alsa-devel mailing list