3 error_log( "Using Adorno backend: ". $c->daemon_type
);
4 function daemon_play_track( $path ) {
5 $fifo = fopen( "/var/run/adorno/fifo", "w" );
6 fputs( $fifo, "queue $path\n" );
12 function daemon_current_track() {
13 $result = (object) array();
15 if ( ! file_exists( "/var/run/adorno/queue.txt" ) ) return $result;
17 $fd = fopen( "/var/run/adorno/queue.txt", "r" );
19 $track = fgets( $fd, 300 );
20 $track = trim( $track, "\n" );
21 $started = fgets( $fd, 300 );
22 $started = trim( $started, "\n" );
25 $result->track
= $track;
26 $result->started
= $started;
32 function daemon_get_queue() {
33 if ( ! file_exists( "/var/run/adorno/queue.txt" ) ) return array();
34 $fd = fopen( "/var/run/adorno/queue.txt", "r" );
36 $track = fgets( $fd, 2048 ); // Skip the "now playing" - it showed at the top.
37 $track = fgets( $fd, 300 ); // Skip the start time...
40 while( !feof( $fd ) ) {
41 $tracks[] = fgets( $fd, 2048 ); // Yes: we assume all tracks are less than 2048 bytes.
48 function daemon_other_command( $action, $track ) {
49 $fifo = fopen( "/var/run/adorno/fifo", "w" );
50 if ( ! ereg( "^(/music)|(http://)", "$track" ) ) {
51 $track = "/music" . "$track";
53 # $track = eregi_replace( " ", "\\ ", $track);
54 fputs( $fifo, "$action $track\n" );