Re: [linux-audio-dev] Reborn

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] Reborn
From: Kjetil S. Matheussen (k.s.matheussen_AT_notam02.no)
Date: Mon Aug 19 2002 - 15:42:54 EEST


On Tue, 13 Aug 2002, Steve Harris wrote:

> On Tue, Aug 13, 2002 at 10:57:55 +0200, günter geiger wrote:
> >
> > On Tue, 13 Aug 2002, Steve Harris wrote:
> > > That was my thought too. As we have seen before, when software is designed
> > > with OSS in mind it can be very hard to refactor it to jack stylee.
> >
> > Does this mean it will be easier to port applications that where designed
> > to use ALSA, or will it be the same ?
>
> No idea. What I actually meant was "open, read, write" apps. I;ve never
> written a raw alsa app, so I don't know what the API is like.
>

I guess that depends how good performance you want.
Hacking some open/read/write support for a program using jack isn't
very hard.

Here are some code from ceres to play:

struct JackPlayChannel{
  jack_port_t *output_port;
  sample_t buffer[BUFFERSIZE];
};

struct Jackplay{
  struct JackPlayChannel jpc[4];
  jack_client_t *client;
  struct FFTSound *fftsound;
  int writeplace;
  int readplace;
  int buffersize;
  int unread;
};

/* Consumer */

int jackprocess (nframes_t nframes, void *arg){
  int ch,i;
  struct Jackplay *jackplay=(struct Jackplay *)arg;
  int numch=jackplay->fftsound->samps_per_frame;
  sample_t *out[numch];

  for(ch=0;ch<numch;ch++){
    out[ch]= (sample_t *) jack_port_get_buffer (jackplay->jpc[ch].output_port, nframes);
    memset(out[ch],0.0f,nframes*sizeof(sample_t));
  }

  for(i=0;i<nframes;i++){
    if(jackplay->unread==0) break;

    for(ch=0;ch<numch;ch++){
      out[ch][i]=jackplay->jpc[ch].buffer[jackplay->readplace];
    }
    jackplay->unread--;

    jackplay->readplace++;
    if(jackplay->readplace==jackplay->buffersize){
      jackplay->readplace=0;
    }
  }

  return 0;
}

/* Providor */

void JackWritePlay(
                   struct FFTSound *fftsound,
                   void *port,double **samples,int num_samples
                   )
{
  struct Jackplay *jackplay=(struct Jackplay *)port;

  int i,ch;

  for (i=0; i<num_samples; i++) {
    while(jackplay->unread==jackplay->buffersize){
      usleep(128);
    }
    for (ch=0; ch<fftsound->samps_per_frame; ch++){
      jackplay->jpc[ch].buffer[jackplay->writeplace]=(sample_t)samples[ch][i];
    }
    jackplay->unread++;
    jackplay->writeplace++;
    if(jackplay->writeplace==jackplay->buffersize){
      jackplay->writeplace=0;
    }
  }
}

-- 


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Mon Aug 19 2002 - 15:42:12 EEST