Beispiel #1
0
// --------------------------------------------------------------------------
// StopProduction(): see wxSoundStream
// --------------------------------------------------------------------------
bool wxSoundStreamESD::StopProduction()
{
#ifndef HAVE_ESD_H
    m_snderror = wxSOUND_INVDEV;
    return false;
#else
    if (m_esd_stop)
        return false;

    if (m_fd_input != -1) {
        esd_close(m_fd_input);
#ifdef __WXGTK__
        gdk_input_remove(m_tag_input);
#endif
    }
    if (m_fd_output != -1) {
        esd_close(m_fd_output);
#ifdef __WXGTK__
        gdk_input_remove(m_tag_output);
#endif
    }

    m_fd_input = -1;
    m_fd_output= -1;
    m_esd_stop = true;
    m_q_filled = true;
    return true;
#endif // defined HAVE_ESD_H
}
Beispiel #2
0
int AudioESound::close_all()
{
	if(device->r || device->d)
	{ 
    	close(esd_in_fd);
		esd_close(esd_in);      
	}

	if(device->w || device->d)
	{
 	   	close(esd_out_fd);
		esd_close(esd_out);     
	}
}
Beispiel #3
0
void X11Audio::close(void)
{
	if ( isinit() )
	{
		esd_close(m_esd_connection);
	}
}
Beispiel #4
0
int ao_plugin_close(ao_device *device)
{
  ao_esd_internal *internal = (ao_esd_internal *) device->internal;

  if(internal->bugfill && internal->sock != -1){

    if(internal->bugfill<4096){
      switch(internal->bits){
      case 8:
        memset(internal->bugbuffer + internal->bugfill, 128, 4096-internal->bugfill);
        break;
      default:
        memset(internal->bugbuffer + internal->bugfill, 0, 4096-internal->bugfill);
        break;
      }
    }

    write4096(internal->sock,internal->bugbuffer);
    internal->bugfill = 0;
  }

  if(internal->sock != -1)
    esd_close(internal->sock);
  internal->sock=-1;
  return 1;
}
static int ao_esd_get_property (ao_driver_t *this_gen, int property) {
  esd_driver_t      *this = (esd_driver_t *) this_gen;
  int                mixer_fd;
  esd_player_info_t *esd_pi;
  esd_info_t        *esd_i;

  switch(property) {
  case AO_PROP_MIXER_VOL:

    if((mixer_fd = esd_open_sound(NULL)) >= 0) {
      if((esd_i = esd_get_all_info(mixer_fd)) != NULL) {
	for(esd_pi = esd_i->player_list; esd_pi != NULL; esd_pi = esd_pi->next) {
	  if(!strcmp(this->pname, esd_pi->name)) {

	    this->mixer.source_id = esd_pi->source_id;

	    if(!this->mixer.mute)
	      this->mixer.volume  = (((esd_pi->left_vol_scale * 100)  / 256) +
				     ((esd_pi->right_vol_scale * 100) / 256)) >> 1;

	  }
	}
	esd_free_all_info(esd_i);
      }
      esd_close(mixer_fd);
    }

    return this->mixer.volume;
    break;

  case AO_PROP_MUTE_VOL:
    return this->mixer.mute;
    break;
  }
CSndserv::~CSndserv()
{
#ifdef G_OS_WIN32
#else
	if (fd>=0) esd_close(fd);
#endif
}
void __rouexit() {

#ifdef CHECK_STACK
  unsigned t;
  long maxFrames = 0;
  while (cstkszv[ELG_MY_THREAD] > 0) {
      elg_ui4 rid=ELG_NO_ID;
      long frame = --cstkszv[ELG_MY_THREAD];
      if (frame < EpkMaxFrames) rid=cstackv[ELG_MY_THREAD][frame];
      elg_warning("Missed exit for frame %d (rid=%d)", frame, rid);
      /* esd_exit(rid); */
  }
  for (t=0; t<ELG_NUM_THREADS; t++) {
      if (cstackv[t]) free(cstackv[t]);
      if (cstkmxv[t] > maxFrames) maxFrames = cstkmxv[t];
  }
  if (cstackv) free(cstackv);
  if (cstkszv) free(cstkszv);
  if (cstkmxv) free(cstkmxv);
  elg_cntl_msg("Freed %d-depth callstacks (max=%d) for %d threads",
        	EpkMaxFrames, maxFrames, ELG_NUM_THREADS);
  if (maxFrames > EpkMaxFrames)
        elg_warning("Depth %d callstacks truncated by ESD_FRAMES=%d",
                maxFrames, EpkMaxFrames);
#endif

  /* set after measurement to be reported during finalization */
  epk_comp_status = &epk_filter_status;

  /* close measurement */
  esd_close();
}
//_______________________________________________
//
//
//_______________________________________________
uint8_t  esdAudioDevice::stop(void) {
    if (esdDevice > 0) {
        esd_close(esdDevice);
        esdDevice = 0;
    }
    return 1;
}
Beispiel #9
0
/*
 * close audio device
 */
static void uninit(int immed)
{
    if (esd_play_fd >= 0) {
	esd_close(esd_play_fd);
	esd_play_fd = -1;
    }

    if (esd_svinfo) {
	esd_free_server_info(esd_svinfo);
	esd_svinfo = NULL;
    }

    if (esd_fd >= 0) {
	esd_close(esd_fd);
	esd_fd = -1;
    }
}
Beispiel #10
0
int AudioStopPlayback (int flush_output)
{
  if (audio.playsock != -1) {
    esd_close(audio.playsock);
    audio.playsock = -1;
  }
  return 0;
}
Beispiel #11
0
int ao_plugin_test()
{
	int sock;

	/* don't wake up the beast while detecting */
	putenv(strdup("ESD_NO_SPAWN=1"));
	sock = esd_open_sound(NULL);
        portable_unsetenv("ESD_NO_SPAWN");
	if (sock < 0)
		return 0;
	if (esd_get_standby_mode(sock) != ESM_RUNNING) {
		esd_close(sock);
		return 0;
	}

	esd_close(sock);
	return 1;
}
Beispiel #12
0
static
int finish(struct audio_finish *finish)
{
  if (esd_close(esd) < 0) {
    audio_error = ":esd_close";
    return -1;
  }

  return 0;
}
Beispiel #13
0
static void ao_esd_exit(ao_driver_t *this_gen)
{
  esd_driver_t *this = (esd_driver_t *) this_gen;

  if (this->audio_fd != -1)
    esd_close(this->audio_fd);

  free(this->pname);

  free (this);
}
Beispiel #14
0
static void close_esd(void * data)
  {
  esd_t * e = data;
  esd_close(e->esd_socket);
  gavl_audio_frame_destroy(e->f);
  if(e->src)
    {
    gavl_audio_source_destroy(e->src);
    e->src = NULL;
    }
  }
Beispiel #15
0
static gboolean
gst_esdsink_close (GstAudioSink * asink)
{
  GstEsdSink *esdsink = GST_ESDSINK (asink);

  GST_DEBUG_OBJECT (esdsink, "close");

  gst_caps_replace (&esdsink->cur_caps, NULL);
  esd_close (esdsink->ctrl_fd);
  esdsink->ctrl_fd = -1;

  return TRUE;
}
Beispiel #16
0
void release_esd(void *handle) {
	esd_openal_info_t *eh;

	if(handle == NULL) {
		return;
	}

	eh = (esd_openal_info_t *) handle;

	esd_close(eh->esdhandle);

	return;
}
Beispiel #17
0
static      vmResult
esd_term(void)
{
	if (server_fd > 0) {
		esd_close(server_fd);
		server_fd = 0;
	}
	if (sound_fd > 0) {
		esd_close(sound_fd);
		sound_fd = 0;
	}

/*
	if (server_fd > 0) {
		close(server_fd);
		server_fd = 0;
	}
	if (sound_fd > 0) {
		close(sound_fd);
		sound_fd = 0;
	}
*/
	return vmOk;
}
Beispiel #18
0
int X11Audio::play(int1 * p_sample, uint4 p_samplesize, uint p_rate)
{
	if ( isinit() ) 
	{
		uint t_func = ESD_PLAY | ESD_STREAM | m_flags; 
		
		int chan ;
		chan = esd_play_stream(t_func, p_rate, NULL, NULL);
		
		uint t_bytes_written ;
		t_bytes_written = write(chan, p_sample, p_samplesize);
		
		esd_close(chan);
		
		return t_bytes_written ;
	}
}
Beispiel #19
0
void TrashAudio(void)
{
#ifndef NO_SOUND
    int Error;

    // Sound off, pause off
    SndRate     = 0;
    AudioPaused = 0;

#ifdef __PLAYBOOK__
    SDL_CloseAudio();
#else
    // Wait for audio thread to finish
    if(Thr) pthread_join(Thr,0);
#endif

    // Sound trashed
#ifndef __PLAYBOOK__
    // If audio was initialized...
    if(SoundFD>=0)
    {
#if defined(PULSE_AUDIO)
        if(SoundFD) pa_simple_free(SoundFD);
#elif defined(ESD_AUDIO)
        esd_close(SoundFD);
#elif defined(SUN_AUDIO)
        close(SoundFD);
#else
        ioctl(SoundFD,SNDCTL_DSP_RESET);
        close(SoundFD);
#endif
    }

    SoundFD = -1;
    Thr     = 0;
#endif

    // If buffers were allocated...
    if(SndData) free(SndData);
    SndData = 0;
    SndSize = 0;
    RPtr    = 0;
    WPtr    = 0;
#endif
}
Beispiel #20
0
wxSoundStreamESD::wxSoundStreamESD(const wxString& hostname)
{
#ifndef HAVE_ESD_H
    m_snderror = wxSOUND_INVDEV;
    return;
#else
    wxSoundFormatPcm pcm_default;

    // First, we make some basic test: is there ESD on this computer ?
    m_esd_ok = false;

    if (hostname.IsNull())
        m_fd_output = esd_play_stream(ESD_PLAY | ESD_STREAM, 22050,
                                      hostname.mb_str(), MY_ESD_NAME);
    else
        m_fd_output = esd_play_stream(ESD_PLAY | ESD_STREAM, 22050,
                                      NULL, MY_ESD_NAME);
    if (m_fd_output == -1) {
        // Answer: no. We return with an error.
        m_snderror = wxSOUND_INVDEV;
        return;
    }

    // Close this unuseful stream.
    esd_close(m_fd_output);

    m_hostname = hostname;

    // Set the default audio format
    SetSoundFormat(pcm_default);

    // Initialize some variable
    m_snderror = wxSOUND_NOERROR;
    m_esd_stop = true;
    m_q_filled = true;
    m_esd_ok   = true;
    m_fd_output= -1;
    m_fd_input = -1;
#endif // defined HAVE_ESD_H
}
Beispiel #21
0
static
int config(struct audio_config *config)
{
  unsigned int bitdepth;
  esd_format_t format = ESD_STREAM | ESD_PLAY;
  extern char const *argv0;
  int result = 0;

  bitdepth = config->precision & ~7;
  if (bitdepth == 0 || bitdepth > 16)
    bitdepth = 16;

  switch (config->precision = bitdepth) {
  case 8:
    audio_pcm = audio_pcm_u8;
    format |= ESD_BITS8;
    break;

  case 16:
    audio_pcm = audio_pcm_s16;
    format |= ESD_BITS16;
    break;
  }

  format |= (config->channels == 2) ? ESD_STEREO : ESD_MONO;

  if (esd_close(esd) < 0) {
    audio_error = ":esd_close";
    result = -1;
  }

  esd = esd_play_stream_fallback(format, config->speed, host, argv0);
  if (esd < 0 && result == 0) {
    audio_error = ":esd_play_stream_fallback";
    result = -1;
  }

  return result;
}
Beispiel #22
0
static int open_esound(audio_output_t *ao)
{
	esd_format_t format = ESD_STREAM | ESD_PLAY;

	if (!esd_rate)
	{
		int esd;
		esd_server_info_t *info;
		esd_format_t fmt;
		
		if ((esd = esd_open_sound(NULL)) >= 0)
		{
			info = esd_get_server_info(esd);
			esd_rate = info->rate;
			fmt = info->format;
			esd_free_server_info(info);
			esd_close(esd);
		}
		else
		{
			esd_rate = esd_audio_rate;
			fmt = esd_audio_format;
		}
		esd_format = MPG123_ENC_UNSIGNED_8;
		
		if ((fmt & ESD_MASK_BITS) == ESD_BITS16)
			esd_format |= MPG123_ENC_SIGNED_16;
		esd_channels = fmt & ESD_MASK_CHAN;
	}
	
	if (ao->format == -1)
		ao->format = esd_format;
	else if (!(ao->format & esd_format))
	{
		error1("Unsupported audio format: %d\n", ao->format);
		errno = EINVAL;
		return -1;
	}
	
	
	if (ao->format & MPG123_ENC_SIGNED_16)
		format |= ESD_BITS16;
	else if (ao->format & MPG123_ENC_UNSIGNED_8)
		format |= ESD_BITS8;
	else assert(0);
	
	if (ao->channels == -1) ao->channels = 2;
	else if (ao->channels <= 0 || ao->channels > esd_channels)
	{
		error1("Unsupported no of channels: %d\n", ao->channels);
		errno = EINVAL;
		return -1;
	}
	if (ao->channels == 1)
		format |= ESD_MONO;
	else if (ao->channels == 2)
		format |= ESD_STEREO;
	else assert(0);
	
	if (ao->rate == -1) ao->rate = esd_rate;
	else if (ao->rate > esd_rate)
	return -1;
	
	ao->fn = esd_play_stream_fallback(format, ao->rate, ao->device, "mpg123");
	return (ao->fn);
}
Beispiel #23
0
int
main(
    int                                 argc,
    char **                             argv)
{
    int                                 fd;
	int                                 count;
    SoundSample *                       ss;
    int                                 buf_len;
    int                                 l;
    int                                 r;
    int                                 ml = 1;
    int                                 mr = 1;
    int                                 x;
    int                                 i;
    char                                VU[16];
    char                                packet[128];
    float                               xf;
    struct sockaddr_in                  si_other;
    int                                 s;
    int                                 slen=sizeof(si_other);
    int                                 rc;
    char *                              srv_ip;

    srv_ip = argv[1];

    slen = sizeof(si_other);
    if ((s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1)
    {
        printf("failed to make the socket\n");
        exit(1);
    }
    memset((char *) &si_other, 0, sizeof(si_other));
    si_other.sin_family = AF_INET;
    si_other.sin_port = htons(PORT);
    if (inet_aton(srv_ip, &si_other.sin_addr)==0)
    {
        fprintf(stderr, "inet_aton() failed\n");
        exit(1);
    }

    memset(VU, '\0', 16);
    memset(packet, '\0', 128);
    fd = esd_monitor_stream(
        SOUND_FORMAT, SAMPLE_RATE, NULL, "gkrellmss");
    if (fd < 0)
    {
        printf("vouldnt open it succa\n");
		esd_close(fd);
        return;
    }

    signal(2, cnt_c);
    count = 1024;
    ss = (SoundSample *) calloc(sizeof(SoundSample), count);
    while(!g_done)
    {
        buf_len = sizeof(SoundSample) * count;
	    count = read(fd, ss, buf_len);
    	if (count < 0)
        {
            goto err;
        }
        l = abs(ss[0].left);
        r = abs(ss[0].right);
        l = l * 707 / 1000;
        r = r * 707 / 1000;

        if(l > ml) ml = l;
        if(r > mr) mr = r;
/*
        printf("%f %f \r", (float)l/ml, (float)r/mr);
*/
        memset(VU, ' ', 15);
        xf = 10.0 * (float)l/(float)ml;
        
        x = (int)xf;
        if (xf - (float)x > 0.5)
        {
            x++;
        } 
        x--;
        for(i = 0; i < x; i++)
        {
            VU[i] = 'F';
        }
        printf("%s\r", VU);

        buf_len = strlen(packet);
        sprintf(packet, "uid 0FFFFFFFFF 0%s", VU);
        rc = sendto(s, packet, buf_len, 0, &si_other, slen);
        if(rc < 0)
        {
            printf("failed to send a packet");
            exit(3);
        }
        
        sprintf(packet, "cab 0FFFFFFFFF 0%s", VU);
        rc = sendto(s, packet, buf_len, 0, &si_other, slen);
        if(rc < 0)
        {
            printf("failed to send a packet");
            exit(3);
        }

        usleep(10);
    }
    close(s);
    esd_close(fd);

    printf("\n");
    printf("done\n");
    return 0;

err:
    esd_close(fd);

    return 1;
}
Beispiel #24
0
static void stop_esd(void * p)
  {
  esd_t * e = p;
  esd_close(e->esd_socket);
  }
Beispiel #25
0
/*
 * connect to esd
 */
static int ao_esd_open(ao_driver_t *this_gen,
		       uint32_t bits, uint32_t rate, int mode)
{
  esd_driver_t *this = (esd_driver_t *) this_gen;
  esd_format_t     format;

  xprintf (this->xine, XINE_VERBOSITY_DEBUG,
	   "audio_esd_out: ao_open bits=%d rate=%d, mode=%d\n", bits, rate, mode);

  if ( (mode & this->capabilities) == 0 ) {
    xprintf (this->xine, XINE_VERBOSITY_DEBUG, "audio_esd_out: unsupported mode %08x\n", mode);
    return 0;
  }

  if (this->audio_fd>=0) {

    if ( (mode == this->mode) && (rate == this->input_sample_rate) )
      return this->output_sample_rate;

    esd_close (this->audio_fd);
  }

  this->mode                   = mode;
  this->input_sample_rate      = rate;
  this->output_sample_rate     = rate;
  this->bytes_in_buffer        = 0;
  this->start_time.tv_sec      = 0;

  /*
   * open stream to ESD server
   */

  format = ESD_STREAM | ESD_PLAY | ESD_BITS16;
  switch (mode) {
  case AO_CAP_MODE_MONO:
    format |= ESD_MONO;
    this->num_channels = 1;
    break;
  case AO_CAP_MODE_STEREO:
    format |= ESD_STEREO;
    this->num_channels = 2;
    break;
  }
  xprintf (this->xine, XINE_VERBOSITY_DEBUG, "audio_esd_out: %d channels output\n",this->num_channels);

  this->bytes_per_frame=(bits*this->num_channels)/8;

#if ESD_RESAMPLE
  /* esd resamples (only for sample rates < the esd server's sample rate) */
  if (this->output_sample_rate > this->server_sample_rate)
    this->output_sample_rate = this->server_sample_rate;
#else
  /* use xine's resample code */
  this->output_sample_rate = this->server_sample_rate;
#endif
  this->output_sample_k_rate = this->output_sample_rate / 1000;

  this->audio_fd = esd_play_stream(format, this->output_sample_rate, NULL, this->pname);
  if (this->audio_fd < 0) {
    char *server = getenv("ESPEAKER");
    xprintf(this->xine, XINE_VERBOSITY_LOG,
	    _("audio_esd_out: connecting to ESD server %s: %s\n"),
	    server ? server : "<default>", strerror(errno));
    return 0;
  }

  return this->output_sample_rate;
}
Beispiel #26
0
int audio_open(struct audio_info_struct *ai)
{
  esd_format_t format = ESD_STREAM | ESD_PLAY;

  if (!esd_rate)
  {
    int esd;
    esd_server_info_t *info;
    esd_format_t fmt;

    if ((esd = esd_open_sound(NULL)) >= 0)
    {
      info = esd_get_server_info(esd);
      esd_rate = info->rate;
      fmt = info->format;
      esd_free_server_info(info);
      esd_close(esd);
    }
    else
    {
      esd_rate = esd_audio_rate;
      fmt = esd_audio_format;
    }
    esd_format = AUDIO_FORMAT_UNSIGNED_8;
    if ((fmt & ESD_MASK_BITS) == ESD_BITS16)
      esd_format |= AUDIO_FORMAT_SIGNED_16;
    esd_channels = fmt & ESD_MASK_CHAN;
  }

  if (ai->format == -1)
    ai->format = esd_format;
  else if (!(ai->format & esd_format))
  {
    fprintf(stderr, "audio: Unsupported audio format: %d\n", ai->format);
    errno = EINVAL;
    return -1;
  }
  if (ai->format & AUDIO_FORMAT_SIGNED_16)
    format |= ESD_BITS16;
  else if (ai->format & AUDIO_FORMAT_UNSIGNED_8)
    format |= ESD_BITS8;
  else
    assert(0);

  if (ai->channels == -1)
    ai->channels = 2;
  else if (ai->channels <= 0 || ai->channels > esd_channels)
  {
    fprintf(stderr, "audio: Unsupported no of channels: %d\n", ai->channels);
    errno = EINVAL;
    return -1;
  }
  if (ai->channels == 1)
    format |= ESD_MONO;
  else if (ai->channels == 2)
    format |= ESD_STEREO;
  else
    assert(0);
  
  if (ai->rate == -1)
    ai->rate = esd_rate;
  else if (ai->rate > esd_rate)
    return -1;

  ai->fn = esd_play_stream_fallback(format, ai->rate, param.esdserver, "mpg123");
  return (ai->fn);
}
Beispiel #27
0
static void ao_esd_close(ao_driver_t *this_gen)
{
  esd_driver_t *this = (esd_driver_t *) this_gen;
  esd_close(this->audio_fd);
  this->audio_fd = -1;
}
void cyg_profile_finalize () {
  esd_close();
}