[MSEide-MSEgui-talk] MSE pcaudio.

classic Classic list List threaded Threaded
112 messages Options
123456
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

fredvs
> Is this a workaround or a bug fix?

Ho, it is a workaround to test pcaudiolib with your demo.

Now for the bug-fix, I will propose something like (if wavethread has
freeonterminate):

wavethread.terminate();

while wavethread <> nil do sleep(1);

Fre;D




--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

mse
Administrator
In reply to this post by fredvs
On 03/09/2018 07:34 PM, fredvs wrote:
>> As you like. ;-)
>
> Huh, you do not trust me ?
>
> main.zip <http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/main.zip>  
>
Are you sure that the program still is OK with your changes?

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

fredvs
> Are you sure that the program still is OK with your changes?

Ok, re-re-re checked.

With forced:
 ch1on.value := true;
 ch2on.value := true;
 twochannel:= true;
 channels := 2;

 and audio_object_write(faudioobj,p1,bytelen div channels)

And with sleep(100) after wavethread.terminate() :

---> With those changes, yes the sound of the stereo sine-wave is perfect,

PS: The file in attachment was not a fix, only to show the behavior with
chan = 2.

Fre;D





--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

fredvs
Re-re-re Hello.

About the crash of the demo, this solves all on my system:

procedure tmainfo.soundoff() at line 220:

  wavethread.terminate();
  wavethread.active:= false; // add this here, not 4 lines later.

Ok, I stop to annoy you with this.

Fre;D




--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

mse
Administrator
In reply to this post by fredvs
On 03/09/2018 08:09 PM, fredvs wrote:

