Calling SDL_OpenAudio twice

Hi,
I’m trying to play two audio files simultaneously by calling
SDL_OpenAudio twice with different SDL_AudioSpec.callback and
SDL_AudioSpec.userdata, but I still get the usual error:
“SDL_OpenAudio: Audio device is already opened”

What have I missed?

Fedora 10, SDL 1.2.

Thanks,
Tomer

Hello !

I’m trying to play two audio files simultaneously by calling
SDL_OpenAudio twice with different SDL_AudioSpec.callback and
SDL_AudioSpec.userdata, but I still get the usual error:
“SDL_OpenAudio: Audio device is already opened”

What have I missed?

Nothing, this is a limitation of SDL 1.2.
It can only open one audio channel at the time.
The same, as it can open only one window at the time.

Have a look at SDL 1.3. Most limitations are gone there.

CU

Hi Torsten, and thanks for your reply.On Tue, Feb 17, 2009 at 5:56 PM, Torsten Giebl wrote:

Hello !

I’m trying to play two audio files simultaneously by calling
SDL_OpenAudio twice with different SDL_AudioSpec.callback and
SDL_AudioSpec.userdata, but I still get the usual error:
“SDL_OpenAudio: Audio device is already opened”

What have I missed?

Nothing, this is a limitation of SDL 1.2.
It can only open one audio channel at the time.
The same, as it can open only one window at the time.

Have a look at SDL 1.3. Most limitations are gone there.

The thing is, that when I open two different instances of my
application - I do get two audio channels.
I also tested it with FFmpeg’s player application - FFplay, which uses
SDL to render video and audio. Two instances of FFplay playing the
same file will work simultaneously.

Tomer

Hello !

The thing is, that when I open two different instances of my
application - I do get two audio channels.
I also tested it with FFmpeg’s player application - FFplay, which uses
SDL to render video and audio. Two instances of FFplay playing the
same file will work simultaneously.

This is a different thing. Running two instances
(better to say two processes) of for example playwave
is different then opening two channels at the same time in one process.

CU

How about opening the audio twice in the same program run, after
having closed it the first time? It works fine for me in all my
testing (with NVidia video hardware), but several people have reported
issues of it not working with ATI hardware.

I reported this a while back. Has anyone ever heard of this before??

SAOn February 17, 2009 01:10:10 pm Torsten Giebl wrote:

Hello !

The thing is, that when I open two different instances of my
application - I do get two audio channels.
I also tested it with FFmpeg’s player application - FFplay, which
uses SDL to render video and audio. Two instances of FFplay playing
the same file will work simultaneously.

This is a different thing. Running two instances
(better to say two processes) of for example playwave
is different then opening two channels at the same time in one
process.

The thing is that I want to swap between those two sources multiple
times. I planned to do this by pausing one, then resuming the other,
which will be faster than repeatedly opening (allocating) and closing
(releasing) the channel.

TomerOn Tue, Feb 17, 2009 at 6:53 PM, Stephen Anthony wrote:

How about opening the audio twice in the same program run, after
having closed it the first time? It works fine for me in all my
testing (with NVidia video hardware), but several people have reported
issues of it not working with ATI hardware.

Hello !

How about opening the audio twice in the same program run, after
having closed it the first time? It works fine for me in all my
testing (with NVidia video hardware), but several people have reported
issues of it not working with ATI hardware.

I think he wants to play two sound files at the same time within
two channels. How would opening and closing audio help you in that case ?

CU

The thing is that I want to swap between those two sources multiple
times. I planned to do this by pausing one, then resuming the other,
which will be faster than repeatedly opening (allocating) and closing
(releasing) the channel.

Maybe what you need is SDL_mixer?On Tue, Feb 17, 2009 at 12:05 PM, Tomer Barletz wrote:


http://pphaneuf.livejournal.com/

Actually, I wasn’t suggesting that approach, but asking if anyone had
seen the problems with ATI hardware that I’d found. But I can see how
I worded it as a suggestion :slight_smile:

SAOn February 17, 2009 01:35:31 pm Tomer Barletz wrote:

On Tue, Feb 17, 2009 at 6:53 PM, Stephen Anthony <@Stephen_Anthony> wrote:

How about opening the audio twice in the same program run, after
having closed it the first time? It works fine for me in all my
testing (with NVidia video hardware), but several people have
reported issues of it not working with ATI hardware.

The thing is that I want to swap between those two sources multiple
times. I planned to do this by pausing one, then resuming the other,
which will be faster than repeatedly opening (allocating) and closing
(releasing) the channel.

As in my previous response, it wouldn’t. I didn’t mean this to be a
suggestion; I was asking if anyone has seen similar problems with ATI
video cards, and opening the audio subsystem any time after it has been
closed once is not working.

SAOn February 17, 2009 01:38:12 pm Torsten Giebl wrote:

Hello !

How about opening the audio twice in the same program run, after
having closed it the first time? It works fine for me in all my
testing (with NVidia video hardware), but several people have
reported issues of it not working with ATI hardware.

I think he wants to play two sound files at the same time within
two channels. How would opening and closing audio help you in that
case ?

Hello !

As in my previous response, it wouldn’t. I didn’t mean this to be a
suggestion; I was asking if anyone has seen similar problems with ATI
video cards, and opening the audio subsystem any time after it has been
closed once is not working.

I am sorry then i misread it :frowning:

Can you put together a minimal example that shows
the problem or is there already one in Bugzilla ?

I know two people that have ATI cards, would
like to test it out on there computers.

CU

Sorry, I can’t provide a test case right now, as this was reported by
end users with ATI hardware, and I don’t have such hardware. That’s
why I originally inquired about it; to see if anyone else has
experienced the same problem, and where I can possibly start in
tracking it down. In fact, I’m not even sure it’s related to ATI
hardware (that seems to be the only constant with the people that are
having the problem).

SAOn February 17, 2009 02:03:08 pm Torsten Giebl wrote:

Hello !

As in my previous response, it wouldn’t. I didn’t mean this to be
a suggestion; I was asking if anyone has seen similar problems with
ATI video cards, and opening the audio subsystem any time after it
has been closed once is not working.

I am sorry then i misread it :frowning:

Can you put together a minimal example that shows
the problem or is there already one in Bugzilla ?

I know two people that have ATI cards, would
like to test it out on there computers.

You cannot.

Most operating systems (or more accurately, the most common APIs to
get audio out of your application and into your computer’s audio DAC)
do not allow you to open more than one audio stream to be plugged into
some separate mixer before being sent to your DAC (or, rather
similarly, sent to a unified device that does both mixing and DAC.)

The result is that if you want to play two sounds at the same time,
you need to mix them.

Are you playing music? Is your music comprised of multiple concurrent
sounds? Wonder how they were able to put multiple concurrent sounds
into the same audio track? Probably not, but it’s called “mixing,” and
if it isn’t done ahead of time (because it probably cannot be done
ahead of time) then it has to be done just-in-time (in your
application.)

What kind of application are you working on? SDL may not be the most
appropriate choice if you’re really only doing audio. I myself am
becoming quite fond of GStreamer (http://gstreamer.freedesktop.org/)
and if your application’s primary programming challenges are things
like mixing multimedia streams, I recommend switching to GStreamer
immediately!

On the other hand, if you’re writing a game, stick with SDL: writing a
mixer is not extremely complex, and can in fact be quite simple.On Tue, Feb 17, 2009 at 10:28 AM, Tomer Barletz wrote:

Hi,
I’m trying to [call] SDL_OpenAudio twice …

What have I missed?


http://codebad.com/