Re: [hatari-devel] SDL1 vs. SDL2 sound pausing |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [hatari-devel] SDL1 vs. SDL2 sound pausing
- From: David Savinkoff <dsavnkff@xxxxxxxxx>
- Date: Sat, 10 Sep 2016 13:20:12 -0600 (MDT)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telus.net; s=neo; t=1473535212; bh=RdeozGVJT9BuY7ZiZwvfURPf3pt8zpku47U1DhNQGPs=; h=Date:From:To:In-Reply-To:Subject; b=NK9/vTOnjx60fEwo0AUvF3CGJDg4g5/6hPnIIGgaB1UkoG1HI2JWigoUYY9I1fVrs 5xBSW7hi9rla2ufLc7BLBWk7Glgd4ILjEcYVTfvltnER0FSbRm5Sv+4fjxogI1t18u AdKHxhZC3qXP/OMNaMWc2SI8iXT1x/BYVVXwbqkU0Can8LzT2m7oCZ/6rHNhcehd+b 0gkJPvbZPiB83I1HQeHAVwtsHNrse+HSZxTfC565ftDa8cvIKGZPHv/9wgkunmtFLD xzjVfzke8/FCCjh8bPZHWyS0dYcGez0gWWG5D9T0/5UgukgFv99O3ehhh2nsPxLvDr v6oFzYkv1xuzg==
- Thread-index: aoqhzakZuzn06Fpq62kMf+5Cj9ZQLQ==
- Thread-topic: SDL1 vs. SDL2 sound pausing
Thomas Huth wrote:
> Am Sat, 10 Sep 2016 18:32:05 +0200
> schrieb Nicolas Pomarède:
>
> > Le 10/09/2016 à 17:45, Thomas Huth a écrit :
> > > Am Sat, 10 Sep 2016 17:03:16 +0200
> > > schrieb Jerome Vernet:
> > >
> > >> Le 10/09/2016 à 16:09, Nicolas Pomarède a écrit :
> > >>> printf ( "audio cbk %d %d\n" , nGeneratedSamples ,
> > >>> CompleteSndBufIdx )
> > >> You're right, nGeneratedSamples == 0 while in menus (or in other
> > >> thing, before emulation can be paused), and CompleteSndBufIdx stay
> > >> on the same value until the release the menu.
> > >
> > > I guess we should simply mute audio completely if nGeneratedSamples
> > > is 0. Jerome, could you please try a patch like this:
> > >
> > > diff -r b98a852e12f2 src/audio.c
> > > --- a/src/audio.c Sat Sep 10 17:39:20 2016 +0200
> > > +++ b/src/audio.c Sat Sep 10 17:43:52 2016 +0200
> > > @@ -87,7 +87,13 @@
> > > CompleteSndBufIdx += len;
> > > nGeneratedSamples -= len;
> > > }
> > > - else /* Not enough samples available: */
> > > + else if (nGeneratedSamples == 0)
> > > + {
> > > + /* No samples - that could mean that the main
> > > thread has been
> > > + * halted. Simply mute audio to avoid annoying
> > > audio loops */
> > > + memset(pBuffer, 0, len * 4);
> > > + }
> > > + else /* Some, but not enough samples available: */
> > > {
> > > for (i = 0; i < nGeneratedSamples; i++)
> > > {
> >
> > Hi
> >
> > I was thinking at a similar patch, but I think we should completely
> > remove the case that mirror half of the data if we don't have enough
> > sample ; I'm not sure that duplicating previous data will give better
> > audio result if we don't fill Buffer fast enough, we should as well
> > just put 0 bytes in Buffer to complete it
>
> Not sure, but in case there are just some few samples missing, I think
> the memset-to-zero will cause audible disturbing noises, while the
> duplication might hide the missing samples quite well...
> I guess this needs some tests to be done to see what's the best
> approach here... any volunteers?
>
> Thomas
>
Hi,
Looking at audio.c, one can see that *pBuffer++ is not touched
when nGeneratedSamples is == 0.
This leaves old data to be repeated. Zeroing the data leaves
silence to be repeated.
However, repeated old data is better than chunks of silence
when Not paused. (note: repeated data is milliseconds long)
I think Thomas' patch is correct with a small modification:
+ else if (nGeneratedSamples == 0 && emulator_paused)