I have developed a client server application using dbus. The client sends 2 input arguments using dbus_message and server returns the sum. I am mainly interested in using DBusWatch so I can send from multiple clients and get the server to respond to them. Can anyone please help me in code and explain me how DbusWatch works?
code
client.c
#include <stdio.h>
#include <stdlib.h>
#include <dbus/dbus.h>
#include <stdbool.h>
#include <ctype.h>
void caller(int param,int param1)
{
DBusMessage* msg;
DBusMessageIter args;
DBusConnection* conn;
DBusError err;
DBusPendingCall* pending;
int ret;
int level;
printf("Calling remote method with %d %d\n",param,param1);
// initialiset the errors
dbus_error_init(&err);
// connect to the system bus and check for errors
conn = dbus_bus_get(DBUS_BUS_SESSION, &err);
if (dbus_error_is_set(&err)) {
fprintf(stderr, "Connection Error (%s)\n", err.message);
dbus_error_free(&err);
}
if (NULL == conn) {
exit(1);
}
// request our name on the bus
ret = dbus_bus_request_name(conn, "test.client.caller", DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
if (dbus_error_is_set(&err)) {
fprintf(stderr, "Name Error (%s)\n", err.message);
dbus_error_free(&err);
}
// create a new method call and check for errors
msg = dbus_message_new_method_call("test.server.source", // target for the method call
"/test/method/Object", // object to call on
"test.method.Type", // interface to call on
"Method"); // method name
if (NULL == msg) {
fprintf(stderr, "Message Null\n");
exit(1);
}
// append arguments
dbus_message_iter_init_append(msg, &args);
if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, ¶m)) {
fprintf(stderr, "Out Of Memory!\n");
exit(1);
}
if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, ¶m1)) {
fprintf(stderr, "Out Of Memory!\n");
exit(1);
}
// send message and get a handle for a reply
if (!dbus_connection_send_with_reply (conn, msg, &pending, -1)) { // -1 is default timeout
fprintf(stderr, "Out Of Memory!\n");
exit(1);
}
if (NULL == pending) {
fprintf(stderr, "Pending Call Null\n");
exit(1);
}
dbus_connection_flush(conn);
printf("Request Sent\n");
// free message
dbus_message_unref(msg);
// block until we recieve a reply
dbus_pending_call_block(pending);
// get the reply message
msg = dbus_pending_call_steal_reply(pending);
if (NULL == msg) {
fprintf(stderr, "Reply Null\n");
exit(1);
}
// free the pending message handle
dbus_pending_call_unref(pending);
// read the parameters
if (!dbus_message_iter_init(msg, &args))
fprintf(stderr, "Message has no arguments!\n");
else
dbus_message_iter_get_basic(&args, &level);
printf("Got Reply:%d\n",level);
// free reply and close connection
dbus_message_unref(msg);
dbus_connection_close(conn);
}
int main(int argc, char **argv)
{
if (argc == 1)
return -1;
else if(argc==3)
{
int param = atoi(argv[1]);
int param1 = atoi(argv[2]);
caller(param,param1);
}
else
{
printf("Number of arguments should be 2 integers\n");
}
}
server.c
#include <stdbool.h>
#include <stdlib.h>
#include <dbus/dbus-glib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <dbus-1.0/dbus/dbus.h>
#include <math.h>
void reply_to_method_call(DBusMessage* msg, DBusConnection* conn)
{
DBusMessage* reply;
DBusMessageIter rootIter;
dbus_uint32_t serial = 0;
dbus_uint32_t a;
dbus_uint32_t b;
dbus_uint32_t sum;
// read the arguments
if (!dbus_message_iter_init(msg,&rootIter))
fprintf(stderr, "Message has no arguments!\n");
dbus_message_iter_get_basic(&rootIter, &a);
printf("Method called with %d\n", a);
if(dbus_message_iter_has_next(&rootIter))
{
dbus_message_iter_next(&rootIter);
dbus_message_iter_get_basic(&rootIter, &b);
printf("Method called with %d\n", b);
}
if ( dbus_message_is_method_call( msg, "test.method.Type", "Method" ) )
{
sum=a+b;
}
// create a reply from the message
reply = dbus_message_new_method_return(msg);
// add the arguments to the reply
dbus_message_iter_init_append(reply, &rootIter);
if (!dbus_message_iter_append_basic(&rootIter, DBUS_TYPE_INT32, &sum)) {
fprintf(stderr, "Out Of Memory!\n");
exit(1);
}
// send the reply && flush the connection
if (!dbus_connection_send(conn, reply, &sum)) {
fprintf(stderr, "Out Of Memory!\n");
exit(1);
}
dbus_connection_flush(conn);
// free the reply
dbus_message_unref(reply);
}
int main()
{
DBusMessage* msg;
DBusMessage* reply;
DBusMessageIter args;
DBusConnection* conn;
DBusError err;
int ret;
char* param;
printf("Listening for method calls\n");
// initialise the error
dbus_error_init(&err);
// connect to the bus and check for errors
conn = dbus_bus_get(DBUS_BUS_SESSION, &err);
if (dbus_error_is_set(&err)) {
fprintf(stderr, "Connection Error (%s)\n", err.message);
dbus_error_free(&err);
}
if (NULL == conn) {
fprintf(stderr, "Connection Null\n");
exit(1);
}
// request our name on the bus and check for errors
ret = dbus_bus_request_name(conn,"test.server.source", DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
if (dbus_error_is_set(&err)) {
fprintf(stderr, "Name Error (%s)\n", err.message);
dbus_error_free(&err);
}
// loop, testing for new messages
while (true) {
// non blocking read of the next available message
dbus_connection_read_write(conn, 0);
msg = dbus_connection_pop_message(conn);
// loop again if we haven't got a message
if (NULL == msg) {
sleep(1);
continue;
}
if ( dbus_message_has_interface(msg, "test.method.Type") )
reply_to_method_call( msg, conn );
// free the message
dbus_message_unref(msg);
}
// close the connection
dbus_connection_close(conn);
}
And the Makefile to build these files;
CC=gcc
CPP=g++
LDFLAGS =-ldbus-1
LDFLAGS+=-ldbus-glib-1
CFLAGS =.
CFLAGS+=-I/usr/include/dbus-1.0
CFLAGS+=-I/usr/lib/x86_64-linux-gnu/dbus-1.0/include
CFLAGS+=-I/usr/include/glib-2.0
CFLAGS+=-I/usr/lib/x86_64-linux-gnu/glib-2.0/include
CFLAGS+=-Wall
CFLAGS+=-Wextra
CFLAGS+=-g
all: server client
rebuild: clean all
%.o: %.c
#echo " CC $^"
$(CC) $(CFLAGS) -c -o $# $^
server: server.o
#echo " LINK $^"
$(CC) $^ $(LDFLAGS) -o $#
client: client.o
#echo " LINK $^"
$(CC) $^ $(LDFLAGS) -o $#
clean:
rm -f *.o server client
Related
I'm trying to call D-Bus method, but don't understand how to add needed args.
Method name: CreateSession (String destination, Dict of {String, Variant} args) ↦ (Object Path session)
Bus Name: org.bluez.obex
Object Path: /org/bluez/obex
Interface: org.bluez.obex.Client1
I successfully can call this method in D-Feet app with this arguments:
"D0:9C:7A:A1:A4:63",{'Target':GLib.Variant('s','OPP')}
But how make the same using only dbus.h?
Here's my code:
// Do before compile sudo apt-get install -y libdbus-1-dev
// gcc -o test -Wall test.c `pkg-config --cflags dbus-1` `pkg-config --libs dbus-1`
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dbus/dbus.h>
int main() {
DBusConnection *sesBusCon;
DBusError error;
DBusMessage *call;
DBusMessage *reply;
dbus_error_init(&error);
if (dbus_error_is_set(&error)) {
fprintf(stderr, "%s", error.message);
return 1;
}
sesBusCon = dbus_bus_get(DBUS_BUS_SESSION, &error);
if (dbus_error_is_set(&error)) {
fprintf(stderr, "%s", error.message);
return 1;
}
call = dbus_message_new_method_call("org.bluez.obex", "/org/bluez/obex", "org.bluez.obex.Client1", "CreateSession");
reply = dbus_connection_send_with_reply_and_block (sesBusCon, call, 100000, &error);
if (dbus_error_is_set(&error)) {
fprintf(stderr, "%s", error.message);
return 1;
}
return 0;
}
Maybe it helps someone:
// Do before compile sudo apt-get install -y libdbus-1-dev
// gcc -o test -Wall test.c `pkg-config --cflags dbus-1` `pkg-config --libs dbus-1`
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dbus/dbus.h>
int main() {
DBusConnection *sesBusCon;
DBusError error;
DBusMessage *call;
DBusMessage *reply;
DBusMessageIter iterInit, iterDict, iterEntry, iterValue;
dbus_error_init(&error);
if (dbus_error_is_set(&error)) {
fprintf(stderr, "%s", error.message);
return 1;
}
sesBusCon = dbus_bus_get(DBUS_BUS_SESSION, &error);
if (dbus_error_is_set(&error)) {
fprintf(stderr, "%s", error.message);
return 1;
}
call = dbus_message_new_method_call("org.bluez.obex", "/org/bluez/obex", "org.bluez.obex.Client1", "CreateSession");
char *destination = "D0:9C:7A:A1:A4:63";
dbus_message_append_args(call, DBUS_TYPE_STRING, &destination, DBUS_TYPE_INVALID);
dbus_message_iter_init_append(call, &iterInit);
dbus_message_iter_open_container(&iterInit, DBUS_TYPE_ARRAY,
DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &iterDict);
dbus_message_iter_open_container(&iterDict, DBUS_TYPE_DICT_ENTRY, NULL, &iterEntry);
char *key = "Target";
dbus_message_iter_append_basic(&iterEntry, DBUS_TYPE_STRING, &key);
dbus_message_iter_open_container(&iterEntry, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &iterValue);
void *val = "OPP";
dbus_message_iter_append_basic(&iterValue, DBUS_TYPE_STRING, &val);
dbus_message_iter_close_container(&iterEntry, &iterValue);
dbus_message_iter_close_container(&iterDict, &iterEntry);
dbus_message_iter_close_container(&iterInit, &iterDict);
DBusPendingCall* replyPending;
DBusMessage* replyMessage;
DBusMessageIter replyIter;
dbus_connection_send_with_reply(sesBusCon, call, &replyPending, -1);
dbus_pending_call_block(replyPending);
if (dbus_pending_call_get_completed (replyPending))
{
replyMessage = dbus_pending_call_steal_reply(replyPending);
dbus_message_iter_init(replyMessage, &replyIter);
char *objectPath;
dbus_message_iter_get_basic(&replyIter, &objectPath);
printf("object path %s \n",objectPath);
}
return 0;
}
I am trying to run two processes which are basically sending and receiving messages using message queue(SYS V). While I can run two process on same terminal tab by keeping my receiver in background
./receiver &
and sender in the foreground.
./sender
which is working fine but causing all my prints from sender & receiver display on same tab.
If I try to run receiver on one terminal tab and sender on other terminal-tab, the processes are not working correctly, they fail to identify message queue exist on the system.
I am not sure if its the terminal issue, or my program issue, I am using MobaXterm terminal.
Added code below, Am I missing w.r.t running processes on two different terminals I would like to know.
receiver.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#define PATH "/tmp/CMN_KEY"
struct message_text {
int qid;
char buf [200];
};
struct message {
long message_type;
struct message_text message_text;
};
int main (int argc, char **argv)
{
key_t key;
int qid;
struct message message;
if ((key = ftok (PATH,'Z')) == -1) {
printf ("ftok");
exit (1);
}
if ((qid = msgget (key, IPC_CREAT | 0660)) == -1) {
printf ("msgget");
exit (1);
}
printf ("Receiver: Waiting for MSG!\n");
while (1) {
// read an incoming message
if (msgrcv (qid, &message, sizeof (struct message_text), 0, 0) == -1) {
printf ("msgrcv");
exit (1);
}
printf ("Receiver: MSG Received.\n");
// message from sender
int length = strlen (message.message_text.buf);
char buf [20];
sprintf (buf, " %d", length);
strcat (message.message_text.buf, buf);
int client_qid = message.message_text.qid;
message.message_text.qid = qid;
// send reply message to Sender
if (msgsnd (client_qid, &message, sizeof (struct message_text), 0) == -1) {
printf ("msgget");
exit (1);
}
printf ("Receiver: Response sent to Sender .\n");
}
}
sender.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#define PATH "/tmp/CMN_KEY"
struct message_text {
int qid;
char buf [200];
};
struct message {
long message_type;
struct message_text message_text;
};
int main (int argc, char **argv)
{
key_t key;
int sender_qid, myqid;
struct message my_message, return_message;
// queue for receiving messages from receiver
if ((myqid = msgget (IPC_PRIVATE, 0660)) == -1) {
printf ("msgget: myqid");
exit (1);
}
printf("Sender created q with ID: %d\n" , myqid);
if ((key = ftok (PATH,'Z')) == -1) {
printf ("ftok");
exit (1);
}
if ((sender_qid = msgget (key, 0)) == -1) {
printf ("msgget: sender_qid");
exit (1);
}
my_message.message_type = 1;
my_message.message_text.qid = myqid;
printf ("Input a message: ");
while (fgets (my_message.message_text.buf, 198, stdin)) {
int length = strlen (my_message.message_text.buf);
if (my_message.message_text.buf [length - 1] == '\n')
my_message.message_text.buf [length - 1] = '\0';
// send message to Receiver
if (msgsnd (sender_qid, &my_message, sizeof (struct message_text), 0) == -1) {
printf ("client: msgsnd");
exit (1);
}
// read response from Receiver
if (msgrcv (myqid, &return_message, sizeof (struct message_text), 0, 0) == -1) {
printf ("client: msgrcv");
exit (1);
}
// Return message from Receiver
printf ("Return Message From Receiver: %s\n\n", return_message.message_text.buf);
printf ("type a one more message: ");
}
// remove message queue
if (msgctl (myqid, IPC_RMID, NULL) == -1) {
printf ("client: msgctl");
exit (1);
}
return
}
/* Edited */
my Cmakefile.txt file is:
cmake_minimum_required(VERSION 3.3)
project(WebServer)
set(CMAKE_C_COMPILER "/usr/bin/gcc")
set(SOURCE_FILES io.c server.c lock_fcntl.c sig_handler.c thread_job.c msg_parser.c)
set(LIB http-parser-master/http_parser.c)
set(CMAKE_USE_PTHREADS_INIT true)
set(CMAKE_USE_PTHREADS_INIT ON)
find_package(Threads REQUIRED)
add_executable(server ${SOURCE_FILES} ${LIB})
target_link_libraries(server Threads::Threads)
add_executable(client client.c io.c)
include_directories(header)
include_directories(http-parser-master)
In this way, I can compile and link my code. However pthread_create seems not work.
server.c:
void create_thread(int socket) {
data_t *data;
data = malloc(sizeof(data_t));
if (data == NULL) {
fprintf(stderr, "error in memory allocation");
exit(EXIT_FAILURE);
}
data->sock = socket;
/* debug */
fprintf(stdout, "[*] Creating thread\n");
fflush(stdout);
if (pthread_create(data->tid, NULL, job_t, data) != 0) {
fprintf(stderr, "Error returned by pthread_create()\n");
exit(EXIT_FAILURE);
}
/* debug */
fprintf(stdout, "[*] Thread created\n");
fflush(stdout);
}
thread_job.c:
void *job_t(void *arg) {
data_t *data = arg;
char *http_msg_h;
int nread;
/* debug */
fprintf(stdout, "start listening\n");
fflush(stdout);
/* read http header from connsd socket and store it in msg buffer */
nread = receive_msg_h(data->sock, (void **) &http_msg_h);
/* debug */
fprintf(stdout, "[+] parsing completed");
fflush(stdout);
}
Neither "start listening nor "Thread creation" is printed in output.
it is as if the function does not return but it doesn't work.
CMakeLists.txt is correct. My error was in code.
I change
pthread_create(data->tid, NULL, job_t, data) != 0
in pthread_create(&data->tid, NULL, job_t, data) != 0.
I'm trying to write a honeypot in C to replicate an SSH session. I'm aiming for a low interaction honeypot (similar to Kippo).
The idea is: client connects to honeypot via SSH, honeypot then understands and responds to pre-defined commands (e.g. wget, env etc).
The bit I'm stuck on is creating the initial SSH connection. I've read through the RFC for SSH to get an understanding of how SSH session are initiated. Then I've been looking at the libraries OpenSSH, libssh and libssh2 - but I can't see how to initiate an SSH session similar to sshd.
Not sure if I can use the sshd service to create the SSH session and then run the honeypot from that?
Hope that makes sense. Any help on this would be much appreciated.
Think I found what I was looking for: libssh. There's a good example on their github page of how to implement an ssh daemon in C: https://github.com/substack/libssh/blob/master/examples/samplesshd.c
For a basic SSH honeypot implementation in C there's project on github called sshpot by Pete Morris (https://github.com/PeteMo/sshpot):
#include "config.h"
#include "auth.h"
#include <libssh/libssh.h>
#include <libssh/server.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <getopt.h>
#include <errno.h>
#include <sys/wait.h>
#define MINPORT 0
#define MAXPORT 65535
/* Global so they can be cleaned up at SIGINT. */
static ssh_session session;
static ssh_bind sshbind;
/* Print usage information to `stream', exit with `exit_code'. */
static void usage(FILE *stream, int exit_code) {
fprintf(stream, "Usage: sshpot [-h] [-p <port>]\n");
fprintf(stream,
" -h --help Display this usage information.\n"
" -p --port <port> Port to listen on; defaults to 22.\n");
exit(exit_code);
}
/* Return the c-string `p' as an int if it is a valid port
* in the range of MINPORT - MAXPORT, or -1 if invalid. */
static int valid_port(char *p) {
int port;
char *endptr;
port = strtol(p, &endptr, 10);
if (port >= MINPORT && port <= MAXPORT && !*endptr && errno == 0)
return port;
return -1;
}
/* Signal handler for cleaning up after children. We want to do cleanup
* at SIGCHILD instead of waiting in main so we can accept multiple
* simultaneous connections. */
static int cleanup(void) {
int status;
int pid;
pid_t wait3(int *statusp, int options, struct rusage *rusage);
while ((pid=wait3(&status, WNOHANG, NULL)) > 0) {
if (DEBUG) { printf("process %d reaped\n", pid); }
}
/* Re-install myself for the next child. */
signal(SIGCHLD, (void (*)())cleanup);
return 0;
}
/* SIGINT handler. Cleanup the ssh* objects and exit. */
static void wrapup(void) {
ssh_disconnect(session);
ssh_bind_free(sshbind);
ssh_finalize();
exit(0);
}
int main(int argc, char *argv[]) {
int port = DEFAULTPORT;
/* Handle command line options. */
int next_opt = 0;
const char *short_opts = "hp:";
const struct option long_opts[] = {
{ "help", 0, NULL, 'h' },
{ "port", 1, NULL, 'p' },
{ NULL, 0, NULL, 0 }
};
while (next_opt != -1) {
next_opt = getopt_long(argc, argv, short_opts, long_opts, NULL);
switch (next_opt) {
case 'h':
usage(stdout, 0);
break;
case 'p':
if ((port = valid_port(optarg)) < 0) {
fprintf(stderr, "Port must range from %d - %d\n\n", MINPORT, MAXPORT);
usage(stderr, 1);
}
break;
case '?':
usage(stderr, 1);
break;
case -1:
break;
default:
fprintf(stderr, "Fatal error, aborting...\n");
exit(1);
}
}
/* There shouldn't be any other parameters. */
if (argv[optind]) {
fprintf(stderr, "Invalid parameter `%s'\n\n", argv[optind]);
usage(stderr, 1);
}
/* Install the signal handlers to cleanup after children and at exit. */
signal(SIGCHLD, (void (*)())cleanup);
signal(SIGINT, (void(*)())wrapup);
/* Create and configure the ssh session. */
session=ssh_new();
sshbind=ssh_bind_new();
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDADDR, LISTENADDRESS);
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDPORT, &port);
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_HOSTKEY, "ssh-rsa");
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY,RSA_KEYFILE);
/* Listen on `port' for connections. */
if (ssh_bind_listen(sshbind) < 0) {
printf("Error listening to socket: %s\n",ssh_get_error(sshbind));
return -1;
}
if (DEBUG) { printf("Listening on port %d.\n", port); }
/* Loop forever, waiting for and handling connection attempts. */
while (1) {
if (ssh_bind_accept(sshbind, session) == SSH_ERROR) {
fprintf(stderr, "Error accepting a connection: `%s'.\n",ssh_get_error(sshbind));
return -1;
}
if (DEBUG) { printf("Accepted a connection.\n"); }
switch (fork()) {
case -1:
fprintf(stderr,"Fork returned error: `%d'.\n",-1);
exit(-1);
case 0:
exit(handle_auth(session));
default:
break;
}
}
return 0;
}
I am trying to record and playback audio data using pulse audio API in centOS 6.2. But it records and playbacks nothing. I am using a code from pulseaudio. I need help to get it working in my PC. What should I do? My code is also given below-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <pulse/simple.h>
#include <pulse/error.h>
#define BUFSIZE 32
int main(int argc, char*argv[]) {
/* The Sample format to use */
static const pa_sample_spec ss = {
.format = PA_SAMPLE_S16LE,
.rate = 44100,
.channels = 2
};
pa_simple *s_in, *s_out = NULL;
int ret = 1;
int error;
/* Create a new playback stream */
if (!(s_out = pa_simple_new(NULL, argv[0], PA_STREAM_PLAYBACK, NULL, "playback", &ss, NULL, NULL, &error))) {
fprintf(stderr, __FILE__": pa_simple_new() failed: %s\n", pa_strerror(error));
goto finish;
}
if (!(s_in = pa_simple_new(NULL, argv[0], PA_STREAM_RECORD, NULL, "record", &ss, NULL, NULL, &error))) {
fprintf(stderr, __FILE__": pa_simple_new() failed: %s\n", pa_strerror(error));
goto finish;
}
for (;;) {
uint8_t buf[BUFSIZE];
ssize_t r;
#if 1
pa_usec_t latency;
if ((latency = pa_simple_get_latency(s_in, &error)) == (pa_usec_t) -1) {
fprintf(stderr, __FILE__": pa_simple_get_latency() failed: %s\n", pa_strerror(error));
goto finish;
}
fprintf(stderr, "In: %0.0f usec \r\n", (float)latency);
if ((latency = pa_simple_get_latency(s_out, &error)) == (pa_usec_t) -1) {
fprintf(stderr, __FILE__": pa_simple_get_latency() failed: %s\n", pa_strerror(error));
goto finish;
}
fprintf(stderr, "Out: %0.0f usec \r\n", (float)latency);
#endif
if (pa_simple_read(s_in, buf, sizeof(buf), &error) < 0) {
fprintf(stderr, __FILE__": read() failed: %s\n", strerror(errno));
goto finish;
}
/* ... and play it */
if (pa_simple_write(s_out, buf, sizeof(buf), &error) < 0) {
fprintf(stderr, __FILE__": pa_simple_write() failed: %s\n", pa_strerror(error));
goto finish;
}
}
/* Make sure that every single sample was played */
if (pa_simple_drain(s_out, &error) < 0) {
fprintf(stderr, __FILE__": pa_simple_drain() failed: %s\n", pa_strerror(error));
goto finish;
}
ret = 0;
finish:
if (s_in)
pa_simple_free(s_in);
if (s_out)
pa_simple_free(s_out);
return ret;
}
Successfully done. It was an error in my OS, because I haven't updated the plugins for a while. After re-installing the OS it worked.
Thanks