Fixed DevStudio 2003 build with memory check code.
[pwlib.git] / src / ptlib / unix / dummyaudio.cxx
blobc8df126c2e4f1fc20d203fafd4eae2d692d6a62f
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.5 2005/07/13 13:02:35 csoutheren
31 * Unified interface across Windows and Unix
33 * Revision 1.4 2002/02/09 00:52:01 robertj
34 * Slight adjustment to API and documentation for volume functions.
36 * Revision 1.3 2002/02/07 20:57:21 dereks
37 * add SetVolume and GetVolume methods to PSoundChannel
39 * Revision 1.2 2001/09/27 08:37:45 rogerh
40 * remove unwanted lastError
42 * Revision 1.1 2001/02/23 08:48:10 rogerh
43 * Implement a dummy PSoundChannel class. There is no functionality
44 * but it allows OpenH323 to link.
49 #pragma implementation "sound.h"
51 #include <ptlib.h>
53 PSound::PSound(unsigned channels,
54 unsigned samplesPerSecond,
55 unsigned bitsPerSample,
56 PINDEX bufferSize,
57 const BYTE * buffer)
59 encoding = 0;
60 numChannels = channels;
61 sampleRate = samplesPerSecond;
62 sampleSize = bitsPerSample;
63 SetSize(bufferSize);
64 if (buffer != NULL)
65 memcpy(GetPointer(), buffer, bufferSize);
69 PSound::PSound(const PFilePath & filename)
71 encoding = 0;
72 numChannels = 1;
73 sampleRate = 8000;
74 sampleSize = 16;
75 Load(filename);
79 PSound & PSound::operator=(const PBYTEArray & data)
81 PBYTEArray::operator=(data);
82 return *this;
86 void PSound::SetFormat(unsigned channels,
87 unsigned samplesPerSecond,
88 unsigned bitsPerSample)
90 encoding = 0;
91 numChannels = channels;
92 sampleRate = samplesPerSecond;
93 sampleSize = bitsPerSample;
94 formatInfo.SetSize(0);
98 BOOL PSound::Load(const PFilePath & /*filename*/)
100 return FALSE;
104 BOOL PSound::Save(const PFilePath & /*filename*/)
106 return FALSE;
109 BOOL PSound::Play(const PString & device)
112 PSoundChannel channel(device,
113 PSoundChannel::Player);
114 if (!channel.IsOpen())
115 return FALSE;
117 return channel.PlaySound(*this, TRUE);
120 ///////////////////////////////////////////////////////////////////////////////
122 PSoundChannel::PSoundChannel()
124 Construct();
128 PSoundChannel::PSoundChannel(const PString & device,
129 Directions dir,
130 unsigned numChannels,
131 unsigned sampleRate,
132 unsigned bitsPerSample)
134 Construct();
135 Open(device, dir, numChannels, sampleRate, bitsPerSample);
139 void PSoundChannel::Construct()
144 PSoundChannel::~PSoundChannel()
146 Close();
150 PStringArray PSoundChannel::GetDeviceNames(Directions /*dir*/)
152 PStringArray array;
154 array[0] = "/dev/audio";
155 array[1] = "/dev/dsp";
157 return array;
161 PString PSoundChannel::GetDefaultDevice(Directions /*dir*/)
163 return "/dev/audio";
167 BOOL PSoundChannel::Open(const PString & device,
168 Directions dir,
169 unsigned numChannels,
170 unsigned sampleRate,
171 unsigned bitsPerSample)
173 Close();
175 if (!ConvertOSError(os_handle = ::open(device, dir == Player ? O_RDONLY : O_WRONLY)))
176 return FALSE;
178 return SetFormat(numChannels, sampleRate, bitsPerSample);
182 BOOL PSoundChannel::Close()
184 return PChannel::Close();
188 BOOL PSoundChannel::SetFormat(unsigned numChannels,
189 unsigned sampleRate,
190 unsigned bitsPerSample)
192 Abort();
194 PAssert(numChannels >= 1 && numChannels <= 2, PInvalidParameter);
195 PAssert(bitsPerSample == 8 || bitsPerSample == 16, PInvalidParameter);
197 return TRUE;
201 BOOL PSoundChannel::SetBuffers(PINDEX size, PINDEX count)
203 Abort();
205 PAssert(size > 0 && count > 0 && count < 65536, PInvalidParameter);
207 return TRUE;
211 BOOL PSoundChannel::GetBuffers(PINDEX & size, PINDEX & count)
213 return TRUE;
217 BOOL PSoundChannel::Write(const void * buffer, PINDEX length)
219 return PChannel::Write(buffer, length);
223 BOOL PSoundChannel::PlaySound(const PSound & sound, BOOL wait)
225 Abort();
227 if (!Write((const BYTE *)sound, sound.GetSize()))
228 return FALSE;
230 if (wait)
231 return WaitForPlayCompletion();
233 return TRUE;
237 BOOL PSoundChannel::PlayFile(const PFilePath & filename, BOOL wait)
239 return TRUE;
243 BOOL PSoundChannel::HasPlayCompleted()
245 return TRUE;
249 BOOL PSoundChannel::WaitForPlayCompletion()
251 return TRUE;
255 BOOL PSoundChannel::Read(void * buffer, PINDEX length)
257 return PChannel::Read(buffer, length);
261 BOOL PSoundChannel::RecordSound(PSound & sound)
263 return TRUE;
267 BOOL PSoundChannel::RecordFile(const PFilePath & filename)
269 return TRUE;
273 BOOL PSoundChannel::StartRecording()
275 return TRUE;
279 BOOL PSoundChannel::IsRecordBufferFull()
281 return TRUE;
285 BOOL PSoundChannel::AreAllRecordBuffersFull()
287 return TRUE;
291 BOOL PSoundChannel::WaitForRecordBufferFull()
293 if (os_handle < 0) {
294 return FALSE;
297 return PXSetIOBlock(PXReadBlock, readTimeout);
301 BOOL PSoundChannel::WaitForAllRecordBuffersFull()
303 return FALSE;
307 BOOL PSoundChannel::Abort()
309 return TRUE;
312 BOOL PSoundChannel::SetVolume(unsigned newVolume)
314 return FALSE;
317 BOOL PSoundChannel::GetVolume(unsigned & volume)
319 return FALSE;
323 // End of file