2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP 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.
11 VOMP 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.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39 int AudioMVP::init(UCHAR tstreamType)
41 if (initted) return 0;
44 // if ((fdAudio = open("/dev/adec_mpg", O_RDWR | O_NONBLOCK)) < 0) return 0;
45 if ((fdAudio = open("/dev/adec_mpg", O_WRONLY)) < 0) return 0;
47 streamType = tstreamType;
57 // Set the volume variable to what the hardware is set at now
59 int hwvolFail = ioctl(fdAudio, AV_GET_AUD_VOLUME, &hwvol);
62 volume = 20 - ((hwvol >> 16) & 0xFF);
63 if ((volume < 0) || (volume > 20)) volume = 20;
69 int AudioMVP::initAllParams()
71 return (setStreamType(streamType) && setChannel() && setSource());
74 int AudioMVP::shutdown()
76 if (!initted) return 0;
84 if (!initted) return 0;
89 int AudioMVP::write(char *buf, int len)
91 return 0; //write(fdAudio, buf, len);
94 int AudioMVP::setStreamType(UCHAR type)
96 if (!initted) return 0;
98 if (ioctl(fdAudio, AV_SET_AUD_STREAMTYPE, type) != 0) return 0;
102 int AudioMVP::setChannel()
104 if (!initted) return 0;
106 if (ioctl(fdAudio, AV_SET_AUD_CHANNEL, 0) != 0) return 0;
110 int AudioMVP::setSource()
112 if (!initted) return 0;
114 if (ioctl(fdAudio, AV_SET_AUD_SRC, 1) != 0) return 0;
120 if (!initted) return 0;
122 if (ioctl(fdAudio, AV_SET_AUD_SYNC, 2) != 0) return 0;
128 if (!initted) return 0;
130 if (ioctl(fdAudio, AV_SET_AUD_PLAY, 0) != 0) return 0;
136 if (!initted) return 0;
138 if (ioctl(fdAudio, AV_SET_AUD_RESET, 0x11) != 0) return 0;
144 if (!initted) return 0;
146 if (ioctl(fdAudio, AV_SET_AUD_MUTE, 1) != 0) return 0;
147 Log::getInstance()->log("Audio", Log::DEBUG, "MUTE MUTE MUTE");
153 int AudioMVP::unMute()
155 if (!initted) return 0;
157 if (ioctl(fdAudio, AV_SET_AUD_MUTE, 0) != 0) return 0;
158 Log::getInstance()->log("Audio", Log::DEBUG, "MUTE OFF OFF OFF");
164 int AudioMVP::pause()
166 if (!initted) return 0;
168 if (ioctl(fdAudio, AV_SET_AUD_PAUSE, 1) != 0) return 0;
172 int AudioMVP::unPause()
174 if (!initted) return 0;
176 if (ioctl(fdAudio, AV_SET_AUD_UNPAUSE, 1) != 0) return 0;
180 int AudioMVP::reset()
182 if (!initted) return 0;
184 if (ioctl(fdAudio, AV_SET_AUD_RESET, 0x11) != 0) return 0;
185 if (ioctl(fdAudio, AV_SET_AUD_PLAY, 0) != 0) return 0;
191 int AudioMVP::setVolume(int tvolume)
193 // parameter: 0 for silence, 20 for full
194 if ((tvolume < 0) || (tvolume > 20)) return 0;
196 // volume = 2 * (20 - volume);
197 // Right, that one was rubbish... 0-10 were almost
198 // inaudible, 11-20 did what should have been done
199 // over the whole 0-20 range
201 tvolume = 20 - tvolume;
203 unsigned long vol = (tvolume << 24) | (tvolume << 16);
205 Log::getInstance()->log("Audio", Log::DEBUG, "%lx", vol);
206 Log::getInstance()->log("Audio", Log::DEBUG, "%i", tvolume);
208 if (ioctl(fdAudio, AV_SET_AUD_VOLUME, &vol) != 0) return 0;
216 // return ioctl(fdAudio, AV_SET_AUD_STC, &stc);
222 int b = ioctl(fdAudio, AV_SET_AUD_DISABLE_SYNC, &a);
225 printf("Audio sync disable = %i\n", b); // is in a DEV block