Exemple #1
0
static int output_data(char *buf, int32 nbytes)
{
    int n;

    if (stream == 0) return -1;

    while(nbytes > 0)
    {
	if((n = arts_write(stream, buf, nbytes)) < 0)
	{
	    ctl->cmsg(CMSG_WARNING, VERB_VERBOSE,
		      "%s: %s", dpm.name, arts_error_text(n));
	    if(errno == EWOULDBLOCK)
	    {
		/* It is possible to come here because of bug of the
		 * sound driver.
		 */
		continue;
	    }
	    return -1;
	}
	output_count += n;
	buf += n;
	nbytes -= n;
    }

    return 0;
}
Exemple #2
0
static int op_arts_write(const char *buffer, int count)
{
	int rc;

	rc = arts_write(arts_stream, buffer, count);
	if (rc < 0) {
		d_print("rc = %d, count = %d\n", rc, count);
		return -1;
	}
	return rc;
}
Exemple #3
0
/* send audio to soundcard */
void audio_write(audio_dev_handle* handle, unsigned char* buffer, int size)
{
#ifdef HAS_ARTS
    if(handle->use_arts)
    {
        arts_write(handle->arts_handle, buffer, size);
    }
    else
#endif
    {
        snd_pcm_writei(handle->alsa_handle, buffer, size);
    }
}
Exemple #4
0
int AudioPutPCM (char *buf, int len)
{
  short *header;
  int n;
  char *ptr;

  ptr = buf;
  while (ptr < buf + len) {
    header = (short*)ptr;
    len = header[HEADER_OFFSET_PCM_LENGTH];
    n = arts_write(audio.playsock, ptr+BLOCK_HEADER_SIZE, len);
    if (n < 0 || header[HEADER_OFFSET_END_OF_PCM])
      break;
    ptr += audio.blocklen;
  }
  return 0;
}
Exemple #5
0
static int arts_dsp_write(struct sysdep_dsp_struct *dsp, unsigned char *data,
   int count)
{
   int result;
   struct arts_dsp_priv_data *priv = dsp->_priv;

   result = arts_write(priv->stream, data, count *
      arts_dsp_bytes_per_sample[dsp->hw_info.type]);
      
   if (result < 0)
   {
      fprintf(stderr,
         "arts_write error: %s\n", arts_error_text(result));
      return -1;
   }
      
   return result / arts_dsp_bytes_per_sample[dsp->hw_info.type];
}
Exemple #6
0
static void ARTSC_PlayAudio(_THIS)
{
	int written;

	/* Write the audio data */
	written = arts_write(stream, mixbuf, mixlen);
	
	/* If timer synchronization is enabled, set the next write frame */
	if ( frame_ticks ) {
		next_frame += frame_ticks;
	}

	/* If we couldn't write, assume fatal error for now */
	if ( written < 0 ) {
		this->enabled = 0;
	}
#ifdef DEBUG_AUDIO
	fprintf(stderr, "Wrote %d bytes of audio data\n", written);
#endif
}
static void
gst_artsdsink_chain (GstPad * pad, GstData * _data)
{
  GstBuffer *buf = GST_BUFFER (_data);
  GstArtsdsink *artsdsink;

  g_return_if_fail (pad != NULL);
  g_return_if_fail (GST_IS_PAD (pad));
  g_return_if_fail (buf != NULL);

  artsdsink = GST_ARTSDSINK (gst_pad_get_parent (pad));

  if (GST_BUFFER_DATA (buf) != NULL) {
    gst_trace_add_entry (NULL, 0, GPOINTER_TO_INT (buf),
        "artsdsink: writing to server");
    if (!artsdsink->mute && artsdsink->connected) {
      int bytes;
      void *bufptr = GST_BUFFER_DATA (buf);
      int bufsize = GST_BUFFER_SIZE (buf);

      GST_DEBUG ("artsdsink: stream=%p data=%p size=%d",
          artsdsink->stream, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));

      do {
        bytes = arts_write (artsdsink->stream, bufptr, bufsize);
        if (bytes < 0) {
          fprintf (stderr, "arts_write error: %s\n", arts_error_text (bytes));
          gst_buffer_unref (buf);
          return;
        }
        bufptr += bytes;
        bufsize -= bytes;
      } while (bufsize > 0);
    }
  }
  gst_buffer_unref (buf);
}
static int play(void* data,int len,int flags)
{
	return arts_write(stream, data, len);
}