本文整理汇总了C++中ERROR0函数的典型用法代码示例。如果您正苦于以下问题:C++ ERROR0函数的具体用法?C++ ERROR0怎么用?C++ ERROR0使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ERROR0函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Java_com_sun_media_sound_MixerSynth_nDestroySynthesizer
JNIEXPORT void JNICALL
Java_com_sun_media_sound_MixerSynth_nDestroySynthesizer(JNIEnv* e, jobject thisObj, jlong id)
{
GM_Song *pSong = (GM_Song *) (INT_PTR) id;
TRACE0("Java_com_sun_media_sound_MixerSynth_nDestroySynthesizer.\n");
if (pSong) {
GM_KillSongNotes(pSong);
pSong->disposeSongDataWhenDone = TRUE; // free our midi pointer
GM_FreeSong((void *)e, pSong);
} else {
ERROR0("pSong is NULL\n");
}
TRACE0("Java_com_sun_media_sound_MixerSynth_nDestroySynthesizer completed.\n");
}
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:21,代码来源:MixerSynth.c
示例2: anongame_wol_matchlist_destroy
extern int anongame_wol_matchlist_destroy(void)
{
t_anongame_wol_player * player;
t_elem * curr;
if (anongame_wol_matchlist_head) {
LIST_TRAVERSE(anongame_wol_matchlist_head,curr) {
if (!(player = (t_anongame_wol_player*)elem_get_data(curr))) { /* should not happen */
ERROR0("wol_matchlist contains NULL item");
continue;
}
anongame_wol_player_destroy(player,&curr);
}
if (list_destroy(anongame_wol_matchlist_head)<0)
return -1;
anongame_wol_matchlist_head = NULL;
}
return 0;
}
开发者ID:blast-hardcheese,项目名称:pvpgn,代码行数:21,代码来源:anongame_wol.cpp
示例3: Java_com_sun_media_sound_MidiInDevice_nOpen
JNIEXPORT jlong JNICALL
Java_com_sun_media_sound_MidiInDevice_nOpen(JNIEnv* e, jobject thisObj, jint index) {
MidiDeviceHandle* deviceHandle = NULL;
TRACE1("Java_com_sun_media_sound_MidiInDevice_nOpen: index: %d\n", index);
#if USE_PLATFORM_MIDI_IN == TRUE
deviceHandle = MIDI_IN_OpenDevice((INT32) index);
#endif
// if we didn't get a valid handle, throw a MidiUnavailableException
// $$kk: 06.24.99: should be getting more information here!
if ( !deviceHandle ) {
char *msg = "Failed to open the device.\0";
ERROR0("Java_com_sun_media_sound_MidiInDevice_nOpen: Failed to open the device\n");
ThrowJavaMessageException(e, JAVA_MIDI_PACKAGE_NAME"/MidiUnavailableException", msg);
}
TRACE0("Java_com_sun_media_sound_MidiInDevice_nOpen succeeded\n");
return (jlong) (UINT_PTR) deviceHandle;
}
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:21,代码来源:MidiInDevice.c
示例4: apireglist_destroy
extern int apireglist_destroy(void)
{
t_apiregmember * apiregmember;
t_elem * curr;
if (apireglist_head) {
LIST_TRAVERSE(apireglist_head,curr) {
if (!(apiregmember = (t_apiregmember*)elem_get_data(curr))) {
ERROR0("channel list contains NULL item");
continue;
}
apiregmember_destroy(apiregmember,&curr);
}
if (list_destroy(apireglist_head)<0)
return -1;
apireglist_head = NULL;
}
return 0;
}
开发者ID:DizKragnet,项目名称:pvpgn,代码行数:21,代码来源:handle_apireg.cpp
示例5: switch
char const *
Directory::read() const
{
const char * result;
#ifdef WIN32
switch (status) {
default:
case -1: /* couldn't rewind */
ERROR0("got status -1");
return 0;
case 0: /* freshly opened */
status = 1;
if (lFindHandle < 0) return 0;
result = fileinfo.name;
break;
case 1: /* reading */
if (lFindHandle < 0) return 0;
if (_findnext(lFindHandle, &fileinfo) < 0) {
status = 2;
return 0;
}
else result = fileinfo.name;
break;
case 2: /* EOF */
return 0;
}
#else /* POSIX */
struct dirent *dentry = dir ? readdir(dir) : 0;
if (!dentry) return 0;
result = dentry->d_name;
#endif /* WIN32-POSIX */
if (!(strcmp(result, ".") && strcmp(result, "..")))
/* here we presume we don't get an infinite number of "." or ".." ;) */
return read();
return result;
}
开发者ID:AleXoundOS,项目名称:pvpgn,代码行数:40,代码来源:pdir.cpp
示例6: DAUDIO_Write
// returns -1 on error
int DAUDIO_Write(void* id, char* data, int byteSize) {
AlsaPcmInfo* info = (AlsaPcmInfo*) id;
int ret, count;
snd_pcm_sframes_t frameSize, writtenFrames;
TRACE1("> DAUDIO_Write %d bytes\n", byteSize);
/* sanity */
if (byteSize <= 0 || info->frameSize <= 0) {
ERROR2(" DAUDIO_Write: byteSize=%d, frameSize=%d!\n",
(int) byteSize, (int) info->frameSize);
TRACE0("< DAUDIO_Write returning -1\n");
return -1;
}
count = 2; // maximum number of trials to recover from underrun
//frameSize = snd_pcm_bytes_to_frames(info->handle, byteSize);
frameSize = (snd_pcm_sframes_t) (byteSize / info->frameSize);
do {
writtenFrames = snd_pcm_writei(info->handle, (const void*) data, (snd_pcm_uframes_t) frameSize);
if (writtenFrames < 0) {
ret = xrun_recovery(info, (int) writtenFrames);
if (ret <= 0) {
TRACE1("DAUDIO_Write: xrun recovery returned %d -> return.\n", ret);
return ret;
}
if (count-- <= 0) {
ERROR0("DAUDIO_Write: too many attempts to recover from xrun/suspend\n");
return -1;
}
} else {
break;
}
} while (TRUE);
//ret = snd_pcm_frames_to_bytes(info->handle, writtenFrames);
ret = (int) (writtenFrames * info->frameSize);
TRACE1("< DAUDIO_Write: returning %d bytes.\n", ret);
return ret;
}
开发者ID:michalwarecki,项目名称:ManagedRuntimeInitiative,代码行数:40,代码来源:PLATFORM_API_LinuxOS_ALSA_PCM.c
示例7: _handle_stats_request
static void _handle_stats_request(connection_t *con,
http_parser_t *parser, char *uri)
{
stats_connection_t *stats;
stats_event_inc(NULL, "stats_connections");
if (!connection_check_admin_pass(parser)) {
ERROR0("Bad password for stats connection");
connection_close(con);
httpp_destroy(parser);
return;
}
stats_event_inc(NULL, "stats");
/* create stats connection and create stats handler thread */
stats = (stats_connection_t *)malloc(sizeof(stats_connection_t));
stats->parser = parser;
stats->con = con;
thread_create("Stats Connection", stats_connection, (void *)stats, THREAD_DETACHED);
}
开发者ID:miksago,项目名称:icecast,代码行数:23,代码来源:connection.c
示例8: _parse_directory
static int _parse_directory (xmlNodePtr node, void *arg)
{
ice_config_t *config = arg;
struct cfg_tag icecast_tags[] =
{
{ "yp-url", config_get_str, &config->yp_url [config->num_yp_directories]},
{ "yp-url-timeout", config_get_int, &config->yp_url_timeout [config->num_yp_directories]},
{ "touch-interval", config_get_int, &config->yp_touch_interval [config->num_yp_directories]},
{ NULL, NULL, NULL }
};
if (config->num_yp_directories >= MAX_YP_DIRECTORIES)
{
ERROR0("Maximum number of yp directories exceeded!");
return -1;
}
if (parse_xml_tags (node, icecast_tags))
return -1;
config->num_yp_directories++;
return 0;
}
开发者ID:miksago,项目名称:icecast,代码行数:23,代码来源:cfgfile.c
示例9: Java_com_sun_media_sound_MixerSynth_nStartSynthesizer
JNIEXPORT jboolean JNICALL
Java_com_sun_media_sound_MixerSynth_nStartSynthesizer(JNIEnv* e, jobject thisObj, jlong id)
{
OPErr opErr = NO_ERR;
GM_Song *pSong = (GM_Song *) (INT_PTR) id;
TRACE0("Java_com_sun_media_sound_MixerSynth_nStartSynthesizer.\n");
// $$kk: 03.23.98: hard coding instrument loading here
opErr = GM_StartLiveSong(pSong, 1);
if (opErr)
{
ERROR0("FAILED TO START MIDI DIRECT: error on GM_StartLiveSong\n");
// $$kk: 09.17.98: what to do here?
return (jboolean)FALSE;
}
TRACE0("Java_com_sun_media_sound_MixerSynth_nStartSynthesizer.completed\n");
return (jboolean)TRUE;
}
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:23,代码来源:MixerSynth.c
示例10: sizeof
int
FDWEpollBackend::add(int idx, unsigned rw)
{
// eventlog(eventlog_level_trace, __FUNCTION__, "called fd: %d rw: %d", fd, rw);
struct epoll_event tmpev;
std::memset(&tmpev, 0, sizeof(tmpev));
tmpev.events = 0;
if (rw & fdwatch_type_read)
tmpev.events |= EPOLLIN;
if (rw & fdwatch_type_write)
tmpev.events |= EPOLLOUT;
int op = fdw_rw(fdw_fds + idx) ? EPOLL_CTL_MOD : EPOLL_CTL_ADD;
tmpev.data.fd = idx;
if (epoll_ctl(epfd, op, fdw_fd(fdw_fds + idx), &tmpev)) {
ERROR0("got error from epoll_ctl()");
return -1;
}
return 0;
}
开发者ID:DizKragnet,项目名称:pvpgn,代码行数:23,代码来源:fdwatch_epoll.cpp
示例11: MIDI_Utils_StopDevice
INT32 MIDI_Utils_StopDevice(MacMidiDeviceHandle* handle) {
OSStatus err = noErr;
if (!handle || !handle->h.deviceHandle) {
ERROR0("ERROR: MIDI_Utils_StopDevice: handle or native handle is NULL\n");
return MIDI_INVALID_HANDLE;
}
if (handle->isStarted) {
/* set the flag that we don't want to receive messages anymore */
handle->isStarted = FALSE;
if (handle->direction == MIDI_IN) {
err = MIDIPortDisconnectSource(inPort, (MIDIEndpointRef) (intptr_t) (handle->h.deviceHandle));
} else if (handle->direction == MIDI_OUT) {
// Unschedules previously-sent packets.
err = MIDIFlushOutput((MIDIEndpointRef) (intptr_t) handle->h.deviceHandle);
}
MIDI_CHECK_ERROR;
}
return MIDI_SUCCESS;
}
开发者ID:kgilmer,项目名称:openjdk-7-mermaid,代码行数:23,代码来源:PLATFORM_API_MacOSX_MidiUtils.c
示例12: CreatePortControl
// returns java control
static void* CreatePortControl(PortMixer *mixer, PortControlCreator *creator, PortControl::ControlType type,
AudioControl **audioControls, int offset, int len) {
void *jControl = NULL;
PortControl *control = (PortControl *)calloc(1, sizeof(PortControl));
float precision = 0.01;
control->type = type;
control->controlCount = len;
control->audioControls = (AudioControl **)malloc(len * sizeof(AudioControl *));
memcpy(control->audioControls, audioControls + offset, len * sizeof(AudioControl *));
switch (control->type) {
case PortControl::Volume:
jControl = creator->newFloatControl(creator, control, CONTROL_TYPE_VOLUME, 0, 1, precision, "");
break;
case PortControl::Mute:
jControl = creator->newBooleanControl(creator, control, CONTROL_TYPE_MUTE);
break;
case PortControl::Balance:
jControl = creator->newFloatControl(creator, control, CONTROL_TYPE_BALANCE, -1, 1, precision, "");
break;
};
if (jControl == NULL) {
ERROR0("CreatePortControl: javaControl was not created\n");
free(control->audioControls);
free(control);
return NULL;
}
// add the control to mixer control list;
control->next = mixer->portControls;
mixer->portControls = control;
return jControl;
}
开发者ID:1d7500,项目名称:jdk7u-jdk,代码行数:37,代码来源:PLATFORM_API_MacOSX_Ports.cpp
示例13: DAUDIO_Flush
int DAUDIO_Flush(void* id, int isSource) {
DS_Info* info = (DS_Info*) id;
//TRACE0("DAUDIO_Flush\n");
if (info->isSource) {
info->playBuffer->Stop();
DS_clearBuffer(info, false /* entire buffer */);
} else {
DWORD captureCursor, readCursor;
/* set the read pointer to the current read position */
if (FAILED(info->captureBuffer->GetCurrentPosition(&captureCursor, &readCursor))) {
ERROR0("DAUDIO_Flush: ERROR: Failed to get current position.");
return false;
}
DS_clearBuffer(info, false /* entire buffer */);
/* SHOULD set to *captureCursor*,
* but that would be detected as overflow
* in a subsequent GetAvailable() call.
*/
info->writePos = (int) readCursor;
}
return true;
}
开发者ID:bao-boyle,项目名称:CZPlayer,代码行数:24,代码来源:Utils.cpp
示例14: process_initial_page
/* a new BOS page has been seen so check which codec it is */
static int process_initial_page (format_plugin_t *plugin, ogg_page *page)
{
ogg_state_t *ogg_info = plugin->_state;
ogg_codec_t *codec;
if (ogg_info->bos_completed)
{
ogg_info->bitrate = 0;
ogg_info->codec_sync = NULL;
/* need to zap old list of codecs when next group of BOS pages appear */
free_ogg_codecs (ogg_info);
}
do
{
codec = initial_vorbis_page (plugin, page);
if (codec)
break;
#ifdef HAVE_THEORA
codec = initial_theora_page (plugin, page);
if (codec)
break;
#endif
/* any others */
ERROR0 ("Seen BOS page with unknown type");
return -1;
} while (0);
if (codec)
{
/* add codec to list */
codec->next = ogg_info->codecs;
ogg_info->codecs = codec;
}
return 0;
}
开发者ID:kitsune-dsu,项目名称:kitsune-icecast,代码行数:37,代码来源:format_ogg.c
示例15: _parse_directory
static void _parse_directory(xmlDocPtr doc, xmlNodePtr node,
ice_config_t *configuration)
{
char *tmp;
if (configuration->num_yp_directories >= MAX_YP_DIRECTORIES) {
ERROR0("Maximum number of yp directories exceeded!");
return;
}
do {
if (node == NULL) break;
if (xmlIsBlankNode(node)) continue;
if (xmlStrcmp (node->name, XMLSTR("yp-url")) == 0) {
if (configuration->yp_url[configuration->num_yp_directories])
xmlFree(configuration->yp_url[configuration->num_yp_directories]);
configuration->yp_url[configuration->num_yp_directories] =
(char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
} else if (xmlStrcmp (node->name, XMLSTR("yp-url-timeout")) == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
configuration->yp_url_timeout[configuration->num_yp_directories] =
atoi(tmp);
if (tmp) xmlFree(tmp);
} else if (xmlStrcmp (node->name, XMLSTR("server")) == 0) {
_add_server(doc, node->xmlChildrenNode, configuration);
} else if (xmlStrcmp (node->name, XMLSTR("touch-interval")) == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
configuration->yp_touch_interval[configuration->num_yp_directories] =
atoi(tmp);
if (tmp) xmlFree(tmp);
}
} while ((node = node->next));
if (configuration->yp_url [configuration->num_yp_directories] == NULL)
return;
configuration->num_yp_directories++;
}
开发者ID:xaiki,项目名称:IceCast,代码行数:36,代码来源:cfgfile.c
示例16: Java_com_sun_media_sound_HeadspaceSoundbank_nGetInstruments
JNIEXPORT void JNICALL
Java_com_sun_media_sound_HeadspaceSoundbank_nGetInstruments(JNIEnv* e, jobject thisObj, jlong id, jobject instruments)
{
int index = 0; // current index as we iterate through the set of instruments in the bank
int nameLength;
// variables for vector operations
jclass vectorClass;
jmethodID addElementMethodID;
// variables for java instrument manipulations
jclass instrumentClass;
jmethodID initMethodID;
jobject newInstrumentObject;
jstring newName;
// variables for the XGetIndexedFileResource call
XPTR pData;
INT32 instrumentSize;
XLongResourceID instrumentId;
char instrumentName[BANK_NAME_MAX_SIZE]; //$$kk: what should the size be??
TRACE0("Java_com_sun_media_sound_HeadspaceSoundbank_nGetInstruments\n");
// get the vector stuff set up
vectorClass = (*e)->GetObjectClass(e, instruments);
if (vectorClass == NULL)
{
ERROR0("Java_com_sun_media_sound_HeadspaceSoundbank_nGetInstruments: vectorClass is NULL\n");
return;
}
addElementMethodID = (*e)->GetMethodID(e, vectorClass, "addElement", "(Ljava/lang/Object;)V");
if (addElementMethodID == NULL)
{
ERROR0("Java_com_sun_media_sound_HeadspaceSoundbank_nGetInstruments: addElementMethodID is NULL\n");
return;
}
// get the HeadspaceInstrument class, init method id, etc.
instrumentClass = (*e)->FindClass(e, "com/sun/media/sound/HeadspaceInstrument");
if (instrumentClass == NULL)
{
ERROR0("Java_com_sun_media_sound_HeadspaceSoundbank_nGetInstruments: instrumentClass is NULL\n");
return;
}
initMethodID = (*e)->GetMethodID(e, instrumentClass, "<init>", "(Lcom/sun/media/sound/HeadspaceSoundbank;Ljava/lang/String;II)V");
if (initMethodID == NULL)
{
ERROR0("Java_com_sun_media_sound_HeadspaceSoundbank_nGetInstruments: initMethodID is NULL\n");
return;
}
while (TRUE)
{
// get the next instrument
pData = XGetIndexedFileResource((XFILE) (INT_PTR) id, ID_INST, &instrumentId, index, instrumentName, &instrumentSize);
if (pData == NULL)
{
/* done getting instruments */
break;
}
XPtoCstr(instrumentName);
// fix for 4429762: Some instrument names in some soundbanks include bad extra characters
// since XPtoCstr() modifies the contents of instrumentName[], we can do so, too!
nameLength = 0;
while(instrumentName[nameLength]) nameLength++;
while(nameLength > 0 && instrumentName[nameLength-1] < 32) {
instrumentName[nameLength-1] = 0;
nameLength--;
}
newName = (*e)->NewStringUTF(e, instrumentName);
// create a HeadspaceInstrument object
newInstrumentObject = (*e)->NewObject(e, instrumentClass, initMethodID, thisObj, (jstring)newName, (jint)instrumentId, (jint)instrumentSize);
if (newInstrumentObject == NULL)
{
ERROR1("Java_com_sun_media_sound_HeadspaceSoundbank_nGetInstruments: Failed to get instantiate HeadspaceInstrument object for instrument id %lu.\n", instrumentId);
}
else
{
// add it to the vector
(*e)->CallVoidMethod(e, instruments, addElementMethodID, newInstrumentObject);
}
index++;
}
//.........这里部分代码省略.........
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:101,代码来源:HeadspaceSoundbank.c
示例17: Java_com_sun_media_sound_HeadspaceSoundbank_nGetSamples
JNIEXPORT void JNICALL
Java_com_sun_media_sound_HeadspaceSoundbank_nGetSamples(JNIEnv* e, jobject thisObj, jlong id, jobject samples)
{
int index = 0; // current index as we iterate through the set of samples in the bank
// variables for vector operations
jclass vectorClass;
jmethodID addElementMethodID;
// variables for java sample manipulations
jclass sampleClass;
jmethodID initMethodID;
jobject newSampleObject;
jstring newName;
// variables for the XGetIndexedFileResource call
XPTR pData;
INT32 sampleSize;
XLongResourceID sampleId;
char sampleName[BANK_NAME_MAX_SIZE]; //$$kk: what should the size be??
TRACE0("Java_com_sun_media_sound_HeadspaceSoundbank_nGetSamples\n");
// get the vector stuff set up
vectorClass = (*e)->GetObjectClass(e, samples);
if (vectorClass == NULL)
{
ERROR0("Java_com_sun_media_sound_HeadspaceSoundbank_nGetSamples: vectorClass is NULL\n");
return;
}
addElementMethodID = (*e)->GetMethodID(e, vectorClass, "addElement", "(Ljava/lang/Object;)V");
if (addElementMethodID == NULL)
{
ERROR0("Java_com_sun_media_sound_HeadspaceSoundbank_nGetSamples: addElementMethodID is NULL\n");
return;
}
// get the HeadspaceSample class, init method id, etc.
sampleClass = (*e)->FindClass(e, "com/sun/media/sound/HeadspaceSample");
if (sampleClass == NULL)
{
ERROR0("Java_com_sun_media_sound_HeadspaceSoundbank_nGetSamples: sampleClass is NULL\n");
return;
}
initMethodID = (*e)->GetMethodID(e, sampleClass, "<init>", "(Lcom/sun/media/sound/HeadspaceSoundbank;Ljava/lang/String;III)V");
if (initMethodID == NULL)
{
ERROR0("Java_com_sun_media_sound_HeadspaceSoundbank_nGetSamples: initMethodID is NULL\n");
return;
}
while (TRUE)
{
// get the next instrument
pData = XGetIndexedFileResource((XFILE) (INT_PTR) id, ID_INST, &sampleId, index, sampleName, &sampleSize);
// look for compressed version first
pData = XGetIndexedFileResource((XFILE) (INT_PTR) id, ID_CSND, &sampleId, index, sampleName, &sampleSize);
if (pData == NULL)
{
// look for standard version
pData = XGetIndexedFileResource((XFILE) (INT_PTR) id, ID_SND, &sampleId, index, sampleName, &sampleSize);
if (pData == NULL)
{
// look for encrypted version
pData = XGetIndexedFileResource((XFILE) (INT_PTR) id, ID_ESND, &sampleId, index, sampleName, &sampleSize);
}
}
if (pData == NULL)
{
/* done getting instruments */
break;
}
XPtoCstr(sampleName);
newName = (*e)->NewStringUTF(e, sampleName);
// create a HeadspaceSample object
newSampleObject = (*e)->NewObject(e, sampleClass, initMethodID, thisObj, (jstring)newName, (jint)index, (jint)sampleId, (jint)sampleSize);
if (newSampleObject == NULL)
{
ERROR1("Java_com_sun_media_sound_HeadspaceSoundbank_nGetSamples: Failed to get instantiate HeadspaceSample object for sample id %lu.\n", sampleId);
}
else
{
//.........这里部分代码省略.........
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:101,代码来源:HeadspaceSoundbank.c
示例18: pass_on
//.........这里部分代码省略.........
if (written < 0 && errno == EAGAIN) {
/*
* Nothing was written - this is really strange because
* select() told us we could write. Ignore.
*/
} else if (written < 0) {
/*
* A write error. Assume that to_erl has terminated.
*/
clear_outbuf();
sf_close(wfd);
wfd = 0;
} else {
/* Delete the written part (or all) from the buffer. */
outbuf_delete(written);
}
}
/*
* Read master pty and write to FIFO.
*/
if (FD_ISSET(mfd, &readfds)) {
#ifdef DEBUG
status("Pty master read; ");
#endif
if ((len = sf_read(mfd, buf, BUFSIZ)) <= 0) {
sf_close(rfd);
if(wfd) sf_close(wfd);
sf_close(mfd);
unlink(fifo1);
unlink(fifo2);
if (len < 0) {
if(errno == EIO)
ERROR0(LOG_ERR,"Erlang closed the connection.");
else
ERRNO_ERR0(LOG_ERR,"Error in reading from terminal");
exit(1);
}
exit(0);
}
write_to_log(&lfd, &lognum, buf, len);
/*
* Save in the output queue.
*/
if (wfd) {
outbuf_append(buf, len);
}
}
/*
* Read from FIFO, write to master pty
*/
if (FD_ISSET(rfd, &readfds)) {
#ifdef DEBUG
status("FIFO read; ");
#endif
if ((len = sf_read(rfd, buf, BUFSIZ)) < 0) {
sf_close(rfd);
if(wfd) sf_close(wfd);
sf_close(mfd);
unlink(fifo1);
unlink(fifo2);
ERRNO_ERR0(LOG_ERR,"Error in reading from FIFO.");
开发者ID:aiyuefine,项目名称:otp,代码行数:67,代码来源:run_erl.c
示例19: open_pty_master
//.........这里部分代码省略.........
{
/* Unix98 style /dev/ptym/ptyXY and /dev/pty/ttyXY */
static char ptyname[] = "/dev/ptym/ptyXY";
static char ttyname[] = "/dev/pty/ttyXY";
for (major = majorchars; *major; major++) {
ptyname[13] = *major;
for (minor = minorchars; *minor; minor++) {
ptyname[14] = *minor;
if ((mfd = sf_open(ptyname, O_RDWR, 0)) >= 0) {
ttyname[12] = *major;
ttyname[13] = *minor;
*ptyslave = ttyname;
return mfd;
}
}
}
}
{
/* Old style /dev/ptyXY */
static char ptyname[] = "/dev/ptyXY";
for (major = majorchars; *major; major++) {
ptyname[8] = *major;
for (minor = minorchars; *minor; minor++) {
ptyname[9] = *minor;
if ((mfd = sf_open(ptyname, O_RDWR, 0)) >= 0) {
ptyname[5] = 't';
*ptyslave = ptyname;
return mfd;
}
}
}
}
#endif /* !HAVE_OPENPTY */
return -1;
}
static int open_pty_slave(char *name)
{
int sfd;
struct termios tty_rmode;
if ((sfd = sf_open(name, O_RDWR, 0)) < 0) {
return -1;
}
#if defined(__sun) && defined(__SVR4)
/* Load the necessary STREAMS modules for Solaris */
if ((ioctl(sfd, I_FIND, "ldterm")) < 0) {
ERROR0(LOG_ERR, "Failed to find ldterm STREAMS module");
return -1;
}
if (ioctl(sfd, I_PUSH, "ptem") < 0) {
ERROR0(LOG_ERR, "Failed to push ptem STREAMS module");
return -1;
}
if (ioctl(sfd, I_PUSH, "ldterm") < 0) {
ERROR0(LOG_ERR, "Failed to push ldterm STREAMS module");
return -1;
}
if (ioctl(sfd, I_PUSH, "ttcompat") < 0) {
ERROR0(LOG_ERR, "Failed to push ttcompat STREAMS module");
return -1;
}
#endif
if (getenv("RUN_ERL_DISABLE_FLOWCNTRL")) {
if (tcgetattr(sfd, &tty_rmode) < 0) {
fprintf(stderr, "Cannot get terminal's current mode\n");
exit(-1);
}
tty_rmode.c_iflag &= ~IXOFF;
if (tcsetattr(sfd, TCSANOW, &tty_rmode) < 0) {
fprintf(stderr, "Cannot disable terminal's flow control on input\n");
exit(-1);
}
tty_rmode.c_iflag &= ~IXON;
if (tcsetattr(sfd, TCSANOW, &tty_rmode) < 0) {
fprintf(stderr, "Cannot disable terminal's flow control on output\n");
exit(-1);
}
}
#ifdef DEBUG
if (tcgetattr(sfd, &tty_rmode) < 0) {
fprintf(stderr, "Cannot get terminals current mode\n");
exit(-1);
}
show_terminal_settings(&tty_rmode);
#endif
return sfd;
}
开发者ID:aiyuefine,项目名称:otp,代码行数:101,代码来源:run_erl.c
示例20: DAUDIO_Open
void* DAUDIO_Open(INT32 mixerIndex, INT32 deviceID, int isSource,
int encoding, float sampleRate, int sampleSizeInBits,
int frameSize, int channels,
int isSigned, int isBigEndian, int bufferSizeInBytes) {
snd_pcm_format_mask_t* formatMask;
snd_pcm_format_t format;
int dir;
int ret = 0;
AlsaPcmInfo* info = NULL;
/* snd_pcm_uframes_t is 64 bit on 64-bit systems */
snd_pcm_uframes_t alsaPeriodSize = 0;
snd_pcm_uframes_t alsaBufferSizeInFrames = 0;
TRACE0("> DAUDIO_Open\n");
#ifdef USE_TRACE
// for using ALSA debug dump methods
if (ALSA_OUTPUT == NULL) {
snd_output_stdio_attach(&ALSA_OUTPUT, stdout, 0);
}
#endif
info = (AlsaPcmInfo*) malloc(sizeof(AlsaPcmInfo));
if (!info) {
ERROR0("Out of memory\n");
return NULL;
}
memset(info, 0, sizeof(AlsaPcmInfo));
ret = openPCMfromDeviceID(deviceID, &(info->handle), isSource, FALSE /* do open device*/);
if (ret == 0) {
// set to blocking mode
snd_pcm_nonblock(info->handle, 0);
ret = snd_pcm_hw_params_malloc(&(info->hwParams));
if (ret != 0) {
ERROR1(" snd_pcm_hw_params_malloc returned error %d\n", ret);
} else {
ret = -1;
if (getAlsaFormatFromFormat(&format, frameSize / channels, sampleSizeInBits,
isSigned, isBigEndian, encoding)) {
if (setHWParams(info,
sampleRate,
channels,
bufferSizeInBytes / frameSize,
format)) {
info->frameSize = frameSize;
#ifdef ALSA_PCM_NEW_HW_PARAMS_API
ret = snd_pcm_hw_params_get_period_size(info->hwParams, &alsaPeriodSize, &dir);
info->periodSize = (int) alsaPeriodSize;
if (ret < 0) {
ERROR1("ERROR: snd_pcm_hw_params_get_period: %s\n", snd_strerror(ret));
}
snd_pcm_hw_params_get_periods(info->hwParams, &(info->periods), &dir);
snd_pcm_hw_params_get_buffer_size(info->hwParams, &alsaBufferSizeInFrames);
info->bufferSizeInBytes = (int) alsaBufferSizeInFrames * frameSize;
#else
info->periodSize = snd_pcm_hw_params_get_period_size(info->hwParams, &dir);
info->periods = snd_pcm_hw_params_get_periods(info->hwParams, &dir);
info->bufferSizeInBytes = snd_pcm_hw_params_get_buffer_size(info->hwParams) * frameSize;
ret = 0;
#endif
TRACE3(" DAUDIO_Open: period size = %d frames, periods = %d. Buffer size: %d bytes.\n",
(int) info->periodSize, info->periods, info->bufferSizeInBytes);
}
}
}
if (ret == 0) {
// set software parameters
ret = snd_pcm_sw_params_malloc(&(info->swParams));
if (ret != 0) {
ERROR1("snd_pcm_hw_params_malloc returned error %d\n", ret);
} else {
if (!setSWParams(info)) {
ret = -1;
}
}
}
if (ret == 0) {
// prepare device
ret = snd_pcm_prepare(info->handle);
if (ret < 0) {
ERROR1("ERROR: snd_pcm_prepare: %s\n", snd_strerror(ret));
}
}
#ifdef GET_POSITION_METHOD2
if (ret == 0) {
ret = snd_pcm_status_malloc(&(info->positionStatus));
if (ret != 0) {
ERROR1("ERROR in snd_pcm_status_malloc: %s\n", snd_strerror(ret));
}
}
#endif
}
if (ret != 0) {
DAUDIO_Close((void*) info, isSource);
info = NULL;
} else {
// set to non-blocking mode
snd_pcm_nonblock(info->handle, 1);
//.........这里部分代码省略.........
开发者ID:michalwarecki,项目名称:ManagedRuntimeInitiative,代码行数:101,代码来源:PLATFORM_API_LinuxOS_ALSA_PCM.c
注:本文中的ERROR0函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论