pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: audio/flite: remove flush in play_wave()



On Sun, 18 Feb 2024, adr wrote:
Hi, this patch removes a flush call in play_wave(), which makes
parts of the text synthesized directly to the audio device be lost.

Brian if you are reading this, the old version you use doesn't have
it, don't bother. Note that the versions you use of yasr|eflite
don't work correctly with this flite, small amounts of audio are
missing at the end of the synthesis. I'll try with new versions
when I have time.

Regards,
adr

=======================
$NetBSD$

--- src/audio/audio.c.orig	2020-08-13 00:17:09.000000000 +0000
+++ src/audio/audio.c
@@ -247,7 +247,6 @@ int play_wave(cst_wave *w)
     	}
     }

-    audio_flush(ad);
     audio_close(ad);

    return CST_OK_FORMAT;

At first I thought like Brian that they screwed flush and drain in
the sun driver. They didn't. They use the flush term meaning drain
(as in the sun api) and vice versa in all the project.

/usr/pkgsrc/audio/flite/work/flite-2.2/include/cst_audio.h:
=========================
[...]
/* Generic audio functions */
cst_audiodev *audio_open(int sps, int channels, cst_audiofmt fmt);
int audio_close(cst_audiodev *ad);
int audio_write(cst_audiodev *ad, void *buff, int num_bytes);
int audio_flush(cst_audiodev *ad); /* wait for buffers to empty */
int audio_drain(cst_audiodev *ad); /* empty buffers now */
[...]
=========================
Look for example at the relevant part of the alsa code:

/usr/pkgsrc/audio/flite/work/flite-2.2/src/audio/au_alsa.c
=========================
[...]
int audio_flush_alsa(cst_audiodev *ad)
{
    int result;
    result = snd_pcm_drain((snd_pcm_t *) ad->platform_data);
    if (result < 0)
    {
	cst_errmsg("audio_flush_alsa: Error: %s.\n", snd_strerror(result));
    }
    /* Prepare device for more data */
    result = snd_pcm_prepare((snd_pcm_t *) ad->platform_data);
    if (result < 0)
    {
	cst_errmsg("audio_flush_alsa: Error: %s.\n", snd_strerror(result));
    }
    return result;
}

int audio_drain_alsa(cst_audiodev *ad)
{
    int result;
    result = snd_pcm_drop((snd_pcm_t *) ad->platform_data);
    if (result < 0)
    {
	cst_errmsg("audio_drain_alsa: Error: %s.\n", snd_strerror(result));
    }
    /* Prepare device for more data */
    result = snd_pcm_prepare((snd_pcm_t *) ad->platform_data);
    if (result < 0)
    {
	cst_errmsg("audio_drain_alsa: Error: %s.\n", snd_strerror(result));
    }
    return result;
}
[...]
==============================

The flush calls are supposed to do drain in sun terms.  That's why the
new code doesn't work with Brian's patch, it's doing drain when it's
supposed to do flush, &c.

The old code Brian is using works because it hasn't a flush (a
drain in sun terms) in play_wave().

Please, someone with pkgsrc permissions, update the attached patch
and forget the last one I shared. I also updated the name, it
corresponds to the patch patch-ae, please delete it.

adr
$NetBSD: patch-ae,v 1.4 2024/02/16 08:21:36 nia Exp $

- Include missing header
- Use AUDIO_INITINFO for parameter initialization

--- src/audio/au_sun.c.orig	2020-08-13 00:17:09.000000000 +0000
+++ src/audio/au_sun.c
@@ -45,12 +45,18 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <sys/ioctl.h>
 #include <sys/filio.h>
 #include <sys/audioio.h>
 #include "cst_string.h"
 #include "cst_wave.h"
 #include "cst_audio.h"
 
+#ifdef __sun
+#include <stropts.h>
+#include <sys/conf.h>
+#endif
+
 static const char *sun_audio_device = "/dev/audio";
 
 cst_audiodev *audio_open_sun(int sps, int channels, cst_audiofmt fmt)
@@ -76,7 +82,7 @@ cst_audiodev *audio_open_sun(int sps, in
 	    cst_error();
 	}
     }
-    ioctl(fd,AUDIO_GETINFO,&ainfo);
+    AUDIO_INITINFO(&ainfo);
 
     switch (fmt)
     {
@@ -166,9 +172,11 @@ int audio_flush_sun(cst_audiodev *ad)
     return ioctl((int)ad->platform_data, AUDIO_DRAIN, 0);
 }
 
-/* FIXME... */
 int audio_drain_sun(cst_audiodev *ad)
 {
-    return ioctl((int)ad->platform_data, AUDIO_DRAIN, 0);
+#ifdef __sun
+    return ioctl((int)ad->platform_data, I_FLUSH, FLUSHW);
+#else
+    return ioctl((int)ad->platform_data, AUDIO_FLUSH, 0);
+#endif
 }
-


Home | Main Index | Thread Index | Old Index