Stop an SDL_sound stream, or possibly kill the fork?

P

Poly-poly man

I am working on a GTK Midi player (timidgtk.sourceforge.net). As you can
see, it's just a timidity frontend.

With version 0.03, I'm trying to devel it to use SDL_sound to play the
midis. First off, is there a better library for this?
Right now I'm writing a test program to play on console, just so that I can
narrow problems down very quickly. I have a "sound.c" (basically playsound
from SDL_sound, but without a lot of features. I added functions to
initialize (call {SDL, Sound}_init, and the same on exit.) In "test.c" (the
frontend that I link in to sound), I init the stream, fork out, one process
waits for a key then calls the exit functions, the other plays the midi
using the sound function. When I run it, it starts playing, and when I
press a key, it goes back to command line, however, it keeps playing. Only
when I run 'killall myfork' (myfork being the name of the program) does it
stop. I'd like a quick way to stop the music, preferably something
SDL-friendly. If not, tell me how to kill it :)

tia,
poly-p man

I'll give you the source to either source if you need it.
 
W

Walter Roberson

I am working on a GTK Midi player (timidgtk.sourceforge.net). As you can
see, it's just a timidity frontend.
With version 0.03, I'm trying to devel it to use SDL_sound to play the
midis. First off, is there a better library for this?

The C language doesn't know anything about sound, let alone sound
on whatever platform you are using. I suggest that you check
in a newsgroup more specific to your platform.

In "test.c" (the
frontend that I link in to sound), I init the stream, fork out, one process
waits for a key then calls the exit functions, the other plays the midi
using the sound function. When I run it, it starts playing, and when I
press a key, it goes back to command line, however, it keeps playing. Only
when I run 'killall myfork' (myfork being the name of the program) does it
stop. I'd like a quick way to stop the music, preferably something
SDL-friendly. If not, tell me how to kill it :)

fork() is not defined by the C standard, and operates differently
in different operating systems.

In all operating systems that I have looked at, fork() itself returns
different values to the parent (the process that continues executing)
and the child (the new process), and the value returned to the parent
is an identifier of the child. If the child is the one that is set
to play the sound, then when the parent decides that enough is
enough, the parent can use a system-dependant mechanism for killing
the child. One mechanism that is common is to send the child a signal
telling it to quit; a fairly typical name for the operating system
call to do this is kill() .

comp.unix.programmer is a much better venue to discuss fork() and
kill(), if your target platform happens to be Unix compatible.
 
P

Poly-poly man

Walter said:
The C language doesn't know anything about sound, let alone sound
on whatever platform you are using. I suggest that you check
in a newsgroup more specific to your platform.



fork() is not defined by the C standard, and operates differently
in different operating systems.

In all operating systems that I have looked at, fork() itself returns
different values to the parent (the process that continues executing)
and the child (the new process), and the value returned to the parent
is an identifier of the child. If the child is the one that is set
to play the sound, then when the parent decides that enough is
enough, the parent can use a system-dependant mechanism for killing
the child. One mechanism that is common is to send the child a signal
telling it to quit; a fairly typical name for the operating system
call to do this is kill() .

comp.unix.programmer is a much better venue to discuss fork() and
kill(), if your target platform happens to be Unix compatible.

I meant to say that I didn't know if this was the right ng :) I'm
programming in c under linux, with the SDL_sound library, and
c.o.l.anything hates it if you post with programming questions.

poly-p man
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top