Skip to content

Instantly share code, notes, and snippets.

/*
* Simple sound playback using ALSA API and libasound.
*
* Compile:
* $ cc -o play sound_playback.c -lasound
*
* Usage:
* $ ./play <sample_rate> <channels> <seconds> < <file>
*
* Examples:
frame_bytes = runtime->frame_bits >> 3;
chunk_length = 4096 / frame_bytes;
pcm_buffer_size = snd_pcm_lib_buffer_bytes(substream);
period_elapsed = 0;
audio->buffer_pos += chunk_length;
if (audio->buffer_pos >= pcm_buffer_size)
static snd_pcm_uframes_t audio_pointer(struct snd_pcm_substream *substream)
{
struct audio *audio = snd_pcm_substream_chip(substream);
return bytes_to_frames(substream->runtime, audio->buffer_pos);
}
@azizulhakim
azizulhakim / comparison
Last active August 29, 2015 14:23
USB Transfer Speed Comparison
The framebuffer driver works based on page fault.
When there is a page fault, it reads the modified
page and send over USB. So I counted the number of
page fault that occurs while playing a 7 second video
file.
I found that the number of page fault in beaglebone
is way higher than my Ubuntu machine.
Here goes the comparison:

Order Raspberry Pi Open Box

Torrent ArchLinuxArm

wget http://downloads.raspberrypi.org/images/archlinuxarm/archlinuxarm-29-04-2012/archlinuxarm-29-04-2012.zip.torrent
open 
wget http://downloads.raspberrypi.org/images/archlinuxarm/archlinuxarm-29-04-2012/archlinuxarm-29-04-2012.zip

Install

@azizulhakim
azizulhakim / arch linux arm on qemu
Last active October 5, 2016 23:24
Download links and commands to test ArchLinux-ARM in QEMU
Download Image Files:
wget http://downloads.raspberrypi.org/images/archlinuxarm/archlinuxarm-29-04-2012/archlinuxarm-29-04-2012.zip
Download zImage:
https://www.dropbox.com/s/upvruf15j83t7a9/zImage?dl=0
QEMU Command to Run:
<!doctype html>
<html>
<head>
<title>Appbase.io + Socket.io</title>
<link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
<style>
#header {
#header {
background-color:black;
color:white;
text-align:center;
padding:5px;
}
#nav {
line-height:30px;
background-color:#eeeeee;
height:300px;
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io();
</script>
var Appbase = require('appbase-js');
/* appname, username and password should be changed */
var appbaseRef = new Appbase({
url: 'https://scalr.api.appbase.io',
appname: 'Your App Name',
username: 'Your App User Name',
password: 'Your App Password'
});