summaryrefslogtreecommitdiff
path: root/uisimulator/x11/sound.c
diff options
context:
space:
mode:
authorDan Everton <dan@iocaine.org>2006-08-12 10:28:30 +0000
committerDan Everton <dan@iocaine.org>2006-08-12 10:28:30 +0000
commit9d2929b79b22765701e9db240d967877d7f7bab8 (patch)
tree0829913b3e58ce5d1886358395d42c5cee80ce6c /uisimulator/x11/sound.c
parent509ee3d42cfe0660a107ae169a11cef9c0604b1f (diff)
downloadrockbox-9d2929b79b22765701e9db240d967877d7f7bab8.tar.gz
rockbox-9d2929b79b22765701e9db240d967877d7f7bab8.zip
Remove Win32 and X11 simulator sources. They've been deprecated for a while in favour of the SDL sim. Time to go.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10543 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/x11/sound.c')
-rw-r--r--uisimulator/x11/sound.c140
1 files changed, 0 insertions, 140 deletions
diff --git a/uisimulator/x11/sound.c b/uisimulator/x11/sound.c
deleted file mode 100644
index 06d9c014ff..0000000000
--- a/uisimulator/x11/sound.c
+++ /dev/null
@@ -1,140 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Daniel Stenberg <daniel@haxx.se>
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "autoconf.h"
21
22#ifdef ROCKBOX_HAS_SIMSOUND /* play sound in sim enabled */
23
24#include <stdbool.h>
25#include <stdio.h>
26#include <stdlib.h>
27#include <unistd.h>
28#include <sys/stat.h>
29#include <fcntl.h>
30#include <sys/ioctl.h>
31#include <sys/soundcard.h>
32
33#include "sound.h"
34
35static bool playing = false;
36
37int sim_sound_init(void)
38{
39 int fd;
40 int pcmbits;
41 int rc;
42 int channels;
43 int rate;
44
45 fd = open("/dev/dsp", O_WRONLY);
46 if(-1 == fd)
47 return 1;
48
49 pcmbits = 16;
50 rc = ioctl(fd, SOUND_PCM_WRITE_BITS, &pcmbits);
51 rc = ioctl(fd, SOUND_PCM_READ_BITS, &pcmbits);
52
53 channels = 2; /* Number of channels, 1=mono */
54 rc = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &channels);
55 rc = ioctl(fd, SOUND_PCM_READ_CHANNELS, &channels);
56
57 rate = 44100; /* Yeah. sampling rate */
58 rc = ioctl(fd, SOUND_PCM_WRITE_RATE, &rate);
59 rc = ioctl(fd, SOUND_PCM_READ_RATE, &rate);
60
61 return fd;
62}
63
64void sim_sound_play(int soundfd, char *buffer, long len)
65{
66 write(soundfd, buffer, len);
67}
68
69void sound_playback_thread(void)
70{
71 int soundfd = sim_sound_init();
72 unsigned char *buf;
73 long size;
74
75 while(-1 == soundfd)
76 sleep(100000); /* wait forever, can't play sound! */
77
78 do {
79
80 while(!sound_get_pcm)
81 /* TODO: fix a fine thread-synch mechanism here */
82 usleep(10000);
83
84 do {
85 sound_get_pcm(&buf, &size);
86 if(!size) {
87 sound_get_pcm = NULL;
88 break;
89 }
90 sim_sound_play(soundfd, (char *)buf, size);
91 usleep(10000);
92 } while(size);
93
94 } while(1);
95
96}
97
98/* Stubs for PCM audio playback. */
99bool pcm_is_playing(void)
100{
101 return playing;
102}
103
104void pcm_mute(bool state)
105{
106 (void)state;
107}
108
109void pcm_play_pause(bool state)
110{
111 (void)state;
112}
113
114bool pcm_is_paused(void)
115{
116 return false;
117}
118
119void pcm_play_stop(void)
120{
121 playing = false;
122}
123
124void pcm_init(void)
125{
126}
127
128void (*sound_get_pcm)(unsigned char** start, long* size);
129void pcm_play_data(void (*get_more)(unsigned char** start, long* size))
130{
131 sound_get_pcm = get_more;
132 playing = true;
133}
134
135long pcm_get_bytes_waiting(void)
136{
137 return 0;
138}
139
140#endif /* ROCKBOX_HAS_SIMSOUND */