473,325 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Stop an SDL_sound stream, or possibly kill the fork?

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
2 2126
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: shyren | last post by:
Hi All, I have a php program which calls a c++ program using exec. However when user presses stop button in the browser or closes it this program keeps on running on the server. How can I stop it...
1
by: stash | last post by:
When I stop all DB2 services on our Unix box - I still can see the following two DB2 processes running: root 20410 1 0 Oct 28 - 4:16 /usr/opt/db2_08_01/bin/db2fmcd db2as 21780 ...
1
by: Alexander N. Spitzer | last post by:
I am trying to write a program that will fork a process, and execute the given task... the catch is that if it runs too long, I want to clean it up. this seemed pretty straight forward with a...
4
by: kmkz | last post by:
Hi, I have a program A that forks off two other programs, B and C. I need B and C to both terminate if A is closed, but by using the subprocess.call() method this seems to not be the case; I can...
0
by: Dirk Zimmermann | last post by:
Hi, I like to do the following: Via http I get a stream of data and I like to store this data with a python program. So what I need is to start the downloading and to stop it after a given time....
4
by: Helge Jensen | last post by:
In C# 2.0 System.IO.Stream is declared as: public class Stream: ..., IDisposable { ... public void Dispose(); public void Dispose(bool); IDisposable.Dispose(); } Which must be a...
51
by: Hans | last post by:
Hi all, Is there a way that the program that created and started a thread also stops it. (My usage is a time-out). E.g. thread = threading.Thread(target=Loop.testLoop) thread.start() ...
5
by: JoeW | last post by:
Now before I go into detail I just want to say that this is purely for my own benefit and has no real world usage. I remember way back when the tool for *nix systems called forkbomb was created. I...
3
by: CMorgan | last post by:
Hi everybody, I am experiencing an annoying problem with fork() and execv(). In my program I need to launch the "pppd" from a thread, so, I create a new process with fork and then in the child...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.