[SDL] callback issue
chris.2.dobbs at bt.com
chris.2.dobbs at bt.com
Mon Apr 30 08:07:24 PDT 2007
Ok, thanks that kindof makes sense to me. Currently I do this in my
callback routine
void audio_out(void *userdata, Uint8 *stream, int len)
{
Lock internal data queue
Pull off queue len bytes of PCM data into data_p pointer
Call SDL_MixAudio(stream, (const Uint8*)data_p, len, SDL_MIX_MAXVOLUME)
Unlock internal data queue
}
My internal data queue is populated by another thread which receives AMR
data via network, decodes it to PCM and stuffs onto queue ready for this
callback to playback.
Are you saying that I need to get the callback to play slightly before
the start of the next queue block retreived?
Many thanks for your help by the way!
-Chris
-----Original Message-----
From: sdl-bounces at lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org]
On Behalf Of Scott Harper
Sent: 28 April 2007 18:25
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] callback issue
As far as I'm aware, the audio hardware on different systems will ask
for different amounts of audio data each callback, so your
responsibility is to provide it with however much data it asks for.
Often (for me, at least) this has meant playing through the end of one
sample/source and starting the next one just a little bit before the
next callback. It's not clean, but the result sounds nice anyway.
-- Scott
On Apr 28, 2007, at 10:25 AM, Chris Dobbs wrote:
> Futher update on this:
> I tried it on another linux box and guess what ? yep, I get 512 passed
> in as the length as expected.
> Guess this means there is something not right with the other box,
> anyone got and ideas what it could be. I am running with SDL1.2 in
> tandem with the SDL_AudioIn project to provide microphone input.
> Strange thing is I have looke thru some old logs and it definitley
> used to behave correctly so unless I have installed something that's
> upset the sound layer or worse the dsp is shot.
>
> -Chris
> ----- Original Message -----
> From: Chris Dobbs
> To: sdl at lists.libsdl.org
> Sent: Saturday, April 28, 2007 4:28 PM
> Subject: [SDL] callback issue
>
> All,
> Can someone verify if the following behaviour is correct (and if so
> why) regarding audio output.
>
> I have opened the audio device with following params:
> frequency=8000
> samples=256
> channels=1
> format=AUDIO_S16SYS
>
> The audio callback routine I have assigned fires ok but the length
> parameter passed to it is not 512 as I would expect, instead it is
> 340...!?
>
> The way I understand this is that I have asked SDL to allow me to feed
> in 256 16 bit samples (512 bytes) every time the callback fires.
>
> Is this correct or am I missing something - It is possible that my DSP
> has developed a problem as I have noticed odd crackles occasionally in
> the speaker.
> The OS is 2.6.18 custom on a DELL inspiron 6000
>
> Any help is appreciated as usual.
> -Chris
>
>
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
_______________________________________________
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
More information about the SDL
mailing list