root/sweep/trunk/src/driver_solaris.c

Revision 681, 3.2 kB (checked in by erikd, 2 years ago)

Rename internal OSS and Solaris driver functions for consistency.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2  * Sweep, a sound wave editor.
3  *
4  * Copyright (C) 2000 Conrad Parker
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20
21 #ifdef HAVE_CONFIG_H
22 #  include <config.h>
23 #endif
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <sys/time.h>
29 #include <sys/types.h>
30 #include <sys/stat.h>
31 #include <unistd.h>
32 #include <fcntl.h>
33 #include <math.h>
34 #include <sys/ioctl.h>
35 #include <pthread.h>
36 #include <errno.h>
37
38 #include <sweep/sweep_types.h>
39 #include <sweep/sweep_sample.h>
40
41 #include "driver.h"
42 #include "question_dialogs.h"
43
44 #ifdef DRIVER_SOLARIS_AUDIO
45 #include <sys/audioio.h>
46 #include <stropts.h>
47 #include <sys/conf.h>
48 #define DEV_AUDIO "/dev/audio"
49
50 static sw_handle solaris_handle = {
51  0, -1, 0, 0, NULL
52 };
53
54 static sw_handle *
55 solaris_open (int cueing, int flags)
56 {
57   int dev_audio;
58   sw_handle * handle = &solaris_handle;
59
60   if (cueing) return NULL;
61
62   if((dev_audio = open(DEV_AUDIO, O_WRONLY, 0)) == -1) {
63     sweep_perror (errno, "Unable to open device " DEV_AUDIO);
64     return NULL;
65   }
66
67   handle->driver_flags = flags;
68   handle->driver_fd = dev_audio;
69
70   return handle;
71 }
72
73 static void
74 solaris_setup (sw_handle * handle, sw_format * format)
75 {
76   audio_info_t info;
77
78   AUDIO_INITINFO(&info);
79   info.play.precision = 16;     /* cs4231 doesn't handle 16-bit linear PCM */
80   info.play.encoding = AUDIO_ENCODING_LINEAR;
81   info.play.channels = format->channels;
82   info.play.sample_rate = format->rate;
83   if(ioctl(handle->driver_fd, AUDIO_SETINFO, &info) < 0)
84     sweep_perror(errno, "Unable to configure audio device");
85
86   handle->driver_channels = info.play.channels;
87 }
88
89 static ssize_t
90 solaris_write (sw_handle * handle, void * buf, size_t count)
91 {
92   return write (handle->driver_fd, buf, count);
93 }
94
95 static void
96 solaris_reset (sw_handle * handle)
97 {
98 }
99
100 static void
101 solaris_flush (sw_handle * handle)
102 {
103   if (ioctl(handle->driver_fd, I_FLUSH, FLUSHW) == -1)
104     perror("I_FLUSH");
105 }
106
107 static void
108 solaris_drain (sw_handle * handle)
109 {
110   if(ioctl(handle->driver_fd, AUDIO_DRAIN, 0) == -1)
111       perror("AUDIO_DRAIN");
112 }
113
114 static void
115 solaris_close (sw_handle * handle)
116 {
117   close (handle->driver_fd);
118   handle->driver_fd = -1;
119 }
120
121 static sw_driver _driver_solaris = {
122   "Solaris",
123   NULL, /* config */
124   solaris_open,
125   solaris_setup,
126   NULL,
127   solaris_write,
128   solaris_reset,
129   solaris_flush,
130   solaris_drain,
131   solaris_close,
132   "solaris_primary_device",
133   "solaris_monitor_device",
134   "solaris_log_frags"
135 };
136
137 #else
138
139 static sw_driver _driver_solaris = {
140   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
141 };
142
143 #endif
144
145 sw_driver * driver_solaris = &_driver_solaris;
Note: See TracBrowser for help on using the browser.