~ubuntu-branches/ubuntu/karmic/openoffice.org-l10n/karmic

« back to all changes in this revision

Viewing changes to ooo-build/patches/src680/cws-unifysound01-vcl-m4.diff

  • Committer: Bazaar Package Importer
  • Author(s): Chris Cheney, Chris Cheney, Matthias Klose
  • Date: 2008-04-01 23:01:30 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20080401230130-kiv3et1lcgwqr3ix
Tags: 1:2.4.0-3ubuntu1
* Copy of the openoffice.org source.
  - debian/changelog: Change source name.
  - debian/control.in: Change source name.
  - debian/control: Regenerate control file.
  - Note this version does not include the launchpad rosetta translations
    due to bugs in rosetta causing very long export time.

[ Chris Cheney ]
* Resynchronise with Debian (r1044). Remaining changes:
  - debian/broffice.org.postrm.in:
    . Change diversions to ubuntu bitmap filenames.
  - debian/broffice.org.preinst.in:
    . Change diversions to ubuntu bitmap filenames.
  - debian/control.in:
    . Change maintainer line.
    . Use imagemagick instead of graphicsmagick.
    . Change bzr repo location.
    . Add package openoffice.org-style-human.
    . Add replaces openoffice.org-gtk (<< 2.0.3-1) for openoffice.org-gnome
      dapper upgrade.
  - debian/control.l10n.in:
    . Add file for Ubuntu.
  - debian/control.lang.in:
    . Add L10N_COMMON to Depends.
  - debian/control.mozilla.in:
    . Add Xb-Npp-xxx tags according to "firefox distro add-on suport" spec.
  - debian/control.ubuntu-feisty.in:
    . Add file for Ubuntu.
  - debian/deppackage.postinst.in:
    . Add file for Ubuntu.
  - debian/module-po.map:
    . Add file for Ubuntu.
  - debian/ooo-build-ubuntu.diff:
    . Various Ubuntu specific changes to ooo-build.
  - debian/openoffice.org-base.mime:
    . Update and sort mime-types.
  - debian/openoffice.org-calc.mime:
    . Update and sort mime-types.
  - debian/openoffice.org-draw.mime:
    . Update and sort mime-types.
  - debian/openoffice.org-filter-binfilter.mime:
    . Update and sort mime-types.
  - debian/openoffice.org-impress.mime:
    . Update and sort mime-types.
  - debian/openoffice.org-math.mime:
    . Update and sort mime-types.
  - debian/openoffice.org-writer.mime:
    . Update and sort mime-types.
  - debian/rules:
    . Add BUILD_SPARC option.
    . Add USE_COMMON_DOCDIR option.
    . Add USE_LZMA_COMPRESS option.
    . Add support to build on lpia.
    . Add support to build l10n as a separate source.
    . Add support to chmod +x programs in debian dir.
    . Add support to uuencode binary files in ubuntu dir.
    . Add support for Ubuntu specific bitmaps.
    . Add support for openoffice.org-style-human package.
    . Add support for launchpad translations.
    . Update location of aotcompile.py file.
    . Use imagemagick instead of graphicsmagick.
    . Use openjdk-6-jre instead of icedtea-java7-jre. Closes LP: #203636
    . Various Ubuntu specific changes.
  - debian/scripts/convert2po:
    . Add file for Ubuntu.
  - debian/scripts/fix_image_rgb:
    . Use imagemagick instead of graphicsmagick.
  - debian/scripts/gsifilter.py:
    . Add file for Ubuntu.
  - debian/scripts/splitgsi:
    . Add file for Ubuntu.
  - debian/template.desktop.in:
    . Add NoDisplay=true.
* Resynchronise with ooo-build (r12081).
  - Closes LP: #54776, #62256, #105906, #113358, #131272, #137469, #138252
    Closes LP: #148552, #154940, #160988, #175983, #194759, #197451, #197622
* ubuntu/*:
  - Update splash screen for OOo 2.4. Closes LP: #199193
  - Various Ubuntu specific changes.

[ Matthias Klose ]
* ubuntu/lpi2gsi: Add templates and conversion scripts to generate
  the additional help menu entries.
* Update translations for the OOo help menu, taken from a fresh
  launchpad-integration translations export.
* ooo-build/patches/src680/ubuntu-lpi.diff: Update Launchpad URLs
  (remove /distros), use answers.launchpad.net and translations.launchpad.net
  for +gethelp and +translate respectively
* debian/ooo-build-ubuntu.diff: Remove.
* ubuntu/desktop-templates.diff: Updated, merged from the ooo-build trunk.
* ubuntu/desktop-translations.diff: Updated from a fresh ooo-build
  translations export.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Index: vcl/aqua/inc/salinst.h
2
 
===================================================================
3
 
RCS file: /cvs/gsl/vcl/aqua/inc/salinst.h,v
4
 
retrieving revision 1.13
5
 
retrieving revision 1.12.56.2
6
 
diff -u -p -u -p -r1.13 -r1.12.56.2
7
 
--- vcl/aqua/inc/salinst.h      9 Oct 2007 15:09:54 -0000       1.13
8
 
+++ vcl/aqua/inc/salinst.h      16 Oct 2007 08:32:39 -0000      1.12.56.2
9
 
@@ -126,7 +126,6 @@ public:
10
 
     virtual void                       GetPrinterQueueState( SalPrinterQueueInfo* pInfo );
11
 
     virtual void                       DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo );
12
 
     virtual String             GetDefaultPrinter();
13
 
-    virtual SalSound*                  CreateSalSound();
14
 
     virtual SalTimer*                  CreateSalTimer();
15
 
     virtual SalOpenGL*                 CreateSalOpenGL( SalGraphics* pGraphics );
16
 
     virtual SalI18NImeStatus*  CreateI18NImeStatus();
17
 
#Index: vcl/aqua/inc/salsound.h
18
 
#===================================================================
19
 
#RCS file: vcl/aqua/inc/salsound.h
20
 
#diff -N vcl/aqua/inc/salsound.h
21
 
#--- vcl/aqua/inc/salsound.h    5 Jul 2007 15:57:25 -0000       1.3
22
 
#+++ /dev/null  1 Jan 1970 00:00:00 -0000
23
 
#@@ -1,109 +0,0 @@
24
 
#-/*************************************************************************
25
 
#-*
26
 
#-*  OpenOffice.org - a multi-platform office productivity suite
27
 
#-*
28
 
#-*  $RCSfile: salsound.h,v $
29
 
#-*
30
 
#-*  $Revision: 1.4 $
31
 
#-*
32
 
#-*  last change: $Author: kz $ $Date: 2007/10/09 15:11:21 $
33
 
#-*
34
 
#-*  The Contents of this file are made available subject to
35
 
#-*  the terms of GNU Lesser General Public License Version 2.1.
36
 
#-*
37
 
#-*
38
 
#-*    GNU Lesser General Public License Version 2.1
39
 
#-*    =============================================
40
 
#-*    Copyright 2005 by Sun Microsystems, Inc.
41
 
#-*    901 San Antonio Road, Palo Alto, CA 94303, USA
42
 
#-*
43
 
#-*    This library is free software; you can redistribute it and/or
44
 
#-*    modify it under the terms of the GNU Lesser General Public
45
 
#-*    License version 2.1, as published by the Free Software Foundation.
46
 
#-*
47
 
#-*    This library is distributed in the hope that it will be useful,
48
 
#-*    but WITHOUT ANY WARRANTY; without even the implied warranty of
49
 
#-*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
50
 
#-*    Lesser General Public License for more details.
51
 
#-*
52
 
#-*    You should have received a copy of the GNU Lesser General Public
53
 
#-*    License along with this library; if not, write to the Free Software
54
 
#-*    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
55
 
#-*    MA  02111-1307  USA
56
 
#-*
57
 
#-************************************************************************/
58
 
#-
59
 
#-#ifndef _SV_SALSOUND_H
60
 
#-#define _SV_SALSOUND_H
61
 
#-
62
 
#-//#ifndef _SV_WINCOMP_HXX
63
 
#-//#include <wincomp.hxx>
64
 
#-//#endif
65
 
#-
66
 
#-#ifndef _GEN_HXX
67
 
#-#include <tools/gen.hxx>
68
 
#-#endif
69
 
#-#ifndef _STRING_HXX
70
 
#-#include <tools/string.hxx>
71
 
#-#endif
72
 
#-
73
 
#-#ifndef _SV_SV_H
74
 
#-#include <vcl/sv.h>
75
 
#-#endif
76
 
#-
77
 
#-#include <osl/module.h>
78
 
#-
79
 
#-#ifndef _SV_SALFRAME_HXX
80
 
#-#include <vcl/salframe.hxx>
81
 
#-#endif
82
 
#-#ifndef _SV_SALSTYPE_HXX
83
 
#-#include <vcl/salstype.hxx>
84
 
#-#endif
85
 
#-#ifndef _SV_SALSOUND_HXX
86
 
#-#include <vcl/salsound.hxx>
87
 
#-#endif
88
 
#-
89
 
#-// ------------
90
 
#-// - SalSound -
91
 
#-// ------------
92
 
#-
93
 
#-class AquaSalSound : public SalSound
94
 
#-{
95
 
#-private:
96
 
#-//    static oslModule        mhMCILib;
97
 
#-      static ULONG            mnSoundState;
98
 
#-      SALSOUNDPROC            mpProc;
99
 
#-//    static void*            mpMCIFnc;
100
 
#-//    ULONG                           mnStartTime;
101
 
#-//    ULONG                           mnPlayLen;
102
 
#-//    HWND                            mhSoundWnd;
103
 
#-//    UINT                            mnDeviceId;
104
 
#-      bool                            mbLoop;
105
 
#-      bool                            mbPaused;
106
 
#-    
107
 
#-public:
108
 
#-    void                              ImplSetError( int nMciErr );
109
 
#-      void                            ImplNotify( SoundNotification eNotification, ULONG nError );
110
 
#-    
111
 
#-public:
112
 
#-        AquaSalSound();
113
 
#-    virtual ~AquaSalSound();
114
 
#-    
115
 
#-    virtual bool              IsValid();
116
 
#-    virtual bool              Init( const String&     rSoundName,
117
 
#-                              ULONG&          rSoundLen );
118
 
#-      virtual void            Play( ULONG nStartTime, ULONG nPlayTime, bool bLoop );
119
 
#-      virtual void            Stop();
120
 
#-      virtual void            Pause();
121
 
#-      virtual void            Continue();
122
 
#-    virtual bool              IsLoopMode() const;
123
 
#-      virtual bool            IsPlaying() const;
124
 
#-    virtual bool              IsPaused() const;
125
 
#-    
126
 
#-    
127
 
#-      bool                            ImplCreate();
128
 
#-      void                            ImplDestroy();
129
 
#-      static void             Release();
130
 
#-};
131
 
#-
132
 
#-#endif // _SV_SALSOUND_H
133
 
#Index: vcl/aqua/inc/salsound.hxx
134
 
#===================================================================
135
 
#RCS file: vcl/aqua/inc/salsound.hxx
136
 
#diff -N vcl/aqua/inc/salsound.hxx
137
 
#--- vcl/aqua/inc/salsound.hxx  27 Jun 2007 19:50:41 -0000      1.6
138
 
#+++ /dev/null  1 Jan 1970 00:00:00 -0000
139
 
#@@ -1,88 +0,0 @@
140
 
#-/*************************************************************************
141
 
#- *
142
 
#- *  OpenOffice.org - a multi-platform office productivity suite
143
 
#- *
144
 
#- *  $RCSfile: salsound.hxx,v $
145
 
#- *
146
 
#- *  $Revision: 1.7 $
147
 
#- *
148
 
#- *  last change: $Author: kz $ $Date: 2007/10/09 15:11:34 $
149
 
#- *
150
 
#- *  The Contents of this file are made available subject to
151
 
#- *  the terms of GNU Lesser General Public License Version 2.1.
152
 
#- *
153
 
#- *
154
 
#- *    GNU Lesser General Public License Version 2.1
155
 
#- *    =============================================
156
 
#- *    Copyright 2005 by Sun Microsystems, Inc.
157
 
#- *    901 San Antonio Road, Palo Alto, CA 94303, USA
158
 
#- *
159
 
#- *    This library is free software; you can redistribute it and/or
160
 
#- *    modify it under the terms of the GNU Lesser General Public
161
 
#- *    License version 2.1, as published by the Free Software Foundation.
162
 
#- *
163
 
#- *    This library is distributed in the hope that it will be useful,
164
 
#- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
165
 
#- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
166
 
#- *    Lesser General Public License for more details.
167
 
#- *
168
 
#- *    You should have received a copy of the GNU Lesser General Public
169
 
#- *    License along with this library; if not, write to the Free Software
170
 
#- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
171
 
#- *    MA  02111-1307  USA
172
 
#- *
173
 
#- ************************************************************************/
174
 
#-
175
 
#-#ifndef _SV_SALSOUND_HXX
176
 
#-#define _SV_SALSOUND_HXX
177
 
#-
178
 
#-#ifndef _GEN_HXX
179
 
#-#include <tools/gen.hxx>
180
 
#-#endif
181
 
#-#ifndef _STRING_HXX
182
 
#-#include <tools/string.hxx>
183
 
#-#endif
184
 
#-
185
 
#-#ifndef _SV_SV_H
186
 
#-#include <vcl/sv.h>
187
 
#-#endif
188
 
#-
189
 
#-#ifndef _SV_SALFRAME_HXX
190
 
#-#include <vcl/salframe.hxx>
191
 
#-#endif
192
 
#-#ifndef _SV_SALSTYPE_HXX
193
 
#-#include <vcl/salstype.hxx>
194
 
#-#endif
195
 
#-
196
 
#-// ------------
197
 
#-// - SalSound -
198
 
#-// ------------
199
 
#-
200
 
#-class SalSound
201
 
#-{
202
 
#-private:
203
 
#-      static ULONG            mnSoundState;
204
 
#-      SALSOUNDPROC            mpProc;
205
 
#-      void*                           mpInst;
206
 
#-      BOOL                            mbLoop;
207
 
#-      BOOL                            mbPaused;
208
 
#-
209
 
#-public:
210
 
#-                                              SalSound();
211
 
#-                                              ~SalSound();
212
 
#-
213
 
#-      BOOL                            Create();
214
 
#-      static void             Release();
215
 
#-      static BOOL             IsValid() { return( SOUND_STATE_VALID == SalSound::mnSoundState ); }
216
 
#-
217
 
#-      BOOL                            Init( SalFrame* pFrame, const String& rSoundName, ULONG& rSoundLen );
218
 
#-      BOOL                            Init( SalFrame* pFrame, const BYTE* pSound, ULONG nDataLen, ULONG& rSoundLen );
219
 
#-      void                            Play( ULONG nStartTime, ULONG nPlayTime, BOOL bLoop );
220
 
#-      void                            Stop();
221
 
#-      void                            Pause();
222
 
#-
223
 
#-      void                            SetNotifyProc( void* pInst, SALSOUNDPROC pProc )
224
 
#-                                                      { mpInst = pInst; mpProc = pProc; }
225
 
#-};
226
 
#-
227
 
#-#endif // _SV_SALSOUND_HXX
228
 
Index: vcl/aqua/source/app/makefile.mk
229
 
===================================================================
230
 
RCS file: /cvs/gsl/vcl/aqua/source/app/makefile.mk,v
231
 
retrieving revision 1.14
232
 
retrieving revision 1.14.56.1
233
 
diff -u -p -u -p -r1.14 -r1.14.56.1
234
 
--- vcl/aqua/source/app/makefile.mk     5 Jul 2007 08:18:05 -0000       1.14
235
 
+++ vcl/aqua/source/app/makefile.mk     31 Aug 2007 09:44:56 -0000      1.14.56.1
236
 
Index: vcl/aqua/source/app/salinst.cxx
237
 
===================================================================
238
 
RCS file: /cvs/gsl/vcl/aqua/source/app/salinst.cxx,v
239
 
retrieving revision 1.40
240
 
retrieving revision 1.38.10.3
241
 
@@ -61,7 +61,6 @@
242
 
             $(SLO)$/vclnsapp.obj        \
243
 
                        $(SLO)$/saltimer.obj            \
244
 
                        $(SLO)$/salnstimer.obj          \
245
 
-                       $(SLO)$/salsound.obj            \
246
 
                        $(SLO)$/salsys.obj
247
 
 
248
 
 .ENDIF         # "$(GUIBASE)"!="aqua"
249
 
diff -u -p -u -p -r1.40 -r1.38.10.3
250
 
--- vcl/aqua/source/app/salinst.cxx     9 Oct 2007 15:12:57 -0000       1.40
251
 
+++ vcl/aqua/source/app/salinst.cxx     16 Oct 2007 08:32:33 -0000      1.38.10.3
252
 
@@ -938,13 +938,6 @@ void* AquaSalInstance::GetConnectionIden
253
 
 
254
 
 // -----------------------------------------------------------------------
255
 
 
256
 
-SalSound* AquaSalInstance::CreateSalSound()
257
 
-{
258
 
-    return new AquaSalSound();
259
 
-}
260
 
-
261
 
-// -----------------------------------------------------------------------
262
 
-
263
 
 SalTimer* AquaSalInstance::CreateSalTimer()
264
 
 {
265
 
     return new AquaSalTimer();
266
 
Index: vcl/inc/vcl/salinst.hxx
267
 
===================================================================
268
 
RCS file: /cvs/gsl/vcl/inc/vcl/salinst.hxx,v
269
 
retrieving revision 1.2
270
 
retrieving revision 1.2.136.1
271
 
diff -u -p -u -p -r1.2 -r1.2.136.1
272
 
--- vcl/inc/vcl/salinst.hxx     11 Apr 2007 18:07:19 -0000      1.2
273
 
+++ vcl/inc/vcl/salinst.hxx     31 Aug 2007 09:44:56 -0000      1.2.136.1
274
 
@@ -60,7 +60,6 @@ struct ImplJobSetup;
275
 
 class SalGraphics;
276
 
 class SalFrame;
277
 
 class SalObject;
278
 
-class SalSound;
279
 
 class SalOpenGL;
280
 
 class SalMenu;
281
 
 class SalMenuItem;
282
 
@@ -136,8 +135,6 @@ public:
283
 
     virtual void                               DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ) = 0;
284
 
     virtual String             GetDefaultPrinter() = 0;
285
 
 
286
 
-    // SalSound
287
 
-    virtual SalSound*                  CreateSalSound() = 0;
288
 
     // SalTimer
289
 
     virtual SalTimer*                  CreateSalTimer() = 0;
290
 
     // SalOpenGL
291
 
Index: vcl/inc/vcl/salsound.hxx
292
 
===================================================================
293
 
RCS file: vcl/inc/vcl/salsound.hxx
294
 
diff -N vcl/inc/vcl/salsound.hxx
295
 
--- vcl/inc/vcl/salsound.hxx    11 Apr 2007 18:08:49 -0000      1.2
296
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
297
 
@@ -1,97 +0,0 @@
298
 
-/*************************************************************************
299
 
- *
300
 
- *  OpenOffice.org - a multi-platform office productivity suite
301
 
- *
302
 
- *  $RCSfile: salsound.hxx,v $
303
 
- *
304
 
- *  $Revision: 1.2 $
305
 
- *
306
 
- *  last change: $Author: vg $ $Date: 2007/04/11 18:08:49 $
307
 
- *
308
 
- *  The Contents of this file are made available subject to
309
 
- *  the terms of GNU Lesser General Public License Version 2.1.
310
 
- *
311
 
- *
312
 
- *    GNU Lesser General Public License Version 2.1
313
 
- *    =============================================
314
 
- *    Copyright 2005 by Sun Microsystems, Inc.
315
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
316
 
- *
317
 
- *    This library is free software; you can redistribute it and/or
318
 
- *    modify it under the terms of the GNU Lesser General Public
319
 
- *    License version 2.1, as published by the Free Software Foundation.
320
 
- *
321
 
- *    This library is distributed in the hope that it will be useful,
322
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
323
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
324
 
- *    Lesser General Public License for more details.
325
 
- *
326
 
- *    You should have received a copy of the GNU Lesser General Public
327
 
- *    License along with this library; if not, write to the Free Software
328
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
329
 
- *    MA  02111-1307  USA
330
 
- *
331
 
- ************************************************************************/
332
 
-
333
 
-#ifndef _SV_SALSOUND_HXX
334
 
-#define _SV_SALSOUND_HXX
335
 
-
336
 
-#ifndef _GEN_HXX
337
 
-#include <tools/gen.hxx>
338
 
-#endif
339
 
-#ifndef _SV_SV_H
340
 
-#include <vcl/sv.h>
341
 
-#endif
342
 
-#ifndef _VCL_DLLAPI_H
343
 
-#include <vcl/dllapi.h>
344
 
-#endif
345
 
-
346
 
-#ifndef _STRING_HXX
347
 
-#include <tools/string.hxx>
348
 
-#endif
349
 
-#ifndef _SV_SALSTYPE_HXX
350
 
-#include <vcl/salstype.hxx>
351
 
-#endif
352
 
-
353
 
-class VCL_DLLPUBLIC SalSound
354
 
-{
355
 
-       // for notification
356
 
-       void*                                   m_pInst;
357
 
-       SALSOUNDPROC                    m_aPROC;
358
 
-public:
359
 
-    SalSound() : m_pInst( NULL ), m_aPROC( NULL ) {}
360
 
-    virtual ~SalSound();
361
 
-
362
 
-    // checks whether sound system is ready for input and hence
363
 
-    // SalSound can be initialized
364
 
-    virtual bool               IsValid() = 0;
365
 
-    // initialize with sound file name, returns success and // FIXME: rSoundLen ?
366
 
-    virtual bool               Init( const String&     rSoundName,
367
 
-                              ULONG&           rSoundLen ) = 0;
368
 
-    // play the sound, start at nStartTime (ms), play for nPlayTime (ms),
369
 
-       // loop = true/false
370
 
-       virtual void            Play( ULONG nStartTime, ULONG nPlayTime, bool bLoop ) = 0;
371
 
-    // stop playing
372
 
-       virtual void            Stop() = 0;
373
 
-    // pause playing
374
 
-       virtual void            Pause() = 0;
375
 
-    // continue a paused play
376
 
-       virtual void            Continue() = 0;
377
 
-    // is looping ?
378
 
-    virtual bool               IsLoopMode() const = 0;
379
 
-    // is playing ?
380
 
-       virtual bool            IsPlaying() const = 0;
381
 
-    // is paused ?
382
 
-    virtual bool               IsPaused() const = 0;
383
 
-
384
 
-    // register a callback to be called when state changes
385
 
-       void            SetNotifyProc( void* pInst, SALSOUNDPROC pProc )
386
 
-    { m_pInst = pInst; m_aPROC = pProc; }
387
 
-    void               CallNotifyProc( SoundNotification eNotification, ULONG nError )
388
 
-    {
389
 
-        if( m_aPROC )
390
 
-            m_aPROC( m_pInst, eNotification, nError );
391
 
-    }
392
 
-};
393
 
-
394
 
-#endif
395
 
Index: vcl/inc/vcl/salstype.hxx
396
 
===================================================================
397
 
RCS file: vcl/inc/vcl/salstype.hxx
398
 
diff -N vcl/inc/vcl/salstype.hxx
399
 
--- vcl/inc/vcl/salstype.hxx    11 Apr 2007 18:08:58 -0000      1.2
400
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
401
 
@@ -1,92 +0,0 @@
402
 
-/*************************************************************************
403
 
- *
404
 
- *  OpenOffice.org - a multi-platform office productivity suite
405
 
- *
406
 
- *  $RCSfile: salstype.hxx,v $
407
 
- *
408
 
- *  $Revision: 1.2 $
409
 
- *
410
 
- *  last change: $Author: vg $ $Date: 2007/04/11 18:08:58 $
411
 
- *
412
 
- *  The Contents of this file are made available subject to
413
 
- *  the terms of GNU Lesser General Public License Version 2.1.
414
 
- *
415
 
- *
416
 
- *    GNU Lesser General Public License Version 2.1
417
 
- *    =============================================
418
 
- *    Copyright 2005 by Sun Microsystems, Inc.
419
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
420
 
- *
421
 
- *    This library is free software; you can redistribute it and/or
422
 
- *    modify it under the terms of the GNU Lesser General Public
423
 
- *    License version 2.1, as published by the Free Software Foundation.
424
 
- *
425
 
- *    This library is distributed in the hope that it will be useful,
426
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
427
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
428
 
- *    Lesser General Public License for more details.
429
 
- *
430
 
- *    You should have received a copy of the GNU Lesser General Public
431
 
- *    License along with this library; if not, write to the Free Software
432
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
433
 
- *    MA  02111-1307  USA
434
 
- *
435
 
- ************************************************************************/
436
 
-
437
 
-#ifndef _SV_SALSTYPE_HXX
438
 
-#define _SV_SALSTYPE_HXX
439
 
-
440
 
-#ifndef _GEN_HXX
441
 
-#include <tools/gen.hxx>
442
 
-#endif
443
 
-
444
 
-// -----------------
445
 
-// - Sound defines -
446
 
-// -----------------
447
 
-
448
 
-#define SOUND_PLAYALL                  (0xFFFFFFFFUL)
449
 
-
450
 
-// -----------------
451
 
-// - State defines -
452
 
-// -----------------
453
 
-
454
 
-#define SOUND_STATE_UNLOADED   (0x00000000UL)
455
 
-#define SOUND_STATE_INVALID            (0x00000001UL)
456
 
-#define        SOUND_STATE_VALID               (0x00000002UL)
457
 
-
458
 
-// ---------------------
459
 
-// - SoundNotification -
460
 
-// ---------------------
461
 
-
462
 
-enum SoundNotification 
463
 
-{
464
 
-       SOUND_NOTIFY_NOTHING, 
465
 
-       SOUND_NOTIFY_SUCCESS,
466
 
-       SOUND_NOTIFY_ABORTED,
467
 
-       SOUND_NOTIFY_ERROR 
468
 
-};
469
 
-
470
 
-// ---------------
471
 
-// - SoundErrors -
472
 
-// ---------------
473
 
-
474
 
-#define SOUNDERR_SUCCESS                (0x00000000UL)
475
 
-#define SOUNDERR_GENERAL_ERROR          (0x00000001UL)
476
 
-#define SOUNDERR_CANNOT_LOAD_DRIVER     (0x00000003UL)
477
 
-#define SOUNDERR_DEVICE_LOCKED          (0x00000004UL)
478
 
-#define SOUNDERR_SOUND_NOT_FOUND        (0x00000005UL)
479
 
-#define SOUNDERR_HARDWARE_ERROR         (0x00000006UL)
480
 
-#define SOUNDERR_OUT_OF_MEMORY          (0x00000007UL)
481
 
-#define SOUNDERR_UNSUPPORTED_FUNCTION   (0x00000008UL)
482
 
-#define SOUNDERR_DEVICE_NOT_FOUND       (0x00000009UL)
483
 
-#define SOUNDERR_DEVICE_NOT_READY       (0x0000000aUL)
484
 
-#define SOUNDERR_CANNOT_READ_SOUND      (0x0000000bUL)
485
 
-#define SOUNDERR_INVALID_FILE           (0x0000000cUL)
486
 
-
487
 
-// ------------------
488
 
-// - Sound-Callback    -
489
 
-// ------------------
490
 
-
491
 
-typedef void (*SALSOUNDPROC)( void* pInst, SoundNotification eNotification, ULONG nError );
492
 
-
493
 
-#endif // _SV_SALSTYPE_HXX
494
 
Index: vcl/inc/vcl/settings.hxx
495
 
===================================================================
496
 
RCS file: /cvs/gsl/vcl/inc/vcl/settings.hxx,v
497
 
retrieving revision 1.3
498
 
retrieving revision 1.3.86.1
499
 
diff -u -p -u -p -r1.3 -r1.3.86.1
500
 
--- vcl/inc/vcl/settings.hxx    4 Jun 2007 14:57:34 -0000       1.3
501
 
+++ vcl/inc/vcl/settings.hxx    31 Aug 2007 09:44:56 -0000      1.3.86.1
502
 
@@ -1019,55 +1019,6 @@ public:
503
 
                                         { return !(*this == rSet); }
504
 
 };
505
 
 
506
 
-// -----------------
507
 
-// - ImplSoundData -
508
 
-// -----------------
509
 
-
510
 
-class ImplSoundData
511
 
-{
512
 
-    friend class SoundSettings;
513
 
-
514
 
-                                    ImplSoundData();
515
 
-                                    ImplSoundData( const ImplSoundData& rData );
516
 
-
517
 
-private:
518
 
-    ULONG                           mnRefCount;
519
 
-    ULONG                           mnOptions;
520
 
-};
521
 
-
522
 
-// -----------------
523
 
-// - SoundSettings -
524
 
-// -----------------
525
 
-
526
 
-#define SOUND_OPTION_ON             ((ULONG)0x00000001)
527
 
-#define SOUND_OPTION_NOTIFYBEEP     ((ULONG)0x00000002)
528
 
-#define SOUND_OPTION_WARNINGBEEP    ((ULONG)0x00000004)
529
 
-#define SOUND_OPTION_ERRORBEEP      ((ULONG)0x00000008)
530
 
-
531
 
-class VCL_DLLPUBLIC SoundSettings
532
 
-{
533
 
-    void                            CopyData();
534
 
-
535
 
-private:
536
 
-    ImplSoundData*                  mpData;
537
 
-
538
 
-public:
539
 
-                                    SoundSettings();
540
 
-                                    SoundSettings( const SoundSettings& rSet );
541
 
-                                    ~SoundSettings();
542
 
-
543
 
-    void                            SetOptions( ULONG nOptions )
544
 
-                                        { CopyData(); mpData->mnOptions = nOptions; }
545
 
-    ULONG                           GetOptions() const
546
 
-                                        { return mpData->mnOptions; }
547
 
-
548
 
-    const SoundSettings&            operator =( const SoundSettings& rSet );
549
 
-
550
 
-    BOOL                            operator ==( const SoundSettings& rSet ) const;
551
 
-    BOOL                            operator !=( const SoundSettings& rSet ) const
552
 
-                                        { return !(*this == rSet); }
553
 
-};
554
 
-
555
 
 // ------------------------
556
 
 // - ImplNotificationData -
557
 
 // ------------------------
558
 
@@ -1193,7 +1144,6 @@ private:
559
 
     KeyboardSettings                        maKeyboardSettings;
560
 
     StyleSettings                           maStyleSettings;
561
 
     MiscSettings                            maMiscSettings;
562
 
-    SoundSettings                           maSoundSettings;
563
 
     NotificationSettings                    maNotificationSettings;
564
 
     HelpSettings                            maHelpSettings;
565
 
     ::com::sun::star::lang::Locale          maLocale;
566
 
@@ -1272,11 +1222,6 @@ public:
567
 
     const MiscSettings&                     GetMiscSettings() const
568
 
                                                 { return mpData->maMiscSettings; }
569
 
 
570
 
-    void                                    SetSoundSettings( const SoundSettings& rSet )
571
 
-                                                { CopyData(); mpData->maSoundSettings = rSet; }
572
 
-    const SoundSettings&                    GetSoundSettings() const
573
 
-                                                { return mpData->maSoundSettings; }
574
 
-
575
 
     void                                    SetNotificationSettings( const NotificationSettings& rSet )
576
 
                                                 { CopyData(); mpData->maNotificationSettings = rSet; }
577
 
     const NotificationSettings&             GetNotificationSettings() const
578
 
Index: vcl/inc/vcl/sound.hxx
579
 
===================================================================
580
 
RCS file: /cvs/gsl/vcl/inc/vcl/sound.hxx,v
581
 
retrieving revision 1.2
582
 
retrieving revision 1.2.136.1
583
 
diff -u -p -u -p -r1.2 -r1.2.136.1
584
 
--- vcl/inc/vcl/sound.hxx       11 Apr 2007 18:11:10 -0000      1.2
585
 
+++ vcl/inc/vcl/sound.hxx       31 Aug 2007 09:44:56 -0000      1.2.136.1
586
 
@@ -53,14 +53,9 @@
587
 
 #ifndef _TIME_HXX
588
 
 #include <tools/time.hxx>
589
 
 #endif
590
 
-#ifndef _SV_SALSTYPE_HXX
591
 
-#include <vcl/salstype.hxx>
592
 
-#endif
593
 
 
594
 
 class Window;
595
 
 class Timer;
596
 
-class SalSound;
597
 
-class RMSound;
598
 
 
599
 
 // ---------
600
 
 // - Sound -
601
 
@@ -68,70 +63,8 @@ class RMSound;
602
 
 
603
 
 class VCL_DLLPUBLIC Sound
604
 
 {
605
 
-private:
606
 
-
607
 
-       SalSound*                       mpSound;
608
 
-       XubString                       maSoundName;
609
 
-       Window*                         mpWindow;
610
 
-       BYTE*                           mpSoundData_NOTUSED;
611
 
-       ULONG                           mnDataLen;
612
 
-       ULONG                           mnSoundLen;
613
 
-       ULONG                           mnStartTime;
614
 
-       ULONG                           mnPlayTime;
615
 
-       ULONG                           mnErrorCode;
616
 
-       SoundNotification       meNotification;
617
 
-       BOOL                            mbPlaying;
618
 
-       BOOL                            mbLoopMode;
619
 
-    Link                maNotifyHdl;
620
 
-       void*                           mpExtraData;
621
 
-
622
 
-private:
623
 
-
624
 
-                        Sound( const Sound& rSound );
625
 
-    Sound&              operator=( const Sound& rSound );
626
 
-
627
 
-//#if 0 // _SOLAR__PRIVATE
628
 
 public:
629
 
-       SAL_DLLPRIVATE void     ImplNotify( SoundNotification eNotification, ULONG nError );
630
 
-//#endif // __PRIVATE
631
 
-
632
 
-public:
633
 
-                        Sound( Window* pWindow = NULL );
634
 
-    virtual             ~Sound();
635
 
-
636
 
-    virtual void        Notify();
637
 
-
638
 
-       void                            SetWindow( Window* pWindow ) { mpWindow = pWindow; }
639
 
-       Window*                         GetWindow() const { return mpWindow; }
640
 
-       BOOL                            SetSoundName( const XubString& rSoundName );
641
 
-       const XubString&        GetSoundName() const { return maSoundName; }
642
 
-       ULONG                           GetSoundLen() const { return mnSoundLen; }
643
 
-
644
 
-    void                               Play();
645
 
-       void                            Stop();
646
 
-       void                            Pause();
647
 
-    BOOL                IsPlaying() const { return mbPlaying; }
648
 
-
649
 
-       void                            SetStartTime( ULONG nStartTime = 0 );
650
 
-       ULONG                           GetStartTime() const { return mnStartTime; }
651
 
-       void                            SetPlayTime( ULONG nPlayTime = SOUND_PLAYALL );
652
 
-       ULONG                           GetPlayTime() const { return mnPlayTime; }
653
 
-       void                            SetLoopMode( BOOL bLoop );
654
 
-       BOOL                            IsLoopMode() const { return mbLoopMode; }
655
 
-
656
 
-    void                ClearError();
657
 
-    ULONG               GetLastError() const { return mnErrorCode; }
658
 
-    SoundNotification   GetNotification() const { return meNotification; }
659
 
-
660
 
-    void                SetNotifyHdl( const Link& rLink ) { maNotifyHdl = rLink; }
661
 
-    const Link&         GetNotifyHdl() const { return maNotifyHdl; }
662
 
-
663
 
     static void         Beep( SoundType eType = SOUND_DEFAULT, Window* pWindow = NULL );
664
 
-
665
 
-       static void                     SetSoundPath( const XubString& rSoundPath );
666
 
-       static const XubString& GetSoundPath();
667
 
-
668
 
-    static BOOL         IsSoundFile( const XubString& rSoundPath );
669
 
 };
670
 
 
671
 
 #endif // _SV_SOUND_HXX
672
 
Index: vcl/prj/build.lst
673
 
===================================================================
674
 
RCS file: /cvs/gsl/vcl/prj/build.lst,v
675
 
retrieving revision 1.55
676
 
retrieving revision 1.54.20.2
677
 
diff -u -p -u -p -r1.55 -r1.54.20.2
678
 
--- vcl/prj/build.lst   20 Sep 2007 16:24:09 -0000      1.55
679
 
+++ vcl/prj/build.lst   4 Oct 2007 22:03:55 -0000       1.54.20.2
680
 
@@ -1,4 +1,4 @@
681
 
-vc     vcl     :       BOOST:boost NAS:nas FREETYPE:freetype psprint rsc sot ucbhelper unotools ICU:icu i18npool unoil ridljar X11_EXTENSIONS:x11_extensions offuh basegfx basebmp SNDFILE:sndfile PORTAUDIO:portaudio tools transex3 NULL
682
 
+vc     vcl     :       BOOST:boost FREETYPE:freetype psprint rsc sot ucbhelper unotools ICU:icu i18npool unoil ridljar X11_EXTENSIONS:x11_extensions offuh basegfx basebmp tools transex3 NULL
683
 
 vc     vcl                                                                             usr1    -       all     vc_mkout NULL
684
 
 vc     vcl\inc                                                                 nmake   -       all     vc_inc NULL
685
 
 vc     vcl\source\glyphs                                               nmake   -       all     vc_glyphs vc_inc NULL
686
 
Index: vcl/source/app/makefile.mk
687
 
===================================================================
688
 
RCS file: /cvs/gsl/vcl/source/app/makefile.mk,v
689
 
retrieving revision 1.21
690
 
retrieving revision 1.21.158.1
691
 
diff -u -p -u -p -r1.21 -r1.21.158.1
692
 
--- vcl/source/app/makefile.mk  6 Feb 2007 14:18:13 -0000       1.21
693
 
+++ vcl/source/app/makefile.mk  31 Aug 2007 09:44:57 -0000      1.21.158.1
694
 
@@ -48,10 +48,6 @@ ENABLE_EXCEPTIONS=TRUE
695
 
 
696
 
 CDEFS+=-DDLLPOSTFIX=$(DLLPOSTFIX)
697
 
 
698
 
-.IF "$(SYSTEM_NAS)"=="YES"
699
 
-CFLAGS+=-I$(NAS_INCLUDES)
700
 
-.ENDIF
701
 
-
702
 
 # --- Files --------------------------------------------------------
703
 
 
704
 
 SLOFILES=      $(SLO)$/dbggui.obj              \
705
 
Index: vcl/source/app/salvtables.cxx
706
 
===================================================================
707
 
RCS file: /cvs/gsl/vcl/source/app/salvtables.cxx,v
708
 
retrieving revision 1.9
709
 
retrieving revision 1.8.22.2
710
 
diff -u -p -u -p -r1.9 -r1.8.22.2
711
 
--- vcl/source/app/salvtables.cxx       9 Oct 2007 15:19:13 -0000       1.9
712
 
+++ vcl/source/app/salvtables.cxx       16 Oct 2007 08:32:24 -0000      1.8.22.2
713
 
@@ -41,7 +41,6 @@
714
 
 #include <vcl/salvd.hxx>
715
 
 #include <vcl/salprn.hxx>
716
 
 #include <vcl/saltimer.hxx>
717
 
-#include <vcl/salsound.hxx>
718
 
 #include <vcl/salogl.hxx>
719
 
 #include <vcl/salimestatus.hxx>
720
 
 #include <vcl/salsys.hxx>
721
 
@@ -61,10 +60,6 @@ SalInstance::~SalInstance()
722
 
 {
723
 
 }
724
 
 
725
 
-SalSound::~SalSound()
726
 
-{
727
 
-}
728
 
-
729
 
 SalTimer::~SalTimer()
730
 
 {
731
 
 }
732
 
Index: vcl/source/app/settings.cxx
733
 
===================================================================
734
 
RCS file: /cvs/gsl/vcl/source/app/settings.cxx,v
735
 
retrieving revision 1.72
736
 
retrieving revision 1.72.20.1
737
 
diff -u -p -u -p -r1.72 -r1.72.20.1
738
 
--- vcl/source/app/settings.cxx 24 Jul 2007 10:04:42 -0000      1.72
739
 
+++ vcl/source/app/settings.cxx 31 Aug 2007 09:44:57 -0000      1.72.20.1
740
 
@@ -1311,98 +1311,6 @@ BOOL MiscSettings::GetEnableLocalizedDec
741
 
     return mpData->mbEnableLocalizedDecimalSep;
742
 
 }
743
 
 
744
 
-
745
 
-
746
 
-// =======================================================================
747
 
-
748
 
-ImplSoundData::ImplSoundData()
749
 
-{
750
 
-    mnRefCount                  = 1;
751
 
-    mnOptions                   = 0;
752
 
-}
753
 
-
754
 
-// -----------------------------------------------------------------------
755
 
-
756
 
-ImplSoundData::ImplSoundData( const ImplSoundData& rData )
757
 
-{
758
 
-    mnRefCount                  = 1;
759
 
-    mnOptions                   = rData.mnOptions;
760
 
-}
761
 
-
762
 
-// -----------------------------------------------------------------------
763
 
-
764
 
-SoundSettings::SoundSettings()
765
 
-{
766
 
-    mpData = new ImplSoundData();
767
 
-}
768
 
-
769
 
-// -----------------------------------------------------------------------
770
 
-
771
 
-SoundSettings::SoundSettings( const SoundSettings& rSet )
772
 
-{
773
 
-    DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "SoundSettings: RefCount overflow" );
774
 
-
775
 
-    // shared Instance Daten uebernehmen und Referenzcounter erhoehen
776
 
-    mpData = rSet.mpData;
777
 
-    mpData->mnRefCount++;
778
 
-}
779
 
-
780
 
-// -----------------------------------------------------------------------
781
 
-
782
 
-SoundSettings::~SoundSettings()
783
 
-{
784
 
-    // Daten loeschen, wenn letzte Referenz
785
 
-    if ( mpData->mnRefCount == 1 )
786
 
-        delete mpData;
787
 
-    else
788
 
-        mpData->mnRefCount--;
789
 
-}
790
 
-
791
 
-// -----------------------------------------------------------------------
792
 
-
793
 
-const SoundSettings& SoundSettings::operator =( const SoundSettings& rSet )
794
 
-{
795
 
-    DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "SoundSettings: RefCount overflow" );
796
 
-
797
 
-    // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
798
 
-    rSet.mpData->mnRefCount++;
799
 
-
800
 
-    // Daten loeschen, wenn letzte Referenz
801
 
-    if ( mpData->mnRefCount == 1 )
802
 
-        delete mpData;
803
 
-    else
804
 
-        mpData->mnRefCount--;
805
 
-
806
 
-    mpData = rSet.mpData;
807
 
-
808
 
-    return *this;
809
 
-}
810
 
-
811
 
-// -----------------------------------------------------------------------
812
 
-
813
 
-void SoundSettings::CopyData()
814
 
-{
815
 
-    // Falls noch andere Referenzen bestehen, dann kopieren
816
 
-    if ( mpData->mnRefCount != 1 )
817
 
-    {
818
 
-        mpData->mnRefCount--;
819
 
-        mpData = new ImplSoundData( *mpData );
820
 
-    }
821
 
-}
822
 
-
823
 
-// -----------------------------------------------------------------------
824
 
-
825
 
-BOOL SoundSettings::operator ==( const SoundSettings& rSet ) const
826
 
-{
827
 
-    if ( mpData == rSet.mpData )
828
 
-        return TRUE;
829
 
-
830
 
-    if ( (mpData->mnOptions             == rSet.mpData->mnOptions) )
831
 
-        return TRUE;
832
 
-    else
833
 
-        return FALSE;
834
 
-}
835
 
-
836
 
 // =======================================================================
837
 
 
838
 
 ImplNotificationData::ImplNotificationData()
839
 
@@ -1625,7 +1533,6 @@ ImplAllSettingsData::ImplAllSettingsData
840
 
     maKeyboardSettings( rData.maKeyboardSettings ),
841
 
     maStyleSettings( rData.maStyleSettings ),
842
 
     maMiscSettings( rData.maMiscSettings ),
843
 
-    maSoundSettings( rData.maSoundSettings ),
844
 
     maNotificationSettings( rData.maNotificationSettings ),
845
 
     maHelpSettings( rData.maHelpSettings ),
846
 
     maLocale( rData.maLocale ),
847
 
@@ -1795,16 +1702,6 @@ ULONG AllSettings::Update( ULONG nFlags,
848
 
         }
849
 
     }
850
 
 
851
 
-    if ( nFlags & SETTINGS_SOUND )
852
 
-    {
853
 
-        if ( mpData->maSoundSettings != rSet.mpData->maSoundSettings )
854
 
-        {
855
 
-            CopyData();
856
 
-            mpData->maSoundSettings = rSet.mpData->maSoundSettings;
857
 
-            nChangeFlags |= SETTINGS_SOUND;
858
 
-        }
859
 
-    }
860
 
-
861
 
     if ( nFlags & SETTINGS_NOTIFICATION )
862
 
     {
863
 
         if ( mpData->maNotificationSettings != rSet.mpData->maNotificationSettings )
864
 
@@ -1876,9 +1773,6 @@ ULONG AllSettings::GetChangeFlags( const
865
 
     if ( mpData->maMiscSettings != rSet.mpData->maMiscSettings )
866
 
         nChangeFlags |= SETTINGS_MISC;
867
 
 
868
 
-    if ( mpData->maSoundSettings != rSet.mpData->maSoundSettings )
869
 
-        nChangeFlags |= SETTINGS_SOUND;
870
 
-
871
 
     if ( mpData->maNotificationSettings != rSet.mpData->maNotificationSettings )
872
 
         nChangeFlags |= SETTINGS_NOTIFICATION;
873
 
 
874
 
@@ -1909,7 +1803,6 @@ BOOL AllSettings::operator ==( const All
875
 
          (mpData->maKeyboardSettings        == rSet.mpData->maKeyboardSettings)     &&
876
 
          (mpData->maStyleSettings           == rSet.mpData->maStyleSettings)        &&
877
 
          (mpData->maMiscSettings            == rSet.mpData->maMiscSettings)         &&
878
 
-         (mpData->maSoundSettings           == rSet.mpData->maSoundSettings)        &&
879
 
          (mpData->maNotificationSettings    == rSet.mpData->maNotificationSettings) &&
880
 
          (mpData->maHelpSettings            == rSet.mpData->maHelpSettings)         &&
881
 
          (mpData->mnSystemUpdate            == rSet.mpData->mnSystemUpdate)         &&
882
 
Index: vcl/source/app/sound.cxx
883
 
===================================================================
884
 
RCS file: /cvs/gsl/vcl/source/app/sound.cxx,v
885
 
retrieving revision 1.14
886
 
retrieving revision 1.14.60.1
887
 
diff -u -p -u -p -r1.14 -r1.14.60.1
888
 
--- vcl/source/app/sound.cxx    27 Jun 2007 20:02:09 -0000      1.14
889
 
+++ vcl/source/app/sound.cxx    31 Aug 2007 09:44:57 -0000      1.14.60.1
890
 
@@ -48,9 +48,6 @@
891
 
 #ifndef _SV_SVSYS_HXX
892
 
 #include <svsys.h>
893
 
 #endif
894
 
-#ifndef _SV_SALSOUND_HXX
895
 
-#include <vcl/salsound.hxx>
896
 
-#endif
897
 
 #ifndef _SV_SALFRAME_HXX
898
 
 #include <vcl/salframe.hxx>
899
 
 #endif
900
 
@@ -63,9 +60,6 @@
901
 
 #ifndef _SV_WINDOW_HXX
902
 
 #include <vcl/window.hxx>
903
 
 #endif
904
 
-#ifndef _SV_SALSOUND_HXX
905
 
-#include <vcl/salsound.hxx>
906
 
-#endif
907
 
 #ifndef _SV_SALBTYPE_HXX
908
 
 #include <vcl/salbtype.hxx>
909
 
 #endif
910
 
@@ -76,194 +70,6 @@
911
 
 #include <vcl/salinst.hxx>
912
 
 #endif
913
 
 
914
 
-
915
 
-
916
 
-// ----------------------
917
 
-// - SalSound-Callback -
918
 
-// ----------------------
919
 
-
920
 
-void SalSoundProc( void* pInst, SoundNotification eNotification, ULONG nError )
921
 
-{
922
 
-       ( (Sound*) pInst )->ImplNotify( eNotification, nError );
923
 
-}
924
 
-
925
 
-// ---------
926
 
-// - Sound -
927
 
-// ---------
928
 
-
929
 
-Sound::Sound( Window* pWindow ) :
930
 
-                       mpWindow                ( pWindow ),
931
 
-                       mnDataLen               ( 0UL ),
932
 
-                       mnSoundLen              ( 0UL ),
933
 
-                       mnStartTime             ( 0UL ),
934
 
-                       mnPlayTime              ( SOUND_PLAYALL ),
935
 
-                       mnErrorCode             ( 0UL ),
936
 
-                       meNotification  ( SOUND_NOTIFY_SUCCESS ),
937
 
-                       mbPlaying               ( FALSE ),
938
 
-                       mbLoopMode              ( FALSE )
939
 
-{
940
 
-       mpSound = ImplGetSVData()->mpDefInst->CreateSalSound();
941
 
-
942
 
-       if( mpSound->IsValid() )
943
 
-               mpSound->SetNotifyProc( this, SalSoundProc );
944
 
-}
945
 
-
946
 
-// -----------------------------------------------------------------------
947
 
-
948
 
-Sound::~Sound()
949
 
-{
950
 
-       delete mpSound;
951
 
-}
952
 
-
953
 
-// -----------------------------------------------------------------------
954
 
-
955
 
-void Sound::ImplNotify( SoundNotification eNotification, ULONG nError )
956
 
-{
957
 
-       meNotification = eNotification;
958
 
-       mbPlaying = FALSE;
959
 
-
960
 
-       if( SOUND_NOTIFY_ERROR == meNotification )
961
 
-               mnErrorCode = nError;
962
 
-
963
 
-       Notify();
964
 
-
965
 
-       if( maNotifyHdl.IsSet() )
966
 
-               maNotifyHdl.Call( this );
967
 
-}
968
 
-
969
 
-// -----------------------------------------------------------------------
970
 
-
971
 
-void Sound::Notify()
972
 
-{
973
 
-}
974
 
-
975
 
-// -----------------------------------------------------------------------
976
 
-
977
 
-BOOL Sound::SetSoundName( const XubString& rSoundName )
978
 
-{
979
 
-       BOOL bRet( FALSE );
980
 
-
981
 
-       if( !rSoundName.Len() )
982
 
-       {
983
 
-               mnDataLen = 0UL;
984
 
-               mnSoundLen = 0UL;
985
 
-               mnStartTime = 0UL;
986
 
-               mnPlayTime = SOUND_PLAYALL;
987
 
-               mnErrorCode = 0UL;
988
 
-               meNotification = SOUND_NOTIFY_SUCCESS;
989
 
-               mbPlaying = FALSE;
990
 
-               mbLoopMode = FALSE;
991
 
-               bRet = TRUE;
992
 
-
993
 
-               mpSound->Init( rSoundName, mnSoundLen );
994
 
-       }
995
 
-       else if( mpSound->IsValid() )
996
 
-       {
997
 
-               INetURLObject   aSoundURL( rSoundName );
998
 
-               String                  aSoundName, aTmp;
999
 
-        BOOL            bValidName( FALSE );
1000
 
-
1001
 
-        // #106654# Accept only local sound files
1002
 
-               if( aSoundURL.GetProtocol() == INET_PROT_FILE )
1003
 
-               {
1004
 
-                       utl::LocalFileHelper::ConvertURLToPhysicalName( aSoundURL.GetMainURL( INetURLObject::NO_DECODE ), aSoundName );
1005
 
-            bValidName = TRUE;
1006
 
-               }
1007
 
-               else if( aSoundURL.GetProtocol() == INET_PROT_NOT_VALID &&
1008
 
-                 ::utl::LocalFileHelper::ConvertPhysicalNameToURL( rSoundName, aTmp ) )
1009
 
-        {
1010
 
-            aSoundName = rSoundName;
1011
 
-            bValidName = TRUE;
1012
 
-        }
1013
 
-               else
1014
 
-               {
1015
 
-            // no valid sound file name
1016
 
-                       aSoundName = String();
1017
 
-
1018
 
-            // #106654# Don't set bRet to true for invalid sound file
1019
 
-            // names, but init with empty string, anyway
1020
 
-                   mpSound->Init( aSoundName, mnSoundLen );
1021
 
-               }
1022
 
-
1023
 
-        if( bValidName )
1024
 
-                   bRet = mpSound->Init( aSoundName, mnSoundLen );
1025
 
-       }
1026
 
-
1027
 
-       maSoundName = rSoundName;
1028
 
-
1029
 
-       // if sound could not be initialized, but we've gotten _no_
1030
 
-       // notification ==> create common error notification
1031
 
-       if( !bRet && !mnErrorCode )
1032
 
-               ImplNotify( SOUND_NOTIFY_ERROR, SOUNDERR_GENERAL_ERROR );
1033
 
-
1034
 
-       return bRet;
1035
 
-}
1036
 
-
1037
 
-// -----------------------------------------------------------------------
1038
 
-
1039
 
-void Sound::SetStartTime( ULONG nStartTime ) 
1040
 
-{
1041
 
-       mnStartTime = nStartTime;
1042
 
-}
1043
 
-
1044
 
-// -----------------------------------------------------------------------
1045
 
-
1046
 
-void Sound::SetPlayTime( ULONG nPlayTime )
1047
 
-{
1048
 
-       mnPlayTime = nPlayTime; 
1049
 
-}
1050
 
-
1051
 
-// -----------------------------------------------------------------------
1052
 
-
1053
 
-void Sound::SetLoopMode( BOOL bLoop ) 
1054
 
-{
1055
 
-       mbLoopMode = bLoop; 
1056
 
-}
1057
 
-
1058
 
-// -----------------------------------------------------------------------
1059
 
-
1060
 
-void Sound::ClearError() 
1061
 
-{
1062
 
-       mnErrorCode = 0; 
1063
 
-}
1064
 
-
1065
 
-// -----------------------------------------------------------------------
1066
 
-
1067
 
-void Sound::Play()
1068
 
-{
1069
 
-       BOOL bRet;
1070
 
-
1071
 
-       if( mpSound->IsValid() && !mnErrorCode )
1072
 
-       {
1073
 
-               mpSound->Play( mnStartTime, mnPlayTime, mbLoopMode );
1074
 
-        mbPlaying = TRUE;
1075
 
-       }
1076
 
-       else
1077
 
-               bRet = FALSE;
1078
 
-}
1079
 
-
1080
 
-// -----------------------------------------------------------------------
1081
 
-
1082
 
-void Sound::Stop()
1083
 
-{
1084
 
-       mbPlaying = FALSE;
1085
 
-       
1086
 
-       if( mpSound->IsValid() )
1087
 
-               mpSound->Stop();
1088
 
-}
1089
 
-
1090
 
-// -----------------------------------------------------------------------
1091
 
-
1092
 
-void Sound::Pause()
1093
 
-{
1094
 
-       mbPlaying = FALSE;
1095
 
-       
1096
 
-       if( mpSound->IsValid() )
1097
 
-               mpSound->Pause();
1098
 
-}
1099
 
-
1100
 
-// -----------------------------------------------------------------------
1101
 
-
1102
 
 void Sound::Beep( SoundType eType, Window* pWindow )
1103
 
 {
1104
 
     if( !pWindow )
1105
 
@@ -274,62 +80,3 @@ void Sound::Beep( SoundType eType, Windo
1106
 
     else
1107
 
         pWindow->ImplGetFrame()->Beep( eType );
1108
 
 }
1109
 
-
1110
 
-// -----------------------------------------------------------------------
1111
 
-
1112
 
-void Sound::SetSoundPath( const XubString& )
1113
 
-{
1114
 
-}
1115
 
-
1116
 
-// -----------------------------------------------------------------------
1117
 
-
1118
 
-const XubString& Sound::GetSoundPath()
1119
 
-{
1120
 
-       return ImplGetSVEmptyStr();
1121
 
-}
1122
 
-
1123
 
-// -----------------------------------------------------------------------
1124
 
-
1125
 
-BOOL Sound::IsSoundFile( const XubString& rSoundPath )
1126
 
-{
1127
 
-    BOOL bRet = FALSE;
1128
 
-
1129
 
-    if( rSoundPath.Len() )
1130
 
-    {
1131
 
-               INetURLObject   aSoundURL( rSoundPath );
1132
 
-               String                  aSoundName;
1133
 
-
1134
 
-               if( aSoundURL.GetProtocol() != INET_PROT_NOT_VALID )
1135
 
-                       aSoundName = aSoundURL.GetMainURL( INetURLObject::NO_DECODE );
1136
 
-               else if( !::utl::LocalFileHelper::ConvertPhysicalNameToURL( rSoundPath, aSoundName ) )
1137
 
-                       aSoundName.Erase();
1138
 
-
1139
 
-        if( aSoundName.Len() )
1140
 
-        {
1141
 
-            SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aSoundName, STREAM_READ );
1142
 
-
1143
 
-            if( pIStm )
1144
 
-            {
1145
 
-                sal_Char aData[ 12 ];
1146
 
-
1147
 
-                if( ( pIStm->Read( aData, 12 ) == 12 ) && !pIStm->GetError() )
1148
 
-                {
1149
 
-                    // check for WAV
1150
 
-                    bRet = ( aData[ 0 ] == 'R' && aData[ 1 ] == 'I' && aData[ 2 ] == 'F' && aData[ 3 ] == 'F' &&
1151
 
-                             aData[ 8 ] == 'W' && aData[ 9 ] == 'A' && aData[ 10 ] == 'V' && aData[ 11 ] == 'E' );
1152
 
-                }
1153
 
-
1154
 
-                delete pIStm;
1155
 
-            }
1156
 
-
1157
 
-            if( !bRet )
1158
 
-            {
1159
 
-                // check it the hard way
1160
 
-                Sound aTestSound;
1161
 
-                bRet = aTestSound.SetSoundName( rSoundPath );
1162
 
-            }
1163
 
-        }
1164
 
-    }
1165
 
-
1166
 
-    return bRet;
1167
 
-}
1168
 
Index: vcl/source/app/svmain.cxx
1169
 
===================================================================
1170
 
RCS file: /cvs/gsl/vcl/source/app/svmain.cxx,v
1171
 
retrieving revision 1.70
1172
 
retrieving revision 1.70.22.1
1173
 
diff -u -p -u -p -r1.70 -r1.70.22.1
1174
 
--- vcl/source/app/svmain.cxx   24 Jul 2007 10:05:33 -0000      1.70
1175
 
+++ vcl/source/app/svmain.cxx   31 Aug 2007 09:44:57 -0000      1.70.22.1
1176
 
@@ -57,9 +57,6 @@
1177
 
 #ifndef _SV_SALINST_HXX
1178
 
 #include <vcl/salinst.hxx>
1179
 
 #endif
1180
 
-#ifndef _SV_SALSOUND_HXX
1181
 
-#include <vcl/salsound.hxx>
1182
 
-#endif
1183
 
 #ifndef _SV_SALOGL_HXX
1184
 
 #include <vcl/salogl.hxx>
1185
 
 #endif
1186
 
Index: vcl/unx/gtk/window/gtkframe.cxx
1187
 
===================================================================
1188
 
RCS file: /cvs/gsl/vcl/unx/gtk/window/gtkframe.cxx,v
1189
 
retrieving revision 1.71
1190
 
retrieving revision 1.67.12.3
1191
 
diff -u -p -u -p -r1.71 -r1.67.12.3
1192
 
--- vcl/unx/gtk/window/gtkframe.cxx     9 Oct 2007 15:21:04 -0000       1.71
1193
 
+++ vcl/unx/gtk/window/gtkframe.cxx     16 Oct 2007 08:32:30 -0000      1.67.12.3
1194
 
@@ -2154,9 +2154,17 @@ void GtkSalFrame::UpdateSettings( AllSet
1195
 
         ReleaseGraphics( pGraphics );
1196
 
 }
1197
 
 
1198
 
-void GtkSalFrame::Beep( SoundType /*eType*/ )
1199
 
+void GtkSalFrame::Beep( SoundType eType )
1200
 
 {
1201
 
-    gdk_display_beep( getGdkDisplay() );
1202
 
+    switch( eType )
1203
 
+    {
1204
 
+        case SOUND_DEFAULT:
1205
 
+        case SOUND_ERROR:
1206
 
+            gdk_display_beep( getGdkDisplay() );
1207
 
+            break;
1208
 
+        default:
1209
 
+            break;
1210
 
+    }
1211
 
 }
1212
 
 
1213
 
 const SystemEnvData* GtkSalFrame::GetSystemData() const
1214
 
Index: vcl/unx/headless/svpdummies.cxx
1215
 
===================================================================
1216
 
RCS file: /cvs/gsl/vcl/unx/headless/svpdummies.cxx,v
1217
 
retrieving revision 1.2
1218
 
retrieving revision 1.2.22.1
1219
 
diff -u -p -u -p -r1.2 -r1.2.22.1
1220
 
--- vcl/unx/headless/svpdummies.cxx     24 Jul 2007 10:26:21 -0000      1.2
1221
 
+++ vcl/unx/headless/svpdummies.cxx     31 Aug 2007 09:44:57 -0000      1.2.22.1
1222
 
@@ -46,44 +46,6 @@ void SvpSalOpenGL::OGLExit( SalGraphics*
1223
 
 void SvpSalOpenGL::StartScene( SalGraphics* ) {}
1224
 
 void SvpSalOpenGL::StopScene() {}
1225
 
 
1226
 
-// SalSound
1227
 
-SvpSalSound::~SvpSalSound() {}
1228
 
-bool SvpSalSound::IsValid() { return true; }
1229
 
-bool SvpSalSound::Init( const String&, ULONG& rSoundLen )
1230
 
-{
1231
 
-    rSoundLen = 0;
1232
 
-    return true;
1233
 
-}
1234
 
-void SvpSalSound::Play( ULONG, ULONG, bool bLoop )
1235
 
-{
1236
 
-    m_bPlaying = true;
1237
 
-    m_bLooping = bLoop;
1238
 
-}
1239
 
-void SvpSalSound::Stop()
1240
 
-{
1241
 
-    m_bPlaying = m_bLooping = false;
1242
 
-}
1243
 
-void SvpSalSound::Pause()
1244
 
-{
1245
 
-    m_bPaused = true;
1246
 
-}
1247
 
-void SvpSalSound::Continue()
1248
 
-{
1249
 
-    m_bPaused = false;
1250
 
-}
1251
 
-bool SvpSalSound::IsLoopMode() const
1252
 
-{
1253
 
-    return m_bLooping;
1254
 
-}
1255
 
-bool SvpSalSound::IsPlaying() const
1256
 
-{
1257
 
-    return m_bPlaying;
1258
 
-}
1259
 
-bool SvpSalSound::IsPaused() const
1260
 
-{
1261
 
-    return m_bPaused;
1262
 
-}
1263
 
-
1264
 
 // SalObject
1265
 
 SvpSalObject::SvpSalObject()
1266
 
 {
1267
 
Index: vcl/unx/headless/svpdummies.hxx
1268
 
===================================================================
1269
 
RCS file: /cvs/gsl/vcl/unx/headless/svpdummies.hxx,v
1270
 
retrieving revision 1.2
1271
 
retrieving revision 1.2.22.1
1272
 
diff -u -p -u -p -r1.2 -r1.2.22.1
1273
 
--- vcl/unx/headless/svpdummies.hxx     24 Jul 2007 10:26:33 -0000      1.2
1274
 
+++ vcl/unx/headless/svpdummies.hxx     31 Aug 2007 09:44:57 -0000      1.2.22.1
1275
 
@@ -36,7 +36,6 @@
1276
 
 #ifndef _SVP_SVPDUMMIES_HXX
1277
 
 
1278
 
 #include <vcl/salogl.hxx>
1279
 
-#include <vcl/salsound.hxx>
1280
 
 #include <vcl/salobj.hxx>
1281
 
 #include <vcl/sysdata.hxx>
1282
 
 #include <vcl/salimestatus.hxx>
1283
 
@@ -59,28 +58,6 @@ public:                                      
1284
 
        virtual void            StopScene();
1285
 
 };
1286
 
 
1287
 
-class SvpSalSound : public SalSound
1288
 
-{
1289
 
-    bool m_bPlaying;
1290
 
-    bool m_bLooping;
1291
 
-    bool m_bPaused;
1292
 
-public:
1293
 
-    SvpSalSound() : m_bPlaying( false ), m_bLooping( false ), m_bPaused( false ) {}
1294
 
-       virtual ~SvpSalSound();
1295
 
-       
1296
 
-    // overload all pure virtual methods
1297
 
-    virtual bool               IsValid();
1298
 
-    virtual bool               Init( const String&     rSoundName,
1299
 
-                              ULONG&           rSoundLen );
1300
 
-       virtual void            Play( ULONG nStartTime, ULONG nPlayTime, bool bLoop );
1301
 
-       virtual void            Stop();
1302
 
-       virtual void            Pause();
1303
 
-       virtual void            Continue();
1304
 
-    virtual bool               IsLoopMode() const;
1305
 
-       virtual bool            IsPlaying() const;
1306
 
-    virtual bool               IsPaused() const;
1307
 
-};
1308
 
-
1309
 
 class SvpSalObject : public SalObject
1310
 
 {
1311
 
 public:
1312
 
Index: vcl/unx/headless/svpinst.cxx
1313
 
===================================================================
1314
 
RCS file: /cvs/gsl/vcl/unx/headless/svpinst.cxx,v
1315
 
retrieving revision 1.2
1316
 
retrieving revision 1.2.22.1
1317
 
diff -u -p -u -p -r1.2 -r1.2.22.1
1318
 
--- vcl/unx/headless/svpinst.cxx        24 Jul 2007 10:27:49 -0000      1.2
1319
 
+++ vcl/unx/headless/svpinst.cxx        31 Aug 2007 09:44:57 -0000      1.2.22.1
1320
 
@@ -269,11 +269,6 @@ void SvpSalInstance::DestroyVirtualDevic
1321
 
     delete pDevice;
1322
 
 }
1323
 
 
1324
 
-SalSound* SvpSalInstance::CreateSalSound()
1325
 
-{
1326
 
-    return new SvpSalSound();
1327
 
-}
1328
 
-
1329
 
 SalTimer* SvpSalInstance::CreateSalTimer()
1330
 
 {
1331
 
     return new SvpSalTimer( this );
1332
 
Index: vcl/unx/headless/svpinst.hxx
1333
 
===================================================================
1334
 
RCS file: /cvs/gsl/vcl/unx/headless/svpinst.hxx,v
1335
 
retrieving revision 1.2
1336
 
retrieving revision 1.2.22.1
1337
 
diff -u -p -u -p -r1.2 -r1.2.22.1
1338
 
--- vcl/unx/headless/svpinst.hxx        24 Jul 2007 10:27:59 -0000      1.2
1339
 
+++ vcl/unx/headless/svpinst.hxx        31 Aug 2007 09:44:57 -0000      1.2.22.1
1340
 
@@ -166,8 +166,6 @@ public:
1341
 
     virtual void                       DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo );
1342
 
     virtual String          GetDefaultPrinter();
1343
 
 
1344
 
-    // SalSound
1345
 
-    virtual SalSound*          CreateSalSound();
1346
 
     // SalTimer
1347
 
     virtual SalTimer*          CreateSalTimer();
1348
 
     // SalOpenGL
1349
 
Index: vcl/unx/inc/postx.h
1350
 
===================================================================
1351
 
RCS file: /cvs/gsl/vcl/unx/inc/postx.h,v
1352
 
retrieving revision 1.5
1353
 
retrieving revision 1.5.408.1
1354
 
diff -u -p -u -p -r1.5 -r1.5.408.1
1355
 
--- vcl/unx/inc/postx.h 19 Jun 2006 19:46:31 -0000      1.5
1356
 
+++ vcl/unx/inc/postx.h 31 Aug 2007 09:44:57 -0000      1.5.408.1
1357
 
@@ -69,9 +69,6 @@
1358
 
 #undef InitializeToken
1359
 
 #undef NextRequest
1360
 
 
1361
 
-/* Network Audio System */
1362
 
-#undef Sound
1363
 
-
1364
 
 #ifdef KeyPress
1365
 
 #if KeyPress != 2
1366
 
 Error KeyPress must be Equal 2
1367
 
Index: vcl/unx/inc/prex.h
1368
 
===================================================================
1369
 
RCS file: /cvs/gsl/vcl/unx/inc/prex.h,v
1370
 
retrieving revision 1.15
1371
 
retrieving revision 1.15.116.1
1372
 
diff -u -p -u -p -r1.15 -r1.15.116.1
1373
 
--- vcl/unx/inc/prex.h  26 Apr 2007 10:40:23 -0000      1.15
1374
 
+++ vcl/unx/inc/prex.h  31 Aug 2007 09:44:57 -0000      1.15.116.1
1375
 
@@ -51,9 +51,6 @@
1376
 
 #define Region         XLIB_Region
1377
 
 #define Boolean                XLIB_Boolean
1378
 
 
1379
 
-/* fuer Network Audio System */
1380
 
-#define Sound          XLIB_Sound
1381
 
-
1382
 
 #if defined __cplusplus
1383
 
 extern "C" {
1384
 
 #endif
1385
 
Index: vcl/unx/inc/salinst.h
1386
 
===================================================================
1387
 
RCS file: /cvs/gsl/vcl/unx/inc/salinst.h,v
1388
 
retrieving revision 1.14
1389
 
retrieving revision 1.14.60.1
1390
 
diff -u -p -u -p -r1.14 -r1.14.60.1
1391
 
--- vcl/unx/inc/salinst.h       27 Jun 2007 20:41:36 -0000      1.14
1392
 
+++ vcl/unx/inc/salinst.h       31 Aug 2007 09:44:57 -0000      1.14.60.1
1393
 
@@ -108,7 +108,6 @@ public:
1394
 
     virtual void                               DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo );
1395
 
     virtual String             GetDefaultPrinter();
1396
 
 
1397
 
-    virtual SalSound*                  CreateSalSound();
1398
 
     virtual SalTimer*                  CreateSalTimer();
1399
 
     virtual SalOpenGL*                 CreateSalOpenGL( SalGraphics* pGraphics );
1400
 
     virtual SalI18NImeStatus*  CreateI18NImeStatus();
1401
 
Index: vcl/unx/inc/salsound.h
1402
 
===================================================================
1403
 
RCS file: vcl/unx/inc/salsound.h
1404
 
diff -N vcl/unx/inc/salsound.h
1405
 
--- vcl/unx/inc/salsound.h      27 Jun 2007 20:42:40 -0000      1.5
1406
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
1407
 
@@ -1,93 +0,0 @@
1408
 
-/*************************************************************************
1409
 
- *
1410
 
- *  OpenOffice.org - a multi-platform office productivity suite
1411
 
- *
1412
 
- *  $RCSfile: salsound.h,v $
1413
 
- *
1414
 
- *  $Revision: 1.5 $
1415
 
- *
1416
 
- *  last change: $Author: hr $ $Date: 2007/06/27 20:42:40 $
1417
 
- *
1418
 
- *  The Contents of this file are made available subject to
1419
 
- *  the terms of GNU Lesser General Public License Version 2.1.
1420
 
- *
1421
 
- *
1422
 
- *    GNU Lesser General Public License Version 2.1
1423
 
- *    =============================================
1424
 
- *    Copyright 2005 by Sun Microsystems, Inc.
1425
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
1426
 
- *
1427
 
- *    This library is free software; you can redistribute it and/or
1428
 
- *    modify it under the terms of the GNU Lesser General Public
1429
 
- *    License version 2.1, as published by the Free Software Foundation.
1430
 
- *
1431
 
- *    This library is distributed in the hope that it will be useful,
1432
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
1433
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1434
 
- *    Lesser General Public License for more details.
1435
 
- *
1436
 
- *    You should have received a copy of the GNU Lesser General Public
1437
 
- *    License along with this library; if not, write to the Free Software
1438
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1439
 
- *    MA  02111-1307  USA
1440
 
- *
1441
 
- ************************************************************************/
1442
 
-
1443
 
-#ifndef _SV_SALSOUND_H
1444
 
-#define _SV_SALSOUND_H
1445
 
-
1446
 
-#ifndef _SV_SALSOUND_HXX
1447
 
-#include <vcl/salsound.hxx>
1448
 
-#endif
1449
 
-
1450
 
-// ------------
1451
 
-// - SalSound -
1452
 
-// ------------
1453
 
-
1454
 
-namespace vcl_sal { class VSound; }
1455
 
-
1456
 
-class X11SalSound : public SalSound
1457
 
-{
1458
 
-// public for VSound sub classes
1459
 
-public:
1460
 
-       // the real sound
1461
 
-       vcl_sal::VSound*                m_pVSound;
1462
 
-       
1463
 
-       // the sound to play
1464
 
-       ByteString                              m_aSoundFile;
1465
 
-       
1466
 
-       // state data
1467
 
-       bool                                    m_bLoop;
1468
 
-       bool                                    m_bPlaying;
1469
 
-       bool                                    m_bPaused;
1470
 
-       
1471
 
-       ULONG                                   m_nStartTime;
1472
 
-       ULONG                                   m_nPlayTime;
1473
 
-       
1474
 
-       static ULONG                    s_nSoundState;
1475
 
-       
1476
 
-       void changeStateStop();
1477
 
-       void changeStatePause();
1478
 
-       void changeStateCont();
1479
 
-       void changeStatePlay();
1480
 
-       void setError( ULONG );
1481
 
-public:
1482
 
-    X11SalSound();
1483
 
-       virtual ~X11SalSound();
1484
 
-       
1485
 
-    // overload all pure virtual methods
1486
 
-    virtual bool               IsValid();
1487
 
-    virtual bool               Init( const String&     rSoundName,
1488
 
-                              ULONG&           rSoundLen );
1489
 
-       virtual void            Play( ULONG nStartTime, ULONG nPlayTime, bool bLoop );
1490
 
-       virtual void            Stop();
1491
 
-       virtual void            Pause();
1492
 
-       virtual void            Continue();
1493
 
-    virtual bool               IsLoopMode() const;
1494
 
-       virtual bool            IsPlaying() const;
1495
 
-    virtual bool               IsPaused() const;
1496
 
-       
1497
 
-       static void Release();
1498
 
-};
1499
 
-
1500
 
-#endif // _SV_SALSOUND_HXX
1501
 
Index: vcl/unx/source/app/audioconvert.cxx
1502
 
===================================================================
1503
 
RCS file: vcl/unx/source/app/audioconvert.cxx
1504
 
diff -N vcl/unx/source/app/audioconvert.cxx
1505
 
--- vcl/unx/source/app/audioconvert.cxx 17 Sep 2006 12:31:15 -0000      1.3
1506
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
1507
 
@@ -1,166 +0,0 @@
1508
 
-/*************************************************************************
1509
 
- *
1510
 
- *  OpenOffice.org - a multi-platform office productivity suite
1511
 
- *
1512
 
- *  $RCSfile: audioconvert.cxx,v $
1513
 
- *
1514
 
- *  $Revision: 1.3 $
1515
 
- *
1516
 
- *  last change: $Author: obo $ $Date: 2006/09/17 12:31:15 $
1517
 
- *
1518
 
- *  The Contents of this file are made available subject to
1519
 
- *  the terms of GNU Lesser General Public License Version 2.1.
1520
 
- *
1521
 
- *
1522
 
- *    GNU Lesser General Public License Version 2.1
1523
 
- *    =============================================
1524
 
- *    Copyright 2005 by Sun Microsystems, Inc.
1525
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
1526
 
- *
1527
 
- *    This library is free software; you can redistribute it and/or
1528
 
- *    modify it under the terms of the GNU Lesser General Public
1529
 
- *    License version 2.1, as published by the Free Software Foundation.
1530
 
- *
1531
 
- *    This library is distributed in the hope that it will be useful,
1532
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
1533
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1534
 
- *    Lesser General Public License for more details.
1535
 
- *
1536
 
- *    You should have received a copy of the GNU Lesser General Public
1537
 
- *    License along with this library; if not, write to the Free Software
1538
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1539
 
- *    MA  02111-1307  USA
1540
 
- *
1541
 
- ************************************************************************/
1542
 
-
1543
 
-// MARKER(update_precomp.py): autogen include statement, do not remove
1544
 
-#include "precompiled_vcl.hxx"
1545
 
-
1546
 
-#include <vsound.hxx>
1547
 
-
1548
 
-using namespace vcl_sal;
1549
 
-
1550
 
-#include <sunconvert.cxx>
1551
 
-
1552
 
-AudioConverter::~AudioConverter()
1553
 
-{
1554
 
-}
1555
 
-
1556
 
-class G721ToULawConverter : public AudioConverter
1557
 
-{
1558
 
-       g72x_state              m_aState;
1559
 
-public:
1560
 
-       G721ToULawConverter();
1561
 
-       virtual ~G721ToULawConverter();
1562
 
-
1563
 
-       virtual void reset();
1564
 
-       virtual char* convert( char* In, int nBytesIn, int& nBytesOut );
1565
 
-};
1566
 
-
1567
 
-G721ToULawConverter::G721ToULawConverter()
1568
 
-{
1569
 
-       reset();
1570
 
-}
1571
 
-
1572
 
-G721ToULawConverter::~G721ToULawConverter()
1573
 
-{
1574
 
-}
1575
 
-
1576
 
-void G721ToULawConverter::reset()
1577
 
-{
1578
 
-       g72x_init_state( &m_aState );
1579
 
-}
1580
 
-
1581
 
-char* G721ToULawConverter::convert(
1582
 
-       char* pBuffer,
1583
 
-       int nBytesIn,
1584
 
-       int& nBytesOut )
1585
 
-{
1586
 
-       char* pRet = new char[ nBytesOut = nBytesIn*2 ];
1587
 
-       for( int m=0; m < nBytesOut; m++ )
1588
 
-               pRet[ m ] = (g721_decoder(
1589
 
-                       m & 1 ? pBuffer[ m/2 ] >> 4 : pBuffer[ m/2 ] & 0x0f,
1590
 
-                       AUDIO_ENCODING_ULAW,
1591
 
-                       &m_aState ) & 0xff);
1592
 
-
1593
 
-       return pRet;
1594
 
-}
1595
 
-
1596
 
-AudioConverter* AudioConverter::createG721ToULawConverter()
1597
 
-{
1598
 
-       return new G721ToULawConverter;
1599
 
-}
1600
 
-
1601
 
-
1602
 
-class INT8ToUINT16Converter : public AudioConverter
1603
 
-{
1604
 
-public:
1605
 
-       INT8ToUINT16Converter() {}
1606
 
-       virtual ~INT8ToUINT16Converter();
1607
 
-
1608
 
-       virtual void reset();
1609
 
-       virtual char* convert( char* In, int nBytesIn, int& nBytesOut );
1610
 
-};
1611
 
-
1612
 
-INT8ToUINT16Converter::~INT8ToUINT16Converter()
1613
 
-{
1614
 
-}
1615
 
-
1616
 
-void INT8ToUINT16Converter::reset()
1617
 
-{
1618
 
-}
1619
 
-
1620
 
-char* INT8ToUINT16Converter::convert( char* pBuffer, int nBytesIn, int& nBytesOut )
1621
 
-{
1622
 
-       unsigned short* pShorts = new unsigned short[ nBytesIn ];
1623
 
-       nBytesOut = 2*nBytesIn;
1624
 
-
1625
 
-       for( int i=0; i < nBytesIn; i++ )
1626
 
-       {
1627
 
-               signed char cByte = pBuffer[ i ];
1628
 
-               int nValue = cByte;
1629
 
-               nValue += 128;
1630
 
-               pShorts[ i ] = 257*nValue;
1631
 
-       } 
1632
 
-       return (char*)pShorts;
1633
 
-}
1634
 
-
1635
 
-AudioConverter* AudioConverter::createINT8ToUINT16Converter()
1636
 
-{
1637
 
-       return new INT8ToUINT16Converter();
1638
 
-}
1639
 
-
1640
 
-class SwapINT16Converter : public AudioConverter
1641
 
-{
1642
 
-public:
1643
 
-       SwapINT16Converter() {}
1644
 
-       virtual ~SwapINT16Converter();
1645
 
-
1646
 
-       virtual void reset();
1647
 
-       virtual char* convert( char* In, int nBytesIn, int& nBytesOut );
1648
 
-};
1649
 
-
1650
 
-SwapINT16Converter::~SwapINT16Converter()
1651
 
-{
1652
 
-}
1653
 
-
1654
 
-void SwapINT16Converter::reset()
1655
 
-{
1656
 
-}
1657
 
-
1658
 
-char* SwapINT16Converter::convert( char* In, int nBytesIn, int& nBytesOut )
1659
 
-{
1660
 
-       char* pRet = new char[ nBytesOut = nBytesIn ];
1661
 
-
1662
 
-       for( int i = 0; i < nBytesIn; i+=2 )
1663
 
-       {
1664
 
-               pRet[ i   ] = In[ i+1 ];
1665
 
-               pRet[ i+1 ] = In[ i ];
1666
 
-       }
1667
 
-       return pRet;
1668
 
-}
1669
 
-
1670
 
-AudioConverter* AudioConverter::createSwapINT16Converter()
1671
 
-{
1672
 
-       return new SwapINT16Converter();
1673
 
-}
1674
 
Index: vcl/unx/source/app/devaudiosound.cxx
1675
 
===================================================================
1676
 
RCS file: vcl/unx/source/app/devaudiosound.cxx
1677
 
diff -N vcl/unx/source/app/devaudiosound.cxx
1678
 
--- vcl/unx/source/app/devaudiosound.cxx        27 Jun 2007 20:45:27 -0000      1.15
1679
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
1680
 
@@ -1,547 +0,0 @@
1681
 
-/*************************************************************************
1682
 
- *
1683
 
- *  OpenOffice.org - a multi-platform office productivity suite
1684
 
- *
1685
 
- *  $RCSfile: devaudiosound.cxx,v $
1686
 
- *
1687
 
- *  $Revision: 1.15 $
1688
 
- *
1689
 
- *  last change: $Author: hr $ $Date: 2007/06/27 20:45:27 $
1690
 
- *
1691
 
- *  The Contents of this file are made available subject to
1692
 
- *  the terms of GNU Lesser General Public License Version 2.1.
1693
 
- *
1694
 
- *
1695
 
- *    GNU Lesser General Public License Version 2.1
1696
 
- *    =============================================
1697
 
- *    Copyright 2005 by Sun Microsystems, Inc.
1698
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
1699
 
- *
1700
 
- *    This library is free software; you can redistribute it and/or
1701
 
- *    modify it under the terms of the GNU Lesser General Public
1702
 
- *    License version 2.1, as published by the Free Software Foundation.
1703
 
- *
1704
 
- *    This library is distributed in the hope that it will be useful,
1705
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
1706
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1707
 
- *    Lesser General Public License for more details.
1708
 
- *
1709
 
- *    You should have received a copy of the GNU Lesser General Public
1710
 
- *    License along with this library; if not, write to the Free Software
1711
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1712
 
- *    MA  02111-1307  USA
1713
 
- *
1714
 
- ************************************************************************/
1715
 
-
1716
 
-// MARKER(update_precomp.py): autogen include statement, do not remove
1717
 
-#include "precompiled_vcl.hxx"
1718
 
-
1719
 
-#include <salsound.h>
1720
 
-#include <salimpsound.hxx>
1721
 
-
1722
 
-#include <vcl/svapp.hxx>
1723
 
-
1724
 
-#ifdef USE_DEVAUDIO
1725
 
-
1726
 
-#include <sys/types.h>
1727
 
-#include <sys/stat.h>
1728
 
-#include <fcntl.h>
1729
 
-#include <stdio.h>
1730
 
-#include <unistd.h>
1731
 
-#include <string.h>
1732
 
-#include <sys/ioctl.h>
1733
 
-#include <sys/audioio.h>
1734
 
-#include <errno.h>
1735
 
-
1736
 
-#ifndef _SAL_TYPES_H_
1737
 
-#include <sal/types.h>
1738
 
-#endif
1739
 
-
1740
 
-using namespace vcl_sal;
1741
 
-using namespace vos;
1742
 
-using namespace osl;
1743
 
-
1744
 
-int                                                                    DevAudioSound::s_nDevice = -1;
1745
 
-DevAudioDataList                                       DevAudioSound::s_aDataList;
1746
 
-osl::Mutex                                                     DevAudioSound::s_aProtector;
1747
 
-DevAudioSoundList                                      DevAudioSound::s_aSounds;
1748
 
-
1749
 
-static const char* getAudioDevName()
1750
 
-{
1751
 
-    static const char* pDev = NULL;
1752
 
-    if( ! pDev )
1753
 
-    {
1754
 
-        pDev = getenv( "AUDIODEV" );
1755
 
-        if( ! pDev || ! *pDev )
1756
 
-            pDev = "/dev/audio";
1757
 
-    }
1758
 
-    return pDev;
1759
 
-}
1760
 
-
1761
 
-BOOL DevAudioSound::open()
1762
 
-{
1763
 
-       MutexGuard aGuard( s_aProtector );
1764
 
-       if( s_nDevice == -1 )
1765
 
-       {
1766
 
-               s_nDevice = ::open( getAudioDevName(), O_WRONLY | O_NDELAY );
1767
 
-               if( s_nDevice == -1 )
1768
 
-               {
1769
 
-                       SalDbgAssert( "ERROR: could not open %s, errno=%d\n", getAudioDevName(), errno );
1770
 
-                       return FALSE;
1771
 
-               }
1772
 
-#if OSL_DEBUG_LEVEL > 1
1773
 
-               audio_device_t aDevice;
1774
 
-               if( ! ioctl( s_nDevice, AUDIO_GETDEV, &aDevice ) )
1775
 
-                 SalDbgAssert( "\nopened %s of type:\nName: %s\nVersion: %s\nConfig: %s\n\n",
1776
 
-                          getAudioDevName(), aDevice.name, aDevice.version, aDevice.config );
1777
 
-#endif
1778
 
-       }
1779
 
-       else
1780
 
-       {
1781
 
-               // sadly there is no documented reset control for /dev/audio
1782
 
-               // ioctl( s_nDevice, SNDCTL_DSP_RESET, 0 );
1783
 
-       }
1784
 
-       return TRUE;
1785
 
-}
1786
 
-
1787
 
-void DevAudioSound::close()
1788
 
-{
1789
 
-       MutexGuard aGuard( s_aProtector );
1790
 
-       if( s_nDevice != -1 )
1791
 
-       {
1792
 
-         ioctl( s_nDevice, AUDIO_DRAIN, NULL );
1793
 
-               ::close( s_nDevice );
1794
 
-       }
1795
 
-       s_nDevice = -1;
1796
 
-}
1797
 
-
1798
 
-BOOL DevAudioSound::startSound( DevAudioData* pData )
1799
 
-{
1800
 
-       if( pData && pData->m_pSound && pData->m_pSound->m_pBuffer &&
1801
 
-               s_nDevice >= 0 )
1802
 
-       {
1803
 
-               if( ! strncmp( pData->m_pSound->m_pBuffer, ".snd", 4 ) )
1804
 
-                       return startAU( pData );
1805
 
-               else if( ! strncmp( pData->m_pSound->m_pBuffer, "RIFF", 4 ) )
1806
 
-                       return startRIFF( pData );
1807
 
-       }
1808
 
-       return FALSE;
1809
 
-}
1810
 
-
1811
 
-BOOL DevAudioSound::startAU( DevAudioData* pData )
1812
 
-{
1813
 
-       char* pBuffer = pData->m_pSound->m_pBuffer;
1814
 
-       ULONG nDataOffset       = readBELong( pBuffer + 4 );
1815
 
-       ULONG nDataLen          = readBELong( pBuffer + 8 );
1816
 
-       ULONG nEncoding         = readBELong( pBuffer + 12 );
1817
 
-       ULONG nSampleRate       = readBELong( pBuffer + 16 );
1818
 
-       ULONG nChannels         = readBELong( pBuffer + 20 );
1819
 
-
1820
 
-       if( nDataLen == ~0 )
1821
 
-               nDataLen = pData->m_pSound->m_aStat.st_size - nDataOffset;
1822
 
-
1823
 
-       pData->m_nDataLen       = nDataLen;
1824
 
-       pData->m_nStartPos      = nDataOffset;
1825
 
-       pData->m_nEndPos        = pData->m_nStartPos + pData->m_nDataLen;
1826
 
-
1827
 
-       if( nChannels != 1 && nChannels != 2 )
1828
 
-       {
1829
 
-               SalDbgAssert( "%d Channels are not supported\n" );
1830
 
-               return FALSE;
1831
 
-       }
1832
 
-
1833
 
-       audio_info_t aAudioInfo;
1834
 
-       AUDIO_INITINFO( &aAudioInfo );
1835
 
-
1836
 
-       aAudioInfo.play.gain                    = 127;
1837
 
-       aAudioInfo.play.channels                = nChannels;
1838
 
-       aAudioInfo.play.sample_rate             = nSampleRate;
1839
 
-       switch( nEncoding )
1840
 
-       {
1841
 
-               case 1:
1842
 
-                       aAudioInfo.play.encoding = AUDIO_ENCODING_ULAW;
1843
 
-                       break;
1844
 
-               case 2:
1845
 
-                       aAudioInfo.play.precision       = 8;
1846
 
-                       aAudioInfo.play.encoding        = AUDIO_ENCODING_LINEAR;
1847
 
-                       break;
1848
 
-               case 3:
1849
 
-                       aAudioInfo.play.precision       = 16;
1850
 
-                       aAudioInfo.play.encoding        = AUDIO_ENCODING_LINEAR;
1851
 
-                       break;
1852
 
-               case 23:
1853
 
-                       aAudioInfo.play.encoding        = AUDIO_ENCODING_ULAW;
1854
 
-                       pData->m_pConverter = AudioConverter::createG721ToULawConverter();
1855
 
-                       break;
1856
 
-               default:
1857
 
-                       SalDbgAssert( "au format %d unsupported\n", nEncoding );
1858
 
-                       return FALSE;
1859
 
-       };
1860
 
-
1861
 
-       if( ioctl( s_nDevice, AUDIO_SETINFO, &aAudioInfo ) )
1862
 
-       {
1863
 
-               SalDbgAssert( "ERROR: ioctl AUDIO_SETINFO failed\n" );
1864
 
-               return FALSE;
1865
 
-       }
1866
 
-
1867
 
-       SalDbgAssert( "playing %d data bytes at %d bytes/s in format %d on %d channels \n", pData->m_nDataLen, nSampleRate, nEncoding, nChannels );
1868
 
-       return TRUE;
1869
 
-}
1870
 
-
1871
 
-BOOL DevAudioSound::startRIFF( DevAudioData* pData )
1872
 
-{
1873
 
-       int nPos = findChunk( pData, "fmt " );
1874
 
-       if( nPos == -1 )
1875
 
-               return FALSE;
1876
 
-
1877
 
-       int nFormat             = readLEShort( pData->m_pSound->m_pBuffer + nPos + 8 );
1878
 
-       int nChannels   = readLEShort( pData->m_pSound->m_pBuffer + nPos + 10 );
1879
 
-       int nSampleRate = readLEInt( pData->m_pSound->m_pBuffer + nPos + 12 );
1880
 
-       int nByteRate   = readLEInt( pData->m_pSound->m_pBuffer + nPos + 16 );
1881
 
-       int nAlign              = readLEShort( pData->m_pSound->m_pBuffer + nPos + 20 );
1882
 
-       SalDbgAssert( "format is tag = %x, channels = %d, samplesPerSec = %d, avgBytesPerSec = %d, blockAlign = %d\n", nFormat, nChannels, nSampleRate, nByteRate, nAlign );
1883
 
-       if( nChannels != 1 && nChannels != 2 )
1884
 
-       {
1885
 
-               SalDbgAssert( "%d Channels are not supported\n" );
1886
 
-               return FALSE;
1887
 
-       }
1888
 
-
1889
 
-       int nBitsPerSample = 0;
1890
 
-       switch( nFormat )
1891
 
-       {
1892
 
-               default:
1893
 
-                       SalDbgAssert( "unknown format\n" );
1894
 
-                       return FALSE;
1895
 
-               case 1:
1896
 
-                       nBitsPerSample = readLEShort( pData->m_pSound->m_pBuffer + nPos + 22 );
1897
 
-                       break;
1898
 
-       }
1899
 
-
1900
 
-       nPos = findChunk( pData, "data" );
1901
 
-       if( nPos == -1 )
1902
 
-       {
1903
 
-               SalDbgAssert( "ERROR: no \"data\" chunk found\n" );
1904
 
-               return FALSE;
1905
 
-       }
1906
 
-
1907
 
-       pData->m_nDataLen = readLEInt( pData->m_pSound->m_pBuffer + nPos + 4 );
1908
 
-       pData->m_nStartPos = nPos+8;
1909
 
-       pData->m_nEndPos = pData->m_nStartPos + pData->m_nDataLen;
1910
 
-
1911
 
-       audio_info_t aAudioInfo;
1912
 
-       AUDIO_INITINFO( &aAudioInfo );
1913
 
-
1914
 
-       aAudioInfo.play.gain                    = 127;
1915
 
-       aAudioInfo.play.channels                = nChannels;
1916
 
-       aAudioInfo.play.sample_rate             = nSampleRate;
1917
 
-       switch( nBitsPerSample )
1918
 
-       {
1919
 
-               case 8:
1920
 
-#if defined SOLARIS && defined SPARC
1921
 
-                       aAudioInfo.play.precision       = 16;
1922
 
-                       aAudioInfo.play.encoding        = AUDIO_ENCODING_LINEAR;
1923
 
-                       pData->m_pConverter = AudioConverter::createINT8ToUINT16Converter();
1924
 
-#else
1925
 
-                       aAudioInfo.play.precision       = 8;
1926
 
-                       aAudioInfo.play.encoding        = AUDIO_ENCODING_LINEAR;
1927
 
-#endif
1928
 
-                       break;
1929
 
-               case 16:
1930
 
-                       aAudioInfo.play.precision       = 16;
1931
 
-                       aAudioInfo.play.encoding        = AUDIO_ENCODING_LINEAR;
1932
 
-#ifdef SPARC
1933
 
-                       pData->m_pConverter = AudioConverter::createSwapINT16Converter();
1934
 
-#endif
1935
 
-                       break;
1936
 
-               default:
1937
 
-                       SalDbgAssert( "%d bits per sample is not usable\n", nBitsPerSample );
1938
 
-                       return FALSE;
1939
 
-       };
1940
 
-
1941
 
-       if( ioctl( s_nDevice, AUDIO_SETINFO, &aAudioInfo ) )
1942
 
-       {
1943
 
-               SalDbgAssert( "ERROR: ioctl AUDIO_SETINFO failed\n" );
1944
 
-               return FALSE;
1945
 
-       }
1946
 
-
1947
 
-       SalDbgAssert( "playing %d data bytes at %d bytes/s in %d bits quality on %d channels \n", pData->m_nDataLen, nSampleRate, nBitsPerSample, nChannels );
1948
 
-       return TRUE;
1949
 
-}
1950
 
-
1951
 
-int DevAudioSound::findChunk( DevAudioData* pData, const char* pChunk )
1952
 
-{
1953
 
-       if( !pData || ! pData->m_pSound || ! pData->m_pSound->m_pBuffer )
1954
 
-               return -1;
1955
 
-
1956
 
-       int nPos = 12;
1957
 
-       while( nPos < pData->m_pSound->m_aStat.st_size )
1958
 
-       {
1959
 
-               if( ! strncmp( pData->m_pSound->m_pBuffer+nPos, pChunk, 4 ) )
1960
 
-                       return nPos;
1961
 
-
1962
 
-               // get LSB int length
1963
 
-               nPos += readLEInt( pData->m_pSound->m_pBuffer+nPos+4 ) + 8;
1964
 
-       }
1965
 
-       return -1;
1966
 
-}
1967
 
-
1968
 
-short int DevAudioSound::readLEShort( const char* pBuf )
1969
 
-{
1970
 
-       const unsigned char* pBuffer = (const unsigned char*)pBuf;
1971
 
-       short int nRet = *pBuffer++;
1972
 
-       nRet |= *pBuffer << 8;
1973
 
-
1974
 
-       return nRet;
1975
 
-}
1976
 
-
1977
 
-ULONG DevAudioSound::readBELong( const char* pBuf )
1978
 
-{
1979
 
-       const unsigned char* pBuffer = (const unsigned char*)pBuf;
1980
 
-       ULONG nRet       = *pBuffer++ << 24;
1981
 
-       nRet            |= *pBuffer++ << 16;
1982
 
-       nRet            |= *pBuffer++ << 8;
1983
 
-       nRet            |= *pBuffer;
1984
 
-
1985
 
-       return nRet;
1986
 
-}
1987
 
-
1988
 
-int DevAudioSound::readLEInt( const char* pBuf )
1989
 
-{
1990
 
-       const unsigned char* pBuffer = (const unsigned char*)pBuf;
1991
 
-       int nRet = *pBuffer++;
1992
 
-       nRet |= (int)(*pBuffer++) << 8;
1993
 
-       nRet |= (int)(*pBuffer++) << 16;
1994
 
-       nRet |= (int)(*pBuffer++) << 24;
1995
 
-
1996
 
-       return nRet;
1997
 
-}
1998
 
-
1999
 
-static oslThread aThreadWorker= NULL;
2000
 
-extern "C" {
2001
 
-    void SAL_CALL DevAudioThreadWorker(void*)
2002
 
-    {
2003
 
-        DevAudioSound::run();
2004
 
-    }
2005
 
-}
2006
 
-
2007
 
-void DevAudioSound::run()
2008
 
-{
2009
 
-       SalDbgAssert( "DevAudioWorker::run\n" );
2010
 
-       DevAudioData* pData;
2011
 
-    if( open() )
2012
 
-    {
2013
 
-        do
2014
 
-        {
2015
 
-            ResettableMutexGuard aGuard( s_aProtector );
2016
 
-            pData = s_aDataList.Count() ? s_aDataList.GetObject( 0 ) : NULL;
2017
 
-            if( ! pData )
2018
 
-                break;
2019
 
-
2020
 
-            bool bDataValid = true;
2021
 
-            if( startSound( pData ) )
2022
 
-            {
2023
 
-                pData->m_nCurPos = pData->m_nStartPos;
2024
 
-                while( pData->m_nCurPos < pData->m_nEndPos )
2025
 
-                {
2026
 
-                    int nBytes = 4096;
2027
 
-
2028
 
-                    char* pBuffer = pData->m_pSound->m_pBuffer;
2029
 
-
2030
 
-                    if( pData->m_nCurPos + nBytes > pData->m_nEndPos )
2031
 
-                        nBytes = pData->m_nEndPos - pData->m_nCurPos;
2032
 
-
2033
 
-                    if( pData->m_pConverter )
2034
 
-                    {
2035
 
-                        int nBytesOut;
2036
 
-                        char* pConvBuffer = pData->m_pConverter->convert( pBuffer + pData->m_nCurPos, nBytes, nBytesOut );
2037
 
-                        write( s_nDevice, pConvBuffer, nBytesOut );
2038
 
-                        delete pConvBuffer;
2039
 
-                    }
2040
 
-                    else
2041
 
-                    {
2042
 
-                        nBytes = write( s_nDevice,
2043
 
-                                        pBuffer + pData->m_nCurPos, nBytes );
2044
 
-                    }
2045
 
-                    pData->m_nCurPos += nBytes;
2046
 
-
2047
 
-                    aGuard.clear();
2048
 
-                    TimeValue aVal;
2049
 
-                    aVal.Seconds = 0;
2050
 
-                    aVal.Nanosec = 50000000;
2051
 
-                    osl_waitThread( &aVal );
2052
 
-                    aGuard.reset();
2053
 
-
2054
 
-                    if( s_aDataList.GetObject( 0 ) != pData )
2055
 
-                    {
2056
 
-                        bDataValid = false;
2057
 
-                        break;
2058
 
-                    }
2059
 
-                }
2060
 
-                if( bDataValid )
2061
 
-                {
2062
 
-                    if( pData->m_pSound->m_pSalSound->m_bLoop )
2063
 
-                        pData->m_pSound->play();
2064
 
-                    else
2065
 
-                    {
2066
 
-                        // /dev/audio does not seem to have a mechanism to request
2067
 
-                        // wether the device is actually playing. Therefore
2068
 
-                        // we need to synchronzie before signaling sound stop
2069
 
-                        ioctl( s_nDevice, AUDIO_DRAIN, NULL );
2070
 
-                        Application::PostUserEvent( LINK( pData->m_pSound, DevAudioSound, notifyStopHdl ), NULL );
2071
 
-                    }
2072
 
-                }
2073
 
-            }
2074
 
-            else
2075
 
-                               Application::PostUserEvent( LINK( pData->m_pSound, DevAudioSound, notifyErrorHdl ), (void*)SOUNDERR_INVALID_FILE );
2076
 
-
2077
 
-            s_aDataList.Remove( pData );
2078
 
-            delete pData;
2079
 
-        } while( pData );
2080
 
-        close();
2081
 
-    }
2082
 
-
2083
 
-    MutexGuard aGuard( s_aProtector );
2084
 
-    osl_destroyThread( aThreadWorker );
2085
 
-    aThreadWorker = NULL;
2086
 
-}
2087
 
-
2088
 
-void DevAudioSound::append( DevAudioSound* pSound )
2089
 
-{
2090
 
-       MutexGuard aGuard( s_aProtector );
2091
 
-       s_aDataList.Insert( new DevAudioData( pSound ), LIST_APPEND );
2092
 
-       if( ! aThreadWorker )
2093
 
-        aThreadWorker = osl_createThread( DevAudioThreadWorker, NULL );
2094
 
-}
2095
 
-
2096
 
-void DevAudioSound::remove( DevAudioSound* pSound )
2097
 
-{
2098
 
-       MutexGuard aGuard( s_aProtector );
2099
 
-       DevAudioData* pData;
2100
 
-       for( int i = s_aDataList.Count()-1; i >= 0; i-- )
2101
 
-       {
2102
 
-               pData = s_aDataList.GetObject( i );
2103
 
-               if( pData->m_pSound == pSound )
2104
 
-               {
2105
 
-                       s_aDataList.Remove( i );
2106
 
-                       if( i > 0 )
2107
 
-                               delete pData;
2108
 
-               }
2109
 
-       }
2110
 
-}
2111
 
-
2112
 
-DevAudioSound::DevAudioSound( ::X11SalSound* pSound ) :
2113
 
-               VSound( pSound )
2114
 
-{
2115
 
-       initBuffer();
2116
 
-       s_aSounds.Insert( this );
2117
 
-}
2118
 
-
2119
 
-DevAudioSound::~DevAudioSound()
2120
 
-{
2121
 
-       stop();
2122
 
-       if( m_pBuffer )
2123
 
-               releaseBuffer();
2124
 
-       s_aSounds.Remove( this );
2125
 
-}
2126
 
-
2127
 
-BOOL DevAudioSound::isValid()
2128
 
-{
2129
 
-       if( ! m_pBuffer )
2130
 
-               return FALSE;
2131
 
-
2132
 
-    if( s_nDevice == -1 )
2133
 
-    {
2134
 
-        int nTryOpen = ::open( getAudioDevName(), O_WRONLY | O_NDELAY );
2135
 
-        if( nTryOpen == -1 )
2136
 
-            return FALSE;
2137
 
-        ::close( nTryOpen );
2138
 
-    }
2139
 
-
2140
 
-       // check for valid file format
2141
 
-       if( ! strncmp( "RIFF", m_pBuffer, 4 ) )
2142
 
-       {
2143
 
-               DevAudioData aData( this );
2144
 
-
2145
 
-               // check for data chunk
2146
 
-               if( findChunk( &aData, "data" ) == -1 )
2147
 
-                       goto failed;
2148
 
-               int nPos = findChunk( &aData, "fmt " );
2149
 
-               if( nPos == -1 )
2150
 
-                       goto failed;
2151
 
-
2152
 
-               int nFormat             = readLEShort( m_pBuffer + nPos + 8 );
2153
 
-               int nChannels   = readLEShort( m_pBuffer + nPos + 10 );
2154
 
-               // check channels
2155
 
-               if( nChannels != 1 && nChannels != 2 )
2156
 
-                       goto failed;
2157
 
-               // check formats
2158
 
-               // playable is MS-PCM only at now
2159
 
-               if( nFormat != 1 )
2160
 
-                       goto failed;
2161
 
-               return TRUE;
2162
 
-       }
2163
 
-       else if( ! strncmp( ".snd", m_pBuffer, 4 ) )
2164
 
-       {
2165
 
-               ULONG nEncoding         = readBELong( m_pBuffer + 12 );
2166
 
-               ULONG nChannels         = readBELong( m_pBuffer + 20 );
2167
 
-
2168
 
-               // check for playable encodings
2169
 
-               if( nEncoding != 1 && nEncoding != 2 && nEncoding != 3 && nEncoding != 23 )
2170
 
-                       goto failed;
2171
 
-               // check channels
2172
 
-               if( nChannels != 1 && nChannels != 2 )
2173
 
-                       goto failed;
2174
 
-               return TRUE;
2175
 
-       }
2176
 
-  failed:
2177
 
-       releaseBuffer();
2178
 
-       return FALSE;
2179
 
-}
2180
 
-
2181
 
-void DevAudioSound::play()
2182
 
-{
2183
 
-       if( ! m_pBuffer )
2184
 
-               return;
2185
 
-
2186
 
-       append( this );
2187
 
-       m_pSalSound->m_bPlaying = TRUE;
2188
 
-       m_pSalSound->m_bPaused  = FALSE;
2189
 
-}
2190
 
-
2191
 
-void DevAudioSound::stop()
2192
 
-{
2193
 
-       remove( this );
2194
 
-       m_pSalSound->m_bPlaying = FALSE;
2195
 
-       m_pSalSound->m_bPaused  = FALSE;
2196
 
-}
2197
 
-
2198
 
-void DevAudioSound::pause()
2199
 
-{
2200
 
-       remove( this );
2201
 
-       m_pSalSound->m_bPaused = TRUE;
2202
 
-}
2203
 
-
2204
 
-void DevAudioSound::cont()
2205
 
-{
2206
 
-       play();
2207
 
-}
2208
 
-
2209
 
-IMPL_LINK( DevAudioSound, notifyStopHdl, void*, EMPTYARG )
2210
 
-{
2211
 
-       if( s_aSounds.GetPos( this ) != LIST_ENTRY_NOTFOUND )
2212
 
-       {
2213
 
-               m_pSalSound->changeStateStop();
2214
 
-       }
2215
 
-       return 0;
2216
 
-}
2217
 
-
2218
 
-IMPL_LINK( DevAudioSound, notifyErrorHdl, void*, nError )
2219
 
-{
2220
 
-       if( s_aSounds.GetPos( this ) != LIST_ENTRY_NOTFOUND )
2221
 
-       {
2222
 
-               m_pSalSound->setError( (ULONG)nError );
2223
 
-       }
2224
 
-       return 0;
2225
 
-}
2226
 
-
2227
 
-#endif
2228
 
Index: vcl/unx/source/app/makefile.mk
2229
 
===================================================================
2230
 
RCS file: /cvs/gsl/vcl/unx/source/app/makefile.mk,v
2231
 
retrieving revision 1.28
2232
 
retrieving revision 1.28.16.1
2233
 
diff -u -p -u -p -r1.28 -r1.28.16.1
2234
 
--- vcl/unx/source/app/makefile.mk      31 Jul 2007 13:01:37 -0000      1.28
2235
 
+++ vcl/unx/source/app/makefile.mk      31 Aug 2007 09:44:58 -0000      1.28.16.1
2236
 
@@ -69,13 +69,7 @@ SLOFILES=\
2237
 
                        $(SLO)$/soicon.obj                      \
2238
 
                        $(SLO)$/sm.obj                          \
2239
 
                        $(SLO)$/keysymnames.obj         \
2240
 
-                       $(SLO)$/wmadaptor.obj           \
2241
 
-                       $(SLO)$/salsound2.obj           \
2242
 
-                       $(SLO)$/osssound.obj            \
2243
 
-                       $(SLO)$/devaudiosound.obj               \
2244
 
-                       $(SLO)$/audioconvert.obj                \
2245
 
-                       $(SLO)$/rptpsound.obj           \
2246
 
-                       $(SLO)$/nassound.obj            
2247
 
+                       $(SLO)$/wmadaptor.obj
2248
 
 
2249
 
 EXCEPTIONSFILES=\
2250
 
                        $(SLO)$/wmadaptor.obj           \
2251
 
@@ -87,22 +81,6 @@ EXCEPTIONSFILES=\
2252
 
             $(SLO)$/salsys.obj
2253
 
 
2254
 
 
2255
 
-.IF "$(ENABLE_NAS)" != ""
2256
 
-CDEFS+=-DUSE_NAS
2257
 
-.ENDIF
2258
 
-
2259
 
-.IF "$(ENABLE_PASF)" != ""
2260
 
-CDEFS+=-DUSE_PASF -DPA_VER=$(PA_VER)
2261
 
-SLOFILES+=$(SLO)$/pasfsound.obj
2262
 
-.IF "$(SYSTEM_SNDFILE)" == "YES"
2263
 
-CDEFS+=-DSYSTEM_SNDFILE
2264
 
-CFLAGS+=$(SNDFILE_CFLAGS)
2265
 
-.ENDIF
2266
 
-.IF "$(SYSTEM_PORTAUDIO)" == "YES"
2267
 
-CDEFS+=-DSYSTEM_PORTAUDIO
2268
 
-.ENDIF
2269
 
-.ENDIF
2270
 
-
2271
 
 .IF "$(WITH_LIBSN)"=="YES"
2272
 
 CDEFS+=-DHAVE_LIBSN
2273
 
 CFLAGS+=$(LIBSN_CFLAGS)
2274
 
Index: vcl/unx/source/app/nassound.cxx
2275
 
===================================================================
2276
 
RCS file: vcl/unx/source/app/nassound.cxx
2277
 
diff -N vcl/unx/source/app/nassound.cxx
2278
 
--- vcl/unx/source/app/nassound.cxx     17 Sep 2006 12:33:50 -0000      1.10
2279
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
2280
 
@@ -1,278 +0,0 @@
2281
 
-/*************************************************************************
2282
 
- *
2283
 
- *  OpenOffice.org - a multi-platform office productivity suite
2284
 
- *
2285
 
- *  $RCSfile: nassound.cxx,v $
2286
 
- *
2287
 
- *  $Revision: 1.10 $
2288
 
- *
2289
 
- *  last change: $Author: obo $ $Date: 2006/09/17 12:33:50 $
2290
 
- *
2291
 
- *  The Contents of this file are made available subject to
2292
 
- *  the terms of GNU Lesser General Public License Version 2.1.
2293
 
- *
2294
 
- *
2295
 
- *    GNU Lesser General Public License Version 2.1
2296
 
- *    =============================================
2297
 
- *    Copyright 2005 by Sun Microsystems, Inc.
2298
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
2299
 
- *
2300
 
- *    This library is free software; you can redistribute it and/or
2301
 
- *    modify it under the terms of the GNU Lesser General Public
2302
 
- *    License version 2.1, as published by the Free Software Foundation.
2303
 
- *
2304
 
- *    This library is distributed in the hope that it will be useful,
2305
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
2306
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2307
 
- *    Lesser General Public License for more details.
2308
 
- *
2309
 
- *    You should have received a copy of the GNU Lesser General Public
2310
 
- *    License along with this library; if not, write to the Free Software
2311
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2312
 
- *    MA  02111-1307  USA
2313
 
- *
2314
 
- ************************************************************************/
2315
 
-
2316
 
-// MARKER(update_precomp.py): autogen include statement, do not remove
2317
 
-#include "precompiled_vcl.hxx"
2318
 
-#include <salimpsound.hxx>
2319
 
-#include <salsound.h>
2320
 
-
2321
 
-#ifdef USE_NAS
2322
 
-
2323
 
-#define INT8 AU_INT8
2324
 
-#include <audio/audiolib.h>
2325
 
-#include <audio/soundlib.h>
2326
 
-#undef INT8
2327
 
-
2328
 
-#include <salunx.h>
2329
 
-#include <saldata.hxx>
2330
 
-#include <saldisp.hxx>
2331
 
-
2332
 
-#include <unistd.h>
2333
 
-
2334
 
-using namespace vcl_sal;
2335
 
-using namespace vos;
2336
 
-
2337
 
-BOOL                                           NASSound::s_bFailedOnce = FALSE;
2338
 
-NASSound::NASSoundList         NASSound::s_aSounds;
2339
 
-void*                                          NASSound::s_pServer = NULL;
2340
 
-
2341
 
-void NASSound::callback( void*, void*, void* event, void* pThis )
2342
 
-{
2343
 
-       SalDbgAssert( "NASSound::callback called\n" );
2344
 
-
2345
 
-       NASSound* pSound = (NASSound*)pThis;
2346
 
-       if( s_aSounds.GetPos( pSound ) != LIST_ENTRY_NOTFOUND )
2347
 
-       {
2348
 
-               AuEvent* pEvent = (AuEvent*)event;
2349
 
-               SalDbgAssert( "   on event type %d\n", pEvent->type );
2350
 
-               if( pSound->m_pSalSound &&
2351
 
-                       pEvent->type == AuEventTypeElementNotify )
2352
 
-               {
2353
 
-                       switch( pEvent->auelementnotify.cur_state )
2354
 
-                       {
2355
 
-                               case AuStateStop:
2356
 
-                               {
2357
 
-                                       pSound->m_nFlowID = 0;
2358
 
-                                       pSound->m_pSalSound->changeStateStop();
2359
 
-                                       break;
2360
 
-                               }
2361
 
-                               case AuStatePause:
2362
 
-                                       pSound->m_pSalSound->changeStatePause();
2363
 
-                                       break;
2364
 
-                               case AuStateStart:
2365
 
-                                       pSound->m_pSalSound->changeStateCont();
2366
 
-                                       break;
2367
 
-                               default:
2368
 
-                                       break;
2369
 
-                       }
2370
 
-               }
2371
 
-       }
2372
 
-       else
2373
 
-               SalDbgAssert( "NASSound %p is adressed in callback but unknown !\n", pSound );
2374
 
-}
2375
 
-
2376
 
-BOOL NASSound::connect()
2377
 
-{
2378
 
-       if( ! s_pServer && ! s_bFailedOnce )
2379
 
-       {
2380
 
-               char* pServerMessage = NULL;
2381
 
-               s_pServer = AuOpenServer( NULL, 0, NULL, 0, NULL, &pServerMessage );
2382
 
-               if( ! s_pServer )
2383
 
-               {
2384
 
-                       SalDbgAssert( "AuOpenServer failed: %s\n",
2385
 
-                                                 pServerMessage ?
2386
 
-                                                 pServerMessage : "<unknown reason>" );
2387
 
-                       AuFree( pServerMessage );
2388
 
-                       s_bFailedOnce = TRUE;
2389
 
-               }
2390
 
-               else
2391
 
-               {
2392
 
-                       GetX11SalData()->GetLib()->Insert( AuServerConnectionNumber( (AuServer*)s_pServer ),
2393
 
-                                                                                       NULL,
2394
 
-                                                                                       (YieldFunc)pending,
2395
 
-                                                                                       (YieldFunc)queued,
2396
 
-                                                                                       (YieldFunc)handleEvents );
2397
 
-                       SalDbgAssert( "AudioConnectionNumber is %d, DisplayConnectionNumber is %d\n",
2398
 
-                                                 AuServerConnectionNumber( (AuServer*)s_pServer ),
2399
 
-                                                 ConnectionNumber( GetX11SalData()->GetDisplay()->GetDisplay() ) );
2400
 
-               }
2401
 
-       }
2402
 
-       return s_pServer ? TRUE : FALSE;
2403
 
-}
2404
 
-
2405
 
-void NASSound::disconnect()
2406
 
-{
2407
 
-       if( s_pServer )
2408
 
-       {
2409
 
-               GetX11SalData()->GetLib()->Remove( AuServerConnectionNumber( (AuServer*)s_pServer ) );
2410
 
-               AuCloseServer( (AuServer*)s_pServer );
2411
 
-               s_pServer = NULL;
2412
 
-       }
2413
 
-}
2414
 
-
2415
 
-int NASSound::pending( int, void* )
2416
 
-{
2417
 
-       return s_pServer ? AuEventsQueued( (AuServer*)s_pServer, AuEventsQueuedAlready ) : 0;
2418
 
-}
2419
 
-
2420
 
-int NASSound::queued( int fd, void* pDummy )
2421
 
-{
2422
 
-       return pending( fd, pDummy );
2423
 
-}
2424
 
-
2425
 
-int NASSound::handleEvents( int, void* )
2426
 
-{
2427
 
-       if( s_pServer )
2428
 
-       {
2429
 
-               for( int i = pending(0,0); i && s_pServer; i-- )
2430
 
-               {
2431
 
-                       AuEvent aEvent;
2432
 
-                       AuNextEvent( (AuServer*)s_pServer, AuTrue, &aEvent );
2433
 
-                       AuDispatchEvent( (AuServer*)s_pServer, &aEvent );
2434
 
-               }
2435
 
-       }
2436
 
-       return 1;
2437
 
-}
2438
 
-
2439
 
-NASSound::NASSound( ::X11SalSound* pSalSound ) :
2440
 
-               VSound( pSalSound ),
2441
 
-               m_nFlowID( 0 )
2442
 
-{
2443
 
-       s_aSounds.Insert( this );
2444
 
-}
2445
 
-
2446
 
-NASSound::~NASSound()
2447
 
-{
2448
 
-       s_aSounds.Remove( this );
2449
 
-       if( s_aSounds.Count() < 1 )
2450
 
-               disconnect();
2451
 
-}
2452
 
-
2453
 
-void NASSound::play()
2454
 
-{
2455
 
-       BOOL bStarted = FALSE;
2456
 
-
2457
 
-       if( ! s_pServer )
2458
 
-               connect();
2459
 
-       
2460
 
-       if( s_pServer && m_pSalSound )
2461
 
-       {
2462
 
-               AuFlowID aID;
2463
 
-               AuStatus aStatus;
2464
 
-               if( AuSoundPlayFromFile( (AuServer*)s_pServer,
2465
 
-                                                                m_pSalSound->m_aSoundFile.GetBuffer(),
2466
 
-                                                                AuNone,
2467
 
-                                                                AuFixedPointFromSum( 1, 0 ),
2468
 
-                                                                (void(*)(AuServer*,AuEventHandlerRec*,AuEvent*,void*))callback,
2469
 
-                                                                (AuPointer)this,
2470
 
-                                                                &aID,
2471
 
-                                                                NULL,
2472
 
-                                                                NULL,
2473
 
-                                                                &aStatus )
2474
 
-                       )
2475
 
-               {
2476
 
-                       SalDbgAssert( "AuSoundPlayFromFile yields flow id %d and status %d\n",
2477
 
-                                                 aID, aStatus );
2478
 
-
2479
 
-                       AuElementState aState;
2480
 
-                       aState.flow = aID;
2481
 
-                       aState.element_num = 0;
2482
 
-                       for( int n = 0; n < 20 && ! bStarted; n++ )
2483
 
-                       {
2484
 
-                TimeValue aVal;
2485
 
-                aVal.Seconds = 0;
2486
 
-                aVal.Nanosec = 20000000;
2487
 
-                osl_waitThread( &aVal );
2488
 
-                               AuHandleEvents( (AuServer*)s_pServer );
2489
 
-
2490
 
-                               int nStates = 1;
2491
 
-                               AuElementState* pState =
2492
 
-                                       AuGetElementStates( (AuServer*)s_pServer,
2493
 
-                                                                               &nStates,
2494
 
-                                                                               &aState,
2495
 
-                                                                               &aStatus );
2496
 
-                               if( pState )
2497
 
-                               {
2498
 
-                                       if( pState->state == AuStateStart )
2499
 
-                                               bStarted = TRUE;
2500
 
-                                       AuFreeElementStates( (AuServer*)s_pServer,
2501
 
-                                                                                1, pState );
2502
 
-                               }
2503
 
-                               else
2504
 
-                               {
2505
 
-                                       SalDbgAssert( "AuGetElementStates failed\n" );
2506
 
-                                       break;
2507
 
-                               }
2508
 
-                       }
2509
 
-
2510
 
-            if ( bStarted )
2511
 
-                           SalDbgAssert( "   sound started\n" );
2512
 
-            else
2513
 
-                           SalDbgAssert( "   sound failed to start\n" );
2514
 
-
2515
 
-                       m_pSalSound->m_bPlaying = bStarted;
2516
 
-                       if( bStarted )
2517
 
-                               m_nFlowID = aID;
2518
 
-               }
2519
 
-       }
2520
 
-
2521
 
-       if( ! bStarted && m_pSalSound )
2522
 
-               m_pSalSound->setError( SOUNDERR_INVALID_FILE );
2523
 
-}
2524
 
-
2525
 
-void NASSound::stop()
2526
 
-{
2527
 
-       if( s_pServer && m_nFlowID )
2528
 
-       {
2529
 
-               AuStopFlow( (AuServer*)s_pServer, m_nFlowID, NULL );
2530
 
-               m_nFlowID = 0;
2531
 
-       }
2532
 
-}
2533
 
-
2534
 
-void NASSound::pause()
2535
 
-{
2536
 
-       if( s_pServer && m_nFlowID )
2537
 
-               AuPauseFlow( (AuServer*)s_pServer, m_nFlowID, NULL );
2538
 
-}
2539
 
-
2540
 
-void NASSound::cont()
2541
 
-{
2542
 
-       if( s_pServer && m_nFlowID )
2543
 
-               AuStartFlow( (AuServer*)s_pServer, m_nFlowID, NULL );
2544
 
-}
2545
 
-
2546
 
-BOOL NASSound::isValid()
2547
 
-{
2548
 
-       if( ! m_pSalSound )
2549
 
-               return FALSE;
2550
 
-       if( ! s_pServer )
2551
 
-               connect();
2552
 
-       if( ! s_pServer )
2553
 
-               return FALSE;
2554
 
-
2555
 
-       return access( m_pSalSound->m_aSoundFile.GetBuffer(), R_OK ) ? FALSE : TRUE;
2556
 
-}
2557
 
-
2558
 
-#endif
2559
 
Index: vcl/unx/source/app/osssound.cxx
2560
 
===================================================================
2561
 
RCS file: vcl/unx/source/app/osssound.cxx
2562
 
diff -N vcl/unx/source/app/osssound.cxx
2563
 
--- vcl/unx/source/app/osssound.cxx     27 Jun 2007 20:46:05 -0000      1.10
2564
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
2565
 
@@ -1,521 +0,0 @@
2566
 
-/*************************************************************************
2567
 
- *
2568
 
- *  OpenOffice.org - a multi-platform office productivity suite
2569
 
- *
2570
 
- *  $RCSfile: osssound.cxx,v $
2571
 
- *
2572
 
- *  $Revision: 1.10 $
2573
 
- *
2574
 
- *  last change: $Author: hr $ $Date: 2007/06/27 20:46:05 $
2575
 
- *
2576
 
- *  The Contents of this file are made available subject to
2577
 
- *  the terms of GNU Lesser General Public License Version 2.1.
2578
 
- *
2579
 
- *
2580
 
- *    GNU Lesser General Public License Version 2.1
2581
 
- *    =============================================
2582
 
- *    Copyright 2005 by Sun Microsystems, Inc.
2583
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
2584
 
- *
2585
 
- *    This library is free software; you can redistribute it and/or
2586
 
- *    modify it under the terms of the GNU Lesser General Public
2587
 
- *    License version 2.1, as published by the Free Software Foundation.
2588
 
- *
2589
 
- *    This library is distributed in the hope that it will be useful,
2590
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
2591
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2592
 
- *    Lesser General Public License for more details.
2593
 
- *
2594
 
- *    You should have received a copy of the GNU Lesser General Public
2595
 
- *    License along with this library; if not, write to the Free Software
2596
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2597
 
- *    MA  02111-1307  USA
2598
 
- *
2599
 
- ************************************************************************/
2600
 
-
2601
 
-// MARKER(update_precomp.py): autogen include statement, do not remove
2602
 
-#include "precompiled_vcl.hxx"
2603
 
-#include <salsound.h>
2604
 
-#include <salimpsound.hxx>
2605
 
-
2606
 
-#include <vcl/svapp.hxx>
2607
 
-
2608
 
-#ifdef USE_OSS
2609
 
-
2610
 
-#include <sys/types.h>
2611
 
-#include <sys/stat.h>
2612
 
-#include <fcntl.h>
2613
 
-#include <stdio.h>
2614
 
-#include <unistd.h>
2615
 
-#include <string.h>
2616
 
-#include <sys/ioctl.h>
2617
 
-#ifdef LINUX
2618
 
-#include <linux/soundcard.h>
2619
 
-#else
2620
 
-#include <sys/soundcard.h>
2621
 
-#endif
2622
 
-#include <errno.h>
2623
 
-#include <osl/thread.h>
2624
 
-
2625
 
-using namespace vcl_sal;
2626
 
-using namespace vos;
2627
 
-using namespace osl;
2628
 
-
2629
 
-int                                            OSSSound::s_nDevice = -1;
2630
 
-OSSSound::OSSDataList  OSSSound::s_aDataList;
2631
 
-Mutex                                  OSSSound::s_aProtector;
2632
 
-OSSSound::OSSSoundList OSSSound::s_aSounds;
2633
 
-
2634
 
-BOOL OSSSound::open()
2635
 
-{
2636
 
-       MutexGuard aGuard( s_aProtector );
2637
 
-       if( s_nDevice == -1 )
2638
 
-       {
2639
 
-               s_nDevice = ::open( "/dev/dsp", O_WRONLY );
2640
 
-               if( s_nDevice == -1 )
2641
 
-               {
2642
 
-                       SalDbgAssert( "ERROR: could not open /dev/dsp, errno=%d\n", errno );
2643
 
-                       return FALSE;
2644
 
-               }
2645
 
-       }
2646
 
-       else
2647
 
-       {
2648
 
-               ioctl( s_nDevice, SNDCTL_DSP_RESET, 0 );
2649
 
-       }
2650
 
-       return TRUE;
2651
 
-}
2652
 
-
2653
 
-void OSSSound::close()
2654
 
-{
2655
 
-       MutexGuard aGuard( s_aProtector );
2656
 
-       if( s_nDevice != -1 )
2657
 
-               ::close( s_nDevice );
2658
 
-       s_nDevice = -1;
2659
 
-}
2660
 
-
2661
 
-BOOL OSSSound::startSound( OSSData* pData )
2662
 
-{
2663
 
-       if( pData && pData->m_pSound && pData->m_pSound->m_pBuffer &&
2664
 
-               s_nDevice >= 0 )
2665
 
-       {
2666
 
-               if( ! strncmp( pData->m_pSound->m_pBuffer, ".snd", 4 ) )
2667
 
-                       return startAU( pData );
2668
 
-               else if( ! strncmp( pData->m_pSound->m_pBuffer, "RIFF", 4 ) )
2669
 
-                       return startRIFF( pData );
2670
 
-       }
2671
 
-       return FALSE;
2672
 
-}
2673
 
-
2674
 
-BOOL OSSSound::startAU( OSSData* pData )
2675
 
-{
2676
 
-       char* pBuffer = pData->m_pSound->m_pBuffer;
2677
 
-       ULONG nDataOffset       = readBELong( pBuffer + 4 );
2678
 
-       ULONG nDataLen          = readBELong( pBuffer + 8 );
2679
 
-       ULONG nEncoding         = readBELong( pBuffer + 12 );
2680
 
-       ULONG nSampleRate       = readBELong( pBuffer + 16 );
2681
 
-       ULONG nChannels         = readBELong( pBuffer + 20 );
2682
 
-
2683
 
-       if( nDataLen == 0xffffffff )
2684
 
-               nDataLen = pData->m_pSound->m_aStat.st_size - nDataOffset;
2685
 
-
2686
 
-       pData->m_nDataLen       = nDataLen;
2687
 
-       pData->m_nStartPos      = nDataOffset;
2688
 
-       pData->m_nEndPos        = pData->m_nStartPos + pData->m_nDataLen;
2689
 
-
2690
 
-       if( nChannels != 1 && nChannels != 2 )
2691
 
-       {
2692
 
-               SalDbgAssert( "%d Channels are not supported\n" );
2693
 
-               return FALSE;
2694
 
-       }
2695
 
-
2696
 
-       int nSystemFormat;
2697
 
-       switch( nEncoding )
2698
 
-       {
2699
 
-               case 1: nSystemFormat = AFMT_MU_LAW;break;
2700
 
-               case 2: nSystemFormat = AFMT_U8;break;
2701
 
-               case 3: nSystemFormat = AFMT_S16_BE;break;
2702
 
-               default:
2703
 
-                       SalDbgAssert( "au format %d unsupported\n", nEncoding );
2704
 
-                       return FALSE;
2705
 
-       };
2706
 
-
2707
 
-       int nRealFormat = nSystemFormat;
2708
 
-       if( ioctl( s_nDevice, SNDCTL_DSP_SETFMT, &nRealFormat )==-1 )
2709
 
-       {
2710
 
-               SalDbgAssert( "ERROR: ioctl SNDCTL_DSP_SETFMT failed\n" );
2711
 
-               return FALSE;
2712
 
-       }
2713
 
-       int nRealChannels = nChannels-1;
2714
 
-       if( ioctl( s_nDevice, SNDCTL_DSP_STEREO, &nRealChannels )==-1 )
2715
 
-       {
2716
 
-               SalDbgAssert( "ERROR: ioctl SNDCTL_DSP_STEREO failed\n" );
2717
 
-               return FALSE;
2718
 
-       }
2719
 
-       if( nRealChannels != sal::static_int_cast<int>(nChannels-1) )
2720
 
-       {
2721
 
-               SalDbgAssert( "could not set %d channels\n", nChannels );
2722
 
-               return FALSE;
2723
 
-       }
2724
 
-
2725
 
-       if( ioctl( s_nDevice, SNDCTL_DSP_SPEED, &nSampleRate ) == -1 )
2726
 
-       {
2727
 
-               SalDbgAssert( "ERROR: ioctl SNDCTL_DSP_SPEED failed\n" );
2728
 
-               return FALSE;
2729
 
-       }
2730
 
-       SalDbgAssert( "playing %d data bytes at %d bytes in format %d quality/s on %d channels \n", pData->m_nDataLen, nSampleRate, nEncoding, nChannels );
2731
 
-       return TRUE;
2732
 
-}
2733
 
-
2734
 
-BOOL OSSSound::startRIFF( OSSData* pData )
2735
 
-{
2736
 
-       int nPos = findChunk( pData, "fmt " );
2737
 
-       if( nPos == -1 )
2738
 
-               return FALSE;
2739
 
-       
2740
 
-       int nFormat             = readLEShort( pData->m_pSound->m_pBuffer + nPos + 8 );
2741
 
-       int nChannels   = readLEShort( pData->m_pSound->m_pBuffer + nPos + 10 );
2742
 
-       int nSampleRate = readLEInt( pData->m_pSound->m_pBuffer + nPos + 12 );
2743
 
-       int nByteRate   = readLEInt( pData->m_pSound->m_pBuffer + nPos + 16 );
2744
 
-       int nAlign              = readLEShort( pData->m_pSound->m_pBuffer + nPos + 20 );
2745
 
-       SalDbgAssert( "format is tag = %x, channels = %d, samplesPerSec = %d, avgBytesPerSec = %d, blockAlign = %d\n", nFormat, nChannels, nSampleRate, nByteRate, nAlign );
2746
 
-       if( nChannels != 1 && nChannels != 2 )
2747
 
-       {
2748
 
-               SalDbgAssert( "%d Channels are not supported\n" );
2749
 
-               return FALSE;
2750
 
-       }
2751
 
-       
2752
 
-       int nBitsPerSample = 0;
2753
 
-       switch( nFormat )
2754
 
-       {
2755
 
-               default:
2756
 
-                       SalDbgAssert( "unknown format\n" );
2757
 
-                       return FALSE;
2758
 
-                       break;
2759
 
-               case 1:
2760
 
-                       nBitsPerSample = readLEShort( pData->m_pSound->m_pBuffer + nPos + 22 );
2761
 
-                       break;
2762
 
-       }
2763
 
-       
2764
 
-       nPos = findChunk( pData, "data" );
2765
 
-       if( nPos == -1 )
2766
 
-       {
2767
 
-               SalDbgAssert( "ERROR: no \"data\" chunk found\n" );
2768
 
-               return FALSE;
2769
 
-       }
2770
 
-       
2771
 
-       pData->m_nDataLen = readLEInt( pData->m_pSound->m_pBuffer + nPos + 4 );
2772
 
-       pData->m_nStartPos = nPos+8;
2773
 
-       pData->m_nEndPos = pData->m_nStartPos + pData->m_nDataLen;
2774
 
-       
2775
 
-       int nSystemFormat;
2776
 
-       switch( nBitsPerSample )
2777
 
-       {
2778
 
-               case 8:  nSystemFormat = AFMT_U8; break;
2779
 
-               case 16: nSystemFormat = AFMT_S16_LE; break;
2780
 
-               default:
2781
 
-                       SalDbgAssert( "%d bits per sample is not usable\n", nBitsPerSample );
2782
 
-                       return FALSE;
2783
 
-       }
2784
 
-       
2785
 
-       int nRealFormat = nSystemFormat;
2786
 
-       if( ioctl( s_nDevice, SNDCTL_DSP_SETFMT, &nRealFormat )==-1 )
2787
 
-       {
2788
 
-               SalDbgAssert( "ERROR: ioctl SNDCTL_DSP_SETFMT failed\n" );
2789
 
-               return FALSE;
2790
 
-       }
2791
 
-       
2792
 
-       int nRealChannels = nChannels-1;
2793
 
-       if( ioctl( s_nDevice, SNDCTL_DSP_STEREO, &nRealChannels )==-1 )
2794
 
-       {
2795
 
-               SalDbgAssert( "ERROR: ioctl SNDCTL_DSP_STEREO failed\n" );
2796
 
-               return FALSE;
2797
 
-       }
2798
 
-       if( nRealChannels != nChannels-1 )
2799
 
-       {
2800
 
-               SalDbgAssert( "could not set %d channels\n", nChannels );
2801
 
-               return FALSE;
2802
 
-       }
2803
 
-       
2804
 
-       
2805
 
-       if( ioctl( s_nDevice, SNDCTL_DSP_SPEED, &nSampleRate ) == -1 )
2806
 
-       {
2807
 
-               SalDbgAssert( "ERROR: ioctl SNDCTL_DSP_SPEED failed\n" );
2808
 
-               return FALSE;
2809
 
-       }
2810
 
-       
2811
 
-       SalDbgAssert( "playing %d data bytes at %d bytes in %d bits quality/s on %d channels \n", pData->m_nDataLen, nSampleRate, nBitsPerSample, nChannels );
2812
 
-       return TRUE;
2813
 
-}
2814
 
-
2815
 
-int OSSSound::findChunk( OSSData* pData, const char* pChunk )
2816
 
-{
2817
 
-       if( !pData || ! pData->m_pSound || ! pData->m_pSound->m_pBuffer )
2818
 
-               return -1;
2819
 
-
2820
 
-       int nPos = 12;
2821
 
-       while( nPos < pData->m_pSound->m_aStat.st_size )
2822
 
-       {
2823
 
-               if( ! strncmp( pData->m_pSound->m_pBuffer+nPos, pChunk, 4 ) )
2824
 
-                       return nPos;
2825
 
-
2826
 
-               // get LSB int length
2827
 
-               nPos += readLEInt( pData->m_pSound->m_pBuffer+nPos+4 ) + 8;
2828
 
-       }
2829
 
-       return -1;
2830
 
-}
2831
 
-
2832
 
-short int OSSSound::readLEShort( const char* pBuf )
2833
 
-{
2834
 
-       const unsigned char* pBuffer = (const unsigned char*)pBuf;
2835
 
-       short int nRet = *pBuffer++;
2836
 
-       nRet |= *pBuffer << 8;
2837
 
-
2838
 
-       return nRet;
2839
 
-}
2840
 
-
2841
 
-ULONG OSSSound::readBELong( const char* pBuf )
2842
 
-{
2843
 
-       const unsigned char* pBuffer = (const unsigned char*)pBuf;
2844
 
-       ULONG nRet       = *pBuffer++ << 24;
2845
 
-       nRet            |= *pBuffer++ << 16;
2846
 
-       nRet            |= *pBuffer++ << 8;
2847
 
-       nRet            |= *pBuffer;
2848
 
-
2849
 
-       return nRet;
2850
 
-}
2851
 
-
2852
 
-int OSSSound::readLEInt( const char* pBuf )
2853
 
-{
2854
 
-       const unsigned char* pBuffer = (const unsigned char*)pBuf;
2855
 
-       int nRet = *pBuffer++;
2856
 
-       nRet |= (int)(*pBuffer++) << 8;
2857
 
-       nRet |= (int)(*pBuffer++) << 16;
2858
 
-       nRet |= (int)(*pBuffer++) << 24;
2859
 
-
2860
 
-       return nRet;
2861
 
-}
2862
 
-
2863
 
-static oslThread aThreadWorker= NULL;
2864
 
-extern "C" {
2865
 
-    void SAL_CALL OSSThreadWorker(void*)
2866
 
-    {
2867
 
-        OSSSound::run();
2868
 
-    }
2869
 
-}
2870
 
-
2871
 
-void OSSSound::run()
2872
 
-{
2873
 
-       SalDbgAssert( "OSSWorker::run\n" );
2874
 
-       OSSData* pData;
2875
 
-    do
2876
 
-    {
2877
 
-        ResettableMutexGuard aGuard( s_aProtector );
2878
 
-        pData = s_aDataList.Count() ? s_aDataList.GetObject( 0 ) : NULL;
2879
 
-        if( ! pData )
2880
 
-            break;
2881
 
-        
2882
 
-        if( open() )
2883
 
-        {
2884
 
-            
2885
 
-            bool bDataValid = true;
2886
 
-            if( startSound( pData ) )
2887
 
-            {
2888
 
-                pData->m_nCurPos = pData->m_nStartPos;
2889
 
-                while( pData->m_nCurPos < pData->m_nEndPos )
2890
 
-                {
2891
 
-                    audio_buf_info info;
2892
 
-                    ioctl( s_nDevice, SNDCTL_DSP_GETOSPACE, &info );
2893
 
-                    if( info.bytes > 0 )
2894
 
-                    {
2895
 
-                        int nBytes = info.bytes;
2896
 
-                        if( pData->m_nCurPos + nBytes > pData->m_nEndPos )
2897
 
-                            nBytes = pData->m_nEndPos - pData->m_nCurPos;
2898
 
-                        nBytes = write( s_nDevice,
2899
 
-                                        pData->m_pSound->m_pBuffer + pData->m_nCurPos,
2900
 
-                                        nBytes );
2901
 
-                        if( nBytes > 0 )
2902
 
-                            pData->m_nCurPos += nBytes;
2903
 
-                    }
2904
 
-                    aGuard.clear();
2905
 
-                    TimeValue aVal;
2906
 
-                    aVal.Seconds = 0;
2907
 
-                    aVal.Nanosec = 20000000;
2908
 
-                    osl_waitThread( &aVal );
2909
 
-                    aGuard.reset();
2910
 
-                    if( s_aDataList.GetObject( 0 ) != pData )
2911
 
-                    {
2912
 
-                        ioctl( s_nDevice, SNDCTL_DSP_RESET, 0);
2913
 
-                        bDataValid = false;
2914
 
-                        break;
2915
 
-                    }
2916
 
-                }
2917
 
-                close();
2918
 
-                if( bDataValid )
2919
 
-                {
2920
 
-                    if( pData->m_pSound->m_pSalSound->m_bLoop )
2921
 
-                        pData->m_pSound->play();
2922
 
-                    else
2923
 
-                        Application::PostUserEvent( LINK( pData->m_pSound, OSSSound, notifyStopHdl ), NULL );
2924
 
-                }
2925
 
-            }
2926
 
-            else
2927
 
-                               Application::PostUserEvent( LINK( pData->m_pSound, OSSSound, notifyErrorHdl ), (void*)SOUNDERR_INVALID_FILE );
2928
 
-        }
2929
 
-        s_aDataList.Remove( pData );
2930
 
-        delete pData;
2931
 
-    } while( pData );
2932
 
-
2933
 
-    MutexGuard aGuard( s_aProtector );
2934
 
-    osl_destroyThread( aThreadWorker );
2935
 
-    aThreadWorker = NULL;
2936
 
-}
2937
 
-
2938
 
-void OSSSound::append( OSSSound* pSound )
2939
 
-{
2940
 
-       MutexGuard aGuard( s_aProtector );
2941
 
-       OSSData* pNew = new OSSData;
2942
 
-
2943
 
-       pNew->m_pSound          = pSound;
2944
 
-       pNew->m_nDataLen        = 0;
2945
 
-       pNew->m_nStartPos       = 0;
2946
 
-       pNew->m_nEndPos         = 0;
2947
 
-       pNew->m_nType           = 0;
2948
 
-
2949
 
-       s_aDataList.Insert( pNew, LIST_APPEND );
2950
 
-       if( ! aThreadWorker )
2951
 
-        aThreadWorker = osl_createThread( OSSThreadWorker, NULL );
2952
 
-}
2953
 
-
2954
 
-void OSSSound::remove( OSSSound* pSound )
2955
 
-{
2956
 
-       MutexGuard aGuard( s_aProtector );
2957
 
-       OSSData* pData;
2958
 
-       for( int i = s_aDataList.Count()-1; i >= 0; i-- )
2959
 
-       {
2960
 
-               pData = s_aDataList.GetObject( i );
2961
 
-               if( pData->m_pSound == pSound )
2962
 
-               {
2963
 
-                       s_aDataList.Remove( i );
2964
 
-                       if( i > 0 )
2965
 
-                               delete pData;
2966
 
-               }
2967
 
-       }
2968
 
-}
2969
 
-
2970
 
-OSSSound::OSSSound( ::X11SalSound* pSound ) :
2971
 
-               VSound( pSound )
2972
 
-{
2973
 
-       initBuffer();
2974
 
-       s_aSounds.Insert( this );
2975
 
-}
2976
 
-
2977
 
-OSSSound::~OSSSound()
2978
 
-{
2979
 
-       stop();
2980
 
-       if( m_pBuffer )
2981
 
-               releaseBuffer();
2982
 
-       s_aSounds.Remove( this );
2983
 
-}
2984
 
-
2985
 
-BOOL OSSSound::isValid()
2986
 
-{
2987
 
-    if( ! m_pBuffer )
2988
 
-        return FALSE;
2989
 
-
2990
 
-    if( s_nDevice == -1 )
2991
 
-    {
2992
 
-        int nTryOpen = ::open( "/dev/dsp", O_WRONLY | O_NONBLOCK );
2993
 
-        if( nTryOpen == -1 )
2994
 
-            return FALSE;
2995
 
-        ::close( nTryOpen );
2996
 
-    }
2997
 
-       
2998
 
-       // check for valid file format
2999
 
-       if( ! strncmp( "RIFF", m_pBuffer, 4 ) )
3000
 
-       {
3001
 
-               OSSData aData;
3002
 
-               aData.m_pSound = this;
3003
 
-
3004
 
-               // check for data chunk
3005
 
-               if( findChunk( &aData, "data" ) == -1 )
3006
 
-                       goto failed;
3007
 
-               int nPos = findChunk( &aData, "fmt " );
3008
 
-               if( nPos == -1 )
3009
 
-                       goto failed;
3010
 
-               
3011
 
-               int nFormat             = readLEShort( m_pBuffer + nPos + 8 );
3012
 
-               int nChannels   = readLEShort( m_pBuffer + nPos + 10 );
3013
 
-               // check channels
3014
 
-               if( nChannels != 1 && nChannels != 2 )
3015
 
-                       goto failed;
3016
 
-               // check formats
3017
 
-               // playable is MS-PCM only at now
3018
 
-               if( nFormat != 1 )
3019
 
-                       goto failed;
3020
 
-               return TRUE;
3021
 
-       }
3022
 
-       else if( ! strncmp( ".snd", m_pBuffer, 4 ) )
3023
 
-       {
3024
 
-               ULONG nEncoding         = readBELong( m_pBuffer + 12 );
3025
 
-               ULONG nChannels         = readBELong( m_pBuffer + 20 );
3026
 
-
3027
 
-               // check for playable encodings
3028
 
-               if( nEncoding != 1 && nEncoding != 2 && nEncoding != 3 )
3029
 
-                       goto failed;
3030
 
-               // check channels
3031
 
-               if( nChannels != 1 && nChannels != 2 )
3032
 
-                       goto failed;
3033
 
-               return TRUE;
3034
 
-       }
3035
 
-  failed:
3036
 
-       releaseBuffer();
3037
 
-       return FALSE;
3038
 
-}
3039
 
-
3040
 
-void OSSSound::play()
3041
 
-{
3042
 
-       if( ! m_pBuffer )
3043
 
-               return;
3044
 
-
3045
 
-       append( this );
3046
 
-       m_pSalSound->m_bPlaying = TRUE;
3047
 
-       m_pSalSound->m_bPaused  = FALSE;
3048
 
-}
3049
 
-
3050
 
-void OSSSound::stop()
3051
 
-{
3052
 
-       remove( this );
3053
 
-       m_pSalSound->m_bPlaying = FALSE;
3054
 
-       m_pSalSound->m_bPaused  = FALSE;
3055
 
-}
3056
 
-
3057
 
-void OSSSound::pause()
3058
 
-{
3059
 
-       remove( this );
3060
 
-       m_pSalSound->m_bPaused = TRUE;
3061
 
-}
3062
 
-
3063
 
-void OSSSound::cont()
3064
 
-{
3065
 
-       play();
3066
 
-}
3067
 
-
3068
 
-IMPL_LINK( OSSSound, notifyStopHdl, void*, EMPTYARG )
3069
 
-{
3070
 
-       if( s_aSounds.GetPos( this ) != LIST_ENTRY_NOTFOUND )
3071
 
-       {
3072
 
-               m_pSalSound->changeStateStop();
3073
 
-       }
3074
 
-       return 0;
3075
 
-}
3076
 
-
3077
 
-IMPL_LINK( OSSSound, notifyErrorHdl, void*, nError )
3078
 
-{
3079
 
-       if( s_aSounds.GetPos( this ) != LIST_ENTRY_NOTFOUND )
3080
 
-       {
3081
 
-               m_pSalSound->setError( (ULONG)nError );
3082
 
-       }
3083
 
-       return 0;
3084
 
-}
3085
 
-
3086
 
-#endif
3087
 
Index: vcl/unx/source/app/pasfsound.cxx
3088
 
===================================================================
3089
 
RCS file: vcl/unx/source/app/pasfsound.cxx
3090
 
diff -N vcl/unx/source/app/pasfsound.cxx
3091
 
--- vcl/unx/source/app/pasfsound.cxx    31 Jul 2007 13:01:50 -0000      1.7
3092
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
3093
 
@@ -1,345 +0,0 @@
3094
 
-/*************************************************************************
3095
 
-*
3096
 
- *  OpenOffice.org - a multi-platform office productivity suite
3097
 
- *
3098
 
- *  $RCSfile: pasfsound.cxx,v $
3099
 
- *
3100
 
- *  $Revision: 1.7 $
3101
 
- *
3102
 
- *  last change: $Author: hr $ $Date: 2007/07/31 13:01:50 $
3103
 
- *
3104
 
- *  The Contents of this file are made available subject to
3105
 
- *  the terms of GNU Lesser General Public License Version 2.1.
3106
 
- *
3107
 
- *
3108
 
- *    GNU Lesser General Public License Version 2.1
3109
 
- *    =============================================
3110
 
- *    Copyright 2005 by Sun Microsystems, Inc.
3111
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
3112
 
- *
3113
 
- *    This library is free software; you can redistribute it and/or
3114
 
- *    modify it under the terms of the GNU Lesser General Public
3115
 
- *    License version 2.1, as published by the Free Software Foundation.
3116
 
- *
3117
 
- *    This library is distributed in the hope that it will be useful,
3118
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
3119
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3120
 
- *    Lesser General Public License for more details.
3121
 
- *
3122
 
- *    You should have received a copy of the GNU Lesser General Public
3123
 
- *    License along with this library; if not, write to the Free Software
3124
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
3125
 
- *    MA  02111-1307  USA
3126
 
- *
3127
 
-************************************************************************/
3128
 
-
3129
 
-// MARKER(update_precomp.py): autogen include statement, do not remove
3130
 
-#include "precompiled_vcl.hxx"
3131
 
-
3132
 
-#include <salsound.h>
3133
 
-#include <salimpsound.hxx>
3134
 
-
3135
 
-#ifdef USE_PASF
3136
 
-
3137
 
-#define _SV_PASFSOUND_CXX
3138
 
-
3139
 
-// Replacement SalSound Implementation that makes use of PortAudio to abstract away
3140
 
-// hardware differences, and LibSndFile to convert and access sound formats
3141
 
-// This implementation should work with little or no modification for Linux
3142
 
-// SGI, Solaris, MacOSX, Linux (all arches), FreeBSD, and even WIN
3143
 
-
3144
 
-#include <saldata.hxx>
3145
 
-#include <vcl/salinst.hxx>
3146
 
-
3147
 
-
3148
 
-#include <stdio.h>
3149
 
-
3150
 
-using namespace vcl_sal;
3151
 
-using namespace vos;
3152
 
-using namespace osl;
3153
 
-using namespace rtl;
3154
 
-
3155
 
-extern "C"
3156
 
-{
3157
 
-    
3158
 
-    /* callback that takes data from sound file and converts it and loads it */
3159
 
-#if PA_VER == 18
3160
 
-    static int pasf_in_out_callback (void *inputBuffer, void * outputBuffer,
3161
 
-    unsigned long framesPerBuffer, PaTimestamp outTime, void * userData )
3162
 
-#else
3163
 
-    static int pasf_in_out_callback (const void *inputBuffer, void *outputBuffer,
3164
 
-    unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *outTime, PaStreamCallbackFlags cbFlags, void *userData )
3165
 
-#endif
3166
 
-    {  
3167
 
-        PASFAudioData* paudio_data;
3168
 
-        unsigned int   read_count, bufoff, bytecnt; 
3169
 
-        float*          buffer  = (float *) outputBuffer;
3170
 
-        
3171
 
-        /* prevent warnings for unused variables */
3172
 
-#if PA_VER > 18
3173
 
-        cbFlags = cbFlags;
3174
 
-#endif
3175
 
-        inputBuffer = inputBuffer;
3176
 
-        outTime = outTime;
3177
 
-        
3178
 
-        /* get all other info needed from audio_data structure passed in as userData */
3179
 
-        paudio_data = (PASFAudioData*) userData;
3180
 
-        
3181
 
-        read_count = sf_readf_float (paudio_data->sndfile, buffer, framesPerBuffer);
3182
 
-        if (read_count < framesPerBuffer) 
3183
 
-        {      
3184
 
-               /* fill in the remainder of the buffer with zeros */
3185
 
-            /* convert read_count of frames to offset into float* buffer */
3186
 
-               bufoff = read_count * paudio_data->sfinfo.channels;
3187
 
-            bytecnt = (framesPerBuffer - read_count) * paudio_data->sfinfo.channels * sizeof(float);
3188
 
-            memset (&(buffer [read_count]), 0, bytecnt) ;
3189
 
-        }
3190
 
-        
3191
 
-        /* now check if we reached end of file or preset stopping point */
3192
 
-        if ((read_count == 0) || ((paudio_data->stop_frame > 0) 
3193
 
-            && (paudio_data->frame_count > paudio_data->stop_frame))) 
3194
 
-        {
3195
 
-            if (paudio_data->loop_count > 0) paudio_data->loop_count--;
3196
 
-            
3197
 
-            /* if need to loop again, seek back to start frame and reset frame count */
3198
 
-            if ((paudio_data->loop_count > 0) || (paudio_data->loop_count == -1)) 
3199
 
-            {
3200
 
-                sf_seek(paudio_data->sndfile, paudio_data->start_frame, SEEK_SET);
3201
 
-                paudio_data->frame_count = paudio_data->start_frame;
3202
 
-            } else {
3203
 
-                paudio_data->done_playing = 1 ;
3204
 
-            }
3205
 
-        } 
3206
 
-        
3207
 
-        paudio_data->frame_count = paudio_data->frame_count + framesPerBuffer;
3208
 
-        return paNoError;
3209
 
-    } 
3210
 
-}
3211
 
-
3212
 
-
3213
 
-
3214
 
-PASFSound::PASFSound( ::X11SalSound* pSound) : 
3215
 
-VSound( pSound ), 
3216
 
-m_pStream( NULL ), 
3217
 
-m_pData( NULL )
3218
 
-{
3219
 
-    m_pData = new PASFAudioData();
3220
 
-    if ( ! (m_pData) ) return;
3221
 
-    
3222
 
-    // open the sound file and get info on desired channels and sample rate
3223
 
-    if (! (m_pData->sndfile = sf_open (m_pSalSound->m_aSoundFile.GetBuffer(), SFM_READ, &(m_pData->sfinfo)))) 
3224
 
-    {  
3225
 
-        // fprintf(stderr,"Error opening sound file %s\n", m_aSoundFile.GetBuffer()); fflush(stderr);
3226
 
-        m_pData->sndfile = NULL;
3227
 
-        return;
3228
 
-    }
3229
 
-    
3230
 
-    // check for valid number of channels to prevent problems later
3231
 
-    if (m_pData->sfinfo.channels < 1 || m_pData->sfinfo.channels > 2) 
3232
 
-    {  
3233
 
-        // fprintf(stderr, "Error incorrect number of channels %d.\n", m_pData->sfinfo.channels) ; fflush(stderr);
3234
 
-        sf_close(m_pData->sndfile);
3235
 
-        m_pData->sndfile = NULL;
3236
 
-        return;
3237
 
-    }
3238
 
-    
3239
 
-    
3240
 
-    // store information on desired settings and input buffer format away
3241
 
-    m_pData->format = paFloat32;
3242
 
-    m_pData->bufsize = PASF_BUFFER_LEN;
3243
 
-    
3244
 
-    // Using the default output device for this
3245
 
-#if PA_VER == 18
3246
 
-    m_pData->device = Pa_GetDefaultOutputDeviceID();
3247
 
-#else
3248
 
-    m_pData->device = Pa_GetDefaultOutputDevice();
3249
 
-#endif
3250
 
-    
3251
 
-    // the size of a frame in bytes is the number of channels of data * the size of the 
3252
 
-    // underlying data type type being used to store data for each for each channel
3253
 
-    // (we are using paFloat32 as input to PaOpenDefaultStream )
3254
 
-    
3255
 
-    unsigned int bytesPerFrame = m_pData->sfinfo.channels * sizeof(float);
3256
 
-    unsigned int framesPerBuffer = (unsigned int) (m_pData->bufsize / bytesPerFrame); 
3257
 
-    
3258
 
-    // Open an audio I/O stream for output only on the default output device
3259
 
-    PaError err = Pa_OpenDefaultStream(
3260
 
-    &m_pStream,
3261
 
-    0,                             // no input channels == no input device
3262
 
-    m_pData->sfinfo.channels,      // get desired output channels from file
3263
 
-    m_pData->format,               // 32 bit floating point format for each item
3264
 
-    m_pData->sfinfo.samplerate,    // get desired sampling rate from file
3265
 
-    framesPerBuffer,               // frames per buffer
3266
 
-#if PA_VER == 18
3267
 
-    0,                             // number of buffers, if zero then use optimal number as determined by Pa
3268
 
-#endif
3269
 
-    pasf_in_out_callback,          // call back to load data into the stream
3270
 
-    m_pData );                     // pass along m_pData pointer so that callback can get access to info
3271
 
-    
3272
 
-    if( err != paNoError ) {
3273
 
-        m_pStream = NULL;
3274
 
-        sf_close(m_pData->sndfile);
3275
 
-        m_pData->sndfile = NULL;
3276
 
-    } 
3277
 
-}
3278
 
-
3279
 
-
3280
 
-PASFSound::~PASFSound()
3281
 
-{
3282
 
-    // if stream exists, stop and close it
3283
 
-    if (m_pStream) 
3284
 
-    { 
3285
 
-           Pa_StopStream( m_pStream );
3286
 
-           Pa_CloseStream( m_pStream );
3287
 
-        m_pStream = NULL;
3288
 
-    }
3289
 
-    // clean up the PASFAudioData structure, close any open sound files
3290
 
-    if ( m_pData ) 
3291
 
-    {
3292
 
-           if (m_pData->sndfile) 
3293
 
-        {
3294
 
-            sf_close(m_pData->sndfile);
3295
 
-            m_pData->sndfile = NULL;
3296
 
-           }
3297
 
-        delete m_pData;
3298
 
-           m_pData = NULL;
3299
 
-       }
3300
 
-    m_pSalSound = NULL;
3301
 
-}
3302
 
-
3303
 
-
3304
 
-void PASFSound::play()
3305
 
-{
3306
 
-    int nErr = 1;
3307
 
-    BOOL bLoop = m_pSalSound->m_bLoop;
3308
 
-    ULONG nStartTime = m_pSalSound->m_nStartTime;
3309
 
-    ULONG nPlayTime =  m_pSalSound->m_nPlayTime;
3310
 
-    
3311
 
-    // if ready to go
3312
 
-    if ((m_pData) && (m_pStream)) 
3313
 
-    { 
3314
 
-        // set the player controls
3315
 
-        
3316
 
-        // if looping set the loop count (use -1 for infinity)
3317
 
-        m_pData->loop_count = 1;
3318
 
-        if ( bLoop ) m_pData->loop_count = -1;
3319
 
-        
3320
 
-        // convert StartTime to frame count and seek to starting frame in sound file
3321
 
-        m_pData->start_frame = 0;
3322
 
-        if (nStartTime > 0) 
3323
 
-        {
3324
 
-            m_pData->start_frame = (unsigned long)( (double)nStartTime * m_pData->sfinfo.samplerate / 1000.0 );
3325
 
-            sf_seek(m_pData->sndfile, m_pData->start_frame, SEEK_SET);
3326
 
-        }
3327
 
-        
3328
 
-        // set the frames number to play until (use 0 to indicate play until the end)
3329
 
-        m_pData->stop_frame = 0;
3330
 
-        if (nPlayTime != SOUND_PLAYALL) 
3331
 
-        {
3332
 
-            ULONG nEndTime = nStartTime + nPlayTime;
3333
 
-            m_pData->stop_frame = (unsigned long)( (double)nEndTime * m_pData->sfinfo.samplerate / 1000.0 );
3334
 
-        }
3335
 
-        
3336
 
-        // set set the total frame_count to the starting frame number
3337
 
-        m_pData->frame_count = m_pData->start_frame;
3338
 
-        m_pData->done_playing = 0;
3339
 
-        
3340
 
-        // FIXME?: In Play but already playing will be ignored (no error) is that right?
3341
 
-        nErr = 0;
3342
 
-        if (!(m_pSalSound->m_bPlaying)) 
3343
 
-        {            
3344
 
-            PaError err = Pa_StartStream( m_pStream );
3345
 
-            if( err != paNoError)  nErr = 1;
3346
 
-        }  
3347
 
-    }
3348
 
-    
3349
 
-    if (!nErr) 
3350
 
-    {
3351
 
-        m_pSalSound->changeStatePlay();
3352
 
-        return;
3353
 
-       }
3354
 
-    m_pSalSound->setError(SOUNDERR_GENERAL_ERROR);
3355
 
-}
3356
 
-
3357
 
-
3358
 
-
3359
 
-void PASFSound::stop()
3360
 
-{
3361
 
-    int nErr = 1;
3362
 
-       if ( m_pStream ) 
3363
 
-    { 
3364
 
-        // stop and close the stream
3365
 
-        PaError err = Pa_StopStream( m_pStream );
3366
 
-        PaError err1 = Pa_CloseStream( m_pStream );
3367
 
-        if( (err == paNoError) && (err1 == paNoError) ) nErr = 0;
3368
 
-        m_pStream = NULL;
3369
 
-    }    
3370
 
-    
3371
 
-    // close the sound file sound since another file can be loaded after stop 
3372
 
-    if ((m_pData) && (!(m_pStream))) {
3373
 
-           if (m_pData->sndfile) 
3374
 
-        {
3375
 
-            sf_close(m_pData->sndfile);
3376
 
-            m_pData->sndfile = NULL;
3377
 
-        }
3378
 
-    }
3379
 
-    
3380
 
-    if (!nErr) 
3381
 
-    {
3382
 
-        m_pSalSound->changeStateStop();
3383
 
-        return;
3384
 
-       }
3385
 
-    m_pSalSound->setError(SOUNDERR_GENERAL_ERROR);
3386
 
-    
3387
 
-}
3388
 
-
3389
 
-
3390
 
-
3391
 
-void PASFSound::pause()
3392
 
-{
3393
 
-    int nErr = 1;
3394
 
-       if (m_pStream ) {
3395
 
-        PaError err = Pa_StopStream( m_pStream );
3396
 
-        if( err == paNoError ) nErr = 0;
3397
 
-       }
3398
 
-    
3399
 
-    if (!nErr) 
3400
 
-    {
3401
 
-        m_pSalSound->changeStatePause();
3402
 
-        return;
3403
 
-       }
3404
 
-    m_pSalSound->setError(SOUNDERR_GENERAL_ERROR);
3405
 
-}
3406
 
-
3407
 
-
3408
 
-
3409
 
-void PASFSound::cont()
3410
 
-{
3411
 
-    int nErr = 1;
3412
 
-    if (m_pSalSound->m_bPaused) { 
3413
 
-        if (m_pStream) {
3414
 
-            PaError err = Pa_StartStream( m_pStream );
3415
 
-            if( err == paNoError ) nErr = 0;
3416
 
-        }
3417
 
-    }    
3418
 
-    
3419
 
-    if (!nErr) 
3420
 
-    {
3421
 
-        m_pSalSound->changeStateCont();
3422
 
-        return;
3423
 
-       }
3424
 
-    m_pSalSound->setError(SOUNDERR_GENERAL_ERROR);
3425
 
-}
3426
 
-
3427
 
-
3428
 
-
3429
 
-BOOL PASFSound::isValid()
3430
 
-{
3431
 
-    if ((m_pData) && (m_pStream)) return TRUE;
3432
 
-    return FALSE;
3433
 
-}
3434
 
-
3435
 
-
3436
 
-
3437
 
-#endif
3438
 
-
3439
 
Index: vcl/unx/source/app/rptpsound.cxx
3440
 
===================================================================
3441
 
RCS file: vcl/unx/source/app/rptpsound.cxx
3442
 
diff -N vcl/unx/source/app/rptpsound.cxx
3443
 
--- vcl/unx/source/app/rptpsound.cxx    17 Sep 2006 12:34:30 -0000      1.17
3444
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
3445
 
@@ -1,392 +0,0 @@
3446
 
-/*************************************************************************
3447
 
- *
3448
 
- *  OpenOffice.org - a multi-platform office productivity suite
3449
 
- *
3450
 
- *  $RCSfile: rptpsound.cxx,v $
3451
 
- *
3452
 
- *  $Revision: 1.17 $
3453
 
- *
3454
 
- *  last change: $Author: obo $ $Date: 2006/09/17 12:34:30 $
3455
 
- *
3456
 
- *  The Contents of this file are made available subject to
3457
 
- *  the terms of GNU Lesser General Public License Version 2.1.
3458
 
- *
3459
 
- *
3460
 
- *    GNU Lesser General Public License Version 2.1
3461
 
- *    =============================================
3462
 
- *    Copyright 2005 by Sun Microsystems, Inc.
3463
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
3464
 
- *
3465
 
- *    This library is free software; you can redistribute it and/or
3466
 
- *    modify it under the terms of the GNU Lesser General Public
3467
 
- *    License version 2.1, as published by the Free Software Foundation.
3468
 
- *
3469
 
- *    This library is distributed in the hope that it will be useful,
3470
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
3471
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3472
 
- *    Lesser General Public License for more details.
3473
 
- *
3474
 
- *    You should have received a copy of the GNU Lesser General Public
3475
 
- *    License along with this library; if not, write to the Free Software
3476
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
3477
 
- *    MA  02111-1307  USA
3478
 
- *
3479
 
- ************************************************************************/
3480
 
-
3481
 
-// MARKER(update_precomp.py): autogen include statement, do not remove
3482
 
-#include "precompiled_vcl.hxx"
3483
 
-#if defined(SOLARIS) || defined(MACOSX)
3484
 
-#include <poll.h>
3485
 
-#else
3486
 
-#include <sys/poll.h>
3487
 
-#endif
3488
 
-
3489
 
-#include <salsound.h>
3490
 
-#include <salimpsound.hxx>
3491
 
-
3492
 
-#include <salunx.h>
3493
 
-#include <saldata.hxx>
3494
 
-#include <saldisp.hxx>
3495
 
-#include <psprint/strhelper.hxx>
3496
 
-#include <string.h>
3497
 
-#include <unistd.h>
3498
 
-
3499
 
-using namespace vcl_sal;
3500
 
-using namespace vos;
3501
 
-using namespace psp;
3502
 
-
3503
 
-BOOL                                           RPTPSound::s_bConnected                 = FALSE;
3504
 
-BOOL                                           RPTPSound::s_bFailedOnce                = FALSE;
3505
 
-OConnectorSocket                       RPTPSound::s_aConnector;
3506
 
-RPTPSound::RPTPSoundList       RPTPSound::s_aSounds;
3507
 
-
3508
 
-int RPTPSound::getFileDescriptor()
3509
 
-{
3510
 
-       return *(int*)(oslSocket)s_aConnector;
3511
 
-}
3512
 
-
3513
 
-BOOL RPTPSound::connect()
3514
 
-{
3515
 
-       if( s_bConnected && s_aConnector.isValid() )
3516
 
-               return TRUE;
3517
 
-
3518
 
-       if( s_bFailedOnce )
3519
 
-               return FALSE;
3520
 
-
3521
 
-       s_bConnected = FALSE;
3522
 
-
3523
 
-       static const char* env = getenv( "AUDIOSERVER" );
3524
 
-       static const char* portenv = env ? strchr( env, ':' ) : NULL;
3525
 
-       static char sBuf[1024];
3526
 
-
3527
 
-       if( ! env && GetX11SalData() && GetX11SalData()->GetDisplay() &&
3528
 
-               DisplayString( GetX11SalData()->GetDisplay()->GetDisplay() ) )
3529
 
-       {
3530
 
-               env = strdup( DisplayString( GetX11SalData()->GetDisplay()->GetDisplay() ) );
3531
 
-               portenv = strchr( env, ':' );
3532
 
-       }
3533
 
-
3534
 
-       int nPort = portenv ? atoi( portenv+1 ) : 5556;
3535
 
-       nPort = nPort ? nPort : 5556;
3536
 
-
3537
 
-       strncpy( sBuf, "uninitialized", 14 );
3538
 
-       if( env && portenv )
3539
 
-       {
3540
 
-               if( portenv != env )
3541
 
-               {
3542
 
-                       strncpy( sBuf, env, portenv - env );
3543
 
-                       sBuf[ portenv - env ] = 0;
3544
 
-               }
3545
 
-               else
3546
 
-                       strncpy( sBuf, "localhost", 10 );
3547
 
-       }
3548
 
-       else
3549
 
-               strncpy( sBuf, "localhost", 10 );
3550
 
-
3551
 
-       SalDbgAssert( "resolving \"%s\", env = \"%s\", portenv = \"%s\"\n",
3552
 
-                                 sBuf,
3553
 
-                                 env ? env : "<unset>",
3554
 
-                                 portenv ? portenv : "<unset>"
3555
 
-                                 );
3556
 
-
3557
 
-       ::rtl::OUString aHost( sBuf, strlen(sBuf), gsl_getSystemTextEncoding() );
3558
 
-
3559
 
-       OInetSocketAddr aAddr( OSocketAddr::resolveHostname( aHost ) );
3560
 
-       aAddr.setPort( nPort );
3561
 
-       s_aConnector = OConnectorSocket();
3562
 
-       TimeValue aTimeout = { 0, 100000 };
3563
 
-       if( s_aConnector.connect( aAddr, &aTimeout ) == ISocketTypes::TResult_Ok )
3564
 
-       {
3565
 
-               s_bConnected = TRUE;
3566
 
-               readLine();
3567
 
-               sendCommand( "set notify=done,pause,continue" );
3568
 
-               GetX11SalData()->GetLib()->Insert( getFileDescriptor(),
3569
 
-                                                                  NULL,
3570
 
-                                           (YieldFunc)pending,
3571
 
-                                           (YieldFunc)queued,
3572
 
-                                           (YieldFunc)handleEvents );
3573
 
-       }
3574
 
-       else
3575
 
-       {
3576
 
-               SalDbgAssert( "RPTPSound::connect to \"%s\" on port %d failed\n", sBuf, nPort );
3577
 
-               s_bFailedOnce = TRUE;
3578
 
-       }
3579
 
-       return s_bConnected;
3580
 
-}
3581
 
-
3582
 
-void RPTPSound::disconnect()
3583
 
-{
3584
 
-       if( s_bConnected )
3585
 
-       {
3586
 
-               s_bConnected = FALSE;
3587
 
-               GetX11SalData()->GetLib()->Remove( getFileDescriptor() );
3588
 
-               s_aConnector.write( "quit\r\n", 6 );
3589
 
-               s_aConnector.close();
3590
 
-               SalDbgAssert( "RPTPSound::disconnect\n" );
3591
 
-       }
3592
 
-}
3593
 
-
3594
 
-int RPTPSound::pending( int nFD, void* )
3595
 
-{
3596
 
-       struct pollfd aPollfd;
3597
 
-       aPollfd.fd                      = nFD;
3598
 
-       aPollfd.events          = POLLIN;
3599
 
-
3600
 
-       poll( &aPollfd, 1, 0 );
3601
 
-
3602
 
-       return aPollfd.revents & POLLIN ? 1 : 0;
3603
 
-}
3604
 
-
3605
 
-int RPTPSound::queued( int nFD, void* pObj )
3606
 
-{
3607
 
-       return pending( nFD, pObj );
3608
 
-}
3609
 
-
3610
 
-int RPTPSound::handleEvents( int, void* )
3611
 
-{
3612
 
-       SalDbgAssert( "RPTPSound::handleEvents\n" );
3613
 
-       ByteString aLine = readLine();
3614
 
-       int nPos;
3615
 
-       if( aLine.GetChar( 0 ) == '@' &&
3616
 
-               ( nPos = aLine.Search( "event=" ) ) != STRING_NOTFOUND )
3617
 
-       {
3618
 
-               ULONG nID = ~0;
3619
 
-               RPTPSound* pSound = NULL;
3620
 
-
3621
 
-               ByteString aEvent = aLine.Copy( nPos+6 );
3622
 
-               aEvent = GetCommandLineToken( 0, aEvent );
3623
 
-               aEvent.ToLowerAscii();
3624
 
-
3625
 
-               if( ( nPos = aLine.Search( "id=#" ) ) != STRING_NOTFOUND )
3626
 
-               {
3627
 
-                       nID = aLine.Copy( nPos+4 ).ToInt32();
3628
 
-                       pSound = getSoundById( nID );
3629
 
-               }
3630
 
-
3631
 
-               if( pSound && pSound->m_pSalSound )
3632
 
-               {
3633
 
-                       if( aEvent == "done" )
3634
 
-                       {
3635
 
-                               if( pSound->m_pSalSound->m_bLoop )
3636
 
-                                       pSound->play();
3637
 
-                               else
3638
 
-                                       pSound->m_pSalSound->changeStateStop();
3639
 
-                       }
3640
 
-                       else if( aEvent == "pause" )
3641
 
-                               pSound->m_pSalSound->changeStatePause();
3642
 
-                       else if( aEvent == "continue" )
3643
 
-                               pSound->m_pSalSound->changeStateCont();
3644
 
-               }
3645
 
-       }
3646
 
-       return 0;
3647
 
-}
3648
 
-
3649
 
-ByteString RPTPSound::readLine()
3650
 
-{
3651
 
-       static char pAnswerBuffer[ 1024 ];
3652
 
-
3653
 
-       if( ! s_bConnected && ! connect() )
3654
 
-               return ByteString();
3655
 
-
3656
 
-       memset( pAnswerBuffer, 0, sizeof( pAnswerBuffer ) );
3657
 
-       if( s_aConnector.read( pAnswerBuffer, 1 ) == 1 )
3658
 
-       {
3659
 
-               unsigned int nTimes = 0;
3660
 
-               unsigned int nPos = 1;
3661
 
-               while( nTimes < 1000 && nPos < sizeof( pAnswerBuffer )-1 )
3662
 
-               {
3663
 
-                       while( s_aConnector.recv( pAnswerBuffer + nPos, 1 ) == 1 &&
3664
 
-                                  nPos < sizeof( pAnswerBuffer )-1 )
3665
 
-                       {
3666
 
-                               nPos++;
3667
 
-                               if( pAnswerBuffer[ nPos-2 ] == '\r' &&
3668
 
-                                       pAnswerBuffer[ nPos-1 ] == '\n' )
3669
 
-                               {
3670
 
-                                       pAnswerBuffer[ nPos-2 ] = 0;
3671
 
-                                       goto doreturn;
3672
 
-                               }
3673
 
-                       }
3674
 
-            TimeValue aVal;
3675
 
-            aVal.Seconds = 0;
3676
 
-            aVal.Nanosec = 1000000;
3677
 
-            osl_waitThread( &aVal );
3678
 
-               }
3679
 
-       }
3680
 
-  doreturn:
3681
 
-       SalDbgAssert( "read line \"%s\"\n", pAnswerBuffer );
3682
 
-       return ByteString( pAnswerBuffer );
3683
 
-}
3684
 
-
3685
 
-ByteString RPTPSound::sendCommand( const ByteString& rCommand )
3686
 
-{
3687
 
-       if( ! s_bConnected && ! connect() )
3688
 
-               return ByteString();
3689
 
-
3690
 
-       SalDbgAssert( "RPTPSound::sendCommand( \"%s\" )\n", rCommand.GetBuffer() );
3691
 
-       
3692
 
-       ByteString aCommand( rCommand );
3693
 
-       aCommand += "\r\n";
3694
 
-       s_aConnector.write( aCommand.GetBuffer(), aCommand.Len() );
3695
 
-       return readLine();
3696
 
-}
3697
 
-
3698
 
-RPTPSound* RPTPSound::getSoundById( ULONG nID )
3699
 
-{
3700
 
-       for( unsigned int i = 0; i < s_aSounds.Count(); i++ )
3701
 
-       {
3702
 
-               RPTPSound* pSound = s_aSounds.GetObject( i );
3703
 
-               if( pSound->m_nID == nID )
3704
 
-                       return pSound;
3705
 
-       }
3706
 
-       return NULL;
3707
 
-}
3708
 
-
3709
 
-ULONG RPTPSound::getMaxId()
3710
 
-{
3711
 
-       ULONG nID = 0;
3712
 
-       for( unsigned int i = 0; i < s_aSounds.Count(); i++ )
3713
 
-       {
3714
 
-               RPTPSound* pSound = s_aSounds.GetObject( i );
3715
 
-               if( pSound->m_nID > nID )
3716
 
-                       nID = pSound->m_nID;
3717
 
-       }
3718
 
-       return nID;
3719
 
-}
3720
 
-
3721
 
-RPTPSound::RPTPSound( X11SalSound* pSalSound ) :
3722
 
-               VSound( pSalSound ),
3723
 
-               m_nID( 0 )
3724
 
-{
3725
 
-       s_aSounds.Insert( this );
3726
 
-}
3727
 
-
3728
 
-RPTPSound::~RPTPSound()
3729
 
-{
3730
 
-       s_aSounds.Remove( this );
3731
 
-       m_pSalSound = NULL;
3732
 
-       stop();
3733
 
-       if( s_aSounds.Count() == 0 )
3734
 
-               disconnect();
3735
 
-}
3736
 
-
3737
 
-void RPTPSound::play()
3738
 
-{
3739
 
-       if( ! m_pSalSound )
3740
 
-               return;
3741
 
-
3742
 
-       ByteString aCommand( "find sound=" );
3743
 
-
3744
 
-       aCommand += m_pSalSound->m_aSoundFile;
3745
 
-       ByteString aAnswer = sendCommand( aCommand );
3746
 
-       if( ! aAnswer.Len() || ! s_bConnected )
3747
 
-       {
3748
 
-               m_pSalSound->setError( SOUNDERR_INVALID_FILE );
3749
 
-               return;
3750
 
-       }
3751
 
-       if( aAnswer.GetChar( 0 ) != '+' )
3752
 
-       {
3753
 
-               // the sound is not on the server
3754
 
-               // try to put it (does not really work with rplayd 3.3.0)
3755
 
-               aCommand = "put";
3756
 
-               
3757
 
-               initBuffer();
3758
 
-
3759
 
-               if( ! m_pBuffer )
3760
 
-               {
3761
 
-                       m_pSalSound->setError( SOUNDERR_INVALID_FILE );
3762
 
-                       return;
3763
 
-               }
3764
 
-
3765
 
-               aCommand += " sound=";
3766
 
-               aCommand += m_pSalSound->m_aSoundFile;
3767
 
-               aCommand += " size=";
3768
 
-               aCommand += ByteString::CreateFromInt64((ULONG)m_aStat.st_size);
3769
 
-               
3770
 
-               aAnswer = sendCommand( aCommand );
3771
 
-               
3772
 
-               if( aAnswer.GetChar( 0 ) == '+' )
3773
 
-                       s_aConnector.write( m_pBuffer, m_aStat.st_size );
3774
 
-               // if this fails proceed anyway, because at least rplayd 3.3.0
3775
 
-               // does not seem to grok the "put" command
3776
 
-
3777
 
-               releaseBuffer();
3778
 
-       }
3779
 
-
3780
 
-       aCommand = "play ";
3781
 
-       aCommand += m_pSalSound->m_aSoundFile;
3782
 
-       aAnswer = sendCommand( aCommand );
3783
 
-       if( aAnswer.GetChar( 0 ) == '+' )
3784
 
-       {
3785
 
-               int nPos = aAnswer.Search( "id=#" );
3786
 
-               if( nPos != STRING_NOTFOUND )
3787
 
-                       m_nID = aAnswer.Copy( nPos+4 ).ToInt32();
3788
 
-       }
3789
 
-       else
3790
 
-               m_pSalSound->setError( SOUNDERR_DEVICE_NOT_READY );
3791
 
-
3792
 
-       SalDbgAssert( "RPTPSound::play() yields id %d\n", m_nID );
3793
 
-}
3794
 
-
3795
 
-void RPTPSound::stop()
3796
 
-{
3797
 
-       ByteString aAnswer;
3798
 
-       if( m_nID )
3799
 
-       {
3800
 
-               ByteString aCommand( "stop id=#" );
3801
 
-               aCommand += ByteString::CreateFromInt64(m_nID);
3802
 
-               aAnswer = sendCommand( aCommand );
3803
 
-       }
3804
 
-       if( aAnswer.GetChar( 0 ) != '+' && m_pSalSound)
3805
 
-               m_pSalSound->setError( SOUNDERR_INVALID_FILE );
3806
 
-}
3807
 
-
3808
 
-void RPTPSound::pause()
3809
 
-{
3810
 
-       if( m_nID )
3811
 
-       {
3812
 
-               ByteString aCommand( "pause id=#" );
3813
 
-               aCommand += ByteString::CreateFromInt64(m_nID);
3814
 
-               sendCommand( aCommand );
3815
 
-       }
3816
 
-}
3817
 
-
3818
 
-void RPTPSound::cont()
3819
 
-{
3820
 
-       if( m_nID )
3821
 
-       {
3822
 
-               ByteString aCommand( "continue id=#" );
3823
 
-               aCommand += ByteString::CreateFromInt64(m_nID);
3824
 
-               sendCommand( aCommand );
3825
 
-       }
3826
 
-}
3827
 
-
3828
 
-BOOL RPTPSound::isValid()
3829
 
-{
3830
 
-       if( ! s_bConnected )
3831
 
-               connect();
3832
 
-       if( ! s_bConnected )
3833
 
-               return FALSE;
3834
 
-
3835
 
-       return stat( m_pSalSound->m_aSoundFile.GetBuffer(), &m_aStat ) ? FALSE : TRUE;
3836
 
-}
3837
 
-
3838
 
Index: vcl/unx/source/app/salimpsound.hxx
3839
 
===================================================================
3840
 
RCS file: vcl/unx/source/app/salimpsound.hxx
3841
 
diff -N vcl/unx/source/app/salimpsound.hxx
3842
 
--- vcl/unx/source/app/salimpsound.hxx  31 Jul 2007 13:02:03 -0000      1.10
3843
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
3844
 
@@ -1,305 +0,0 @@
3845
 
-/*************************************************************************
3846
 
- *
3847
 
- *  OpenOffice.org - a multi-platform office productivity suite
3848
 
- *
3849
 
- *  $RCSfile: salimpsound.hxx,v $
3850
 
- *
3851
 
- *  $Revision: 1.10 $
3852
 
- *
3853
 
- *  last change: $Author: hr $ $Date: 2007/07/31 13:02:03 $
3854
 
- *
3855
 
- *  The Contents of this file are made available subject to
3856
 
- *  the terms of GNU Lesser General Public License Version 2.1.
3857
 
- *
3858
 
- *
3859
 
- *    GNU Lesser General Public License Version 2.1
3860
 
- *    =============================================
3861
 
- *    Copyright 2005 by Sun Microsystems, Inc.
3862
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
3863
 
- *
3864
 
- *    This library is free software; you can redistribute it and/or
3865
 
- *    modify it under the terms of the GNU Lesser General Public
3866
 
- *    License version 2.1, as published by the Free Software Foundation.
3867
 
- *
3868
 
- *    This library is distributed in the hope that it will be useful,
3869
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
3870
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3871
 
- *    Lesser General Public License for more details.
3872
 
- *
3873
 
- *    You should have received a copy of the GNU Lesser General Public
3874
 
- *    License along with this library; if not, write to the Free Software
3875
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
3876
 
- *    MA  02111-1307  USA
3877
 
- *
3878
 
- ************************************************************************/
3879
 
-#ifndef _VCL_SALIMPSOUND_HXX
3880
 
-#define _VCL_SALIMPSOUND_HXX
3881
 
-
3882
 
-#include <vsound.hxx>
3883
 
-
3884
 
-#include <osl/mutex.hxx>
3885
 
-#include <vos/socket.hxx>
3886
 
-
3887
 
-#include <tools/list.hxx>
3888
 
-#include <tools/link.hxx>
3889
 
-#include <tools/gen.hxx>
3890
 
-#include <tools/string.hxx>
3891
 
-
3892
 
-#include <vcl/sv.h>
3893
 
-#include <vcl/salstype.hxx>
3894
 
-
3895
 
-#include <unistd.h>
3896
 
-#include <sys/stat.h>
3897
 
-
3898
 
-#ifdef USE_PASF
3899
 
-#ifdef SYSTEM_PORTAUDIO
3900
 
-#include <portaudio.h>
3901
 
-#else
3902
 
-#include <portaudio/portaudio.h>
3903
 
-#endif
3904
 
-#ifdef SYSTEM_SNDFILE
3905
 
-#include <sndfile.h>
3906
 
-#else
3907
 
-#include <sndfile/sndfile.h>
3908
 
-#endif
3909
 
-#endif
3910
 
-
3911
 
-namespace vcl_sal {
3912
 
-
3913
 
-// OSS can only be used on local displays
3914
 
-
3915
 
-#ifdef USE_OSS
3916
 
-       class OSSSound : public VSound
3917
 
-       {
3918
 
-               // thread implementation
3919
 
-               struct OSSData
3920
 
-               {
3921
 
-                       OSSSound*       m_pSound;
3922
 
-                       long            m_nDataLen;
3923
 
-                       long            m_nStartPos;
3924
 
-                       long            m_nEndPos;
3925
 
-                       long            m_nCurPos;
3926
 
-                       int                     m_nType;
3927
 
-               };
3928
 
-               DECLARE_LIST( OSSDataList, OSSData* )
3929
 
-               DECLARE_LIST( OSSSoundList, OSSSound* )
3930
 
-
3931
 
-               static int                                              s_nDevice;
3932
 
-               static OSSDataList                              s_aDataList;
3933
 
-               static osl::Mutex                               s_aProtector;
3934
 
-               static OSSSoundList                     s_aSounds;
3935
 
-
3936
 
-               // static methods
3937
 
-               static BOOL             open();
3938
 
-               static void             close();
3939
 
-               static void             append( OSSSound* );
3940
 
-               static void             remove( OSSSound* );
3941
 
-               static BOOL             startSound( OSSData* pData );
3942
 
-               static BOOL             startAU( OSSData* pData );
3943
 
-               static BOOL             startRIFF( OSSData* pData );
3944
 
-               static int                      findChunk( OSSData* pData, const char* pChunk );
3945
 
-               static short int        readLEShort( const char* );
3946
 
-               static int                      readLEInt( const char* );
3947
 
-               static ULONG            readBELong( const char* );
3948
 
-
3949
 
-               DECL_LINK( notifyStopHdl, void* );
3950
 
-               DECL_LINK( notifyErrorHdl, void* );
3951
 
-       protected:
3952
 
-               virtual BOOL isValid();
3953
 
-       public:
3954
 
-               OSSSound( ::X11SalSound* pSalSound );
3955
 
-               virtual ~OSSSound();
3956
 
-
3957
 
-               virtual void play();
3958
 
-               virtual void stop();
3959
 
-               virtual void pause();
3960
 
-               virtual void cont();
3961
 
-
3962
 
-               static void run(); // thread worker
3963
 
-       };
3964
 
-#endif
3965
 
-
3966
 
-// DEVAUDIO can only be used on local displays
3967
 
-
3968
 
-#ifdef USE_DEVAUDIO
3969
 
-       class DevAudioSound;
3970
 
-       struct DevAudioData
3971
 
-       {
3972
 
-               DevAudioSound*  m_pSound;
3973
 
-               AudioConverter* m_pConverter;
3974
 
-               long                    m_nDataLen;
3975
 
-               long                    m_nStartPos;
3976
 
-               long                    m_nEndPos;
3977
 
-               long                    m_nCurPos;
3978
 
-               int                             m_nType;
3979
 
-
3980
 
-               DevAudioData( DevAudioSound* pSound ) :
3981
 
-                               m_pSound( pSound ), m_pConverter( NULL ), m_nDataLen( 0 ),
3982
 
-                               m_nStartPos( 0 ), m_nEndPos( 0 ), m_nCurPos( 0 ), m_nType( 0 )
3983
 
-                       {}
3984
 
-               ~DevAudioData()
3985
 
-                       { if( m_pConverter ) delete m_pConverter; }
3986
 
-       };
3987
 
-       DECLARE_LIST( DevAudioDataList, DevAudioData* )
3988
 
-       DECLARE_LIST( DevAudioSoundList, DevAudioSound* )
3989
 
-
3990
 
-       class DevAudioSound : public VSound
3991
 
-       {
3992
 
-               // thread implementation
3993
 
-
3994
 
-               static int                                              s_nDevice;
3995
 
-               static DevAudioDataList         s_aDataList;
3996
 
-               static osl::Mutex                               s_aProtector;
3997
 
-               static DevAudioSoundList                s_aSounds;
3998
 
-
3999
 
-               // static methods
4000
 
-               static BOOL             open();
4001
 
-               static void             close();
4002
 
-               static void             append( DevAudioSound* );
4003
 
-               static void             remove( DevAudioSound* );
4004
 
-               static BOOL                     startSound( DevAudioData* pData );
4005
 
-               static BOOL                     startAU( DevAudioData* pData );
4006
 
-               static BOOL                     startRIFF( DevAudioData* pData );
4007
 
-               static int                      findChunk( DevAudioData* pData, const char* pChunk );
4008
 
-               static short int        readLEShort( const char* );
4009
 
-               static int                      readLEInt( const char* );
4010
 
-               static ULONG            readBELong( const char* );
4011
 
-
4012
 
-               DECL_LINK( notifyStopHdl, void* );
4013
 
-               DECL_LINK( notifyErrorHdl, void* );
4014
 
-       protected:
4015
 
-               virtual BOOL isValid();
4016
 
-       public:
4017
 
-               DevAudioSound( ::X11SalSound* pSalSound );
4018
 
-               virtual ~DevAudioSound();
4019
 
-
4020
 
-               virtual void play();
4021
 
-               virtual void stop();
4022
 
-               virtual void pause();
4023
 
-               virtual void cont();
4024
 
-
4025
 
-               static void run();
4026
 
-       };
4027
 
-#endif
4028
 
-
4029
 
-
4030
 
-// Portaudio / libsndfile can only be used on local displays
4031
 
-
4032
 
-#ifdef USE_PASF
4033
 
-#define PASF_BUFFER_LEN  (8192)
4034
 
-
4035
 
-typedef struct
4036
 
-{       
4037
 
-#if PA_VER == 18
4038
 
-    PaDeviceID       device;
4039
 
-#else
4040
 
-    PaDeviceIndex    device;
4041
 
-#endif
4042
 
-    PaSampleFormat   format;
4043
 
-    unsigned int     bufsize;
4044
 
-    SNDFILE          *sndfile;
4045
 
-    SF_INFO          sfinfo;
4046
 
-    int              loop_count;
4047
 
-    unsigned long    start_frame;
4048
 
-    unsigned long    stop_frame;
4049
 
-    unsigned long    frame_count;
4050
 
-    int              done_playing;
4051
 
-} PASFAudioData ;
4052
 
-
4053
 
-
4054
 
-class PASFSound : public VSound
4055
 
-{
4056
 
-       private:        
4057
 
-    PaStream*                    m_pStream;
4058
 
-    PASFAudioData*               m_pData;
4059
 
-    
4060
 
-       protected:
4061
 
-    virtual BOOL isValid();
4062
 
-    
4063
 
-       public:
4064
 
-    PASFSound( ::X11SalSound* pSalSound );
4065
 
-    virtual ~PASFSound();
4066
 
-    
4067
 
-    virtual void play();
4068
 
-    virtual void stop();
4069
 
-    virtual void pause();
4070
 
-    virtual void cont();
4071
 
-    
4072
 
-};
4073
 
-#endif
4074
 
-
4075
 
-
4076
 
-
4077
 
-class RPTPSound : public VSound
4078
 
-{
4079
 
-        DECLARE_LIST( RPTPSoundList, RPTPSound* )
4080
 
-
4081
 
-       static BOOL                                                             s_bConnected;
4082
 
-       static NAMESPACE_VOS(OConnectorSocket)          s_aConnector;
4083
 
-       static RPTPSoundList                                            s_aSounds;
4084
 
-       static BOOL                                                             s_bFailedOnce;
4085
 
-
4086
 
-       static BOOL                     connect();
4087
 
-       static void                     disconnect();
4088
 
-       static ByteString       readLine();
4089
 
-       static ByteString       sendCommand( const ByteString& rCommand );
4090
 
-
4091
 
-       static int getFileDescriptor();
4092
 
-       static RPTPSound* getSoundById( ULONG );
4093
 
-       static ULONG      getMaxId();
4094
 
-
4095
 
-       // SalYieldEntry
4096
 
-       static int pending( int, void* );
4097
 
-       static int queued( int, void* );
4098
 
-       static int handleEvents( int, void* );
4099
 
-
4100
 
-       ULONG                   m_nID;
4101
 
-  protected:
4102
 
-       virtual BOOL isValid();
4103
 
-  public:
4104
 
-  RPTPSound( ::X11SalSound* pSalSound );
4105
 
-
4106
 
-       virtual ~RPTPSound();
4107
 
-
4108
 
-       virtual void play();
4109
 
-       virtual void stop();
4110
 
-       virtual void pause();
4111
 
-       virtual void cont();
4112
 
-};
4113
 
-
4114
 
-
4115
 
-#ifdef USE_NAS
4116
 
-       class NASSound : public VSound
4117
 
-       {
4118
 
-               DECLARE_LIST( NASSoundList, NASSound* )
4119
 
-               
4120
 
-               static NASSoundList                             s_aSounds;
4121
 
-               static void*                                    s_pServer;
4122
 
-               static BOOL                                             s_bFailedOnce;
4123
 
-
4124
 
-               static BOOL     connect();
4125
 
-               static void disconnect();
4126
 
-
4127
 
-               static void callback( void*, void*, void*, void* );
4128
 
-               // SalYieldEntry
4129
 
-               static int pending( int, void* );
4130
 
-               static int queued( int, void* );
4131
 
-               static int handleEvents( int, void* );
4132
 
-
4133
 
-               ULONG   m_nFlowID;
4134
 
-       protected:
4135
 
-               virtual BOOL isValid();
4136
 
-       public:
4137
 
-               NASSound( ::X11SalSound* pSalSound );
4138
 
-
4139
 
-               virtual ~NASSound();
4140
 
-
4141
 
-               virtual void play();
4142
 
-               virtual void stop();
4143
 
-               virtual void pause();
4144
 
-               virtual void cont();
4145
 
-       };
4146
 
-#endif
4147
 
-}
4148
 
-
4149
 
-#endif
4150
 
Index: vcl/unx/source/app/salinst.cxx
4151
 
===================================================================
4152
 
RCS file: /cvs/gsl/vcl/unx/source/app/salinst.cxx,v
4153
 
retrieving revision 1.32
4154
 
retrieving revision 1.32.60.1
4155
 
diff -u -p -u -p -r1.32 -r1.32.60.1
4156
 
--- vcl/unx/source/app/salinst.cxx      27 Jun 2007 20:47:09 -0000      1.32
4157
 
+++ vcl/unx/source/app/salinst.cxx      31 Aug 2007 09:44:58 -0000      1.32.60.1
4158
 
@@ -75,9 +75,6 @@
4159
 
 #ifndef _SV_SALOGL_H
4160
 
 #include <salogl.h>
4161
 
 #endif
4162
 
-#ifndef _SV_SALSOUND_H
4163
 
-#include <salsound.h>
4164
 
-#endif
4165
 
 
4166
 
 // -------------------------------------------------------------------------
4167
 
 //
4168
 
@@ -145,9 +142,6 @@ extern "C"
4169
 
 
4170
 
 X11SalInstance::~X11SalInstance()
4171
 
 {
4172
 
-    // deinitialize global sound resources
4173
 
-    X11SalSound::Release();
4174
 
-
4175
 
     // release (possibly open) OpenGL context
4176
 
     X11SalOpenGL::Release();
4177
 
 
4178
 
@@ -323,9 +317,3 @@ SalOpenGL* X11SalInstance::CreateSalOpen
4179
 
 {
4180
 
     return new X11SalOpenGL( pGraphics );
4181
 
 }
4182
 
-
4183
 
-SalSound* X11SalInstance::CreateSalSound()
4184
 
-{
4185
 
-    return new X11SalSound();
4186
 
-}
4187
 
-
4188
 
Index: vcl/unx/source/app/salsound2.cxx
4189
 
===================================================================
4190
 
RCS file: vcl/unx/source/app/salsound2.cxx
4191
 
diff -N vcl/unx/source/app/salsound2.cxx
4192
 
--- vcl/unx/source/app/salsound2.cxx    27 Jun 2007 20:47:22 -0000      1.11
4193
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
4194
 
@@ -1,334 +0,0 @@
4195
 
-/*************************************************************************
4196
 
- *
4197
 
- *  OpenOffice.org - a multi-platform office productivity suite
4198
 
- *
4199
 
- *  $RCSfile: salsound2.cxx,v $
4200
 
- *
4201
 
- *  $Revision: 1.11 $
4202
 
- *
4203
 
- *  last change: $Author: hr $ $Date: 2007/06/27 20:47:22 $
4204
 
- *
4205
 
- *  The Contents of this file are made available subject to
4206
 
- *  the terms of GNU Lesser General Public License Version 2.1.
4207
 
- *
4208
 
- *
4209
 
- *    GNU Lesser General Public License Version 2.1
4210
 
- *    =============================================
4211
 
- *    Copyright 2005 by Sun Microsystems, Inc.
4212
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
4213
 
- *
4214
 
- *    This library is free software; you can redistribute it and/or
4215
 
- *    modify it under the terms of the GNU Lesser General Public
4216
 
- *    License version 2.1, as published by the Free Software Foundation.
4217
 
- *
4218
 
- *    This library is distributed in the hope that it will be useful,
4219
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
4220
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4221
 
- *    Lesser General Public License for more details.
4222
 
- *
4223
 
- *    You should have received a copy of the GNU Lesser General Public
4224
 
- *    License along with this library; if not, write to the Free Software
4225
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
4226
 
- *    MA  02111-1307  USA
4227
 
- *
4228
 
- ************************************************************************/
4229
 
-
4230
 
-// MARKER(update_precomp.py): autogen include statement, do not remove
4231
 
-#include "precompiled_vcl.hxx"
4232
 
-#include <sys/stat.h>
4233
 
-#include <sys/mman.h>
4234
 
-#include <fcntl.h>
4235
 
-#include <unistd.h>
4236
 
-
4237
 
-#include <salunx.h>
4238
 
-#include <saldata.hxx>
4239
 
-#include <saldisp.hxx>
4240
 
-
4241
 
-#include <salsound.h>
4242
 
-#include <vcl/salstype.hxx>
4243
 
-#include <salimpsound.hxx>
4244
 
-
4245
 
-using namespace vcl_sal;
4246
 
-
4247
 
-ULONG X11SalSound::s_nSoundState = SOUND_STATE_UNLOADED;
4248
 
-
4249
 
-X11SalSound::X11SalSound() :
4250
 
-               m_pVSound( NULL ),
4251
 
-               m_bLoop( false ),
4252
 
-               m_bPlaying( false ),
4253
 
-               m_bPaused( false ),
4254
 
-               m_nStartTime( 0 ),
4255
 
-               m_nPlayTime( SOUND_PLAYALL )
4256
 
-{
4257
 
-       SalDbgAssert( "X11SalSound::X11SalSound()\n" );
4258
 
-    #ifdef USE_PASF
4259
 
-    // initialize the portaudio library (typically just once)
4260
 
-    if (s_nSoundState == SOUND_STATE_UNLOADED) 
4261
 
-    {
4262
 
-        PaError err = Pa_Initialize();  
4263
 
-        if( err == paNoError )
4264
 
-            s_nSoundState = SOUND_STATE_VALID;
4265
 
-    }
4266
 
-    if (s_nSoundState != SOUND_STATE_VALID )
4267
 
-        s_nSoundState = SOUND_STATE_INVALID;
4268
 
-    #else
4269
 
-    s_nSoundState = SOUND_STATE_VALID;
4270
 
-    #endif
4271
 
-}
4272
 
-
4273
 
-X11SalSound::~X11SalSound()
4274
 
-{
4275
 
-       SalDbgAssert( "X11SalSound::~X11SalSound()\n" );
4276
 
-       if( m_pVSound )
4277
 
-               delete m_pVSound;
4278
 
-}
4279
 
-
4280
 
-void X11SalSound::Release()
4281
 
-{
4282
 
-#ifdef USE_PASF
4283
 
-        // terminate the portaudio library
4284
 
-        if ( s_nSoundState == SOUND_STATE_VALID ) Pa_Terminate();
4285
 
-#endif
4286
 
-        s_nSoundState = SOUND_STATE_UNLOADED;
4287
 
-}
4288
 
-
4289
 
-bool X11SalSound::IsValid()
4290
 
-{
4291
 
-  return (X11SalSound::s_nSoundState == SOUND_STATE_VALID);
4292
 
-}
4293
 
-
4294
 
-
4295
 
-bool X11SalSound::Init( const String& rSoundName, ULONG& rSoundLen )
4296
 
-{
4297
 
-    
4298
 
-    // FIXME: NULL file names are passed in
4299
 
-    // This can happen before play of previous sound has completed and this disrupts things
4300
 
-    // simpy ignore this for now
4301
 
-    if (! (rSoundName.Len()))
4302
 
-        return false;
4303
 
-    
4304
 
-       if( m_pVSound )
4305
 
-               delete m_pVSound;
4306
 
-
4307
 
-    #ifdef MACOSX
4308
 
-       m_aSoundFile = ByteString( rSoundName, RTL_TEXTENCODING_UTF8 );
4309
 
-    #else
4310
 
-       m_aSoundFile = ByteString( rSoundName, osl_getThreadTextEncoding() );
4311
 
-    #endif
4312
 
-       SalDbgAssert( "X11SalSound::Init( \"%s\", %d )\n", m_aSoundFile.GetBuffer(), rSoundLen );
4313
 
-    
4314
 
-       m_pVSound = ( !m_aSoundFile.Len() || access( m_aSoundFile.GetBuffer(), R_OK ) ) ? NULL : VSound::createVSound( this );
4315
 
-    
4316
 
-       return m_pVSound ? true : false;
4317
 
-}
4318
 
-
4319
 
-void X11SalSound::Play( ULONG nStartTime, ULONG nPlayTime, bool bLoop )
4320
 
-{
4321
 
-       SalDbgAssert( "SalSound::Play( %d, %d, %s )\n", nStartTime, nPlayTime, bLoop ? "TRUE" : "FALSE" );
4322
 
-       if( m_bPlaying && m_pVSound )
4323
 
-               m_pVSound->stop();
4324
 
-    
4325
 
-       m_bLoop                 = bLoop;
4326
 
-       m_nStartTime    = nStartTime;
4327
 
-       m_nPlayTime             = nPlayTime;
4328
 
-    
4329
 
-       if( m_pVSound )
4330
 
-               m_pVSound->play();
4331
 
-}
4332
 
-
4333
 
-void X11SalSound::Stop()
4334
 
-{
4335
 
-       SalDbgAssert( "X11SalSound::Stop()\n" );
4336
 
-       if( m_bPlaying && m_pVSound )
4337
 
-               m_pVSound->stop();
4338
 
-}
4339
 
-
4340
 
-void X11SalSound::Pause()
4341
 
-{
4342
 
-       if( m_bPlaying && m_pVSound )
4343
 
-               m_pVSound->pause();
4344
 
-}
4345
 
-
4346
 
-void X11SalSound::Continue()
4347
 
-{
4348
 
-       if( m_bPaused && m_pVSound )
4349
 
-               m_pVSound->cont();
4350
 
-}
4351
 
-
4352
 
-bool X11SalSound::IsLoopMode() const
4353
 
-{
4354
 
-    return m_bLoop;
4355
 
-}
4356
 
-
4357
 
-bool X11SalSound::IsPlaying() const
4358
 
-{
4359
 
-    return m_bPlaying;
4360
 
-}
4361
 
-
4362
 
-bool X11SalSound::IsPaused() const
4363
 
-{
4364
 
-    return m_bPaused;
4365
 
-}
4366
 
-
4367
 
-// --------------------------------------------------
4368
 
-
4369
 
-void VSound::initBuffer()
4370
 
-{
4371
 
-       if( stat( m_pSalSound->m_aSoundFile.GetBuffer(), &m_aStat ) )
4372
 
-       {
4373
 
-               SalDbgAssert( "could not stat \"%s\"\n", m_pSalSound->m_aSoundFile.GetBuffer() );
4374
 
-               return;
4375
 
-       }
4376
 
-       int nFile;
4377
 
-       if( ( nFile = ::open( m_pSalSound->m_aSoundFile.GetBuffer(), O_RDONLY ) ) == -1 )
4378
 
-       {
4379
 
-               SalDbgAssert( "could not open %s\n", m_pSalSound->m_aSoundFile.GetBuffer() );
4380
 
-               return;
4381
 
-       }
4382
 
-
4383
 
-       m_pBuffer = (char *)mmap( NULL, m_aStat.st_size, PROT_READ, MAP_SHARED, nFile, 0 );
4384
 
-       ::close( nFile );
4385
 
-       if( m_pBuffer == MAP_FAILED )
4386
 
-       {
4387
 
-               SalDbgAssert( "could not mmap %s\n", m_pSalSound->m_aSoundFile.GetBuffer() );
4388
 
-               m_pBuffer = NULL;
4389
 
-               return;
4390
 
-       }
4391
 
-}
4392
 
-
4393
 
-void VSound::releaseBuffer()
4394
 
-{
4395
 
-       if( m_pBuffer )
4396
 
-       {
4397
 
-               munmap( m_pBuffer, m_aStat.st_size );
4398
 
-               m_pBuffer = NULL;
4399
 
-       }
4400
 
-}
4401
 
-
4402
 
-
4403
 
-VSound* VSound::createVSound( X11SalSound* pX11SalSound )
4404
 
-{
4405
 
-       struct stat aStat;
4406
 
-       if( stat( pX11SalSound->m_aSoundFile.GetBuffer(), & aStat ) )
4407
 
-               return NULL;
4408
 
-
4409
 
-       VSound* pRet = NULL;
4410
 
-
4411
 
-       if( GetX11SalData()->GetDisplay()->IsLocal() )
4412
 
-    {
4413
 
-        #ifdef USE_PASF
4414
 
-        {
4415
 
-            pRet = new PASFSound( pX11SalSound );
4416
 
-            if( pRet && ! pRet->isValid() )
4417
 
-            {
4418
 
-                delete pRet;
4419
 
-                pRet = NULL;
4420
 
-            }
4421
 
-            else
4422
 
-                SalDbgAssert( "got an PASFSound\n" );
4423
 
-        }
4424
 
-        #endif
4425
 
-
4426
 
-        #ifdef USE_OSS
4427
 
-        if( ! pRet )
4428
 
-        {
4429
 
-            pRet = new OSSSound( pX11SalSound );
4430
 
-            if( pRet && ! pRet->isValid() )
4431
 
-            {
4432
 
-                delete pRet;
4433
 
-                pRet = NULL;
4434
 
-            }
4435
 
-            else
4436
 
-                SalDbgAssert( "got an OSSSound\n" );
4437
 
-        }
4438
 
-        #endif
4439
 
-
4440
 
-        #ifdef USE_DEVAUDIO
4441
 
-        if( ! pRet )
4442
 
-        {
4443
 
-            pRet = new DevAudioSound( pX11SalSound );
4444
 
-            if( pRet && ! pRet->isValid() )
4445
 
-            {
4446
 
-                delete pRet;
4447
 
-                pRet = NULL;
4448
 
-            }
4449
 
-            else
4450
 
-                SalDbgAssert( "got an DevAudioSound\n" );
4451
 
-        }
4452
 
-        #endif
4453
 
-    }
4454
 
-    
4455
 
-#ifdef USE_NAS
4456
 
-       if( ! pRet )
4457
 
-       {
4458
 
-               pRet = new NASSound( pX11SalSound );
4459
 
-               if( pRet && ! pRet->isValid() )
4460
 
-               {
4461
 
-                       delete pRet;
4462
 
-                       pRet = NULL;
4463
 
-               }
4464
 
-               else
4465
 
-                       SalDbgAssert( "got an AUSound\n" );
4466
 
-       }
4467
 
-#endif
4468
 
-
4469
 
-       if( ! pRet )
4470
 
-       {
4471
 
-               pRet = new RPTPSound( pX11SalSound );
4472
 
-               if( pRet && ! pRet->isValid() )
4473
 
-               {
4474
 
-                       delete pRet;
4475
 
-                       pRet = NULL;
4476
 
-               }
4477
 
-               else
4478
 
-                       SalDbgAssert( "got an RPTPSound\n" );
4479
 
-       }
4480
 
-       return pRet;
4481
 
-}
4482
 
-
4483
 
-
4484
 
-void X11SalSound::changeStatePlay()
4485
 
-{
4486
 
-       SalDbgAssert( "SalSound(%p)::changeStatePlay()\n", this );
4487
 
-
4488
 
-       m_bPlaying      = TRUE;
4489
 
-       m_bPaused       = FALSE;
4490
 
-
4491
 
-    CallNotifyProc( SOUND_NOTIFY_SUCCESS, SOUNDERR_SUCCESS );
4492
 
-}
4493
 
-
4494
 
-void X11SalSound::changeStateStop()
4495
 
-{
4496
 
-       SalDbgAssert( "X11SalSound(%p)::changeStateStop()\n", this );
4497
 
-
4498
 
-       m_bPlaying      = FALSE;
4499
 
-       m_bPaused       = FALSE;
4500
 
-
4501
 
-    CallNotifyProc( SOUND_NOTIFY_SUCCESS, SOUNDERR_SUCCESS );
4502
 
-}
4503
 
-
4504
 
-void X11SalSound::changeStatePause()
4505
 
-{
4506
 
-       SalDbgAssert( "X11SalSound(%p)::changeStatePause()\n", this );
4507
 
-
4508
 
-       m_bPlaying      = TRUE;
4509
 
-       m_bPaused       = TRUE;
4510
 
-
4511
 
-    CallNotifyProc( SOUND_NOTIFY_SUCCESS, SOUNDERR_SUCCESS );
4512
 
-}
4513
 
-
4514
 
-void X11SalSound::changeStateCont()
4515
 
-{
4516
 
-       SalDbgAssert( "X11SalSound(%p)::changeStateCont()\n", this );
4517
 
-
4518
 
-       m_bPlaying      = TRUE;
4519
 
-       m_bPaused       = FALSE;
4520
 
-
4521
 
-    CallNotifyProc( SOUND_NOTIFY_SUCCESS, SOUNDERR_SUCCESS );
4522
 
-}
4523
 
-
4524
 
-void X11SalSound::setError( ULONG nError )
4525
 
-{
4526
 
-    CallNotifyProc( SOUND_NOTIFY_ERROR, nError );
4527
 
-}
4528
 
-
4529
 
Index: vcl/unx/source/app/sunconvert.cxx
4530
 
===================================================================
4531
 
RCS file: vcl/unx/source/app/sunconvert.cxx
4532
 
diff -N vcl/unx/source/app/sunconvert.cxx
4533
 
--- vcl/unx/source/app/sunconvert.cxx   17 Sep 2006 12:36:39 -0000      1.6
4534
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
4535
 
@@ -1,1330 +0,0 @@
4536
 
-/*************************************************************************
4537
 
- *
4538
 
- *  OpenOffice.org - a multi-platform office productivity suite
4539
 
- *
4540
 
- *  $RCSfile: sunconvert.cxx,v $
4541
 
- *
4542
 
- *  $Revision: 1.6 $
4543
 
- *
4544
 
- *  last change: $Author: obo $ $Date: 2006/09/17 12:36:39 $
4545
 
- *
4546
 
- *  The Contents of this file are made available subject to
4547
 
- *  the terms of GNU Lesser General Public License Version 2.1.
4548
 
- *
4549
 
- *
4550
 
- *    GNU Lesser General Public License Version 2.1
4551
 
- *    =============================================
4552
 
- *    Copyright 2005 by Sun Microsystems, Inc.
4553
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
4554
 
- *
4555
 
- *    This library is free software; you can redistribute it and/or
4556
 
- *    modify it under the terms of the GNU Lesser General Public
4557
 
- *    License version 2.1, as published by the Free Software Foundation.
4558
 
- *
4559
 
- *    This library is distributed in the hope that it will be useful,
4560
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
4561
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4562
 
- *    Lesser General Public License for more details.
4563
 
- *
4564
 
- *    You should have received a copy of the GNU Lesser General Public
4565
 
- *    License along with this library; if not, write to the Free Software
4566
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
4567
 
- *    MA  02111-1307  USA
4568
 
- *
4569
 
- ************************************************************************/
4570
 
-
4571
 
-// MARKER(update_precomp.py): autogen include statement, do not remove
4572
 
-#include "precompiled_vcl.hxx"
4573
 
-#ifndef _G72X_H
4574
 
-#define        _G72X_H
4575
 
-
4576
 
-#define        AUDIO_ENCODING_ULAW     (1)     /* ISDN u-law */
4577
 
-#define        AUDIO_ENCODING_ALAW     (2)     /* ISDN A-law */
4578
 
-#define        AUDIO_ENCODING_LINEAR   (3)     /* PCM 2's-complement (0-center) */
4579
 
-
4580
 
-/*
4581
 
- * The following is the definition of the state structure
4582
 
- * used by the G.721/G.723 encoder and decoder to preserve their internal
4583
 
- * state between successive calls.  The meanings of the majority
4584
 
- * of the state structure fields are explained in detail in the
4585
 
- * CCITT Recommendation G.721.  The field names are essentially indentical
4586
 
- * to variable names in the bit level description of the coding algorithm
4587
 
- * included in this Recommendation.
4588
 
- */
4589
 
-struct g72x_state {
4590
 
-       long yl;        /* Locked or steady state step size multiplier. */
4591
 
-       short yu;       /* Unlocked or non-steady state step size multiplier. */
4592
 
-       short dms;      /* Short term energy estimate. */
4593
 
-       short dml;      /* Long term energy estimate. */
4594
 
-       short ap;       /* Linear weighting coefficient of 'yl' and 'yu'. */
4595
 
-
4596
 
-       short a[2];     /* Coefficients of pole portion of prediction filter. */
4597
 
-       short b[6];     /* Coefficients of zero portion of prediction filter. */
4598
 
-       short pk[2];    /*
4599
 
-                        * Signs of previous two samples of a partially
4600
 
-                        * reconstructed signal.
4601
 
-                        */
4602
 
-       short dq[6];    /*
4603
 
-                        * Previous 6 samples of the quantized difference
4604
 
-                        * signal represented in an internal floating point
4605
 
-                        * format.
4606
 
-                        */
4607
 
-       short sr[2];    /*
4608
 
-                        * Previous 2 samples of the quantized difference
4609
 
-                        * signal represented in an internal floating point
4610
 
-                        * format.
4611
 
-                        */
4612
 
-       char td;        /* delayed tone detect, new in 1988 version */
4613
 
-};
4614
 
-
4615
 
-/* External function definitions. */
4616
 
-
4617
 
-extern void g72x_init_state(struct g72x_state *);
4618
 
-extern int g721_encoder(
4619
 
-               int sample,
4620
 
-               int in_coding,
4621
 
-               struct g72x_state *state_ptr);
4622
 
-extern int g721_decoder(
4623
 
-               int code,
4624
 
-               int out_coding,
4625
 
-               struct g72x_state *state_ptr);
4626
 
-extern int g723_24_encoder(
4627
 
-               int sample,
4628
 
-               int in_coding,
4629
 
-               struct g72x_state *state_ptr);
4630
 
-extern int g723_24_decoder(
4631
 
-               int code,
4632
 
-               int out_coding,
4633
 
-               struct g72x_state *state_ptr);
4634
 
-extern int g723_40_encoder(
4635
 
-               int sample,
4636
 
-               int in_coding,
4637
 
-               struct g72x_state *state_ptr);
4638
 
-extern int g723_40_decoder(
4639
 
-               int code,
4640
 
-               int out_coding,
4641
 
-               struct g72x_state *state_ptr);
4642
 
-
4643
 
-#endif /* !_G72X_H */
4644
 
-/*
4645
 
- * g711.c
4646
 
- *
4647
 
- * u-law, A-law and linear PCM conversions.
4648
 
- */
4649
 
-#define        SIGN_BIT        (0x80)          /* Sign bit for a A-law byte. */
4650
 
-#define        QUANT_MASK      (0xf)           /* Quantization field mask. */
4651
 
-#define        NSEGS           (8)             /* Number of A-law segments. */
4652
 
-#define        SEG_SHIFT       (4)             /* Left shift for segment number. */
4653
 
-#define        SEG_MASK        (0x70)          /* Segment field mask. */
4654
 
-
4655
 
-static short seg_end[8] = {0xFF, 0x1FF, 0x3FF, 0x7FF,
4656
 
-                           0xFFF, 0x1FFF, 0x3FFF, 0x7FFF};
4657
 
-
4658
 
-/* copy from CCITT G.711 specifications */
4659
 
-unsigned char _u2a[128] = {                    /* u- to A-law conversions */
4660
 
-       1,      1,      2,      2,      3,      3,      4,      4,
4661
 
-       5,      5,      6,      6,      7,      7,      8,      8,
4662
 
-       9,      10,     11,     12,     13,     14,     15,     16,
4663
 
-       17,     18,     19,     20,     21,     22,     23,     24,
4664
 
-       25,     27,     29,     31,     33,     34,     35,     36,
4665
 
-       37,     38,     39,     40,     41,     42,     43,     44,
4666
 
-       46,     48,     49,     50,     51,     52,     53,     54,
4667
 
-       55,     56,     57,     58,     59,     60,     61,     62,
4668
 
-       64,     65,     66,     67,     68,     69,     70,     71,
4669
 
-       72,     73,     74,     75,     76,     77,     78,     79,
4670
 
-       81,     82,     83,     84,     85,     86,     87,     88,
4671
 
-       89,     90,     91,     92,     93,     94,     95,     96,
4672
 
-       97,     98,     99,     100,    101,    102,    103,    104,
4673
 
-       105,    106,    107,    108,    109,    110,    111,    112,
4674
 
-       113,    114,    115,    116,    117,    118,    119,    120,
4675
 
-       121,    122,    123,    124,    125,    126,    127,    128};
4676
 
-
4677
 
-unsigned char _a2u[128] = {                    /* A- to u-law conversions */
4678
 
-       1,      3,      5,      7,      9,      11,     13,     15,
4679
 
-       16,     17,     18,     19,     20,     21,     22,     23,
4680
 
-       24,     25,     26,     27,     28,     29,     30,     31,
4681
 
-       32,     32,     33,     33,     34,     34,     35,     35,
4682
 
-       36,     37,     38,     39,     40,     41,     42,     43,
4683
 
-       44,     45,     46,     47,     48,     48,     49,     49,
4684
 
-       50,     51,     52,     53,     54,     55,     56,     57,
4685
 
-       58,     59,     60,     61,     62,     63,     64,     64,
4686
 
-       65,     66,     67,     68,     69,     70,     71,     72,
4687
 
-       73,     74,     75,     76,     77,     78,     79,     79,
4688
 
-       80,     81,     82,     83,     84,     85,     86,     87,
4689
 
-       88,     89,     90,     91,     92,     93,     94,     95,
4690
 
-       96,     97,     98,     99,     100,    101,    102,    103,
4691
 
-       104,    105,    106,    107,    108,    109,    110,    111,
4692
 
-       112,    113,    114,    115,    116,    117,    118,    119,
4693
 
-       120,    121,    122,    123,    124,    125,    126,    127};
4694
 
-
4695
 
-static int
4696
 
-search(
4697
 
-       int             val,
4698
 
-       short           *table,
4699
 
-       int             size)
4700
 
-{
4701
 
-       int             i;
4702
 
-
4703
 
-       for (i = 0; i < size; i++) {
4704
 
-               if (val <= *table++)
4705
 
-                       return (i);
4706
 
-       }
4707
 
-       return (size);
4708
 
-}
4709
 
-
4710
 
-/*
4711
 
- * linear2alaw() - Convert a 16-bit linear PCM value to 8-bit A-law
4712
 
- *
4713
 
- * linear2alaw() accepts an 16-bit integer and encodes it as A-law data.
4714
 
- *
4715
 
- *             Linear Input Code       Compressed Code
4716
 
- *     ------------------------        ---------------
4717
 
- *     0000000wxyza                    000wxyz
4718
 
- *     0000001wxyza                    001wxyz
4719
 
- *     000001wxyzab                    010wxyz
4720
 
- *     00001wxyzabc                    011wxyz
4721
 
- *     0001wxyzabcd                    100wxyz
4722
 
- *     001wxyzabcde                    101wxyz
4723
 
- *     01wxyzabcdef                    110wxyz
4724
 
- *     1wxyzabcdefg                    111wxyz
4725
 
- *
4726
 
- * For further information see John C. Bellamy's Digital Telephony, 1982,
4727
 
- * John Wiley & Sons, pps 98-111 and 472-476.
4728
 
- */
4729
 
-unsigned char
4730
 
-linear2alaw(
4731
 
-       int             pcm_val)        /* 2's complement (16-bit range) */
4732
 
-{
4733
 
-       int             mask;
4734
 
-       int             seg;
4735
 
-       unsigned char   aval;
4736
 
-
4737
 
-       if (pcm_val >= 0) {
4738
 
-               mask = 0xD5;            /* sign (7th) bit = 1 */
4739
 
-       } else {
4740
 
-               mask = 0x55;            /* sign bit = 0 */
4741
 
-               pcm_val = -pcm_val - 8;
4742
 
-       }
4743
 
-
4744
 
-       /* Convert the scaled magnitude to segment number. */
4745
 
-       seg = search(pcm_val, seg_end, 8);
4746
 
-
4747
 
-       /* Combine the sign, segment, and quantization bits. */
4748
 
-
4749
 
-       if (seg >= 8)           /* out of range, return maximum value. */
4750
 
-               return (0x7F ^ mask);
4751
 
-       else {
4752
 
-               aval = seg << SEG_SHIFT;
4753
 
-               if (seg < 2)
4754
 
-                       aval |= (pcm_val >> 4) & QUANT_MASK;
4755
 
-               else
4756
 
-                       aval |= (pcm_val >> (seg + 3)) & QUANT_MASK;
4757
 
-               return (aval ^ mask);
4758
 
-       }
4759
 
-}
4760
 
-
4761
 
-/*
4762
 
- * alaw2linear() - Convert an A-law value to 16-bit linear PCM
4763
 
- *
4764
 
- */
4765
 
-int
4766
 
-alaw2linear(
4767
 
-       unsigned char   a_val)
4768
 
-{
4769
 
-       int             t;
4770
 
-       int             seg;
4771
 
-
4772
 
-       a_val ^= 0x55;
4773
 
-
4774
 
-       t = (a_val & QUANT_MASK) << 4;
4775
 
-       seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT;
4776
 
-       switch (seg) {
4777
 
-       case 0:
4778
 
-               t += 8;
4779
 
-               break;
4780
 
-       case 1:
4781
 
-               t += 0x108;
4782
 
-               break;
4783
 
-       default:
4784
 
-               t += 0x108;
4785
 
-               t <<= seg - 1;
4786
 
-       }
4787
 
-       return ((a_val & SIGN_BIT) ? t : -t);
4788
 
-}
4789
 
-
4790
 
-#define        BIAS            (0x84)          /* Bias for linear code. */
4791
 
-
4792
 
-/*
4793
 
- * linear2ulaw() - Convert a linear PCM value to u-law
4794
 
- *
4795
 
- * In order to simplify the encoding process, the original linear magnitude
4796
 
- * is biased by adding 33 which shifts the encoding range from (0 - 8158) to
4797
 
- * (33 - 8191). The result can be seen in the following encoding table:
4798
 
- *
4799
 
- *     Biased Linear Input Code        Compressed Code
4800
 
- *     ------------------------        ---------------
4801
 
- *     00000001wxyza                   000wxyz
4802
 
- *     0000001wxyzab                   001wxyz
4803
 
- *     000001wxyzabc                   010wxyz
4804
 
- *     00001wxyzabcd                   011wxyz
4805
 
- *     0001wxyzabcde                   100wxyz
4806
 
- *     001wxyzabcdef                   101wxyz
4807
 
- *     01wxyzabcdefg                   110wxyz
4808
 
- *     1wxyzabcdefgh                   111wxyz
4809
 
- *
4810
 
- * Each biased linear code has a leading 1 which identifies the segment
4811
 
- * number. The value of the segment number is equal to 7 minus the number
4812
 
- * of leading 0's. The quantization interval is directly available as the
4813
 
- * four bits wxyz.  * The trailing bits (a - h) are ignored.
4814
 
- *
4815
 
- * Ordinarily the complement of the resulting code word is used for
4816
 
- * transmission, and so the code word is complemented before it is returned.
4817
 
- *
4818
 
- * For further information see John C. Bellamy's Digital Telephony, 1982,
4819
 
- * John Wiley & Sons, pps 98-111 and 472-476.
4820
 
- */
4821
 
-unsigned char
4822
 
-linear2ulaw(
4823
 
-       int             pcm_val)        /* 2's complement (16-bit range) */
4824
 
-{
4825
 
-       int             mask;
4826
 
-       int             seg;
4827
 
-       unsigned char   uval;
4828
 
-
4829
 
-       /* Get the sign and the magnitude of the value. */
4830
 
-       if (pcm_val < 0) {
4831
 
-               pcm_val = BIAS - pcm_val;
4832
 
-               mask = 0x7F;
4833
 
-       } else {
4834
 
-               pcm_val += BIAS;
4835
 
-               mask = 0xFF;
4836
 
-       }
4837
 
-
4838
 
-       /* Convert the scaled magnitude to segment number. */
4839
 
-       seg = search(pcm_val, seg_end, 8);
4840
 
-
4841
 
-       /*
4842
 
-        * Combine the sign, segment, quantization bits;
4843
 
-        * and complement the code word.
4844
 
-        */
4845
 
-       if (seg >= 8)           /* out of range, return maximum value. */
4846
 
-               return (0x7F ^ mask);
4847
 
-       else {
4848
 
-               uval = (seg << 4) | ((pcm_val >> (seg + 3)) & 0xF);
4849
 
-               return (uval ^ mask);
4850
 
-       }
4851
 
-
4852
 
-}
4853
 
-
4854
 
-/*
4855
 
- * ulaw2linear() - Convert a u-law value to 16-bit linear PCM
4856
 
- *
4857
 
- * First, a biased linear code is derived from the code word. An unbiased
4858
 
- * output can then be obtained by subtracting 33 from the biased code.
4859
 
- *
4860
 
- * Note that this function expects to be passed the complement of the
4861
 
- * original code word. This is in keeping with ISDN conventions.
4862
 
- */
4863
 
-int
4864
 
-ulaw2linear(
4865
 
-       unsigned char   u_val)
4866
 
-{
4867
 
-       int             t;
4868
 
-
4869
 
-       /* Complement to obtain normal u-law value. */
4870
 
-       u_val = ~u_val;
4871
 
-
4872
 
-       /*
4873
 
-        * Extract and bias the quantization bits. Then
4874
 
-        * shift up by the segment number and subtract out the bias.
4875
 
-        */
4876
 
-       t = ((u_val & QUANT_MASK) << 3) + BIAS;
4877
 
-       t <<= ((unsigned)u_val & SEG_MASK) >> SEG_SHIFT;
4878
 
-
4879
 
-       return ((u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS));
4880
 
-}
4881
 
-
4882
 
-/* A-law to u-law conversion */
4883
 
-unsigned char
4884
 
-alaw2ulaw(
4885
 
-       unsigned char   aval)
4886
 
-{
4887
 
-       aval &= 0xff;
4888
 
-       return ((aval & 0x80) ? (0xFF ^ _a2u[aval ^ 0xD5]) :
4889
 
-           (0x7F ^ _a2u[aval ^ 0x55]));
4890
 
-}
4891
 
-
4892
 
-/* u-law to A-law conversion */
4893
 
-unsigned char
4894
 
-ulaw2alaw(
4895
 
-       unsigned char   uval)
4896
 
-{
4897
 
-       uval &= 0xff;
4898
 
-       return ((uval & 0x80) ? (0xD5 ^ (_u2a[0xFF ^ uval] - 1)) :
4899
 
-           (0x55 ^ (_u2a[0x7F ^ uval] - 1)));
4900
 
-}
4901
 
-/*
4902
 
- * g72x.c
4903
 
- *
4904
 
- * Common routines for G.721 and G.723 conversions.
4905
 
- */
4906
 
-
4907
 
-static short power2[15] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80,
4908
 
-                       0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000};
4909
 
-
4910
 
-/*
4911
 
- * quan()
4912
 
- *
4913
 
- * quantizes the input val against the table of size short integers.
4914
 
- * It returns i if table[i - 1] <= val < table[i].
4915
 
- *
4916
 
- * Using linear search for simple coding.
4917
 
- */
4918
 
-static int
4919
 
-quan(
4920
 
-       int             val,
4921
 
-       short           *table,
4922
 
-       int             size)
4923
 
-{
4924
 
-       int             i;
4925
 
-
4926
 
-       for (i = 0; i < size; i++)
4927
 
-               if (val < *table++)
4928
 
-                       break;
4929
 
-       return (i);
4930
 
-}
4931
 
-
4932
 
-/*
4933
 
- * fmult()
4934
 
- *
4935
 
- * returns the integer product of the 14-bit integer "an" and
4936
 
- * "floating point" representation (4-bit exponent, 6-bit mantessa) "srn".
4937
 
- */
4938
 
-static int
4939
 
-fmult(
4940
 
-       int             an,
4941
 
-       int             srn)
4942
 
-{
4943
 
-       short           anmag, anexp, anmant;
4944
 
-       short           wanexp, wanmant;
4945
 
-       short           retval;
4946
 
-
4947
 
-       anmag = (an > 0) ? an : ((-an) & 0x1FFF);
4948
 
-       anexp = quan(anmag, power2, 15) - 6;
4949
 
-       anmant = (anmag == 0) ? 32 :
4950
 
-           (anexp >= 0) ? anmag >> anexp : anmag << -anexp;
4951
 
-       wanexp = anexp + ((srn >> 6) & 0xF) - 13;
4952
 
-
4953
 
-       wanmant = (anmant * (srn & 077) + 0x30) >> 4;
4954
 
-       retval = (wanexp >= 0) ? ((wanmant << wanexp) & 0x7FFF) :
4955
 
-           (wanmant >> -wanexp);
4956
 
-
4957
 
-       return (((an ^ srn) < 0) ? -retval : retval);
4958
 
-}
4959
 
-
4960
 
-/*
4961
 
- * g72x_init_state()
4962
 
- *
4963
 
- * This routine initializes and/or resets the g72x_state structure
4964
 
- * pointed to by 'state_ptr'.
4965
 
- * All the initial state values are specified in the CCITT G.721 document.
4966
 
- */
4967
 
-void
4968
 
-g72x_init_state(
4969
 
-       struct g72x_state *state_ptr)
4970
 
-{
4971
 
-       int             cnta;
4972
 
-
4973
 
-       state_ptr->yl = 34816;
4974
 
-       state_ptr->yu = 544;
4975
 
-       state_ptr->dms = 0;
4976
 
-       state_ptr->dml = 0;
4977
 
-       state_ptr->ap = 0;
4978
 
-       for (cnta = 0; cnta < 2; cnta++) {
4979
 
-               state_ptr->a[cnta] = 0;
4980
 
-               state_ptr->pk[cnta] = 0;
4981
 
-               state_ptr->sr[cnta] = 32;
4982
 
-       }
4983
 
-       for (cnta = 0; cnta < 6; cnta++) {
4984
 
-               state_ptr->b[cnta] = 0;
4985
 
-               state_ptr->dq[cnta] = 32;
4986
 
-       }
4987
 
-       state_ptr->td = 0;
4988
 
-}
4989
 
-
4990
 
-/*
4991
 
- * predictor_zero()
4992
 
- *
4993
 
- * computes the estimated signal from 6-zero predictor.
4994
 
- *
4995
 
- */
4996
 
-int
4997
 
-predictor_zero(
4998
 
-       struct g72x_state *state_ptr)
4999
 
-{
5000
 
-       int             i;
5001
 
-       int             sezi;
5002
 
-
5003
 
-       sezi = fmult(state_ptr->b[0] >> 2, state_ptr->dq[0]);
5004
 
-       for (i = 1; i < 6; i++)                 /* ACCUM */
5005
 
-               sezi += fmult(state_ptr->b[i] >> 2, state_ptr->dq[i]);
5006
 
-       return (sezi);
5007
 
-}
5008
 
-/*
5009
 
- * predictor_pole()
5010
 
- *
5011
 
- * computes the estimated signal from 2-pole predictor.
5012
 
- *
5013
 
- */
5014
 
-int
5015
 
-predictor_pole(
5016
 
-       struct g72x_state *state_ptr)
5017
 
-{
5018
 
-       return (fmult(state_ptr->a[1] >> 2, state_ptr->sr[1]) +
5019
 
-           fmult(state_ptr->a[0] >> 2, state_ptr->sr[0]));
5020
 
-}
5021
 
-/*
5022
 
- * step_size()
5023
 
- *
5024
 
- * computes the quantization step size of the adaptive quantizer.
5025
 
- *
5026
 
- */
5027
 
-int
5028
 
-step_size(
5029
 
-       struct g72x_state *state_ptr)
5030
 
-{
5031
 
-       int             y;
5032
 
-       int             dif;
5033
 
-       int             al;
5034
 
-
5035
 
-       if (state_ptr->ap >= 256)
5036
 
-               return (state_ptr->yu);
5037
 
-       else {
5038
 
-               y = state_ptr->yl >> 6;
5039
 
-               dif = state_ptr->yu - y;
5040
 
-               al = state_ptr->ap >> 2;
5041
 
-               if (dif > 0)
5042
 
-                       y += (dif * al) >> 6;
5043
 
-               else if (dif < 0)
5044
 
-                       y += (dif * al + 0x3F) >> 6;
5045
 
-               return (y);
5046
 
-       }
5047
 
-}
5048
 
-
5049
 
-/*
5050
 
- * quantize()
5051
 
- *
5052
 
- * Given a raw sample, 'd', of the difference signal and a
5053
 
- * quantization step size scale factor, 'y', this routine returns the
5054
 
- * ADPCM codeword to which that sample gets quantized.  The step
5055
 
- * size scale factor division operation is done in the log base 2 domain
5056
 
- * as a subtraction.
5057
 
- */
5058
 
-int
5059
 
-quantize(
5060
 
-       int             d,      /* Raw difference signal sample */
5061
 
-       int             y,      /* Step size multiplier */
5062
 
-       short           *table, /* quantization table */
5063
 
-       int             size)   /* table size of short integers */
5064
 
-{
5065
 
-       short           dqm;    /* Magnitude of 'd' */
5066
 
-       short           exp;    /* Integer part of base 2 log of 'd' */
5067
 
-       short           mant;   /* Fractional part of base 2 log */
5068
 
-       short           dl;     /* Log of magnitude of 'd' */
5069
 
-       short           dln;    /* Step size scale factor normalized log */
5070
 
-       int             i;
5071
 
-
5072
 
-       /*
5073
 
-        * LOG
5074
 
-        *
5075
 
-        * Compute base 2 log of 'd', and store in 'dl'.
5076
 
-        */
5077
 
-       dqm = abs(d);
5078
 
-       exp = quan(dqm >> 1, power2, 15);
5079
 
-       mant = ((dqm << 7) >> exp) & 0x7F;      /* Fractional portion. */
5080
 
-       dl = (exp << 7) + mant;
5081
 
-
5082
 
-       /*
5083
 
-        * SUBTB
5084
 
-        *
5085
 
-        * "Divide" by step size multiplier.
5086
 
-        */
5087
 
-       dln = dl - (y >> 2);
5088
 
-
5089
 
-       /*
5090
 
-        * QUAN
5091
 
-        *
5092
 
-        * Obtain codword i for 'd'.
5093
 
-        */
5094
 
-       i = quan(dln, table, size);
5095
 
-       if (d < 0)                      /* take 1's complement of i */
5096
 
-               return ((size << 1) + 1 - i);
5097
 
-       else if (i == 0)                /* take 1's complement of 0 */
5098
 
-               return ((size << 1) + 1); /* new in 1988 */
5099
 
-       else
5100
 
-               return (i);
5101
 
-}
5102
 
-/*
5103
 
- * reconstruct()
5104
 
- *
5105
 
- * Returns reconstructed difference signal 'dq' obtained from
5106
 
- * codeword 'i' and quantization step size scale factor 'y'.
5107
 
- * Multiplication is performed in log base 2 domain as addition.
5108
 
- */
5109
 
-int
5110
 
-reconstruct(
5111
 
-       int             sign,   /* 0 for non-negative value */
5112
 
-       int             dqln,   /* G.72x codeword */
5113
 
-       int             y)      /* Step size multiplier */
5114
 
-{
5115
 
-       short           dql;    /* Log of 'dq' magnitude */
5116
 
-       short           dex;    /* Integer part of log */
5117
 
-       short           dqt;
5118
 
-       short           dq;     /* Reconstructed difference signal sample */
5119
 
-
5120
 
-       dql = dqln + (y >> 2);  /* ADDA */
5121
 
-
5122
 
-       if (dql < 0) {
5123
 
-               return ((sign) ? -0x8000 : 0);
5124
 
-       } else {                /* ANTILOG */
5125
 
-               dex = (dql >> 7) & 15;
5126
 
-               dqt = 128 + (dql & 127);
5127
 
-               dq = (dqt << 7) >> (14 - dex);
5128
 
-               return ((sign) ? (dq - 0x8000) : dq);
5129
 
-       }
5130
 
-}
5131
 
-
5132
 
-
5133
 
-/*
5134
 
- * update()
5135
 
- *
5136
 
- * updates the state variables for each output code
5137
 
- */
5138
 
-void
5139
 
-update(
5140
 
-       int             code_size,      /* distinguish 723_40 with others */
5141
 
-       int             y,              /* quantizer step size */
5142
 
-       int             wi,             /* scale factor multiplier */
5143
 
-       int             fi,             /* for long/short term energies */
5144
 
-       int             dq,             /* quantized prediction difference */
5145
 
-       int             sr,             /* reconstructed signal */
5146
 
-       int             dqsez,          /* difference from 2-pole predictor */
5147
 
-       struct g72x_state *state_ptr)   /* coder state pointer */
5148
 
-{
5149
 
-       int             cnt;
5150
 
-       short           mag, exp;       /* Adaptive predictor, FLOAT A */
5151
 
-       short           a2p = 0;                /* LIMC */
5152
 
-       short           a1ul;           /* UPA1 */
5153
 
-       short           pks1;   /* UPA2 */
5154
 
-       short           fa1;
5155
 
-       char            tr;             /* tone/transition detector */
5156
 
-       short           ylint, thr2, dqthr;
5157
 
-       short           ylfrac, thr1;
5158
 
-       short           pk0;
5159
 
-
5160
 
-       pk0 = (dqsez < 0) ? 1 : 0;      /* needed in updating predictor poles */
5161
 
-
5162
 
-       mag = dq & 0x7FFF;              /* prediction difference magnitude */
5163
 
-       /* TRANS */
5164
 
-       ylint = state_ptr->yl >> 15;    /* exponent part of yl */
5165
 
-       ylfrac = (state_ptr->yl >> 10) & 0x1F;  /* fractional part of yl */
5166
 
-       thr1 = (32 + ylfrac) << ylint;          /* threshold */
5167
 
-       thr2 = (ylint > 9) ? 31 << 10 : thr1;   /* limit thr2 to 31 << 10 */
5168
 
-       dqthr = (thr2 + (thr2 >> 1)) >> 1;      /* dqthr = 0.75 * thr2 */
5169
 
-       if (state_ptr->td == 0)         /* signal supposed voice */
5170
 
-               tr = 0;
5171
 
-       else if (mag <= dqthr)          /* supposed data, but small mag */
5172
 
-               tr = 0;                 /* treated as voice */
5173
 
-       else                            /* signal is data (modem) */
5174
 
-               tr = 1;
5175
 
-
5176
 
-       /*
5177
 
-        * Quantizer scale factor adaptation.
5178
 
-        */
5179
 
-
5180
 
-       /* FUNCTW & FILTD & DELAY */
5181
 
-       /* update non-steady state step size multiplier */
5182
 
-       state_ptr->yu = y + ((wi - y) >> 5);
5183
 
-
5184
 
-       /* LIMB */
5185
 
-       if (state_ptr->yu < 544)        /* 544 <= yu <= 5120 */
5186
 
-               state_ptr->yu = 544;
5187
 
-       else if (state_ptr->yu > 5120)
5188
 
-               state_ptr->yu = 5120;
5189
 
-
5190
 
-       /* FILTE & DELAY */
5191
 
-       /* update steady state step size multiplier */
5192
 
-       state_ptr->yl += state_ptr->yu + ((-state_ptr->yl) >> 6);
5193
 
-
5194
 
-       /*
5195
 
-        * Adaptive predictor coefficients.
5196
 
-        */
5197
 
-       if (tr == 1) {                  /* reset a's and b's for modem signal */
5198
 
-               state_ptr->a[0] = 0;
5199
 
-               state_ptr->a[1] = 0;
5200
 
-               state_ptr->b[0] = 0;
5201
 
-               state_ptr->b[1] = 0;
5202
 
-               state_ptr->b[2] = 0;
5203
 
-               state_ptr->b[3] = 0;
5204
 
-               state_ptr->b[4] = 0;
5205
 
-               state_ptr->b[5] = 0;
5206
 
-               // TODO WHat is the correct value of a2p
5207
 
-               a2p = 0;
5208
 
-       } else {                        /* update a's and b's */
5209
 
-               pks1 = pk0 ^ state_ptr->pk[0];          /* UPA2 */
5210
 
-
5211
 
-               /* update predictor pole a[1] */
5212
 
-               a2p = state_ptr->a[1] - (state_ptr->a[1] >> 7);
5213
 
-               if (dqsez != 0) {
5214
 
-                       fa1 = (pks1) ? state_ptr->a[0] : -state_ptr->a[0];
5215
 
-                       if (fa1 < -8191)        /* a2p = function of fa1 */
5216
 
-                               a2p -= 0x100;
5217
 
-                       else if (fa1 > 8191)
5218
 
-                               a2p += 0xFF;
5219
 
-                       else
5220
 
-                               a2p += fa1 >> 5;
5221
 
-
5222
 
-                       if (pk0 ^ state_ptr->pk[1])
5223
 
-                               /* LIMC */
5224
 
-                               if (a2p <= -12160)
5225
 
-                                       a2p = -12288;
5226
 
-                               else if (a2p >= 12416)
5227
 
-                                       a2p = 12288;
5228
 
-                               else
5229
 
-                                       a2p -= 0x80;
5230
 
-                       else if (a2p <= -12416)
5231
 
-                               a2p = -12288;
5232
 
-                       else if (a2p >= 12160)
5233
 
-                               a2p = 12288;
5234
 
-                       else
5235
 
-                               a2p += 0x80;
5236
 
-               }
5237
 
-
5238
 
-               /* TRIGB & DELAY */
5239
 
-               state_ptr->a[1] = a2p;
5240
 
-
5241
 
-               /* UPA1 */
5242
 
-               /* update predictor pole a[0] */
5243
 
-               state_ptr->a[0] -= state_ptr->a[0] >> 8;
5244
 
-               if (dqsez != 0)
5245
 
-                       if (pks1 == 0)
5246
 
-                               state_ptr->a[0] += 192;
5247
 
-                       else
5248
 
-                               state_ptr->a[0] -= 192;
5249
 
-
5250
 
-               /* LIMD */
5251
 
-               a1ul = 15360 - a2p;
5252
 
-               if (state_ptr->a[0] < -a1ul)
5253
 
-                       state_ptr->a[0] = -a1ul;
5254
 
-               else if (state_ptr->a[0] > a1ul)
5255
 
-                       state_ptr->a[0] = a1ul;
5256
 
-
5257
 
-               /* UPB : update predictor zeros b[6] */
5258
 
-               for (cnt = 0; cnt < 6; cnt++) {
5259
 
-                       if (code_size == 5)             /* for 40Kbps G.723 */
5260
 
-                               state_ptr->b[cnt] -= state_ptr->b[cnt] >> 9;
5261
 
-                       else                    /* for G.721 and 24Kbps G.723 */
5262
 
-                               state_ptr->b[cnt] -= state_ptr->b[cnt] >> 8;
5263
 
-                       if (dq & 0x7FFF) {                      /* XOR */
5264
 
-                               if ((dq ^ state_ptr->dq[cnt]) >= 0)
5265
 
-                                       state_ptr->b[cnt] += 128;
5266
 
-                               else
5267
 
-                                       state_ptr->b[cnt] -= 128;
5268
 
-                       }
5269
 
-               }
5270
 
-       }
5271
 
-
5272
 
-       for (cnt = 5; cnt > 0; cnt--)
5273
 
-               state_ptr->dq[cnt] = state_ptr->dq[cnt-1];
5274
 
-       /* FLOAT A : convert dq[0] to 4-bit exp, 6-bit mantissa f.p. */
5275
 
-       if (mag == 0) {
5276
 
-               state_ptr->dq[0] = (dq >= 0) ? 0x20 : 0xFC20;
5277
 
-       } else {
5278
 
-               exp = quan(mag, power2, 15);
5279
 
-               state_ptr->dq[0] = (dq >= 0) ?
5280
 
-                   (exp << 6) + ((mag << 6) >> exp) :
5281
 
-                   (exp << 6) + ((mag << 6) >> exp) - 0x400;
5282
 
-       }
5283
 
-
5284
 
-       state_ptr->sr[1] = state_ptr->sr[0];
5285
 
-       /* FLOAT B : convert sr to 4-bit exp., 6-bit mantissa f.p. */
5286
 
-       if (sr == 0) {
5287
 
-               state_ptr->sr[0] = 0x20;
5288
 
-       } else if (sr > 0) {
5289
 
-               exp = quan(sr, power2, 15);
5290
 
-               state_ptr->sr[0] = (exp << 6) + ((sr << 6) >> exp);
5291
 
-       } else if (sr > -32768) {
5292
 
-               mag = -sr;
5293
 
-               exp = quan(mag, power2, 15);
5294
 
-               state_ptr->sr[0] =  (exp << 6) + ((mag << 6) >> exp) - 0x400;
5295
 
-       } else
5296
 
-               state_ptr->sr[0] = 0xFC20;
5297
 
-
5298
 
-       /* DELAY A */
5299
 
-       state_ptr->pk[1] = state_ptr->pk[0];
5300
 
-       state_ptr->pk[0] = pk0;
5301
 
-
5302
 
-       /* TONE */
5303
 
-       if (tr == 1)            /* this sample has been treated as data */
5304
 
-               state_ptr->td = 0;      /* next one will be treated as voice */
5305
 
-       else if (a2p < -11776)  /* small sample-to-sample correlation */
5306
 
-               state_ptr->td = 1;      /* signal may be data */
5307
 
-       else                            /* signal is voice */
5308
 
-               state_ptr->td = 0;
5309
 
-
5310
 
-       /*
5311
 
-        * Adaptation speed control.
5312
 
-        */
5313
 
-       state_ptr->dms += (fi - state_ptr->dms) >> 5;           /* FILTA */
5314
 
-       state_ptr->dml += (((fi << 2) - state_ptr->dml) >> 7);  /* FILTB */
5315
 
-
5316
 
-       if (tr == 1)
5317
 
-               state_ptr->ap = 256;
5318
 
-       else if (y < 1536)                                      /* SUBTC */
5319
 
-               state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
5320
 
-       else if (state_ptr->td == 1)
5321
 
-               state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
5322
 
-       else if (abs((state_ptr->dms << 2) - state_ptr->dml) >=
5323
 
-           (state_ptr->dml >> 3))
5324
 
-               state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
5325
 
-       else
5326
 
-               state_ptr->ap += (-state_ptr->ap) >> 4;
5327
 
-}
5328
 
-
5329
 
-/*
5330
 
- * tandem_adjust(sr, se, y, i, sign)
5331
 
- *
5332
 
- * At the end of ADPCM decoding, it simulates an encoder which may be receiving
5333
 
- * the output of this decoder as a tandem process. If the output of the
5334
 
- * simulated encoder differs from the input to this decoder, the decoder output
5335
 
- * is adjusted by one level of A-law or u-law codes.
5336
 
- *
5337
 
- * Input:
5338
 
- *     sr      decoder output linear PCM sample,
5339
 
- *     se      predictor estimate sample,
5340
 
- *     y       quantizer step size,
5341
 
- *     i       decoder input code,
5342
 
- *     sign    sign bit of code i
5343
 
- *
5344
 
- * Return:
5345
 
- *     adjusted A-law or u-law compressed sample.
5346
 
- */
5347
 
-int
5348
 
-tandem_adjust_alaw(
5349
 
-       int             sr,     /* decoder output linear PCM sample */
5350
 
-       int             se,     /* predictor estimate sample */
5351
 
-       int             y,      /* quantizer step size */
5352
 
-       int             i,      /* decoder input code */
5353
 
-       int             sign,
5354
 
-       short           *qtab)
5355
 
-{
5356
 
-       unsigned char   sp;     /* A-law compressed 8-bit code */
5357
 
-       short           dx;     /* prediction error */
5358
 
-       char            id;     /* quantized prediction error */
5359
 
-       int             sd;     /* adjusted A-law decoded sample value */
5360
 
-       int             im;     /* biased magnitude of i */
5361
 
-       int             imx;    /* biased magnitude of id */
5362
 
-
5363
 
-       if (sr <= -32768)
5364
 
-               sr = -1;
5365
 
-       sp = linear2alaw((sr >> 1) << 3);       /* short to A-law compression */
5366
 
-       dx = (alaw2linear(sp) >> 2) - se;       /* 16-bit prediction error */
5367
 
-       id = quantize(dx, y, qtab, sign - 1);
5368
 
-
5369
 
-       if (id == i) {                  /* no adjustment on sp */
5370
 
-               return (sp);
5371
 
-       } else {                        /* sp adjustment needed */
5372
 
-               /* ADPCM codes : 8, 9, ... F, 0, 1, ... , 6, 7 */
5373
 
-               im = i ^ sign;          /* 2's complement to biased unsigned */
5374
 
-               imx = id ^ sign;
5375
 
-
5376
 
-               if (imx > im) {         /* sp adjusted to next lower value */
5377
 
-                       if (sp & 0x80) {
5378
 
-                               sd = (sp == 0xD5) ? 0x55 :
5379
 
-                                   ((sp ^ 0x55) - 1) ^ 0x55;
5380
 
-                       } else {
5381
 
-                               sd = (sp == 0x2A) ? 0x2A :
5382
 
-                                   ((sp ^ 0x55) + 1) ^ 0x55;
5383
 
-                       }
5384
 
-               } else {                /* sp adjusted to next higher value */
5385
 
-                       if (sp & 0x80)
5386
 
-                               sd = (sp == 0xAA) ? 0xAA :
5387
 
-                                   ((sp ^ 0x55) + 1) ^ 0x55;
5388
 
-                       else
5389
 
-                               sd = (sp == 0x55) ? 0xD5 :
5390
 
-                                   ((sp ^ 0x55) - 1) ^ 0x55;
5391
 
-               }
5392
 
-               return (sd);
5393
 
-       }
5394
 
-}
5395
 
-
5396
 
-int
5397
 
-tandem_adjust_ulaw(
5398
 
-       int             sr,     /* decoder output linear PCM sample */
5399
 
-       int             se,     /* predictor estimate sample */
5400
 
-       int             y,      /* quantizer step size */
5401
 
-       int             i,      /* decoder input code */
5402
 
-       int             sign,
5403
 
-       short           *qtab)
5404
 
-{
5405
 
-       unsigned char   sp;     /* u-law compressed 8-bit code */
5406
 
-       short           dx;     /* prediction error */
5407
 
-       char            id;     /* quantized prediction error */
5408
 
-       int             sd;     /* adjusted u-law decoded sample value */
5409
 
-       int             im;     /* biased magnitude of i */
5410
 
-       int             imx;    /* biased magnitude of id */
5411
 
-
5412
 
-       if (sr <= -32768)
5413
 
-               sr = 0;
5414
 
-       sp = linear2ulaw(sr << 2);      /* short to u-law compression */
5415
 
-       dx = (ulaw2linear(sp) >> 2) - se;       /* 16-bit prediction error */
5416
 
-       id = quantize(dx, y, qtab, sign - 1);
5417
 
-       if (id == i) {
5418
 
-               return (sp);
5419
 
-       } else {
5420
 
-               /* ADPCM codes : 8, 9, ... F, 0, 1, ... , 6, 7 */
5421
 
-               im = i ^ sign;          /* 2's complement to biased unsigned */
5422
 
-               imx = id ^ sign;
5423
 
-               if (imx > im) {         /* sp adjusted to next lower value */
5424
 
-                       if (sp & 0x80)
5425
 
-                               sd = (sp == 0xFF) ? 0x7E : sp + 1;
5426
 
-                       else
5427
 
-                               sd = (sp == 0) ? 0 : sp - 1;
5428
 
-
5429
 
-               } else {                /* sp adjusted to next higher value */
5430
 
-                       if (sp & 0x80)
5431
 
-                               sd = (sp == 0x80) ? 0x80 : sp - 1;
5432
 
-                       else
5433
 
-                               sd = (sp == 0x7F) ? 0xFE : sp + 1;
5434
 
-               }
5435
 
-               return (sd);
5436
 
-       }
5437
 
-}
5438
 
-/*
5439
 
- * g721.c
5440
 
- *
5441
 
- * Description:
5442
 
- *
5443
 
- * g721_encoder(), g721_decoder()
5444
 
- *
5445
 
- * These routines comprise an implementation of the CCITT G.721 ADPCM
5446
 
- * coding algorithm.  Essentially, this implementation is identical to
5447
 
- * the bit level description except for a few deviations which
5448
 
- * take advantage of work station attributes, such as hardware 2's
5449
 
- * complement arithmetic and large memory.  Specifically, certain time
5450
 
- * consuming operations such as multiplications are replaced
5451
 
- * with lookup tables and software 2's complement operations are
5452
 
- * replaced with hardware 2's complement.
5453
 
- *
5454
 
- * The deviation from the bit level specification (lookup tables)
5455
 
- * preserves the bit level performance specifications.
5456
 
- *
5457
 
- * As outlined in the G.721 Recommendation, the algorithm is broken
5458
 
- * down into modules.  Each section of code below is preceded by
5459
 
- * the name of the module which it is implementing.
5460
 
- *
5461
 
- */
5462
 
-
5463
 
-static short qtab_721[7] = {-124, 80, 178, 246, 300, 349, 400};
5464
 
-/*
5465
 
- * Maps G.721 code word to reconstructed scale factor normalized log
5466
 
- * magnitude values.
5467
 
- */
5468
 
-static short   _dqlntab_721[16] = {-2048, 4, 135, 213, 273, 323, 373, 425,
5469
 
-                               425, 373, 323, 273, 213, 135, 4, -2048};
5470
 
-
5471
 
-/* Maps G.721 code word to log of scale factor multiplier. */
5472
 
-static short   _witab_721[16] = {-12, 18, 41, 64, 112, 198, 355, 1122,
5473
 
-                               1122, 355, 198, 112, 64, 41, 18, -12};
5474
 
-/*
5475
 
- * Maps G.721 code words to a set of values whose long and short
5476
 
- * term averages are computed and then compared to give an indication
5477
 
- * how stationary (steady state) the signal is.
5478
 
- */
5479
 
-static short   _fitab_721[16] = {0, 0, 0, 0x200, 0x200, 0x200, 0x600, 0xE00,
5480
 
-                               0xE00, 0x600, 0x200, 0x200, 0x200, 0, 0, 0};
5481
 
-
5482
 
-/*
5483
 
- * g721_encoder()
5484
 
- *
5485
 
- * Encodes the input vale of linear PCM, A-law or u-law data sl and returns
5486
 
- * the resulting code. -1 is returned for unknown input coding value.
5487
 
- */
5488
 
-int
5489
 
-g721_encoder(
5490
 
-       int             sl,
5491
 
-       int             in_coding,
5492
 
-       struct g72x_state *state_ptr)
5493
 
-{
5494
 
-       short           sezi, se, sez;          /* ACCUM */
5495
 
-       short           d;                      /* SUBTA */
5496
 
-       short           sr;                     /* ADDB */
5497
 
-       short           y;                      /* MIX */
5498
 
-       short           dqsez;                  /* ADDC */
5499
 
-       short           dq, i;
5500
 
-
5501
 
-       switch (in_coding) {    /* linearize input sample to 14-bit PCM */
5502
 
-       case AUDIO_ENCODING_ALAW:
5503
 
-               sl = alaw2linear(sl) >> 2;
5504
 
-               break;
5505
 
-       case AUDIO_ENCODING_ULAW:
5506
 
-               sl = ulaw2linear(sl) >> 2;
5507
 
-               break;
5508
 
-       case AUDIO_ENCODING_LINEAR:
5509
 
-               sl >>= 2;                       /* 14-bit dynamic range */
5510
 
-               break;
5511
 
-       default:
5512
 
-               return (-1);
5513
 
-       }
5514
 
-
5515
 
-       sezi = predictor_zero(state_ptr);
5516
 
-       sez = sezi >> 1;
5517
 
-       se = (sezi + predictor_pole(state_ptr)) >> 1;   /* estimated signal */
5518
 
-
5519
 
-       d = sl - se;                            /* estimation difference */
5520
 
-
5521
 
-       /* quantize the prediction difference */
5522
 
-       y = step_size(state_ptr);               /* quantizer step size */
5523
 
-       i = quantize(d, y, qtab_721, 7);        /* i = ADPCM code */
5524
 
-
5525
 
-       dq = reconstruct(i & 8, _dqlntab_721[i], y);    /* quantized est diff */
5526
 
-
5527
 
-       sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq;   /* reconst. signal */
5528
 
-
5529
 
-       dqsez = sr + sez - se;                  /* pole prediction diff. */
5530
 
-
5531
 
-       update(4, y, _witab_721[i] << 5, _fitab_721[i], dq, sr, dqsez, state_ptr);
5532
 
-
5533
 
-       return (i);
5534
 
-}
5535
 
-
5536
 
-/*
5537
 
- * g721_decoder()
5538
 
- *
5539
 
- * Description:
5540
 
- *
5541
 
- * Decodes a 4-bit code of G.721 encoded data of i and
5542
 
- * returns the resulting linear PCM, A-law or u-law value.
5543
 
- * return -1 for unknown out_coding value.
5544
 
- */
5545
 
-int
5546
 
-g721_decoder(
5547
 
-       int             i,
5548
 
-       int             out_coding,
5549
 
-       struct g72x_state *state_ptr)
5550
 
-{
5551
 
-       short           sezi, sei, sez, se;     /* ACCUM */
5552
 
-       short           y;                      /* MIX */
5553
 
-       short           sr;                     /* ADDB */
5554
 
-       short           dq;
5555
 
-       short           dqsez;
5556
 
-
5557
 
-       i &= 0x0f;                      /* mask to get proper bits */
5558
 
-       sezi = predictor_zero(state_ptr);
5559
 
-       sez = sezi >> 1;
5560
 
-       sei = sezi + predictor_pole(state_ptr);
5561
 
-       se = sei >> 1;                  /* se = estimated signal */
5562
 
-
5563
 
-       y = step_size(state_ptr);       /* dynamic quantizer step size */
5564
 
-
5565
 
-       dq = reconstruct(i & 0x08, _dqlntab_721[i], y); /* quantized diff. */
5566
 
-
5567
 
-       sr = (dq < 0) ? (se - (dq & 0x3FFF)) : se + dq; /* reconst. signal */
5568
 
-
5569
 
-       dqsez = sr - se + sez;                  /* pole prediction diff. */
5570
 
-
5571
 
-       update(4, y, _witab_721[i] << 5, _fitab_721[i], dq, sr, dqsez, state_ptr);
5572
 
-
5573
 
-       switch (out_coding) {
5574
 
-       case AUDIO_ENCODING_ALAW:
5575
 
-               return (tandem_adjust_alaw(sr, se, y, i, 8, qtab_721));
5576
 
-       case AUDIO_ENCODING_ULAW:
5577
 
-               return (tandem_adjust_ulaw(sr, se, y, i, 8, qtab_721));
5578
 
-       case AUDIO_ENCODING_LINEAR:
5579
 
-               return (sr << 2);       /* sr was 14-bit dynamic range */
5580
 
-       default:
5581
 
-               return (-1);
5582
 
-       }
5583
 
-}
5584
 
-/*
5585
 
- * g723_24.c
5586
 
- *
5587
 
- * Description:
5588
 
- *
5589
 
- * g723_24_encoder(), g723_24_decoder()
5590
 
- *
5591
 
- * These routines comprise an implementation of the CCITT G.723 24 Kbps
5592
 
- * ADPCM coding algorithm.  Essentially, this implementation is identical to
5593
 
- * the bit level description except for a few deviations which take advantage
5594
 
- * of workstation attributes, such as hardware 2's complement arithmetic.
5595
 
- *
5596
 
- */
5597
 
-
5598
 
-/*
5599
 
- * Maps G.723_24 code word to reconstructed scale factor normalized log
5600
 
- * magnitude values.
5601
 
- */
5602
 
-static short   _dqlntab_723_24[8] = {-2048, 135, 273, 373, 373, 273, 135, -2048};
5603
 
-
5604
 
-/* Maps G.723_24 code word to log of scale factor multiplier. */
5605
 
-static short   _witab_723_24[8] = {-128, 960, 4384, 18624, 18624, 4384, 960, -128};
5606
 
-
5607
 
-/*
5608
 
- * Maps G.723_24 code words to a set of values whose long and short
5609
 
- * term averages are computed and then compared to give an indication
5610
 
- * how stationary (steady state) the signal is.
5611
 
- */
5612
 
-static short   _fitab_723_24[8] = {0, 0x200, 0x400, 0xE00, 0xE00, 0x400, 0x200, 0};
5613
 
-
5614
 
-static short qtab_723_24[3] = {8, 218, 331};
5615
 
-
5616
 
-/*
5617
 
- * g723_24_encoder()
5618
 
- *
5619
 
- * Encodes a linear PCM, A-law or u-law input sample and returns its 3-bit code.
5620
 
- * Returns -1 if invalid input coding value.
5621
 
- */
5622
 
-int
5623
 
-g723_24_encoder(
5624
 
-       int             sl,
5625
 
-       int             in_coding,
5626
 
-       struct g72x_state *state_ptr)
5627
 
-{
5628
 
-       short           sei, sezi, se, sez;     /* ACCUM */
5629
 
-       short           d;                      /* SUBTA */
5630
 
-       short           y;                      /* MIX */
5631
 
-       short           sr;                     /* ADDB */
5632
 
-       short           dqsez;                  /* ADDC */
5633
 
-       short           dq, i;
5634
 
-
5635
 
-       switch (in_coding) {    /* linearize input sample to 14-bit PCM */
5636
 
-       case AUDIO_ENCODING_ALAW:
5637
 
-               sl = alaw2linear(sl) >> 2;
5638
 
-               break;
5639
 
-       case AUDIO_ENCODING_ULAW:
5640
 
-               sl = ulaw2linear(sl) >> 2;
5641
 
-               break;
5642
 
-       case AUDIO_ENCODING_LINEAR:
5643
 
-               sl >>= 2;               /* sl of 14-bit dynamic range */
5644
 
-               break;
5645
 
-       default:
5646
 
-               return (-1);
5647
 
-       }
5648
 
-
5649
 
-       sezi = predictor_zero(state_ptr);
5650
 
-       sez = sezi >> 1;
5651
 
-       sei = sezi + predictor_pole(state_ptr);
5652
 
-       se = sei >> 1;                  /* se = estimated signal */
5653
 
-
5654
 
-       d = sl - se;                    /* d = estimation diff. */
5655
 
-
5656
 
-       /* quantize prediction difference d */
5657
 
-       y = step_size(state_ptr);       /* quantizer step size */
5658
 
-       i = quantize(d, y, qtab_723_24, 3);     /* i = ADPCM code */
5659
 
-       dq = reconstruct(i & 4, _dqlntab_723_24[i], y); /* quantized diff. */
5660
 
-
5661
 
-       sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconstructed signal */
5662
 
-
5663
 
-       dqsez = sr + sez - se;          /* pole prediction diff. */
5664
 
-
5665
 
-       update(3, y, _witab_723_24[i], _fitab_723_24[i], dq, sr, dqsez, state_ptr);
5666
 
-
5667
 
-       return (i);
5668
 
-}
5669
 
-
5670
 
-/*
5671
 
- * g723_24_decoder()
5672
 
- *
5673
 
- * Decodes a 3-bit CCITT G.723_24 ADPCM code and returns
5674
 
- * the resulting 16-bit linear PCM, A-law or u-law sample value.
5675
 
- * -1 is returned if the output coding is unknown.
5676
 
- */
5677
 
-int
5678
 
-g723_24_decoder(
5679
 
-       int             i,
5680
 
-       int             out_coding,
5681
 
-       struct g72x_state *state_ptr)
5682
 
-{
5683
 
-       short           sezi, sei, sez, se;     /* ACCUM */
5684
 
-       short           y;                      /* MIX */
5685
 
-       short           sr;                     /* ADDB */
5686
 
-       short           dq;
5687
 
-       short           dqsez;
5688
 
-
5689
 
-       i &= 0x07;                      /* mask to get proper bits */
5690
 
-       sezi = predictor_zero(state_ptr);
5691
 
-       sez = sezi >> 1;
5692
 
-       sei = sezi + predictor_pole(state_ptr);
5693
 
-       se = sei >> 1;                  /* se = estimated signal */
5694
 
-
5695
 
-       y = step_size(state_ptr);       /* adaptive quantizer step size */
5696
 
-       dq = reconstruct(i & 0x04, _dqlntab_723_24[i], y); /* unquantize pred diff */
5697
 
-
5698
 
-       sr = (dq < 0) ? (se - (dq & 0x3FFF)) : (se + dq); /* reconst. signal */
5699
 
-
5700
 
-       dqsez = sr - se + sez;                  /* pole prediction diff. */
5701
 
-
5702
 
-       update(3, y, _witab_723_24[i], _fitab_723_24[i], dq, sr, dqsez, state_ptr);
5703
 
-
5704
 
-       switch (out_coding) {
5705
 
-       case AUDIO_ENCODING_ALAW:
5706
 
-               return (tandem_adjust_alaw(sr, se, y, i, 4, qtab_723_24));
5707
 
-       case AUDIO_ENCODING_ULAW:
5708
 
-               return (tandem_adjust_ulaw(sr, se, y, i, 4, qtab_723_24));
5709
 
-       case AUDIO_ENCODING_LINEAR:
5710
 
-               return (sr << 2);       /* sr was of 14-bit dynamic range */
5711
 
-       default:
5712
 
-               return (-1);
5713
 
-       }
5714
 
-}
5715
 
-/*
5716
 
- * g723_40.c
5717
 
- *
5718
 
- * Description:
5719
 
- *
5720
 
- * g723_40_encoder(), g723_40_decoder()
5721
 
- *
5722
 
- * These routines comprise an implementation of the CCITT G.723 40Kbps
5723
 
- * ADPCM coding algorithm.  Essentially, this implementation is identical to
5724
 
- * the bit level description except for a few deviations which
5725
 
- * take advantage of workstation attributes, such as hardware 2's
5726
 
- * complement arithmetic.
5727
 
- *
5728
 
- * The deviation from the bit level specification (lookup tables),
5729
 
- * preserves the bit level performance specifications.
5730
 
- *
5731
 
- * As outlined in the G.723 Recommendation, the algorithm is broken
5732
 
- * down into modules.  Each section of code below is preceded by
5733
 
- * the name of the module which it is implementing.
5734
 
- *
5735
 
- */
5736
 
-
5737
 
-/*
5738
 
- * Maps G.723_40 code word to ructeconstructed scale factor normalized log
5739
 
- * magnitude values.
5740
 
- */
5741
 
-static short   _dqlntab_723_40[32] = {-2048, -66, 28, 104, 169, 224, 274, 318,
5742
 
-                               358, 395, 429, 459, 488, 514, 539, 566,
5743
 
-                               566, 539, 514, 488, 459, 429, 395, 358,
5744
 
-                               318, 274, 224, 169, 104, 28, -66, -2048};
5745
 
-
5746
 
-/* Maps G.723_40 code word to log of scale factor multiplier. */
5747
 
-static short   _witab_723_40[32] = {448, 448, 768, 1248, 1280, 1312, 1856, 3200,
5748
 
-                       4512, 5728, 7008, 8960, 11456, 14080, 16928, 22272,
5749
 
-                       22272, 16928, 14080, 11456, 8960, 7008, 5728, 4512,
5750
 
-                       3200, 1856, 1312, 1280, 1248, 768, 448, 448};
5751
 
-
5752
 
-/*
5753
 
- * Maps G.723_40 code words to a set of values whose long and short
5754
 
- * term averages are computed and then compared to give an indication
5755
 
- * how stationary (steady state) the signal is.
5756
 
- */
5757
 
-static short   _fitab_723_40[32] = {0, 0, 0, 0, 0, 0x200, 0x200, 0x200,
5758
 
-                       0x200, 0x200, 0x400, 0x600, 0x800, 0xA00, 0xC00, 0xC00,
5759
 
-                       0xC00, 0xC00, 0xA00, 0x800, 0x600, 0x400, 0x200, 0x200,
5760
 
-                       0x200, 0x200, 0x200, 0, 0, 0, 0, 0};
5761
 
-
5762
 
-static short qtab_723_40[15] = {-122, -16, 68, 139, 198, 250, 298, 339,
5763
 
-                               378, 413, 445, 475, 502, 528, 553};
5764
 
-
5765
 
-/*
5766
 
- * g723_40_encoder()
5767
 
- *
5768
 
- * Encodes a 16-bit linear PCM, A-law or u-law input sample and retuens
5769
 
- * the resulting 5-bit CCITT G.723 40Kbps code.
5770
 
- * Returns -1 if the input coding value is invalid.
5771
 
- */
5772
 
-int
5773
 
-g723_40_encoder(
5774
 
-       int             sl,
5775
 
-       int             in_coding,
5776
 
-       struct g72x_state *state_ptr)
5777
 
-{
5778
 
-       short           sei, sezi, se, sez;     /* ACCUM */
5779
 
-       short           d;                      /* SUBTA */
5780
 
-       short           y;                      /* MIX */
5781
 
-       short           sr;                     /* ADDB */
5782
 
-       short           dqsez;                  /* ADDC */
5783
 
-       short           dq, i;
5784
 
-
5785
 
-       switch (in_coding) {    /* linearize input sample to 14-bit PCM */
5786
 
-       case AUDIO_ENCODING_ALAW:
5787
 
-               sl = alaw2linear(sl) >> 2;
5788
 
-               break;
5789
 
-       case AUDIO_ENCODING_ULAW:
5790
 
-               sl = ulaw2linear(sl) >> 2;
5791
 
-               break;
5792
 
-       case AUDIO_ENCODING_LINEAR:
5793
 
-               sl >>= 2;               /* sl of 14-bit dynamic range */
5794
 
-               break;
5795
 
-       default:
5796
 
-               return (-1);
5797
 
-       }
5798
 
-
5799
 
-       sezi = predictor_zero(state_ptr);
5800
 
-       sez = sezi >> 1;
5801
 
-       sei = sezi + predictor_pole(state_ptr);
5802
 
-       se = sei >> 1;                  /* se = estimated signal */
5803
 
-
5804
 
-       d = sl - se;                    /* d = estimation difference */
5805
 
-
5806
 
-       /* quantize prediction difference */
5807
 
-       y = step_size(state_ptr);       /* adaptive quantizer step size */
5808
 
-       i = quantize(d, y, qtab_723_40, 15);    /* i = ADPCM code */
5809
 
-
5810
 
-       dq = reconstruct(i & 0x10, _dqlntab_723_40[i], y);      /* quantized diff */
5811
 
-
5812
 
-       sr = (dq < 0) ? se - (dq & 0x7FFF) : se + dq; /* reconstructed signal */
5813
 
-
5814
 
-       dqsez = sr + sez - se;          /* dqsez = pole prediction diff. */
5815
 
-
5816
 
-       update(5, y, _witab_723_40[i], _fitab_723_40[i], dq, sr, dqsez, state_ptr);
5817
 
-
5818
 
-       return (i);
5819
 
-}
5820
 
-
5821
 
-/*
5822
 
- * g723_40_decoder()
5823
 
- *
5824
 
- * Decodes a 5-bit CCITT G.723 40Kbps code and returns
5825
 
- * the resulting 16-bit linear PCM, A-law or u-law sample value.
5826
 
- * -1 is returned if the output coding is unknown.
5827
 
- */
5828
 
-int
5829
 
-g723_40_decoder(
5830
 
-       int             i,
5831
 
-       int             out_coding,
5832
 
-       struct g72x_state *state_ptr)
5833
 
-{
5834
 
-       short           sezi, sei, sez, se;     /* ACCUM */
5835
 
-       short           y;                      /* MIX */
5836
 
-       short           sr;                     /* ADDB */
5837
 
-       short           dq;
5838
 
-       short           dqsez;
5839
 
-
5840
 
-       i &= 0x1f;                      /* mask to get proper bits */
5841
 
-       sezi = predictor_zero(state_ptr);
5842
 
-       sez = sezi >> 1;
5843
 
-       sei = sezi + predictor_pole(state_ptr);
5844
 
-       se = sei >> 1;                  /* se = estimated signal */
5845
 
-
5846
 
-       y = step_size(state_ptr);       /* adaptive quantizer step size */
5847
 
-       dq = reconstruct(i & 0x10, _dqlntab_723_40[i], y);      /* estimation diff. */
5848
 
-
5849
 
-       sr = (dq < 0) ? (se - (dq & 0x7FFF)) : (se + dq); /* reconst. signal */
5850
 
-
5851
 
-       dqsez = sr - se + sez;          /* pole prediction diff. */
5852
 
-
5853
 
-       update(5, y, _witab_723_40[i], _fitab_723_40[i], dq, sr, dqsez, state_ptr);
5854
 
-
5855
 
-       switch (out_coding) {
5856
 
-       case AUDIO_ENCODING_ALAW:
5857
 
-               return (tandem_adjust_alaw(sr, se, y, i, 0x10, qtab_723_40));
5858
 
-       case AUDIO_ENCODING_ULAW:
5859
 
-               return (tandem_adjust_ulaw(sr, se, y, i, 0x10, qtab_723_40));
5860
 
-       case AUDIO_ENCODING_LINEAR:
5861
 
-               return (sr << 2);       /* sr was of 14-bit dynamic range */
5862
 
-       default:
5863
 
-               return (-1);
5864
 
-       }
5865
 
-}
5866
 
Index: vcl/unx/source/app/vsound.hxx
5867
 
===================================================================
5868
 
RCS file: vcl/unx/source/app/vsound.hxx
5869
 
diff -N vcl/unx/source/app/vsound.hxx
5870
 
--- vcl/unx/source/app/vsound.hxx       19 Jun 2006 19:52:31 -0000      1.11
5871
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
5872
 
@@ -1,118 +0,0 @@
5873
 
-/*************************************************************************
5874
 
- *
5875
 
- *  OpenOffice.org - a multi-platform office productivity suite
5876
 
- *
5877
 
- *  $RCSfile: vsound.hxx,v $
5878
 
- *
5879
 
- *  $Revision: 1.11 $
5880
 
- *
5881
 
- *  last change: $Author: hr $ $Date: 2006/06/19 19:52:31 $
5882
 
- *
5883
 
- *  The Contents of this file are made available subject to
5884
 
- *  the terms of GNU Lesser General Public License Version 2.1.
5885
 
- *
5886
 
- *
5887
 
- *    GNU Lesser General Public License Version 2.1
5888
 
- *    =============================================
5889
 
- *    Copyright 2005 by Sun Microsystems, Inc.
5890
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
5891
 
- *
5892
 
- *    This library is free software; you can redistribute it and/or
5893
 
- *    modify it under the terms of the GNU Lesser General Public
5894
 
- *    License version 2.1, as published by the Free Software Foundation.
5895
 
- *
5896
 
- *    This library is distributed in the hope that it will be useful,
5897
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
5898
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5899
 
- *    Lesser General Public License for more details.
5900
 
- *
5901
 
- *    You should have received a copy of the GNU Lesser General Public
5902
 
- *    License along with this library; if not, write to the Free Software
5903
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
5904
 
- *    MA  02111-1307  USA
5905
 
- *
5906
 
- ************************************************************************/
5907
 
-#ifndef _VCL_VSOUND_HXX
5908
 
-#define _VCL_VSOUND_HXX
5909
 
-
5910
 
-#if (defined(LINUX)) || defined(FREEBSD)
5911
 
-#define USE_OSS
5912
 
-#endif
5913
 
-
5914
 
-#ifdef SOLARIS
5915
 
-#define USE_DEVAUDIO
5916
 
-#endif
5917
 
-
5918
 
-#if STLPORT_VERSION>=321
5919
 
-#include <cstdarg>
5920
 
-#endif
5921
 
-#include <sys/stat.h>
5922
 
-#include <tools/string.hxx>
5923
 
-
5924
 
-class X11SalSound;
5925
 
-
5926
 
-namespace vcl_sal {
5927
 
-       class VSound
5928
 
-       {
5929
 
-        protected:
5930
 
-               VSound( ::X11SalSound* pSound ) : m_pSalSound( pSound ), m_pBuffer( NULL ) {}
5931
 
-        
5932
 
-               // instance data
5933
 
-               ::X11SalSound*                  m_pSalSound;
5934
 
-               // pointer to mmaped file
5935
 
-               char*           m_pBuffer;
5936
 
-               struct stat m_aStat;
5937
 
-        
5938
 
-        void initBuffer();
5939
 
-        void releaseBuffer();
5940
 
-        
5941
 
-               virtual BOOL isValid() = 0;
5942
 
-        public:
5943
 
-               virtual ~VSound() {}
5944
 
-        
5945
 
-               virtual void play() = 0;
5946
 
-               virtual void stop() = 0;
5947
 
-               virtual void pause() = 0;
5948
 
-               virtual void cont() = 0;
5949
 
-        
5950
 
-               static VSound* createVSound( X11SalSound* );
5951
 
-       };
5952
 
-    
5953
 
-    
5954
 
-    // a class to convert bytestreams from one codec to another
5955
 
-    class AudioConverter
5956
 
-    {
5957
 
-        public:
5958
 
-        virtual ~AudioConverter();
5959
 
-        
5960
 
-        virtual void reset() = 0;
5961
 
-        // the returned memory should be deleted by user
5962
 
-        virtual char* convert( char* pBuffer, int nBytesIn, int& nBytesOut ) = 0;
5963
 
-        
5964
 
-        // conversion from G721 encoded data
5965
 
-        // input is G721 conforming byte buffer (actually nibble buffer)
5966
 
-        // output is uLaw encoded byte buffer
5967
 
-        static AudioConverter* createG721ToULawConverter();
5968
 
-        
5969
 
-        static AudioConverter* createINT8ToUINT16Converter();
5970
 
-        static AudioConverter* createSwapINT16Converter();
5971
 
-    };
5972
 
-}
5973
 
-
5974
 
-#if OSL_DEBUG_LEVEL > 1
5975
 
-#include <stdarg.h>
5976
 
-#include <stdio.h>
5977
 
-inline void SalDbgAssert( const char* pFmt, ... )
5978
 
-{
5979
 
-       va_list ap;
5980
 
-       va_start( ap, pFmt );
5981
 
-       vfprintf( stderr, pFmt, ap );
5982
 
-       va_end( ap );
5983
 
-}
5984
 
-#else
5985
 
-inline void SalDbgAssert( const char*, ... )
5986
 
-{
5987
 
-}
5988
 
-#endif
5989
 
-
5990
 
-#endif
5991
 
Index: vcl/util/makefile.mk
5992
 
===================================================================
5993
 
RCS file: /cvs/gsl/vcl/util/makefile.mk,v
5994
 
retrieving revision 1.100
5995
 
retrieving revision 1.98.10.3
5996
 
diff -u -p -u -p -r1.100 -r1.98.10.3
5997
 
--- vcl/util/makefile.mk        15 Oct 2007 13:07:51 -0000      1.100
5998
 
+++ vcl/util/makefile.mk        23 Oct 2007 09:05:48 -0000      1.98.10.3
5999
 
@@ -300,25 +300,6 @@ SHL2STDLIBS += $(XINERAMALIBS)
6000
 
 SHL2STDLIBS+=`pkg-config --libs xrender`
6001
 
 .ENDIF
6002
 
 
6003
 
-
6004
 
-.IF "$(ENABLE_PASF)" != ""
6005
 
-SHL2STDLIBS += $(SNDFILELIB) -lportaudio
6006
 
-.IF "$(OS)"=="MACOSX"
6007
 
-SHL2STDLIBS += -framework CoreAudio -framework AudioToolbox
6008
 
-.ENDIF # "$(OS)"=="MACOSX"
6009
 
-.ENDIF # "$(ENABLE_PASF)"!=""
6010
 
-
6011
 
-.IF "$(ENABLE_NAS)" != ""
6012
 
-SHL2STDLIBS += -laudio
6013
 
-.IF "$(XAU_LIBS)" != ""
6014
 
-SHL2STDLIBS += $(XAU_LIBS)
6015
 
-.ENDIF
6016
 
-.IF "$(OS)"=="SOLARIS"
6017
 
-# needed by libaudio.a
6018
 
-SHL2STDLIBS += -ldl -lnsl -lsocket
6019
 
-.ENDIF # SOLARIS
6020
 
-.ENDIF
6021
 
-
6022
 
 .IF "$(GUIBASE)"=="unx"
6023
 
 
6024
 
 .IF "$(WITH_LIBSN)"=="YES"
6025
 
Index: vcl/win/inc/saldata.hxx
6026
 
===================================================================
6027
 
RCS file: /cvs/gsl/vcl/win/inc/saldata.hxx,v
6028
 
retrieving revision 1.28
6029
 
retrieving revision 1.28.60.1
6030
 
diff -u -p -u -p -r1.28 -r1.28.60.1
6031
 
--- vcl/win/inc/saldata.hxx     27 Jun 2007 20:53:03 -0000      1.28
6032
 
+++ vcl/win/inc/saldata.hxx     31 Aug 2007 09:44:58 -0000      1.28.60.1
6033
 
@@ -297,10 +297,6 @@ int ImplSalWICompareAscii( const wchar_t
6034
 
 #define SAL_MSG_CREATEOBJECT        (WM_USER+116)
6035
 
 // wParam == 0; lParam == pObject;
6036
 
 #define SAL_MSG_DESTROYOBJECT       (WM_USER+117)
6037
 
-// wParam == 0; lParam == this; lResult == bRet
6038
 
-#define SAL_MSG_CREATESOUND         (WM_USER+118)
6039
 
-// wParam == 0; lParam == this
6040
 
-#define SAL_MSG_DESTROYSOUND        (WM_USER+119)
6041
 
 // wParam == hWnd; lParam == 0; lResult == hDC
6042
 
 #define SAL_MSG_GETDC               (WM_USER+120)
6043
 
 // wParam == hWnd; lParam == 0
6044
 
Index: vcl/win/inc/salinst.h
6045
 
===================================================================
6046
 
RCS file: /cvs/gsl/vcl/win/inc/salinst.h,v
6047
 
retrieving revision 1.13
6048
 
retrieving revision 1.13.60.1
6049
 
diff -u -p -u -p -r1.13 -r1.13.60.1
6050
 
--- vcl/win/inc/salinst.h       27 Jun 2007 20:53:41 -0000      1.13
6051
 
+++ vcl/win/inc/salinst.h       31 Aug 2007 09:44:58 -0000      1.13.60.1
6052
 
@@ -83,7 +83,6 @@ public:
6053
 
     virtual void                       GetPrinterQueueState( SalPrinterQueueInfo* pInfo );
6054
 
     virtual void                       DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo );
6055
 
     virtual String             GetDefaultPrinter();
6056
 
-    virtual SalSound*                  CreateSalSound();
6057
 
     virtual SalTimer*                  CreateSalTimer();
6058
 
     virtual SalOpenGL*                 CreateSalOpenGL( SalGraphics* pGraphics );
6059
 
     virtual SalI18NImeStatus*  CreateI18NImeStatus();
6060
 
Index: vcl/win/inc/salsound.h
6061
 
===================================================================
6062
 
RCS file: vcl/win/inc/salsound.h
6063
 
diff -N vcl/win/inc/salsound.h
6064
 
--- vcl/win/inc/salsound.h      27 Jun 2007 20:55:12 -0000      1.5
6065
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
6066
 
@@ -1,108 +0,0 @@
6067
 
-/*************************************************************************
6068
 
- *
6069
 
- *  OpenOffice.org - a multi-platform office productivity suite
6070
 
- *
6071
 
- *  $RCSfile: salsound.h,v $
6072
 
- *
6073
 
- *  $Revision: 1.5 $
6074
 
- *
6075
 
- *  last change: $Author: hr $ $Date: 2007/06/27 20:55:12 $
6076
 
- *
6077
 
- *  The Contents of this file are made available subject to
6078
 
- *  the terms of GNU Lesser General Public License Version 2.1.
6079
 
- *
6080
 
- *
6081
 
- *    GNU Lesser General Public License Version 2.1
6082
 
- *    =============================================
6083
 
- *    Copyright 2005 by Sun Microsystems, Inc.
6084
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
6085
 
- *
6086
 
- *    This library is free software; you can redistribute it and/or
6087
 
- *    modify it under the terms of the GNU Lesser General Public
6088
 
- *    License version 2.1, as published by the Free Software Foundation.
6089
 
- *
6090
 
- *    This library is distributed in the hope that it will be useful,
6091
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
6092
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
6093
 
- *    Lesser General Public License for more details.
6094
 
- *
6095
 
- *    You should have received a copy of the GNU Lesser General Public
6096
 
- *    License along with this library; if not, write to the Free Software
6097
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
6098
 
- *    MA  02111-1307  USA
6099
 
- *
6100
 
- ************************************************************************/
6101
 
-
6102
 
-#ifndef _SV_SALSOUND_H
6103
 
-#define _SV_SALSOUND_H
6104
 
-
6105
 
-#ifndef _SV_WINCOMP_HXX
6106
 
-#include <wincomp.hxx>
6107
 
-#endif
6108
 
-
6109
 
-#ifndef _GEN_HXX
6110
 
-#include <tools/gen.hxx>
6111
 
-#endif
6112
 
-#ifndef _STRING_HXX
6113
 
-#include <tools/string.hxx>
6114
 
-#endif
6115
 
-
6116
 
-#ifndef _SV_SV_H
6117
 
-#include <vcl/sv.h>
6118
 
-#endif
6119
 
-
6120
 
-#include <osl/module.h>
6121
 
-
6122
 
-#ifndef _SV_SALFRAME_HXX
6123
 
-#include <vcl/salframe.hxx>
6124
 
-#endif
6125
 
-#ifndef _SV_SALSTYPE_HXX
6126
 
-#include <vcl/salstype.hxx>
6127
 
-#endif
6128
 
-#ifndef _SV_SALSOUND_HXX
6129
 
-#include <vcl/salsound.hxx>
6130
 
-#endif
6131
 
-
6132
 
-// ------------
6133
 
-// - SalSound -
6134
 
-// ------------
6135
 
-
6136
 
-class WinSalSound : public SalSound
6137
 
-{
6138
 
-private:
6139
 
-       static oslModule        mhMCILib;
6140
 
-       static ULONG            mnSoundState;
6141
 
-       static void*            mpMCIFnc;
6142
 
-       ULONG                           mnStartTime;
6143
 
-       ULONG                           mnPlayLen;
6144
 
-       HWND                            mhSoundWnd;
6145
 
-       UINT                            mnDeviceId;
6146
 
-       bool                            mbLoop;
6147
 
-       bool                            mbPaused;
6148
 
-
6149
 
-public:
6150
 
-       void                            ImplSetError( DWORD nMciErr );
6151
 
-       void                            ImplNotify( SoundNotification eNotification, ULONG nError );
6152
 
-
6153
 
-public:
6154
 
-    WinSalSound();
6155
 
-    virtual ~WinSalSound();
6156
 
-    
6157
 
-    virtual bool               IsValid();
6158
 
-    virtual bool               Init( const String&     rSoundName,
6159
 
-                              ULONG&           rSoundLen );
6160
 
-       virtual void            Play( ULONG nStartTime, ULONG nPlayTime, bool bLoop );
6161
 
-       virtual void            Stop();
6162
 
-       virtual void            Pause();
6163
 
-       virtual void            Continue();
6164
 
-    virtual bool               IsLoopMode() const;
6165
 
-       virtual bool            IsPlaying() const;
6166
 
-    virtual bool               IsPaused() const;
6167
 
-
6168
 
-
6169
 
-       bool                            ImplCreate();
6170
 
-       void                            ImplDestroy();
6171
 
-       static void             Release();
6172
 
-};
6173
 
-
6174
 
-#endif // _SV_SALSOUND_H
6175
 
Index: vcl/win/inc/salsound.hxx
6176
 
===================================================================
6177
 
RCS file: vcl/win/inc/salsound.hxx
6178
 
diff -N vcl/win/inc/salsound.hxx
6179
 
--- vcl/win/inc/salsound.hxx    27 Jun 2007 20:55:24 -0000      1.3
6180
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
6181
 
@@ -1,104 +0,0 @@
6182
 
-/*************************************************************************
6183
 
- *
6184
 
- *  OpenOffice.org - a multi-platform office productivity suite
6185
 
- *
6186
 
- *  $RCSfile: salsound.hxx,v $
6187
 
- *
6188
 
- *  $Revision: 1.3 $
6189
 
- *
6190
 
- *  last change: $Author: hr $ $Date: 2007/06/27 20:55:24 $
6191
 
- *
6192
 
- *  The Contents of this file are made available subject to
6193
 
- *  the terms of GNU Lesser General Public License Version 2.1.
6194
 
- *
6195
 
- *
6196
 
- *    GNU Lesser General Public License Version 2.1
6197
 
- *    =============================================
6198
 
- *    Copyright 2005 by Sun Microsystems, Inc.
6199
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
6200
 
- *
6201
 
- *    This library is free software; you can redistribute it and/or
6202
 
- *    modify it under the terms of the GNU Lesser General Public
6203
 
- *    License version 2.1, as published by the Free Software Foundation.
6204
 
- *
6205
 
- *    This library is distributed in the hope that it will be useful,
6206
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
6207
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
6208
 
- *    Lesser General Public License for more details.
6209
 
- *
6210
 
- *    You should have received a copy of the GNU Lesser General Public
6211
 
- *    License along with this library; if not, write to the Free Software
6212
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
6213
 
- *    MA  02111-1307  USA
6214
 
- *
6215
 
- ************************************************************************/
6216
 
-
6217
 
-#ifndef _SV_SALSOUND_HXX
6218
 
-#define _SV_SALSOUND_HXX
6219
 
-
6220
 
-#ifndef _SV_WINCOMP_HXX
6221
 
-#include <wincomp.hxx>
6222
 
-#endif
6223
 
-
6224
 
-#ifndef _GEN_HXX
6225
 
-#include <tools/gen.hxx>
6226
 
-#endif
6227
 
-#ifndef _STRING_HXX
6228
 
-#include <tools/string.hxx>
6229
 
-#endif
6230
 
-
6231
 
-#ifndef _SV_SV_H
6232
 
-#include <vcl/sv.h>
6233
 
-#endif
6234
 
-
6235
 
-#ifndef _SV_SALFRAME_HXX
6236
 
-#include <vcl/salframe.hxx>
6237
 
-#endif
6238
 
-#ifndef _SV_SALSTYPE_HXX
6239
 
-#include <vcl/salstype.hxx>
6240
 
-#endif
6241
 
-
6242
 
-// ------------
6243
 
-// - SalSound -
6244
 
-// ------------
6245
 
-
6246
 
-class SalSound
6247
 
-{
6248
 
-private:
6249
 
-       static HINSTANCE        mhMCILib;
6250
 
-       static ULONG            mnSoundState;
6251
 
-       static void*            mpMCIFnc;
6252
 
-       SALSOUNDPROC            mpProc;
6253
 
-       void*                           mpInst;
6254
 
-       ULONG                           mnStartTime;
6255
 
-       ULONG                           mnPlayLen;
6256
 
-       HWND                            mhSoundWnd;
6257
 
-       UINT                            mnDeviceId;
6258
 
-       BOOL                            mbLoop;
6259
 
-       BOOL                            mbPaused;
6260
 
-
6261
 
-public:
6262
 
-       void                            ImplSetError( DWORD nMciErr );
6263
 
-       void                            ImplNotify( SoundNotification eNotification, ULONG nError );
6264
 
-
6265
 
-public:
6266
 
-                                               SalSound();
6267
 
-                                               ~SalSound();
6268
 
-
6269
 
-       BOOL                            ImplCreate();
6270
 
-       BOOL                            Create();
6271
 
-       void                            ImplDestroy();
6272
 
-       static void             Release();
6273
 
-       static BOOL             IsValid() { return( SOUND_STATE_VALID == SalSound::mnSoundState ); }
6274
 
-
6275
 
-       BOOL                            Init( SalFrame* pFrame, const String& rSoundName, ULONG& rSoundLen );
6276
 
-       BOOL                            Init( SalFrame* pFrame, const BYTE* pSound, ULONG nDataLen, ULONG& rSoundLen );
6277
 
-       void                            Play( ULONG nStartTime, ULONG nPlayTime, BOOL bLoop );
6278
 
-       void                            Stop();
6279
 
-       void                            Pause();
6280
 
-
6281
 
-       void                            SetNotifyProc( void* pInst, SALSOUNDPROC pProc )
6282
 
-                                                       { mpInst = pInst; mpProc = pProc; }
6283
 
-};
6284
 
-
6285
 
-#endif // _SV_SALSOUND_HXX
6286
 
Index: vcl/win/source/app/MAKEFILE.MK
6287
 
===================================================================
6288
 
RCS file: /cvs/gsl/vcl/win/source/app/MAKEFILE.MK,v
6289
 
retrieving revision 1.8
6290
 
retrieving revision 1.8.160.1
6291
 
diff -u -p -u -p -r1.8 -r1.8.160.1
6292
 
--- vcl/win/source/app/MAKEFILE.MK      6 Feb 2007 14:20:03 -0000       1.8
6293
 
+++ vcl/win/source/app/MAKEFILE.MK      31 Aug 2007 09:44:58 -0000      1.8.160.1
6294
 
@@ -56,7 +56,6 @@ SLOFILES=   $(SLO)$/salshl.obj      \
6295
 
             $(SLO)$/saldata.obj     \
6296
 
             $(SLO)$/salinst.obj     \
6297
 
             $(SLO)$/saltimer.obj    \
6298
 
-            $(SLO)$/salsound.obj    \
6299
 
             $(SLO)$/salinfo.obj
6300
 
 
6301
 
 # --- Targets ------------------------------------------------------
6302
 
Index: vcl/win/source/app/salinst.cxx
6303
 
===================================================================
6304
 
RCS file: /cvs/gsl/vcl/win/source/app/salinst.cxx,v
6305
 
retrieving revision 1.39
6306
 
retrieving revision 1.39.12.1
6307
 
diff -u -p -u -p -r1.39 -r1.39.12.1
6308
 
--- vcl/win/source/app/salinst.cxx      2 Aug 2007 18:29:24 -0000       1.39
6309
 
+++ vcl/win/source/app/salinst.cxx      31 Aug 2007 09:44:58 -0000      1.39.12.1
6310
 
@@ -77,9 +77,6 @@
6311
 
 #ifndef _SV_SALTIMER_H
6312
 
 #include <saltimer.h>
6313
 
 #endif
6314
 
-#ifndef _SV_SALSOUND_H
6315
 
-#include <salsound.h>
6316
 
-#endif
6317
 
 #ifndef _SV_SALATYPE_HXX
6318
 
 #include <vcl/salatype.hxx>
6319
 
 #endif
6320
 
@@ -873,14 +870,6 @@ LRESULT CALLBACK SalComWndProc( HWND hWn
6321
 
                        delete (SalObject*)lParam;
6322
 
                        rDef = FALSE;
6323
 
                        break;
6324
 
-               case SAL_MSG_CREATESOUND:
6325
 
-                       nRet = ((WinSalSound*)lParam)->ImplCreate();
6326
 
-                       rDef = FALSE;
6327
 
-                       break;
6328
 
-               case SAL_MSG_DESTROYSOUND:
6329
 
-                       ((WinSalSound*)lParam)->ImplDestroy();
6330
 
-                       rDef = FALSE;
6331
 
-                       break;
6332
 
                case SAL_MSG_GETDC:
6333
 
                        nRet = (LRESULT)GetDCEx( (HWND)wParam, 0, DCX_CACHE );
6334
 
                        rDef = FALSE;
6335
 
@@ -1120,13 +1109,6 @@ SalTimer* WinSalInstance::CreateSalTimer
6336
 
 
6337
 
 // -----------------------------------------------------------------------
6338
 
 
6339
 
-SalSound* WinSalInstance::CreateSalSound()
6340
 
-{
6341
 
-       return new WinSalSound();
6342
 
-}
6343
 
-
6344
 
-// -----------------------------------------------------------------------
6345
 
-
6346
 
 SalOpenGL* WinSalInstance::CreateSalOpenGL( SalGraphics* pGraphics )
6347
 
 {
6348
 
        return new WinSalOpenGL( pGraphics );
6349
 
Index: vcl/win/source/app/salsound.cxx
6350
 
===================================================================
6351
 
RCS file: vcl/win/source/app/salsound.cxx
6352
 
diff -N vcl/win/source/app/salsound.cxx
6353
 
--- vcl/win/source/app/salsound.cxx     26 Mar 2007 14:40:21 -0000      1.9
6354
 
+++ /dev/null   1 Jan 1970 00:00:00 -0000
6355
 
@@ -1,527 +0,0 @@
6356
 
-/*************************************************************************
6357
 
- *
6358
 
- *  OpenOffice.org - a multi-platform office productivity suite
6359
 
- *
6360
 
- *  $RCSfile: salsound.cxx,v $
6361
 
- *
6362
 
- *  $Revision: 1.9 $
6363
 
- *
6364
 
- *  last change: $Author: vg $ $Date: 2007/03/26 14:40:21 $
6365
 
- *
6366
 
- *  The Contents of this file are made available subject to
6367
 
- *  the terms of GNU Lesser General Public License Version 2.1.
6368
 
- *
6369
 
- *
6370
 
- *    GNU Lesser General Public License Version 2.1
6371
 
- *    =============================================
6372
 
- *    Copyright 2005 by Sun Microsystems, Inc.
6373
 
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
6374
 
- *
6375
 
- *    This library is free software; you can redistribute it and/or
6376
 
- *    modify it under the terms of the GNU Lesser General Public
6377
 
- *    License version 2.1, as published by the Free Software Foundation.
6378
 
- *
6379
 
- *    This library is distributed in the hope that it will be useful,
6380
 
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
6381
 
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
6382
 
- *    Lesser General Public License for more details.
6383
 
- *
6384
 
- *    You should have received a copy of the GNU Lesser General Public
6385
 
- *    License along with this library; if not, write to the Free Software
6386
 
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
6387
 
- *    MA  02111-1307  USA
6388
 
- *
6389
 
- ************************************************************************/
6390
 
-
6391
 
-// MARKER(update_precomp.py): autogen include statement, do not remove
6392
 
-#include "precompiled_vcl.hxx"
6393
 
-
6394
 
-#define INCLUDE_MMSYSTEM
6395
 
-
6396
 
-// ------------
6397
 
-// - Includes -
6398
 
-// ------------
6399
 
-
6400
 
-#ifndef _SVWIN_H
6401
 
-#include <tools/svwin.h>
6402
 
-#endif
6403
 
-
6404
 
-#ifndef _SV_SALDATA_HXX
6405
 
-#include <saldata.hxx>
6406
 
-#endif
6407
 
-#ifndef _SV_SALINST_H
6408
 
-#include <salinst.h>
6409
 
-#endif
6410
 
-#ifndef _SV_SALSOUND_H
6411
 
-#include <salsound.h>
6412
 
-#endif
6413
 
-
6414
 
-// ---------
6415
 
-// - Names -
6416
 
-// ---------
6417
 
-
6418
 
-#define SOUND_LIBNAME          "WINMM.DLL"
6419
 
-#define SOUND_PROCNAMEA        "mciSendCommandA"
6420
 
-#define SOUND_PROCNAMEW        "mciSendCommandW"
6421
 
-#define SOUND_WINDOWCLASSA     "SALSOUNDWND"
6422
 
-#define SOUND_WINDOWCLASSW     L"SALSOUNDWND"
6423
 
-
6424
 
-// ------------
6425
 
-// - Fnc cast -
6426
 
-// ------------
6427
 
-
6428
 
-#define __MCI_CALL __stdcall
6429
 
-
6430
 
-#define MCIFNC ((DWORD( __MCI_CALL * )( UINT, UINT, DWORD, DWORD )) WinSalSound::mpMCIFnc)
6431
 
-
6432
 
-// -----------------
6433
 
-// - Statics init. -
6434
 
-// -----------------
6435
 
-
6436
 
-oslModule      WinSalSound::mhMCILib = 0;
6437
 
-ULONG          WinSalSound::mnSoundState = SOUND_STATE_UNLOADED;
6438
 
-void*          WinSalSound::mpMCIFnc = NULL;
6439
 
-
6440
 
-// -------------------
6441
 
-// - Window-Callback -
6442
 
-// -------------------
6443
 
-
6444
 
-void ImplSalHandleMCINotify( HWND hWnd, WPARAM nPar1, LPARAM )
6445
 
-{
6446
 
-       SoundNotification       eNotification = SOUND_NOTIFY_SUCCESS;
6447
 
-       BOOL                            bNotify = TRUE;
6448
 
-
6449
 
-       switch ( nPar1 )
6450
 
-       {
6451
 
-               case( MCI_NOTIFY_SUCCESSFUL ):
6452
 
-                       eNotification = SOUND_NOTIFY_SUCCESS;
6453
 
-                       break;
6454
 
-
6455
 
-               case( MCI_NOTIFY_ABORTED ):
6456
 
-                       eNotification = SOUND_NOTIFY_ABORTED;
6457
 
-                       break;
6458
 
-
6459
 
-               case( MCI_NOTIFY_FAILURE ):
6460
 
-                       eNotification = SOUND_NOTIFY_ERROR;
6461
 
-                       break;
6462
 
-
6463
 
-               default:
6464
 
-                       bNotify = FALSE;
6465
 
-       }
6466
 
-
6467
 
-       if ( bNotify )
6468
 
-               ((WinSalSound*)GetWindowLong( hWnd, 0 ) )->ImplNotify( eNotification, 0 );
6469
 
-}
6470
 
-
6471
 
-LRESULT CALLBACK SalSoundWndProcA( HWND hWnd, UINT nMsg, WPARAM nPar1, LPARAM nPar2 )
6472
 
-{
6473
 
-       if ( MM_MCINOTIFY == nMsg )
6474
 
-               ImplSalHandleMCINotify( hWnd, nPar1, nPar2 );
6475
 
-       return DefWindowProcA( hWnd, nMsg, nPar1, nPar2 );
6476
 
-}
6477
 
-
6478
 
-LRESULT CALLBACK SalSoundWndProcW( HWND hWnd, UINT nMsg, WPARAM nPar1, LPARAM nPar2 )
6479
 
-{
6480
 
-       if ( MM_MCINOTIFY == nMsg )
6481
 
-               ImplSalHandleMCINotify( hWnd, nPar1, nPar2 );
6482
 
-       return DefWindowProcW( hWnd, nMsg, nPar1, nPar2 );
6483
 
-}
6484
 
-
6485
 
-// ------------
6486
 
-// - SalSound -
6487
 
-// ------------
6488
 
-
6489
 
-WinSalSound::WinSalSound() :
6490
 
-       mhSoundWnd              ( 0 ),
6491
 
-       mnDeviceId              ( 0 ),
6492
 
-       mbLoop                  ( FALSE ),
6493
 
-       mbPaused                ( FALSE )
6494
 
-{
6495
 
-}
6496
 
-
6497
 
-// ------------------------------------------------------------------------
6498
 
-
6499
 
-WinSalSound::~WinSalSound()
6500
 
-{
6501
 
-       Stop();
6502
 
-
6503
 
-       if ( mnDeviceId )
6504
 
-       {
6505
 
-               // close device
6506
 
-               MCI_GENERIC_PARMS aGenericParams;
6507
 
-               aGenericParams.dwCallback = (DWORD) mhSoundWnd;
6508
 
-               MCIFNC( mnDeviceId, MCI_CLOSE, MCI_WAIT, (DWORD)&aGenericParams );
6509
 
-       }
6510
 
-
6511
 
-       // Call Destroy in the main thread, because Create is also called in
6512
 
-       // the main thread and if we don't call this also in the main thread
6513
 
-       // windows doesn't destroy the window
6514
 
-       WinSalInstance* pInst = GetSalData()->mpFirstInstance;
6515
 
-       if ( pInst )
6516
 
-       {
6517
 
-               ImplSendMessage( pInst->mhComWnd, SAL_MSG_DESTROYSOUND,
6518
 
-                                                0, (LPARAM)this );
6519
 
-       }
6520
 
-       else
6521
 
-               ImplDestroy();
6522
 
-}
6523
 
-
6524
 
-// ------------------------------------------------------------------------
6525
 
-
6526
 
-void WinSalSound::ImplSetError( DWORD nMciErr )
6527
 
-{
6528
 
-       struct aMapper { DWORD nMci; ULONG nSv; };
6529
 
-
6530
 
-       ULONG                   nError = SOUNDERR_GENERAL_ERROR;
6531
 
-       static aMapper  aErrArr[] =
6532
 
-       {
6533
 
-               { 0, SOUNDERR_SUCCESS },
6534
 
-               { MCIERR_CANNOT_LOAD_DRIVER, SOUNDERR_CANNOT_LOAD_DRIVER },
6535
 
-               { MCIERR_DEVICE_LOCKED, SOUNDERR_DEVICE_LOCKED },
6536
 
-               { MCIERR_DEVICE_NOT_INSTALLED, SOUNDERR_DEVICE_NOT_FOUND },
6537
 
-               { MCIERR_DEVICE_NOT_READY, SOUNDERR_DEVICE_NOT_READY },
6538
 
-               { MCIERR_DEVICE_TYPE_REQUIRED, SOUNDERR_DEVICE_NOT_FOUND },
6539
 
-               { MCIERR_DRIVER, SOUNDERR_CANNOT_LOAD_DRIVER },
6540
 
-               { MCIERR_DRIVER_INTERNAL, SOUNDERR_CANNOT_LOAD_DRIVER  },
6541
 
-               { MCIERR_EXTENSION_NOT_FOUND, SOUNDERR_SOUND_NOT_FOUND },
6542
 
-               { MCIERR_FILE_NOT_FOUND, SOUNDERR_SOUND_NOT_FOUND },
6543
 
-               { MCIERR_FILE_READ, SOUNDERR_CANNOT_READ_SOUND },
6544
 
-               { MCIERR_FILENAME_REQUIRED, SOUNDERR_SOUND_NOT_FOUND },
6545
 
-               { MCIERR_HARDWARE, SOUNDERR_HARDWARE_ERROR },
6546
 
-               { MCIERR_INVALID_DEVICE_NAME, SOUNDERR_DEVICE_NOT_FOUND },
6547
 
-               { MCIERR_INVALID_FILE, SOUNDERR_INVALID_FILE },
6548
 
-               { MCIERR_OUT_OF_MEMORY, SOUNDERR_OUT_OF_MEMORY },
6549
 
-               { MCIERR_UNSUPPORTED_FUNCTION, SOUNDERR_UNSUPPORTED_FUNCTION }
6550
 
-       };
6551
 
-
6552
 
-       for ( USHORT n=0; n < (sizeof( aErrArr ) / sizeof( aMapper ) ); n++ )
6553
 
-       {
6554
 
-               if ( aErrArr[ n ].nMci == nMciErr )
6555
 
-               {
6556
 
-                       nError = aErrArr[ n ].nSv;
6557
 
-                       break;
6558
 
-               }
6559
 
-       }
6560
 
-
6561
 
-       if ( nError )
6562
 
-               ImplNotify( SOUND_NOTIFY_ERROR, nError );
6563
 
-}
6564
 
-
6565
 
-// ------------------------------------------------------------------------
6566
 
-
6567
 
-void WinSalSound::ImplNotify( SoundNotification eNotification, ULONG nError )
6568
 
-{
6569
 
-       if ( mbLoop && (SOUND_NOTIFY_SUCCESS == eNotification) && !nError )
6570
 
-               Play( mnStartTime, mnPlayLen, TRUE );
6571
 
-
6572
 
-    CallNotifyProc( eNotification, nError );
6573
 
-}
6574
 
-
6575
 
-// ------------------------------------------------------------------------
6576
 
-
6577
 
-bool WinSalSound::ImplCreate()
6578
 
-{
6579
 
-       SalData*        pData = GetSalData();
6580
 
-       bool            bRet = FALSE;
6581
 
-
6582
 
-       if ( SOUND_STATE_UNLOADED == WinSalSound::mnSoundState )
6583
 
-       {
6584
 
-               // load library and init fncpointer
6585
 
-               if ( aSalShlData.mbWNT )
6586
 
-               {
6587
 
-            OUString aLibraryName( RTL_CONSTASCII_USTRINGPARAM( SOUND_LIBNAME ) );
6588
 
-            OUString queryFuncName( RTL_CONSTASCII_USTRINGPARAM( SOUND_PROCNAMEW ) );
6589
 
-            if ( (WinSalSound::mhMCILib = osl_loadModule( aLibraryName.pData, SAL_LOADMODULE_DEFAULT )) != 0 &&
6590
 
-                                (WinSalSound::mpMCIFnc = (void*)osl_getSymbol( WinSalSound::mhMCILib, queryFuncName.pData )) != 0 )
6591
 
-                       {
6592
 
-                               WNDCLASSEXW aWndClass;
6593
 
-
6594
 
-                               memset( &aWndClass, 0, sizeof( aWndClass ) );
6595
 
-                               aWndClass.cbSize                = sizeof( aWndClass );
6596
 
-                               aWndClass.lpfnWndProc   = SalSoundWndProcW;
6597
 
-                               aWndClass.cbWndExtra    = sizeof( SalSound* );
6598
 
-                               aWndClass.hInstance     = pData->mhInst;
6599
 
-                               aWndClass.lpszClassName = SOUND_WINDOWCLASSW;
6600
 
-                               if ( RegisterClassExW( &aWndClass ) )
6601
 
-                               {
6602
 
-                                       WinSalSound::mnSoundState = SOUND_STATE_VALID;
6603
 
-                                       bRet = TRUE;
6604
 
-                               }
6605
 
-                       }
6606
 
-               }
6607
 
-               else
6608
 
-               {
6609
 
-            OUString aLibraryName( RTL_CONSTASCII_USTRINGPARAM( SOUND_LIBNAME ) );
6610
 
-            OUString queryFuncName( RTL_CONSTASCII_USTRINGPARAM( SOUND_PROCNAMEA ) );
6611
 
-            if ( (WinSalSound::mhMCILib = osl_loadModule( aLibraryName.pData, SAL_LOADMODULE_DEFAULT )) != 0 &&
6612
 
-                                (WinSalSound::mpMCIFnc = (void*)osl_getSymbol( WinSalSound::mhMCILib, queryFuncName.pData )) != 0 )
6613
 
-                       {
6614
 
-                               WNDCLASSEXA aWndClass;
6615
 
-
6616
 
-                               memset( &aWndClass, 0, sizeof( aWndClass ) );
6617
 
-                               aWndClass.cbSize                = sizeof( aWndClass );
6618
 
-                               aWndClass.lpfnWndProc   = SalSoundWndProcA;
6619
 
-                               aWndClass.cbWndExtra    = sizeof( SalSound* );
6620
 
-                               aWndClass.hInstance     = pData->mhInst;
6621
 
-                               aWndClass.lpszClassName = SOUND_WINDOWCLASSA;
6622
 
-                               if ( RegisterClassExA( &aWndClass ) )
6623
 
-                               {
6624
 
-                                       WinSalSound::mnSoundState = SOUND_STATE_VALID;
6625
 
-                                       bRet = TRUE;
6626
 
-                               }
6627
 
-                       }
6628
 
-               }
6629
 
-
6630
 
-               if ( !bRet )
6631
 
-               {
6632
 
-                       if ( WinSalSound::mhMCILib )
6633
 
-            {
6634
 
-                               osl_unloadModule( WinSalSound::mhMCILib );
6635
 
-                WinSalSound::mhMCILib = NULL;
6636
 
-            }
6637
 
-
6638
 
-                       WinSalSound::mnSoundState = SOUND_STATE_INVALID;
6639
 
-                       ImplNotify( SOUND_NOTIFY_ERROR, SOUNDERR_CANNOT_LOAD_DRIVER );
6640
 
-               }
6641
 
-       }
6642
 
-       else if ( SOUND_STATE_VALID == WinSalSound::mnSoundState )
6643
 
-               bRet = TRUE;
6644
 
-
6645
 
-       if ( bRet )
6646
 
-       {
6647
 
-               // Create message window
6648
 
-               if ( aSalShlData.mbWNT )
6649
 
-               {
6650
 
-                       mhSoundWnd = CreateWindowExW( 0, SOUND_WINDOWCLASSW, L"", 0, 0, 0, 0, 0,
6651
 
-                                                                                 HWND_DESKTOP, NULL, pData->mhInst, 0 );
6652
 
-               }
6653
 
-               else
6654
 
-               {
6655
 
-                       mhSoundWnd = CreateWindowExA( 0, SOUND_WINDOWCLASSA, "", 0, 0, 0, 0, 0,
6656
 
-                                                                                 HWND_DESKTOP, NULL, pData->mhInst, 0 );
6657
 
-               }
6658
 
-               SetWindowLong( mhSoundWnd, 0, (LONG)this );
6659
 
-       }
6660
 
-       else
6661
 
-               mhSoundWnd = 0;
6662
 
-
6663
 
-       return bRet;
6664
 
-}
6665
 
-
6666
 
-// ------------------------------------------------------------------------
6667
 
-
6668
 
-bool WinSalSound::IsValid()
6669
 
-{
6670
 
-       // Call Create in the main thread, because in the other case the
6671
 
-       // Sound stop, if the calling thread dies.
6672
 
-       WinSalInstance* pInst = GetSalData()->mpFirstInstance;
6673
 
-       if ( pInst )
6674
 
-       {
6675
 
-               return (BOOL)ImplSendMessage( pInst->mhComWnd, SAL_MSG_CREATESOUND,
6676
 
-                                                                         0, (LPARAM)this );
6677
 
-       }
6678
 
-       else
6679
 
-               return ImplCreate();
6680
 
-}
6681
 
-
6682
 
-// ------------------------------------------------------------------------
6683
 
-
6684
 
-void WinSalSound::ImplDestroy()
6685
 
-{
6686
 
-       if ( mhSoundWnd )
6687
 
-               DestroyWindow( mhSoundWnd );
6688
 
-       mhSoundWnd = 0;
6689
 
-}
6690
 
-
6691
 
-// ------------------------------------------------------------------------
6692
 
-
6693
 
-void WinSalSound::Release()
6694
 
-{
6695
 
-       // free library
6696
 
-       if ( WinSalSound::mhMCILib )
6697
 
-    {
6698
 
-               osl_unloadModule( WinSalSound::mhMCILib );
6699
 
-        WinSalSound::mhMCILib = NULL;
6700
 
-    }
6701
 
-
6702
 
-       WinSalSound::mnSoundState = SOUND_STATE_UNLOADED;
6703
 
-}
6704
 
-
6705
 
-// ------------------------------------------------------------------------
6706
 
-
6707
 
-bool WinSalSound::Init( const XubString& rSoundName, ULONG& rSoundLen )
6708
 
-{
6709
 
-       DWORD nMciErr = 0;
6710
 
-       rSoundLen = 0;
6711
 
-
6712
 
-       // clear old device
6713
 
-       if ( mnDeviceId )
6714
 
-       {
6715
 
-               Stop();
6716
 
-
6717
 
-               MCI_GENERIC_PARMS aGenericParams;
6718
 
-               aGenericParams.dwCallback = (DWORD) mhSoundWnd;
6719
 
-               nMciErr = MCIFNC( mnDeviceId, MCI_CLOSE, MCI_WAIT, (DWORD) &aGenericParams );
6720
 
-               mnDeviceId = 0;
6721
 
-       }
6722
 
-
6723
 
-       if ( rSoundName.Len() )
6724
 
-       {
6725
 
-               UINT nDeviceId;
6726
 
-               if ( aSalShlData.mbWNT )
6727
 
-               {
6728
 
-                       MCI_OPEN_PARMSW aOpenParams;
6729
 
-                       aOpenParams.dwCallback = (DWORD)mhSoundWnd;
6730
 
-                       aOpenParams.lpstrElementName =  reinterpret_cast<LPCWSTR>(rSoundName.GetBuffer());
6731
 
-                       aOpenParams.wDeviceID = 0;
6732
 
-                       aOpenParams.lpstrDeviceType = 0;
6733
 
-                       aOpenParams.lpstrAlias = 0;
6734
 
-                       nMciErr = MCIFNC( 0, MCI_OPEN, MCI_WAIT | MCI_OPEN_ELEMENT, (DWORD)&aOpenParams );
6735
 
-                       nDeviceId = aOpenParams.wDeviceID;
6736
 
-               }
6737
 
-               else
6738
 
-               {
6739
 
-                       ByteString aSoundName( ImplSalGetWinAnsiString( rSoundName, TRUE ) );
6740
 
-                       MCI_OPEN_PARMSA aOpenParams;
6741
 
-                       aOpenParams.dwCallback = (DWORD)mhSoundWnd;
6742
 
-                       aOpenParams.lpstrElementName = aSoundName.GetBuffer();
6743
 
-                       aOpenParams.wDeviceID = 0;
6744
 
-                       aOpenParams.lpstrDeviceType = 0;
6745
 
-                       aOpenParams.lpstrAlias = 0;
6746
 
-                       nMciErr = MCIFNC( 0, MCI_OPEN, MCI_WAIT | MCI_OPEN_ELEMENT, (DWORD)&aOpenParams );
6747
 
-                       nDeviceId = aOpenParams.wDeviceID;
6748
 
-               }
6749
 
-
6750
 
-               if ( !nMciErr )
6751
 
-               {
6752
 
-                       // set time format
6753
 
-                       MCI_SET_PARMS aSetParams;
6754
 
-                       mnDeviceId = nDeviceId;
6755
 
-                       aSetParams.dwTimeFormat = MCI_FORMAT_MILLISECONDS;
6756
 
-                       nMciErr = MCIFNC( mnDeviceId, MCI_SET, MCI_WAIT | MCI_SET_TIME_FORMAT, (DWORD)&aSetParams );
6757
 
-
6758
 
-                       if ( !nMciErr )
6759
 
-                       {
6760
 
-                               // get length of sound
6761
 
-                               MCI_STATUS_PARMS aStatus;
6762
 
-                               aStatus.dwItem = MCI_STATUS_LENGTH;
6763
 
-                               nMciErr = MCIFNC( mnDeviceId, MCI_STATUS, MCI_WAIT | MCI_STATUS_ITEM, (DWORD)&aStatus );
6764
 
-
6765
 
-                               if ( !nMciErr )
6766
 
-                                       rSoundLen = (ULONG)aStatus.dwReturn;
6767
 
-                       }
6768
 
-               }
6769
 
-       }
6770
 
-
6771
 
-       if ( nMciErr )
6772
 
-               ImplSetError( nMciErr );
6773
 
-
6774
 
-       return (nMciErr ? false : true);
6775
 
-}
6776
 
-
6777
 
-// ------------------------------------------------------------------------
6778
 
-
6779
 
-void WinSalSound::Play( ULONG nStartTime, ULONG nPlayLen, bool bLoop )
6780
 
-{
6781
 
-       if ( mnDeviceId )
6782
 
-       {
6783
 
-               DWORD nMciErr = 0;
6784
 
-
6785
 
-               if ( !mbPaused )
6786
 
-               {
6787
 
-                       MCI_SEEK_PARMS aSeekParams;
6788
 
-                       aSeekParams.dwCallback = (DWORD) mhSoundWnd;
6789
 
-                       aSeekParams.dwTo = 0;
6790
 
-                       nMciErr = MCIFNC( mnDeviceId, MCI_SEEK,MCI_WAIT | MCI_TO, (DWORD) &aSeekParams );
6791
 
-               }
6792
 
-
6793
 
-               mnStartTime = nStartTime;
6794
 
-               mnPlayLen = nPlayLen;
6795
 
-               mbLoop = bLoop;
6796
 
-               mbPaused = false;
6797
 
-
6798
 
-               if( !nMciErr )
6799
 
-               {
6800
 
-                       MCI_PLAY_PARMS  aPlayParams;
6801
 
-                       DWORD                   nFlags = MCI_NOTIFY;
6802
 
-
6803
 
-                       aPlayParams.dwCallback = (DWORD)mhSoundWnd;
6804
 
-
6805
 
-                       if ( nStartTime )
6806
 
-                       {
6807
 
-                               aPlayParams.dwFrom = nStartTime;
6808
 
-                               nFlags |= MCI_FROM;
6809
 
-                       }
6810
 
-
6811
 
-                       if ( nPlayLen != SOUND_PLAYALL )
6812
 
-                       {
6813
 
-                               aPlayParams.dwTo = nStartTime + nPlayLen;
6814
 
-                               nFlags |= MCI_TO;
6815
 
-                       }
6816
 
-
6817
 
-                       nMciErr = MCIFNC( mnDeviceId, MCI_PLAY, nFlags, (DWORD) &aPlayParams );
6818
 
-
6819
 
-                       if ( !nMciErr )
6820
 
-                               mbPaused = FALSE;
6821
 
-               }
6822
 
-
6823
 
-               if ( nMciErr )
6824
 
-                       ImplSetError( nMciErr );
6825
 
-       }
6826
 
-       else
6827
 
-               ImplSetError( MCIERR_INVALID_FILE );
6828
 
-}
6829
 
-
6830
 
-// ------------------------------------------------------------------------
6831
 
-
6832
 
-void WinSalSound::Stop()
6833
 
-{
6834
 
-       if ( mnDeviceId )
6835
 
-       {
6836
 
-               MCI_GENERIC_PARMS aGenericParams;
6837
 
-               aGenericParams.dwCallback = (DWORD)mhSoundWnd;
6838
 
-               mbLoop = mbPaused = false;
6839
 
-               MCIFNC( mnDeviceId, MCI_STOP, MCI_WAIT, (DWORD) &aGenericParams );
6840
 
-       }
6841
 
-}
6842
 
-
6843
 
-// ------------------------------------------------------------------------
6844
 
-
6845
 
-void WinSalSound::Pause()
6846
 
-{
6847
 
-       if ( mnDeviceId )
6848
 
-       {
6849
 
-               MCI_GENERIC_PARMS aGenericParams;
6850
 
-               aGenericParams.dwCallback = (DWORD)mhSoundWnd;
6851
 
-               mbPaused = true;
6852
 
-               MCIFNC( mnDeviceId, MCI_PAUSE, MCI_WAIT, (DWORD) &aGenericParams );
6853
 
-       }
6854
 
-}
6855
 
-
6856
 
-// ------------------------------------------------------------------------
6857
 
-
6858
 
-void WinSalSound::Continue()
6859
 
-{
6860
 
-    Play( 0, 0, mbLoop );
6861
 
-}
6862
 
-
6863
 
-// ------------------------------------------------------------------------
6864
 
-
6865
 
-bool WinSalSound::IsLoopMode() const
6866
 
-{
6867
 
-    return mbLoop;
6868
 
-}
6869
 
-
6870
 
-// ------------------------------------------------------------------------
6871
 
-
6872
 
-bool WinSalSound::IsPlaying() const
6873
 
-{
6874
 
-    return !mbPaused;
6875
 
-}
6876
 
-
6877
 
-// ------------------------------------------------------------------------
6878
 
-
6879
 
-bool WinSalSound::IsPaused() const
6880
 
-{
6881
 
-    return mbPaused;
6882
 
-}