int esd_record_stream_fallback( esd_format_t format, int rate, const char *host, const char *name ) { int r; if ( (r = esd_record_stream(format, rate, host, name)) != -1 ) { return r; } return esd_record_stream(format, rate, "+fork", name); }
int SoundOpenInput(char *Dev, TAudioInfo *Info) { int fd=-1; #ifdef HAVE_LIBESD esd_format_t esd_format; if ((StrLen(Dev)==0) || (strncmp(Dev,"esd:",4)==0)) { esd_format=ESD_STREAM | ESD_RECORD; if (Info->Channels==2) esd_format |= ESD_STEREO; else esd_format |= ESD_MONO; if (Info->SampleSize==2) esd_format |= ESD_BITS16; else esd_format |= ESD_BITS8; if (StrLen(Dev) > 4) setenv("ESPEAKER",Dev+4,TRUE); else setenv("ESPEAKER","localhost",TRUE); fd=esd_record_stream(esd_format, Info->SampleRate, NULL, "testing"); } #endif #ifdef HAVE_OSS if (fd < 0) fd=OpenOSSInput(Dev, Info); #endif return(fd); }
// -------------------------------------------------------------------------- // StartProduction(): see wxSoundStream // -------------------------------------------------------------------------- bool wxSoundStreamESD::StartProduction(int evt) { #ifndef HAVE_ESD_H m_snderror = wxSOUND_INVDEV; return false; #else wxSoundFormatPcm *pcm; int flag = 0; if (!m_esd_ok) { m_snderror = wxSOUND_INVDEV; return false; } if (!m_esd_stop) StopProduction(); pcm = (wxSoundFormatPcm *)m_sndformat; flag |= (pcm->GetBPS() == 16) ? ESD_BITS16 : ESD_BITS8; flag |= (pcm->GetChannels() == 2) ? ESD_STEREO : ESD_MONO; if ((evt & wxSOUND_OUTPUT) != 0) { flag |= ESD_PLAY | ESD_STREAM; m_fd_output = esd_play_stream(flag, pcm->GetSampleRate(), NULL, MY_ESD_NAME); } if ((evt & wxSOUND_INPUT) != 0) { flag |= ESD_RECORD | ESD_STREAM; m_fd_input = esd_record_stream(flag, pcm->GetSampleRate(), NULL, MY_ESD_NAME); } #ifdef __WXGTK__ if ((evt & wxSOUND_OUTPUT) != 0) { m_tag_output = gdk_input_add(m_fd_output, GDK_INPUT_WRITE, _wxSound_OSS_CBack, (gpointer)this); } if ((evt & wxSOUND_INPUT) != 0) { m_tag_input = gdk_input_add(m_fd_input, GDK_INPUT_READ, _wxSound_OSS_CBack, (gpointer)this); } #endif m_esd_stop = false; m_q_filled = false; return true; #endif // defined HAVE_ESD_H }
int AudioStartRecording (unsigned long *time_zero, int report_errors) { struct tms now; int i; if (audio.recsock == -1) { audio.recsock = esd_record_stream(audio.format, audio.rate, NULL, NULL); if (audio.recsock < 0) { return -1; } i = fcntl(audio.recsock, F_SETFL, O_NONBLOCK); if (i < 0) { return -1; } } *time_zero = 10*times(&now); stop_record = 0; return 0; }
static int open_esd(void * data, gavl_audio_format_t * format, gavl_video_format_t * video_format, gavl_metadata_t * m) { int esd_format; const char * esd_host; char * name; char hostname[128]; esd_t * e = data; e->samples_read = 0; /* Set up format */ memset(format, 0, sizeof(*format)); format->interleave_mode = GAVL_INTERLEAVE_ALL; format->samplerate = 44100; format->sample_format = GAVL_SAMPLE_S16; format->samples_per_frame = ESD_BUF_SIZE / 4; format->num_channels = 2; gavl_set_channel_setup(format); gavl_audio_format_copy(&e->format, format); e->f = gavl_audio_frame_create(format); if(!e->hostname || (*(e->hostname) == '\0')) { esd_host = NULL; } else esd_host = e->hostname; esd_format = ESD_STREAM | ESD_PLAY; if(e->do_monitor) esd_format |= ESD_MONITOR; else esd_format |= ESD_RECORD; esd_format |= (ESD_STEREO|ESD_BITS16); gethostname(hostname, 128); name = bg_sprintf("gmerlin@%s pid: %d", hostname, getpid()); if(e->do_monitor) e->esd_socket = esd_monitor_stream(esd_format, format->samplerate, e->hostname, name); else e->esd_socket = esd_record_stream(esd_format, format->samplerate, e->hostname, name); free(name); if(e->esd_socket < 0) { bg_log(BG_LOG_ERROR, LOG_DOMAIN, "Cannot connect to daemon"); return 0; } e->bytes_per_frame = 4; e->src = gavl_audio_source_create(read_func_esd, e, GAVL_SOURCE_SRC_FRAMESIZE_MAX, format); return 1; }