I have the following problem with SDL audio output.
I’m trying to program a little program which should do nothing more than
receive decompressed audio data from the network and output it to the sound
card. But I can’t manage to get SDL to play the sound seamlessly.
Even though the networking code is not active, the sound card produces hiccup
sounds about everytime my audio callback is called by SDL.
Judging from the output (no “!”) it does not have to wait for a fresh buffer
(which is filled from a separate thread) even once, so I can’t imagine that
the problem is in the availability of data.
Also, I can’t see how I can make that code much faster than it is now.
The problem persists at all sample frequencies, in mono and in stereo, with
8-bit and 16-bit samples, and at all SDL_AudioSpec.samples values that I
tried.
I can’t understand this. Or maybe I’m just too dense. Googling around and
asking in IRC did not turn up any hints.
I have the following problem with SDL audio output.
I’m trying to program a little program which should do nothing more than
receive decompressed audio data from the network and output it to the sound
card. But I can’t manage to get SDL to play the sound seamlessly.
Even though the networking code is not active, the sound card produces hiccup
sounds about everytime my audio callback is called by SDL.
Judging from the output (no “!”) it does not have to wait for a fresh buffer
(which is filled from a separate thread) even once, so I can’t imagine that
the problem is in the availability of data.
Also, I can’t see how I can make that code much faster than it is now.
The problem persists at all sample frequencies, in mono and in stereo, with
8-bit and 16-bit samples, and at all SDL_AudioSpec.samples values that I
tried.
I can’t understand this. Or maybe I’m just too dense. Googling around and
asking in IRC did not turn up any hints.
Can anyone on this list help?
S?bastien, do you know how long your callback takes to execute? I seem to
remember elsewhere on this list someone trying to do something similar, and they
had to have the buffer set up so that it was ready to go before the previous
chunk of audio finished playing. If you aren’t doing that, and if your callback
is taking roughly the same time to execute as the length of the hiccup sound,
I’d say that’s the problem. You should be able to measure the length of the
hiccup by using the sound card itself to record its output to a file of some
description, which you could then open in a wave editor.
Of course, if you are getting the buffer ready before the previous chunk is
finished, then I have no idea!
I have the following problem with SDL audio output.
I’m trying to program a little program which should do nothing more than
receive decompressed audio data from the network and output it to the sound
card. But I can’t manage to get SDL to play the sound seamlessly.
Does the loopwave test program in the SDL source archive have the same
problem?
See ya,
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment
Judging from the output (no “!”) it does not have to wait for a fresh buffer
Put a cerr.flush() in there and see if that’s still true. It’s possibly
buffering your output until it sees a newline, so you are writing "!"
but it’s not getting to the screen.
Also, if you’re on Windows, is cerr going to stderr.txt instead of a
console window?
in the past : obtained->samples was not updated by the SDL_OpenAudio()
call, but obtained->size was updated correctly ||(dunno if it’s true
today). The code which used directly obtained->samples without
recalculating it from
obtain->size and obtain->audioformat was fooled (this was audible only
if the buffer size changed between desired and obtained).
||
Hope this helps
William.
|Sebastien Braun a ?crit :> Dear List,
I have the following problem with SDL audio output.
I’m trying to program a little program which should do nothing more than
receive decompressed audio data from the network and output it to the sound
card. But I can’t manage to get SDL to play the sound seamlessly.
Even though the networking code is not active, the sound card produces hiccup
sounds about everytime my audio callback is called by SDL.
Judging from the output (no “!”) it does not have to wait for a fresh buffer
(which is filled from a separate thread) even once, so I can’t imagine that
the problem is in the availability of data.
Also, I can’t see how I can make that code much faster than it is now.
The problem persists at all sample frequencies, in mono and in stereo, with
8-bit and 16-bit samples, and at all SDL_AudioSpec.samples values that I
tried.
I can’t understand this. Or maybe I’m just too dense. Googling around and
asking in IRC did not turn up any hints.