audioplayer

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

audioplayer

jayt0808
This post has NOT been accepted by the mailing list yet.
Hello octave list
I ran into a stability problem when using audioplayer.  The 2nd time I try and run the following sequence of commands:
player = audioplayer (y, 44100, 24, 10);
play(player);
I get lots of error messages

Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1736
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1904
Expression 'PaAlsaStreamComponent_Initialize( &self->playback, alsaApi, outParams, StreamDirection_Out, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2175
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2840
error: audioplayer: failed to open audio playback stream
error: called from
    play at line 36 column 3

I was starting to poke around the codebase for clues about why this might be happening.  Anyone on here who might have serious insight into what this bug might relate to?

I want to be able to call audioplayer() a 2nd time (or 3rd, etc) because I don't always want to send the same data to my sound device.  There doesn't seem to be any other way to change the data for the audioplayer object.  I checked the get() and set() methods but there doesn't seemt to be any record of the data that was baked into the audioplayer object.

Thanks very much for any info

-Jay
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: audioplayer

jayt0808
This post has NOT been accepted by the mailing list yet.
I put a printf in the code to show what the error is when Pa_OpenStream() is called and it returns -9985.  This is at line 1132 of audiodevinfo.cc file.

According to PortAudio documentation this means paDeviceUnavailable.  Why would the device be not available?
For the record, this specific audio device is a USB audio device that works the first time I call audioplayer().  I can call play(player) as many times as I want.  It is just when I try to call audioplayer() more than once, the error manifests itself when I do subsequent calls to play(player).  This is octave version 4.2.  

Thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: audioplayer

jayt0808
I just created a fix that seems to solve the issue.  In your audioplayer destructor, you don't actually call stop() when the object is destroyed.  You only call it if the stream is still playing.  I so changed the code to always call stop() when the destructor is called like so:

audioplayer::~audioplayer (void)
{
  printf("audioplayer destructor called\n");
 
  if (isplaying ())
    {
      warning ("Octave:audio-interrupt",
               "interrupting playing audioplayer");
//      stop ();
    }
 
  stop();
}

let me know if there is some problem with this.  But I am up and running now, no more crashing when I reinstantiate the audioplayer object.  Ahh the joys of open source.

-Jay
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: audioplayer

siko1056
jayt0808 wrote
I just created a fix that seems to solve the issue.  In your audioplayer destructor, you don't actually call stop() when the object is destroyed.  You only call it if the stream is still playing.  I so changed the code to always call stop() when the destructor is called like so:

audioplayer::~audioplayer (void)
{
  printf("audioplayer destructor called\n");
 
  if (isplaying ())
    {
      warning ("Octave:audio-interrupt",
               "interrupting playing audioplayer");
//      stop ();
    }
 
  stop();
}

let me know if there is some problem with this.  But I am up and running now, no more crashing when I reinstantiate the audioplayer object.  Ahh the joys of open source.

-Jay
Hello Jay,

Kind of a late response, but if you still can reproduce your problem, you should consider to file a bug report [1] including a minimal complete example, that fails for you. From your descriptions, I was not able to reproduce your problem, anyway it looks like the constructor really misses something.

Kai

[1]: https://savannah.gnu.org/bugs/?func=additem&group=octave
Loading...