Uncommented beaudio code
[pwlib.git] / src / ptlib / unix / dummyaudio.cxx
blob1df4ecb1a4259cfbf630823067104287f5e31bf5
1 /*
2 * dummyaudio.cxx
4 * Sound driver implementation.
6 * Portable Windows Library
8 * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
18 * under the License.
20 * The Original Code is Portable Windows Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
25 * All Rights Reserved.
27 * Contributor(s): ______________________________________.
29 * $Log$
30 * Revision 1.4 2002/02/09 00:52:01 robertj
31 * Slight adjustment to API and documentation for volume functions.
33 * Revision 1.3 2002/02/07 20:57:21 dereks
34 * add SetVolume and GetVolume methods to PSoundChannel
36 * Revision 1.2 2001/09/27 08:37:45 rogerh
37 * remove unwanted lastError
39 * Revision 1.1 2001/02/23 08:48:10 rogerh
40 * Implement a dummy PSoundChannel class. There is no functionality
41 * but it allows OpenH323 to link.
46 #pragma implementation "sound.h"
48 #include <ptlib.h>
50 PSound::PSound(unsigned channels,
51 unsigned samplesPerSecond,
52 unsigned bitsPerSample,
53 PINDEX bufferSize,
54 const BYTE * buffer)
56 encoding = 0;
57 numChannels = channels;
58 sampleRate = samplesPerSecond;
59 sampleSize = bitsPerSample;
60 SetSize(bufferSize);
61 if (buffer != NULL)
62 memcpy(GetPointer(), buffer, bufferSize);
66 PSound::PSound(const PFilePath & filename)
68 encoding = 0;
69 numChannels = 1;
70 sampleRate = 8000;
71 sampleSize = 16;
72 Load(filename);
76 PSound & PSound::operator=(const PBYTEArray & data)
78 PBYTEArray::operator=(data);
79 return *this;
83 void PSound::SetFormat(unsigned channels,
84 unsigned samplesPerSecond,
85 unsigned bitsPerSample)
87 encoding = 0;
88 numChannels = channels;
89 sampleRate = samplesPerSecond;
90 sampleSize = bitsPerSample;
91 formatInfo.SetSize(0);
95 BOOL PSound::Load(const PFilePath & /*filename*/)
97 return FALSE;
101 BOOL PSound::Save(const PFilePath & /*filename*/)
103 return FALSE;
107 ///////////////////////////////////////////////////////////////////////////////
109 PSoundChannel::PSoundChannel()
111 Construct();
115 PSoundChannel::PSoundChannel(const PString & device,
116 Directions dir,
117 unsigned numChannels,
118 unsigned sampleRate,
119 unsigned bitsPerSample)
121 Construct();
122 Open(device, dir, numChannels, sampleRate, bitsPerSample);
126 void PSoundChannel::Construct()
131 PSoundChannel::~PSoundChannel()
133 Close();
137 PStringArray PSoundChannel::GetDeviceNames(Directions /*dir*/)
139 PStringArray array;
141 array[0] = "/dev/audio";
142 array[1] = "/dev/dsp";
144 return array;
148 PString PSoundChannel::GetDefaultDevice(Directions /*dir*/)
150 return "/dev/audio";
154 BOOL PSoundChannel::Open(const PString & device,
155 Directions dir,
156 unsigned numChannels,
157 unsigned sampleRate,
158 unsigned bitsPerSample)
160 Close();
162 if (!ConvertOSError(os_handle = ::open(device, dir == Player ? O_RDONLY : O_WRONLY)))
163 return FALSE;
165 return SetFormat(numChannels, sampleRate, bitsPerSample);
169 BOOL PSoundChannel::Close()
171 return PChannel::Close();
175 BOOL PSoundChannel::SetFormat(unsigned numChannels,
176 unsigned sampleRate,
177 unsigned bitsPerSample)
179 Abort();
181 PAssert(numChannels >= 1 && numChannels <= 2, PInvalidParameter);
182 PAssert(bitsPerSample == 8 || bitsPerSample == 16, PInvalidParameter);
184 return TRUE;
188 BOOL PSoundChannel::SetBuffers(PINDEX size, PINDEX count)
190 Abort();
192 PAssert(size > 0 && count > 0 && count < 65536, PInvalidParameter);
194 return TRUE;
198 BOOL PSoundChannel::GetBuffers(PINDEX & size, PINDEX & count)
200 return TRUE;
204 BOOL PSoundChannel::Write(const void * buffer, PINDEX length)
206 return PChannel::Write(buffer, length);
210 BOOL PSoundChannel::PlaySound(const PSound & sound, BOOL wait)
212 Abort();
214 if (!Write((const BYTE *)sound, sound.GetSize()))
215 return FALSE;
217 if (wait)
218 return WaitForPlayCompletion();
220 return TRUE;
224 BOOL PSoundChannel::PlayFile(const PFilePath & filename, BOOL wait)
226 return TRUE;
230 BOOL PSoundChannel::HasPlayCompleted()
232 return TRUE;
236 BOOL PSoundChannel::WaitForPlayCompletion()
238 return TRUE;
242 BOOL PSoundChannel::Read(void * buffer, PINDEX length)
244 return PChannel::Read(buffer, length);
248 BOOL PSoundChannel::RecordSound(PSound & sound)
250 return TRUE;
254 BOOL PSoundChannel::RecordFile(const PFilePath & filename)
256 return TRUE;
260 BOOL PSoundChannel::StartRecording()
262 return TRUE;
266 BOOL PSoundChannel::IsRecordBufferFull()
268 return TRUE;
272 BOOL PSoundChannel::AreAllRecordBuffersFull()
274 return TRUE;
278 BOOL PSoundChannel::WaitForRecordBufferFull()
280 if (os_handle < 0) {
281 return FALSE;
284 return PXSetIOBlock(PXReadBlock, readTimeout);
288 BOOL PSoundChannel::WaitForAllRecordBuffersFull()
290 return FALSE;
294 BOOL PSoundChannel::Abort()
296 return TRUE;
299 BOOL PSoundChannel::SetVolume(unsigned newVolume)
301 return FALSE;
304 BOOL PSoundChannel::GetVolume(unsigned & volume)
306 return FALSE;
310 // End of file