Posts

PulseAudio example

PulseAudio APIs pa_simple_new pa_simple_write pa_simple_drain pa_simple_free https://freedesktop.org/software/pulseaudio/doxygen/examples.html build command gcc -o pulse pulse.c `pkg-config --cflags --libs libpulse-simple` source #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 1024 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 = NULL; int ret = 1; int error; /* replace STDIN with the specified file if needed */ if (argc > 1) { int fd; if ((fd = open(argv[1], O_RDONLY)) < 0) { fprintf(stderr, __FILE__ ": open() failed: %s\n", strerror(errno)); goto finish; } if (dup2(fd, STDIN_

alsa programing example

alsa APIs snd_pcm_open snd_pcm_hw_params_set_format snd_pcm_prepare snd_pcm_writei snd_pcm_drain snd_pcm_close https://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html issues If your device can't support mixer feature, or pcm interface can't open multi times. You can try PulseAudio. pulseaudio example compile cmd gcc -o play play.c `pkg-config --cflags --libs alsa` source #include <alsa/asoundlib.h> #include <stdio.h> #define PCM_DEVICE "default" int main(int argc, char** argv) { unsigned int pcm, tmp, dir; int rate, channels, seconds; snd_pcm_t* pcm_handle; snd_pcm_hw_params_t* params; snd_pcm_uframes_t frames; char* buff; int buff_size, loops; if (argc < 4) { printf("Usage: %s <sample_rate> <channels> <seconds>\n", argv[0]); return -1; } rate = atoi(argv[1]); channels = atoi(argv[2]); seconds = atoi(argv[3]); /* Open the PCM device in playback mode */ if

fix autoconf error : possibly undefined macro: AC_SEARCH_LIBS

configure.ac:109: error: possibly undefined macro: AC_SEARCH_LIBS If this token and others are legitimate, please use m4_pattern_allow. See the Autoconf documentation. autoreconf: /usr/local/bin/autoconf failed with exit status: 1 autoreconf failed solution sudo apt install libtool notes, all below should be installed autoconf automake m4 libtool libevent perl pkg-config

How to install nvidia drivers on ubuntu

First update your new system sudo apt-get update  sudo apt-get dist-upgrade ensure what graphics driver your system needs. ubuntu-drivers devices install intel driver first sudo apt-get install intel-microcode  sudo apt-get install nvidia-xxx That's all. Note: nvidia-xxx you must enter the recommended driver version displayed in ubuntu-drivers devices and I must warn you. Updating the kernel may cause you problems, so once you installed that NVIDIA driver, please don't upgrade with this commands (sudo apt dist-upgrade or sudo apt upgrade and sudo apt-get dist-upgrade), please use sudo apt-get upgrade that command will hold new kernel releases.

Running EFL applications under Wayland based on Ubuntu 14.04 : egl wayland example

Image
For correct functionality when running under Wayland you must use the latest versions of all the EFL components under Wayland. As a precursor to these steps you must have downloaded and compiled Wayland as per the building instructions . example codes // gcc -o eglwayland eglwayland.c `pkg-config --cflags --libs wayland-egl egl glesv2` #include <stdlib.h> #include <stdint.h> #include <stdio.h> #include <string.h> #include <wayland-client.h> #include <wayland-server.h> #include <wayland-client-protocol.h> #include <wayland-egl.h> // Wayland EGL MUST be included before EGL headers #include <EGL/egl.h> #include <EGL/eglplatform.h> #include <GLES2/gl2.h> struct _escontext { /// Native System informations EGLNativeDisplayType native_display; EGLNativeWindowType native_window; uint16_t window_width, window_height; /// EGL display EGLDisplay display; /// EGL context EGLContext context; /// EGL surfac

Running EFL applications under Wayland based on Ubuntu 14.04 : elm example

Image
For correct functionality when running under Wayland you must use the latest versions of all the EFL components under Wayland. As a precursor to these steps you must have downloaded and compiled Wayland as per the building instructions . example codes #include <Elementary.h> static void on_click(void *data, Evas_Object *obj, void *event_info) { evas_object_del(data); } EAPI_MAIN int elm_main(int argc, char **argv) { Evas_Object *win, *btn; elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); win = elm_win_util_standard_add("Main", "Hello, World!"); evas_object_resize(win, 1920, 1080); elm_win_autodel_set(win, EINA_TRUE); btn = elm_button_add(win); elm_object_text_set(btn, "Goodbye Cruel World"); elm_win_resize_object_add(win, btn); evas_object_smart_callback_add(btn, "clicked", on_click, win); evas_object_show(btn); evas_object_show(win); elm_run(); return 0; } ELM_MAIN()

Running EFL applications under Wayland based on Ubuntu 14.04, compile libdrm, mesa, wayland, weston, efl from sources

For correct functionality when running under Wayland you must use the latest versions of all the EFL components under Wayland. As a precursor to these steps you must have downloaded and compiled Wayland. Setting up the environment apt install git autoconf automake libtool autopoint check Installing in a custom location, system wide install would break things. export WLD=$HOME/install # change this to another location if you prefer export LD_LIBRARY_PATH=$WLD/lib export PKG_CONFIG_PATH=$WLD/lib/pkgconfig/:$WLD/share/pkgconfig/ export PATH=$WLD/bin:$PATH export ACLOCAL_PATH=$WLD/share/aclocal export ACLOCAL="aclocal -I $ACLOCAL_PATH" mkdir -p $WLD/share/aclocal # needed by autotools Do not set LD_LIBRARY_PATH as your default, it will break things. Put the above in a script env.sh and source it in the terminal you wish to build the packages. libdrm sudo apt-get install xutils-dev libpciaccess-dev git clone https://anongit.freedesktop.org/git/mesa/drm cd drm/ sour