etrax should not select foxboard-utils by default as the package is now in the packag...
[openwrt.git] / package / fonera-mp3 / src / lib / mp3_playtime.c
1 /*
2 * FOXMP3
3 * Copyright (c) 2006 acmesystems.it - john@acmesystems.it
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
18 *
19 * Feedback, Bugs... info@acmesystems.it
20 *
21 */
22
23
24 #include <unistd.h>
25 #include <signal.h>
26 #include <stdio.h>
27 #include "mp3.h"
28
29
30 static MP3_PLAYTIME *mp3_playtime;
31
32 void sig_alarm_handler(int sig){
33 alarm(1);
34 mp3_playtime->playtime++;
35 mp3_playtime->playtime_secs++;
36 if(mp3_playtime->playtime_secs > 59){
37 mp3_playtime->playtime_mins++;
38 mp3_playtime->playtime_secs = 0;
39 }
40 state_generic_event(MP3_EVENT_GENERIC_PLAYTIME, 0, NULL);
41 };
42
43 void mp3_playtime_init(MP3_PLAYTIME *playtime){
44 mp3_playtime = playtime;
45 signal(SIGALRM, sig_alarm_handler);
46 };
47
48 void mp3_playtime_start(void){
49 mp3_playtime->playtime = 0;
50 mp3_playtime->playtime_secs = 0;
51 mp3_playtime->playtime_mins = 0;
52 alarm(1);
53 state_generic_event(MP3_EVENT_GENERIC_PLAYTIME, 0, NULL);
54 };
55
56 void mp3_playtime_stop(void){
57 alarm(0);
58 mp3_playtime->playtime = 0;
59 mp3_playtime->playtime_secs = 0;
60 mp3_playtime->playtime_mins = 0;
61 };
This page took 0.055957 seconds and 5 git commands to generate.