>> Are you sure that the program still is OK with your changes?
>
> Ok, re-re-re checked.
>
> With forced:
>  ch1on.value := true;
>  ch2on.value := true;
>  twochannel:= true;
>  channels := 2;
>
>  and audio_object_write(faudioobj,p1,bytelen div channels)
>
> And with sleep(100) after wavethread.terminate() :
>
> ---> With those changes, yes the sound of the stereo sine-wave is perfect,
>
The problem with the wrong buffer length is in pcaudiolib/source/src/alsa.c
"
int
alsa_object_open(struct audio_object *object,
                 enum audio_object_format format,
                 uint32_t rate,
                 uint8_t channels)
{
        struct alsa_object *self = to_alsa_object(object);
        if (self->handle)
                return -EEXIST;

        snd_pcm_format_t pcm_format;
#define FORMAT(srcfmt, dstfmt, size) case srcfmt: pcm_format = dstfmt;
self->sample_size = size; break;
"
It probably should be
"
#define FORMAT(srcfmt, dstfmt, size) case srcfmt: pcm_format = dstfmt;
self->sample_size = size*channels; break;
"

There are more problems with pcaudiolib alsa driver because it is not
synchronous as the Windows and the Pulseaudio driver. It probably
doesn't care for eSpeak-ng because eSpeak-ng does internal timing but by
feeding the audio data as fast as possible by the sine wave generator
there are problems.

Suggestion: use Pulseaudio or change the pcaudiolib alsa driver to use
an overlapping buffer pattern like in waveout.c.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

mse
Administrator
On 03/09/2018 10:29 PM, Martin Schreiber wrote:
> There are more problems with pcaudiolib alsa driver because it is not
> synchronous as the Windows and the Pulseaudio driver. It probably
> doesn't care for eSpeak-ng because eSpeak-ng does internal timing but > by
> feeding the audio data as fast as possible by the sine wave generator
> there are problems.

Not sure about that, the asynchronous flag seems not to be set.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

mse
Administrator
In reply to this post by fredvs
On 03/09/2018 10:05 PM, fredvs wrote:
> Re-re-re Hello.
>
> About the crash of the demo, this solves all on my system:
>
> procedure tmainfo.soundoff() at line 220:
>
>   wavethread.terminate();
>   wavethread.active:= false; // add this here, not 4 lines later.
>
The problem probably is
"
int
alsa_object_flush(struct audio_object *object)
{
        struct alsa_object *self = to_alsa_object(object);
        if (!self) return 0;

        // Using snd_pcm_drop does not discard the audio, so reopen the device
        // to reset the sound buffer.
        if (self->is_open) {
                audio_object_close(object); <<<<----
"
there are still pending operations in another thread.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

fredvs
In reply to this post by mse
> The problem with the wrong buffer length is in pcaudiolib/source/src/alsa.c

Wow, you are strong.
Indeed it is the problem.

> It probably should be
> #define FORMAT(srcfmt, dstfmt, size) case srcfmt: pcm_format = dstfmt;
> self->sample_size = size*channels; break;

Yep, it is this.

> Suggestion: use Pulseaudio or change the pcaudiolib alsa driver to use
> an overlapping buffer pattern like in waveout.c.

But it uses PulseAudio, see earlier error message with earlier bug-demo:

Stack:
##0  F70E8C37 raise.c:56 __GI_raise(sig=6, sig@entry=6)
#1  F70EC028 abort.c:89 __GI_abort()
#2  F37B503D :0 pa_mutex_free()
#3  F3C1233A :0 pa_threaded_mainloop_free()
#4  F1D45165 :0 pulse_free()
#5  F1D4435A :0 ??()
#6  F40BB4A2 :0 ??()
#7  F4079EE5 :0 snd_pcm_close()
#8  F431EA42 alsa.c:143 alsa_object_close(object=0xb4c9b0)
#9  F431EBBD alsa.c:180 alsa_object_flush(object=0xb4c9b0)

Or I miss something.... ;-(

Fre;D




--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

mse
Administrator
In reply to this post by mse
On 03/09/2018 10:55 PM, Martin Schreiber wrote:

> On 03/09/2018 10:05 PM, fredvs wrote:
>> Re-re-re Hello.
>>
>> About the crash of the demo, this solves all on my system:
>>
>> procedure tmainfo.soundoff() at line 220:
>>
>>   wavethread.terminate();
>>   wavethread.active:= false; // add this here, not 4 lines later.
>>
> The problem probably is
> "
> int
> alsa_object_flush(struct audio_object *object)
> {
> struct alsa_object *self = to_alsa_object(object);
> if (!self) return 0;
>
> // Using snd_pcm_drop does not discard the audio, so reopen the device
> // to reset the sound buffer.
> if (self->is_open) {
> audio_object_close(object); <<<<----
> "
> there are still pending operations in another thread.
>
"
int
alsa_object_flush(struct audio_object *object)
{
        struct alsa_object *self = to_alsa_object(object);
        if (self && self->handle){
     snd_pcm_drop(self->handle);
        }
        return 0;
}
"
seems to work. There still is the problem that the alsa buffer is many
seconds long.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

mse
Administrator
In reply to this post by fredvs
On 03/09/2018 10:57 PM, fredvs wrote:

>> The problem with the wrong buffer length is in pcaudiolib/source/src/alsa.c
>
> Wow, you are strong.
> Indeed it is the problem.
>
>> It probably should be
>> #define FORMAT(srcfmt, dstfmt, size) case srcfmt: pcm_format = dstfmt;
>> self->sample_size = size*channels; break;
>
> Yep, it is this.
>
>> Suggestion: use Pulseaudio or change the pcaudiolib alsa driver to use
>> an overlapping buffer pattern like in waveout.c.
>
> But it uses PulseAudio, see earlier error message with earlier bug-demo:
>
> Stack:
> ##0  F70E8C37 raise.c:56 __GI_raise(sig=6, sig@entry=6)
> #1  F70EC028 abort.c:89 __GI_abort()
> #2  F37B503D :0 pa_mutex_free()
> #3  F3C1233A :0 pa_threaded_mainloop_free()
> #4  F1D45165 :0 pulse_free()
> #5  F1D4435A :0 ??()
> #6  F40BB4A2 :0 ??()
> #7  F4079EE5 :0 snd_pcm_close()
> #8  F431EA42 alsa.c:143 alsa_object_close(object=0xb4c9b0)
> #9  F431EBBD alsa.c:180 alsa_object_flush(object=0xb4c9b0)
               ^^^^^^
>
It is not pulseaudio but alsa.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

fredvs
> It is not pulseaudio but alsa.

Ok. I will attack this tomorrow.

Many thanks Martin.

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

fredvs
> Ok. I will attack this tomorrow.

Aaargh, I cannot resist.

Bon, ok, re-try with libpcaudio.so,0 compiled with PulseAudio on.

Ok, this time PulseAudio is used with your demo (and mine) and indeed "div
chan" is not needed anymore for stereo channels.

So, yes alsa.c is bugged.
Not only the "numbytes div chan", there are also strange ratios to apply
using different resolution-format.

But the good news is that it will be fixed soon. ;-)
The other excellent news is that using PulseAudio works perfectly and with
the same param as Windows.

AFAIK ALSA is the kernel sound driver used by PulseAudio in Unix os.

IMHO, it should be good that using the kernel sound driver works too.

Fre;D




--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

mse
Administrator
On 03/10/2018 12:26 AM, fredvs wrote:
>
> AFAIK ALSA is the kernel sound driver used by PulseAudio in Unix os.
>
Your stack:
"
##0  F70E8C37 raise.c:56 __GI_raise(sig=6, sig@entry=6)
#1  F70EC028 abort.c:89 __GI_abort()
#2  F37B503D :0 pa_mutex_free()
#3  F3C1233A :0 pa_threaded_mainloop_free()
#4  F1D45165 :0 pulse_free()
#5  F1D4435A :0 ??()
#6  F40BB4A2 :0 ??()
#7  F4079EE5 :0 snd_pcm_close()
#8  F431EA42 alsa.c:143 alsa_object_close(object=0xb4c9b0)
#9  F431EBBD alsa.c:180 alsa_object_flush(object=0xb4c9b0)
"
seems to show that on your system Alsa calls Pulseaudio not the opposite.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

fredvs
> seems to show that on your system Alsa calls Pulseaudio not the opposite.

Hum, difficult to find info about this:
https://en.wikipedia.org/wiki/PulseAudio

Not lot of infos...

I am nearly more than sure that alsa does not know PulseAudio and never call
it in his code.

But those days, so many strange things appends, so who knows....

By the way, thanks for your fixes.

pcaudio + pulseaudio works like charm here:

<http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/msepcaudio.png>

Fre;D








--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

mse
Administrator
On 03/10/2018 11:39 AM, fredvs wrote:
>> seems to show that on your system Alsa calls Pulseaudio not the opposite.
>
Mine too BTW. It seems Pulseaudie os the "native" Linux sound system
nowadays.

> Hum, difficult to find info about this:
> https://en.wikipedia.org/wiki/PulseAudio
>
> Not lot of infos...
>
> I am nearly more than sure that alsa does not know PulseAudio and never call
> it in his code.
>
Please see attachment.

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

pulseaudio.png (163K) Download Attachment
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

mse
Administrator
On 03/10/2018 01:08 PM, Martin Schreiber wrote:
>>
> Please see attachment.
>
or this attachment.

Martin


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

pulseaudio2.png (175K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

fredvs
>> Please see attachment.
> or this attachment.

Huh, sorry but even with clean glasses, it seems to me that
"alsa_object_write()" is a call to ALSA.

Or I miss, one more time, something. ;-(

In fact I know PulseAudio from his (buggy) beginning (2014).

And yes, maybe my mind was altered because of the "alsa vs puleaudio war".

(You may try "alsa vs puleaudio" in Google, you will fast understand).

A other reason why I would like to have direct access to alsa is that some
Linux distro do not have PulseAudio installed.
For example the RaspbianPi distro is given without PulseAudio.

Thanks Martin.

Fre;D




--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

fredvs
Huh, sorry in previous mail, for the date, please read:

In fact I know PulseAudio from his (buggy) beginning (2004).

Fre;D





--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
mse
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

mse
Administrator
In reply to this post by fredvs
On Saturday 10 March 2018 17:13:10 fredvs wrote:
> >> Please see attachment.
> >
> > or this attachment.
>
> Huh, sorry but even with clean glasses, it seems to me that
> "alsa_object_write()" is a call to ALSA.
>
You see that the program stops in Function pa_stream_write() in
file /usr/src/debug/pulseaudio-9-0/src/pulse/stream.c:1613 which clearly is a
Pulseaudio function. Agreed?

This Pulseaudio function is called by the Alsa functions
snd_pcm_ioplug_writei()->snd1_pcm_write_areas()->ioplug_priv_transfer_areas().
Agreed?

Also Wikipedia writes:
"
In a typical installation scenario under Linux, the user configures ALSA to
use a virtual device provided by PulseAudio. Thus, applications using ALSA
will output sound to PulseAudio, which then uses ALSA itself to access the
real sound card. PulseAudio also provides its own native interface to
applications that want to support PulseAudio directly, as well as a legacy
interface for ESD applications, making it suitable as a drop-in replacement
for ESD.
"
https://en.wikipedia.org/wiki/PulseAudio

Agreed?

Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Reply | Threaded
Open this post in threaded view
|

Re: [MSEide-MSEgui-talk] MSE pcaudio.

fredvs
> /usr/src/debug/pulseaudio-9-0/src/pulse/stream.c:1613 which clearly is a
Pulseaudio function.
> Agreed?

OK.

> snd_pcm_ioplug_writei()->snd1_pcm_write_areas()->ioplug_priv_transfer_areas().
> Agreed?
...
...
...
... Grrrr, ..., ok.

> https://en.wikipedia.org/wiki/PulseAudio
> Thus, applications using ALSA will output sound to PulseAudio,
> which then uses ALSA itself to access the real sound card.

Ok, you win.

So, if I understand ok, if PulseAudio is installed on your system and if you
choose to use ALSA, in fact your are being cheated.  You still will use
PulseAudio that will call ALSA for you.

Other thing...

Are you interested with Android developing ?
If yes (and because you are the king of audio) there is a challenge there.

Andoid has it own audio kernel based on opensles.
 https://www.khronos.org/opensles/

opensles.zip
<http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/opensles.zip>  

There are some cross-audio-device projets that try to integrate sles (like
Portaudio or PulseAudio).

https://github.com/Gundersanne/portaudio_opensles
https://github.com/pelya/pulseaudio-android

I did try portaudio_opensles but the result of sound is not ok and there is
no answer to questions (or directly closed).

. <http://mseide-msegui-talk.13964.n8.nabble.com/file/t2/uos_android.png>

Fre;D



--
Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
mseide-msegui-talk mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
123456