By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,864 Members | 1,279 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,864 IT Pros & Developers. It's quick & easy.

Stop an SDL_sound stream, or possibly kill the fork?

P: n/a
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.
--
There's no place like ~
Help!! I'm being Nibbled to death by cats!!!
"Cardboard is the scourge of humanity, but oh, so very tasty."
Aug 23 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In article <sv5Hg.9848$cQ.2837@trndny07>,
Poly-poly man <py***********@gmail.comwrote:
>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.
--
"law -- it's a commodity"
-- Andrew Ryan (The Globe and Mail, 2005/11/26)
Aug 23 '06 #2

P: n/a
Walter Roberson wrote:
In article <sv5Hg.9848$cQ.2837@trndny07>,
Poly-poly man <py***********@gmail.comwrote:
>>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.
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
--
There's no place like ~
Help!! I'm being Nibbled to death by cats!!!
"Cardboard is the scourge of humanity, but oh, so very tasty."
Aug 23 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.