New audio recording patch

Okay, I’ve updated the SDL audio recording patch to be both source and
binary compatible with vanilla SDL 1.2. In order to do this, I had to
make the API for recording different than in my original recording
patch. So here’s how you use the new API:

Before you pass your audio spec to SDL_OpenAudio(), you should abuse the
bits in the format field as follows:

Set AUDIO_INPUT (now defined in SDL_audio.h) to enable recording. Set
AUDIO_OUTPUT (also defined in SDL_audio.h) to enable playback. If you
set neither bit, which is what all current SDL programs do, then only
playback is enabled. Examples:

spec.format |= AUDIO_INPUT; /* enables recording /
spec.format |= AUDIO_OUTPUT; /
enables playback */

Then you just set your single callback as in a normal SDL program. SDL
puts any recorded data in the stream buffer for your callback to use.
And then any data you want to play should be stored in that same stream
buffer by the time the callback returns.

Thanks to David Olofson for the idea of the new backwards-compatible
API. Feedback is definitely welcome.–
Dan Helfman
Jim Henson’s Creature Shop
-------------- next part --------------
A non-text attachment was scrubbed…
Name: SDL-1.2-record.diff.gz
Type: application/x-gzip
Size: 5620 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020416/a777e408/attachment.bin

| Feedback is definitely welcome.

In that case, just loop a wire from your soundcard’s input to its
output and put the received data back when the callback returns.

:-)On Tue, Apr 16, 2002 at 03:13:57PM -0700, Dan Helfman wrote:


I will not whittle hall passes out of soap

6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)

| Feedback is definitely welcome.

In that case, just loop a wire from your soundcard’s input to its
output and put the received data back when the callback returns.

:slight_smile:

Okay, I set myself up for that one. :)On Tue, 2002-04-16 at 15:47, James wrote:

On Tue, Apr 16, 2002 at 03:13:57PM -0700, Dan Helfman wrote:


I will not whittle hall passes out of soap

6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)


Dan Helfman
Jim Henson’s Creature Shop

Is there an SDL bugtracker? Couldn’t find one… anyway…

This code crashes OSX SDL in QZ_SetCaption (distilled down to
essentials, no errors are recieved from the inits):

#include “SDL.h”

int main(int argc, char argv[])
{
char * blah = “crash”;
SDL_Init(SDL_INIT_VIDEO);
SDL_SetVideoMode(800,600, 16, SDL_OPENGL);
SDL_WM_SetCaption(blah, blah);
SDL_SetVideoMode(800,600, 16, SDL_OPENGL | SDL_FULLSCREEN);
SDL_WM_SetCaption(blah, blah); /
Crash here */
SDL_Quit();
return(0);
}

Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0x7848001a

Thread 0 Crashed:
#0 0x706bab68 in objc_msgSend
#1 0x30053254 in QZ_SetCaption
#2 0x30048838 in SDL_WM_SetCaption
#3 0x0000496c in SDL_main
#4 0x0000454c in -[SDLMain applicationDidFinishLaunching:]

Warning: when run in the debugger (only), the monitor remains black
after this crash. I have to kill gdb remotely to recover the screen.

-Ben–
http://homepage.mac.com/bhines/

This code crashes OSX SDL in QZ_SetCaption (distilled down to
essentials, no errors are recieved from the inits):

Good job catching this bug.

Add the following at line 377 in SDL_QuartzVideo.m in
QZ_UnsetVideoMode():

qz_window = nil;

That should do the trick!

-DOn Tuesday, April 16, 2002, at 07:45 PM, Ben Hines wrote:

In fact, you could just return from the callback doing nothing, as the
data is already in place. :slight_smile:

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Wednesday 17 April 2002 00:47, James wrote:

On Tue, Apr 16, 2002 at 03:13:57PM -0700, Dan Helfman wrote:
| Feedback is definitely welcome.

In that case, just loop a wire from your soundcard’s input to its
output and put the received data back when the callback returns.

:slight_smile:

This code crashes OSX SDL in QZ_SetCaption (distilled down to
essentials, no errors are recieved from the inits):

Good job catching this bug.

Add the following at line 377 in SDL_QuartzVideo.m in
QZ_UnsetVideoMode():

qz_window = nil;

That should do the trick!

I’m applying the fix. Out of curiousity, does that mean that OpenGL
MacOS X windows in SDL can’t have their caption set?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment> On Tuesday, April 16, 2002, at 07:45 PM, Ben Hines wrote:

I’m applying the fix. Out of curiousity, does that mean that OpenGL
MacOS X windows in SDL can’t have their caption set?

No. For both OpenGL and 2D, there is a window on the screen - the
difference lies in the window’s view. The OpenGL layer in Mac OS X can’t
create a window for us, we have to bind a context to a window.

-DOn Wednesday, April 17, 2002, at 09:25 AM, Sam Lantinga wrote:

Also there is a typo on SDLMain.m vs the SDLMain.nib:

The quit action in the .m file is:

terminate: in SDLApplication

in the nib file the quit item is connected to:

quit: of SDLMain.

The SDLMain class in SDLMain.m has to quit method and it’s not the
app delegate. So the quit item is disabled in a brand new SDL app.

So i moved terminate stuff to the same thing called “quit” in the
SDLMain class:

  • (void)quit:(id)sender
    {
    /* Post a SDL_QUIT event */
    SDL_Event event;
    event.type = SDL_QUIT;
    SDL_PushEvent(&event);
    }

And it works fine.

-Ben–
http://homepage.mac.com/bhines/

Also there is a typo on SDLMain.m vs the SDLMain.nib:

The quit action in the .m file is:

terminate: in SDLApplication

in the nib file the quit item is connected to:

quit: of SDLMain.

The SDLMain class in SDLMain.m has to quit method and it’s not the
app delegate. So the quit item is disabled in a brand new SDL app.

So i moved terminate stuff to the same thing called “quit” in the
SDLMain class:

  • (void)quit:(id)sender
    {
    /* Post a SDL_QUIT event */
    SDL_Event event;
    event.type = SDL_QUIT;
    SDL_PushEvent(&event);
    }

Does the application exit after the quit method is called? The app should
not quit until the SDL event loop gets the SDL_QUIT, which it can ignore
or return from the app’s event loop to quit the app.

I believe the terminate method can tell the caller whether or not the app
acknowledged the quit, which is what we want.

Can you instead bind the quit menu to the terminate method of SDLMain in
the nib file?

-DOn Wed, 17 Apr 2002, Ben Hines wrote:

At 11:28 AM -0500 4/17/02, Darrell Walisser wrote:

Does the application exit after the quit method is called? The app should
not quit until the SDL event loop gets the SDL_QUIT, which it can ignore
or return from the app’s event loop to quit the app.

With my change it works fine with the OpenGL test app. Without my
change the quit item is disabled, because its action doesn’t exist. I
don’t think you want that… Something is wrong, quit item should be
enabled for the samples. :slight_smile:

I believe the terminate method can tell the caller whether or not the app
acknowledged the quit, which is what we want.

Can you instead bind the quit menu to the terminate method of SDLMain in
the nib file?

SDLMain doesn’t have a terminate method. The terminate method is on
SDLApplication.
I tried giving it one (in IB only, not adding it to the m file) but
the menu item is disabled because Cocoa knows SDLMain doesn’t really
have the method.

Basically the quit item in the nib file is connected to an action in
SDLMain class that doesn’t exist. (“quit”)

I’m not sure what all the poseasclass business is about. Just adding
the quit method to SDLMain works.

-Ben–
http://homepage.mac.com/bhines/