bool OpenALBackend::AddData(const void* src, u32 num_samples) { AUDIT(alIsSource(m_source)); // Unqueue processed buffers, if any unqueue_processed(); // Fail if there are no free buffers remaining if (m_num_unqueued == 0) { LOG_WARNING(GENERAL, "XAudio2Backend : no unqueued buffers remaining"); return false; } // Copy data to the next available buffer alBufferData(m_buffers[m_next_buffer], m_format, src, num_samples * m_sample_size, m_sampling_rate); checkForAlError("AddData->alBufferData"); // Enqueue buffer alSourceQueueBuffers(m_source, 1, &m_buffers[m_next_buffer]); checkForAlError("AddData->alSourceQueueBuffers"); m_num_unqueued--; m_next_buffer = (m_next_buffer + 1) % m_num_buffers; return true; }
void OpenALBackend::Pause() { AUDIT(alIsSource(m_source)); alSourcePause(m_source); checkForAlError("Pause->alSourcePause"); }
bool server_extract_file(twopence_transaction_t *trans, const twopence_file_xfer_t *xfer) { twopence_trans_channel_t *source; const char *username = xfer->user; const char *filename = xfer->remote.name; int status; int fd; AUDIT("extract \"%s\"; user=%s\n", filename, username); if ((fd = server_open_file_as(username, filename, 0600, O_RDONLY, &status)) < 0) { twopence_transaction_fail(trans, status); return false; } source = twopence_transaction_attach_local_source(trans, 0, fd); if (source == NULL) { /* Something is wrong */ twopence_transaction_fail(trans, EIO); close(fd); return false; } twopence_transaction_channel_set_callback_read_eof(source, server_extract_file_source_read_eof); /* We don't expect to receive any packets; sending is taken care of at the channel level */ return true; }
bool server_inject_file(twopence_transaction_t *trans, const twopence_file_xfer_t *xfer) { twopence_trans_channel_t *sink; const char *filename = xfer->remote.name; const char *username = xfer->user; unsigned int filemode = xfer->remote.mode; int status; int fd; AUDIT("inject \"%s\"; user=%s\n", filename, username); if ((fd = server_open_file_as(username, filename, filemode, O_WRONLY|O_CREAT|O_TRUNC, &status)) < 0) { twopence_transaction_fail(trans, status); return false; } sink = twopence_transaction_attach_local_sink(trans, 0, fd); if (sink == NULL) { /* Something is wrong */ close(fd); return false; } twopence_transaction_channel_set_callback_write_eof(sink, server_inject_file_write_eof); /* Tell the client a success status right after we open the file - * this will start the actual transfer */ twopence_transaction_send_major(trans, 0); return true; }
u64 OpenALBackend::GetNumEnqueuedSamples() { AUDIT(alIsSource(m_source)); // Get number of buffers queued ALint num_queued; alGetSourcei(m_source, AL_BUFFERS_QUEUED, &num_queued); checkForAlError("GetNumEnqueuedSamples->alGetSourcei(AL_BUFFERS_QUEUED)"); AUDIT(static_cast<u32>(num_queued) <= m_num_buffers - m_num_unqueued); // Get sample position ALint sample_pos; alGetSourcei(m_source, AL_SAMPLE_OFFSET, &sample_pos); checkForAlError("GetNumEnqueuedSamples->alGetSourcei(AL_SAMPLE_OFFSET)"); // Return return (num_queued * AUDIO_BUFFER_SAMPLES) + (sample_pos % AUDIO_BUFFER_SAMPLES); }
bool alAuditData(unsigned typeLen, char const * type, unsigned msgLen, char const * msg, unsigned dataLen, void const * dataBlock) { StringBuffer typeString(typeLen, type); typeString.toUpperCase(); StringBuffer msgString(msgLen, msg); AuditType typeValue = findAuditType(typeString.str()); if(typeValue >= NUM_AUDIT_TYPES) return false; return AUDIT(typeValue, msgString.str(), dataLen, dataBlock); }
bool OpenALBackend::IsPlaying() { AUDIT(alIsSource(m_source)); ALint state; alGetSourcei(m_source, AL_SOURCE_STATE, &state); checkForAlError("IsPlaying->alGetSourcei(AL_SOURCE_STATE)"); return state == AL_PLAYING; }
void OpenALBackend::Flush() { AUDIT(alIsSource(m_source)); // Stop source first alSourceStop(m_source); checkForAlError("Flush->alSourceStop"); // Unqueue processed buffers (should now be all of them) unqueue_processed(); }
bool server_run_command(twopence_transaction_t *trans, twopence_command_t *cmd) { twopence_trans_channel_t *channel; int status; int command_fds[3]; int nattached = 0; pid_t pid; AUDIT("run \"%s\"; user=%s timeout=%u%s\n", cmd->command, cmd->user, cmd->timeout, cmd->request_tty? ", use a tty" : ""); if ((pid = server_run_command_as(cmd, command_fds, &status)) < 0) { twopence_transaction_fail2(trans, status, 0); return false; } channel = twopence_transaction_attach_local_sink(trans, TWOPENCE_STDIN, command_fds[0]); if (channel == NULL) goto failed; twopence_transaction_channel_set_name(channel, "stdin"); nattached++; channel = twopence_transaction_attach_local_source(trans, TWOPENCE_STDOUT, command_fds[1]); if (channel == NULL) goto failed; twopence_transaction_channel_set_name(channel, "stdout"); nattached++; if (command_fds[2] >= 0) { channel = twopence_transaction_attach_local_source(trans, TWOPENCE_STDERR, command_fds[2]); if (channel == NULL) goto failed; twopence_transaction_channel_set_name(channel, "stderr"); nattached++; } else { /* Tell the client that there's no separate stderr */ twopence_transaction_send_client(trans, twopence_protocol_build_eof_packet(&trans->ps, TWOPENCE_STDERR)); } trans->recv = server_run_command_recv; trans->send = server_run_command_send; trans->pid = pid; return true; failed: twopence_transaction_fail2(trans, EIO, 0); while (nattached < 3) close(command_fds[nattached++]); return false; }
void SecHandler::AuditMessage(AuditType type, const char *filterType, const char *title, const char *parms, ...) { va_list args; va_start(args, parms); StringBuffer msg(title); msg.appendf("\n\tProcess: esp\n\tUser: %s", m_user->getName()); if (parms) msg.append("\n\t").valist_appendf(parms, args); va_end(args); AUDIT(type, msg.str()); }
void OpenALBackend::Play() { AUDIT(alIsSource(m_source)); ALint state; alGetSourcei(m_source, AL_SOURCE_STATE, &state); checkForAlError("Play->alGetSourcei(AL_SOURCE_STATE)"); if (state != AL_PLAYING) { alSourcePlay(m_source); checkForAlError("Play->alSourcePlay"); } }
void OpenALBackend::Open(u32 num_buffers) { AUDIT(!alIsSource(m_source)); // Initialize Source alGenSources(1, &m_source); checkForAlError("Open->alGenSources"); alSourcei(m_source, AL_LOOPING, AL_FALSE); checkForAlError("Open->alSourcei"); // Initialize Buffers alGenBuffers(num_buffers, m_buffers); checkForAlError("Open->alGenBuffers"); m_num_buffers = num_buffers; m_num_unqueued = num_buffers; }
void OpenALBackend::unqueue_processed() { AUDIT(alIsSource(m_source)); // Get number of buffers ALint num_processed; alGetSourcei(m_source, AL_BUFFERS_PROCESSED, &num_processed); checkForAlError("Flush->alGetSourcei(AL_BUFFERS_PROCESSED)"); if (num_processed > 0) { // Unqueue all buffers ALuint x[MAX_AUDIO_BUFFERS]; alSourceUnqueueBuffers(m_source, num_processed, x); checkForAlError("Flush->alSourceUnqueueBuffers"); m_num_unqueued += num_processed; } }
void SecHandler::AuditMessage(AuditType type, const char *filterType, const char *title) { VStringBuffer msg("%s\n\tProcess: esp\n\tUser: %s", title, m_user->getName()); AUDIT(type, msg.str()); }
/** * main() - IUCV CONN program startup */ int main(int argc, char *argv[]) { int rc; int server; struct sockaddr_iucv addr; struct termios ios; struct sigaction sigact; struct passwd *passwd; struct iucvterm_cfg conf; /* gettext initialization */ gettext_init(); /* parse command line options */ parse_options(PROG_IUCV_CONN, &conf, argc, argv); /* open session audit log */ if (conf.sessionlog != NULL) if (open_session_log(conf.sessionlog)) { print_error("Creating the terminal session " "log files failed"); return 1; } /* open socket and connect to server */ server = iucvtty_socket(&addr, conf.host, conf.service); if (server == -1) { print_error((errno == EAFNOSUPPORT) ? N_("The AF_IUCV address family is not available") : N_("Creating the AF_IUCV socket failed")); return 1; } /* syslog */ openlog(SYSLOG_IDENT, LOG_PID, LOG_AUTHPRIV); /* get user information for syslog */ passwd = getpwuid(geteuid()); if (connect(server, (struct sockaddr *) &addr, sizeof(addr)) == -1) { switch (errno) { case EAGAIN: print_error("The new connection would exceed the " "maximum number of IUCV connections"); break; case ENETUNREACH: print_error("The target z/VM guest virtual machine " "is not logged on"); break; case EACCES: print_error("The IUCV authorizations do not permit " "connecting to the target z/VM guest"); break; default: print_error("Connecting to the z/VM guest virtual " "machine failed"); break; } AUDIT("Connection to %s/%s failed for user %s (uid=%i)", conf.host, conf.service, (passwd != NULL) ? passwd->pw_name : "n/a", geteuid()); rc = 2; goto return_on_error; } AUDIT("Established connection to %s/%s for user %s (uid=%i)", conf.host, conf.service, (passwd != NULL) ? passwd->pw_name : "n/a", geteuid()); /* send client params */ iucvtty_tx_termenv(server, DEFAULT_TERM); iucvtty_tx_winsize(server, STDIN_FILENO); /* register signal handler */ sigemptyset(&sigact.sa_mask); sigact.sa_flags = SA_RESTART; sigact.sa_handler = sig_handler; sigaction(SIGWINCH, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); /* modify terminal settings */ if (tcgetattr(STDIN_FILENO, &ios_orig)) { print_error("Getting the terminal I/O settings failed"); rc = 3; goto return_on_error; } memcpy(&ios, &ios_orig, sizeof(ios)); /* put terminal into raw mode */ cfmakeraw(&ios); /* NOTE: If the tty driver (ldisc) runs in TTY_DRIVER_REAL_RAW, * we need to do the input character processing here; * that means to translate CR into CR + NL (ICRNL). * Define TTY_REAL_RAW in for that case. */ #ifdef TTY_REAL_RAW ios.c_iflag |= ICRNL; /* | IGNPAR | IGNBRK; */ #endif tcflush(STDIN_FILENO, TCIOFLUSH); if (tcsetattr(STDIN_FILENO, TCSANOW, &ios)) { print_error("Modifying the terminal I/O settings failed"); rc = 4; goto return_on_error; } iucvtty_worker(server, &conf); tcsetattr(STDIN_FILENO, TCSANOW, &ios_orig); rc = 0; return_on_error: close(server); closelog(); close_session_log(); return rc; }