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
24
#-/*************************************************************************
26
#-* OpenOffice.org - a multi-platform office productivity suite
28
#-* $RCSfile: salsound.h,v $
32
#-* last change: $Author: kz $ $Date: 2007/10/09 15:11:21 $
34
#-* The Contents of this file are made available subject to
35
#-* the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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,
57
#-************************************************************************/
59
#-#ifndef _SV_SALSOUND_H
60
#-#define _SV_SALSOUND_H
62
#-//#ifndef _SV_WINCOMP_HXX
63
#-//#include <wincomp.hxx>
67
#-#include <tools/gen.hxx>
70
#-#include <tools/string.hxx>
77
#-#include <osl/module.h>
79
#-#ifndef _SV_SALFRAME_HXX
80
#-#include <vcl/salframe.hxx>
82
#-#ifndef _SV_SALSTYPE_HXX
83
#-#include <vcl/salstype.hxx>
85
#-#ifndef _SV_SALSOUND_HXX
86
#-#include <vcl/salsound.hxx>
93
#-class AquaSalSound : public SalSound
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;
108
#- void ImplSetError( int nMciErr );
109
#- void ImplNotify( SoundNotification eNotification, ULONG nError );
113
#- virtual ~AquaSalSound();
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;
127
#- bool ImplCreate();
128
#- void ImplDestroy();
129
#- static void Release();
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
140
#-/*************************************************************************
142
#- * OpenOffice.org - a multi-platform office productivity suite
144
#- * $RCSfile: salsound.hxx,v $
146
#- * $Revision: 1.7 $
148
#- * last change: $Author: kz $ $Date: 2007/10/09 15:11:34 $
150
#- * The Contents of this file are made available subject to
151
#- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
173
#- ************************************************************************/
175
#-#ifndef _SV_SALSOUND_HXX
176
#-#define _SV_SALSOUND_HXX
179
#-#include <tools/gen.hxx>
181
#-#ifndef _STRING_HXX
182
#-#include <tools/string.hxx>
186
#-#include <vcl/sv.h>
189
#-#ifndef _SV_SALFRAME_HXX
190
#-#include <vcl/salframe.hxx>
192
#-#ifndef _SV_SALSTYPE_HXX
193
#-#include <vcl/salstype.hxx>
203
#- static ULONG mnSoundState;
204
#- SALSOUNDPROC mpProc;
214
#- static void Release();
215
#- static BOOL IsValid() { return( SOUND_STATE_VALID == SalSound::mnSoundState ); }
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 );
223
#- void SetNotifyProc( void* pInst, SALSOUNDPROC pProc )
224
#- { mpInst = pInst; mpProc = pProc; }
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
242
$(SLO)$/vclnsapp.obj \
243
$(SLO)$/saltimer.obj \
244
$(SLO)$/salnstimer.obj \
245
- $(SLO)$/salsound.obj \
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
254
// -----------------------------------------------------------------------
256
-SalSound* AquaSalInstance::CreateSalSound()
258
- return new AquaSalSound();
261
-// -----------------------------------------------------------------------
263
SalTimer* AquaSalInstance::CreateSalTimer()
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;
282
@@ -136,8 +135,6 @@ public:
283
virtual void DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ) = 0;
284
virtual String GetDefaultPrinter() = 0;
287
- virtual SalSound* CreateSalSound() = 0;
289
virtual SalTimer* CreateSalTimer() = 0;
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
298
-/*************************************************************************
300
- * OpenOffice.org - a multi-platform office productivity suite
302
- * $RCSfile: salsound.hxx,v $
306
- * last change: $Author: vg $ $Date: 2007/04/11 18:08:49 $
308
- * The Contents of this file are made available subject to
309
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
331
- ************************************************************************/
333
-#ifndef _SV_SALSOUND_HXX
334
-#define _SV_SALSOUND_HXX
337
-#include <tools/gen.hxx>
342
-#ifndef _VCL_DLLAPI_H
343
-#include <vcl/dllapi.h>
347
-#include <tools/string.hxx>
349
-#ifndef _SV_SALSTYPE_HXX
350
-#include <vcl/salstype.hxx>
353
-class VCL_DLLPUBLIC SalSound
355
- // for notification
357
- SALSOUNDPROC m_aPROC;
359
- SalSound() : m_pInst( NULL ), m_aPROC( NULL ) {}
360
- virtual ~SalSound();
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;
372
- virtual void Stop() = 0;
374
- virtual void Pause() = 0;
375
- // continue a paused play
376
- virtual void Continue() = 0;
378
- virtual bool IsLoopMode() const = 0;
380
- virtual bool IsPlaying() const = 0;
382
- virtual bool IsPaused() const = 0;
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 )
390
- m_aPROC( m_pInst, eNotification, nError );
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
402
-/*************************************************************************
404
- * OpenOffice.org - a multi-platform office productivity suite
406
- * $RCSfile: salstype.hxx,v $
410
- * last change: $Author: vg $ $Date: 2007/04/11 18:08:58 $
412
- * The Contents of this file are made available subject to
413
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
435
- ************************************************************************/
437
-#ifndef _SV_SALSTYPE_HXX
438
-#define _SV_SALSTYPE_HXX
441
-#include <tools/gen.hxx>
444
-// -----------------
445
-// - Sound defines -
446
-// -----------------
448
-#define SOUND_PLAYALL (0xFFFFFFFFUL)
450
-// -----------------
451
-// - State defines -
452
-// -----------------
454
-#define SOUND_STATE_UNLOADED (0x00000000UL)
455
-#define SOUND_STATE_INVALID (0x00000001UL)
456
-#define SOUND_STATE_VALID (0x00000002UL)
458
-// ---------------------
459
-// - SoundNotification -
460
-// ---------------------
462
-enum SoundNotification
464
- SOUND_NOTIFY_NOTHING,
465
- SOUND_NOTIFY_SUCCESS,
466
- SOUND_NOTIFY_ABORTED,
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)
487
-// ------------------
488
-// - Sound-Callback -
489
-// ------------------
491
-typedef void (*SALSOUNDPROC)( void* pInst, SoundNotification eNotification, ULONG nError );
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); }
506
-// -----------------
507
-// - ImplSoundData -
508
-// -----------------
512
- friend class SoundSettings;
515
- ImplSoundData( const ImplSoundData& rData );
522
-// -----------------
523
-// - SoundSettings -
524
-// -----------------
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)
531
-class VCL_DLLPUBLIC SoundSettings
536
- ImplSoundData* mpData;
540
- SoundSettings( const SoundSettings& rSet );
543
- void SetOptions( ULONG nOptions )
544
- { CopyData(); mpData->mnOptions = nOptions; }
545
- ULONG GetOptions() const
546
- { return mpData->mnOptions; }
548
- const SoundSettings& operator =( const SoundSettings& rSet );
550
- BOOL operator ==( const SoundSettings& rSet ) const;
551
- BOOL operator !=( const SoundSettings& rSet ) const
552
- { return !(*this == rSet); }
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; }
570
- void SetSoundSettings( const SoundSettings& rSet )
571
- { CopyData(); mpData->maSoundSettings = rSet; }
572
- const SoundSettings& GetSoundSettings() const
573
- { return mpData->maSoundSettings; }
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
588
#include <tools/time.hxx>
590
-#ifndef _SV_SALSTYPE_HXX
591
-#include <vcl/salstype.hxx>
601
@@ -68,70 +63,8 @@ class RMSound;
603
class VCL_DLLPUBLIC Sound
608
- XubString maSoundName;
610
- BYTE* mpSoundData_NOTUSED;
616
- SoundNotification meNotification;
624
- Sound( const Sound& rSound );
625
- Sound& operator=( const Sound& rSound );
627
-//#if 0 // _SOLAR__PRIVATE
629
- SAL_DLLPRIVATE void ImplNotify( SoundNotification eNotification, ULONG nError );
630
-//#endif // __PRIVATE
633
- Sound( Window* pWindow = NULL );
636
- virtual void Notify();
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; }
647
- BOOL IsPlaying() const { return mbPlaying; }
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; }
657
- ULONG GetLastError() const { return mnErrorCode; }
658
- SoundNotification GetNotification() const { return meNotification; }
660
- void SetNotifyHdl( const Link& rLink ) { maNotifyHdl = rLink; }
661
- const Link& GetNotifyHdl() const { return maNotifyHdl; }
663
static void Beep( SoundType eType = SOUND_DEFAULT, Window* pWindow = NULL );
665
- static void SetSoundPath( const XubString& rSoundPath );
666
- static const XubString& GetSoundPath();
668
- static BOOL IsSoundFile( const XubString& rSoundPath );
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
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
696
CDEFS+=-DDLLPOSTFIX=$(DLLPOSTFIX)
698
-.IF "$(SYSTEM_NAS)"=="YES"
699
-CFLAGS+=-I$(NAS_INCLUDES)
702
# --- Files --------------------------------------------------------
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
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()
725
-SalSound::~SalSound()
729
SalTimer::~SalTimer()
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;
746
-// =======================================================================
748
-ImplSoundData::ImplSoundData()
754
-// -----------------------------------------------------------------------
756
-ImplSoundData::ImplSoundData( const ImplSoundData& rData )
759
- mnOptions = rData.mnOptions;
762
-// -----------------------------------------------------------------------
764
-SoundSettings::SoundSettings()
766
- mpData = new ImplSoundData();
769
-// -----------------------------------------------------------------------
771
-SoundSettings::SoundSettings( const SoundSettings& rSet )
773
- DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "SoundSettings: RefCount overflow" );
775
- // shared Instance Daten uebernehmen und Referenzcounter erhoehen
776
- mpData = rSet.mpData;
777
- mpData->mnRefCount++;
780
-// -----------------------------------------------------------------------
782
-SoundSettings::~SoundSettings()
784
- // Daten loeschen, wenn letzte Referenz
785
- if ( mpData->mnRefCount == 1 )
788
- mpData->mnRefCount--;
791
-// -----------------------------------------------------------------------
793
-const SoundSettings& SoundSettings::operator =( const SoundSettings& rSet )
795
- DBG_ASSERT( rSet.mpData->mnRefCount < 0xFFFFFFFE, "SoundSettings: RefCount overflow" );
797
- // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann
798
- rSet.mpData->mnRefCount++;
800
- // Daten loeschen, wenn letzte Referenz
801
- if ( mpData->mnRefCount == 1 )
804
- mpData->mnRefCount--;
806
- mpData = rSet.mpData;
811
-// -----------------------------------------------------------------------
813
-void SoundSettings::CopyData()
815
- // Falls noch andere Referenzen bestehen, dann kopieren
816
- if ( mpData->mnRefCount != 1 )
818
- mpData->mnRefCount--;
819
- mpData = new ImplSoundData( *mpData );
823
-// -----------------------------------------------------------------------
825
-BOOL SoundSettings::operator ==( const SoundSettings& rSet ) const
827
- if ( mpData == rSet.mpData )
830
- if ( (mpData->mnOptions == rSet.mpData->mnOptions) )
836
// =======================================================================
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,
851
- if ( nFlags & SETTINGS_SOUND )
853
- if ( mpData->maSoundSettings != rSet.mpData->maSoundSettings )
856
- mpData->maSoundSettings = rSet.mpData->maSoundSettings;
857
- nChangeFlags |= SETTINGS_SOUND;
861
if ( nFlags & SETTINGS_NOTIFICATION )
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;
868
- if ( mpData->maSoundSettings != rSet.mpData->maSoundSettings )
869
- nChangeFlags |= SETTINGS_SOUND;
871
if ( mpData->maNotificationSettings != rSet.mpData->maNotificationSettings )
872
nChangeFlags |= SETTINGS_NOTIFICATION;
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
891
#ifndef _SV_SVSYS_HXX
894
-#ifndef _SV_SALSOUND_HXX
895
-#include <vcl/salsound.hxx>
897
#ifndef _SV_SALFRAME_HXX
898
#include <vcl/salframe.hxx>
901
#ifndef _SV_WINDOW_HXX
902
#include <vcl/window.hxx>
904
-#ifndef _SV_SALSOUND_HXX
905
-#include <vcl/salsound.hxx>
907
#ifndef _SV_SALBTYPE_HXX
908
#include <vcl/salbtype.hxx>
911
#include <vcl/salinst.hxx>
916
-// ----------------------
917
-// - SalSound-Callback -
918
-// ----------------------
920
-void SalSoundProc( void* pInst, SoundNotification eNotification, ULONG nError )
922
- ( (Sound*) pInst )->ImplNotify( eNotification, nError );
929
-Sound::Sound( Window* pWindow ) :
930
- mpWindow ( pWindow ),
932
- mnSoundLen ( 0UL ),
933
- mnStartTime ( 0UL ),
934
- mnPlayTime ( SOUND_PLAYALL ),
935
- mnErrorCode ( 0UL ),
936
- meNotification ( SOUND_NOTIFY_SUCCESS ),
937
- mbPlaying ( FALSE ),
938
- mbLoopMode ( FALSE )
940
- mpSound = ImplGetSVData()->mpDefInst->CreateSalSound();
942
- if( mpSound->IsValid() )
943
- mpSound->SetNotifyProc( this, SalSoundProc );
946
-// -----------------------------------------------------------------------
953
-// -----------------------------------------------------------------------
955
-void Sound::ImplNotify( SoundNotification eNotification, ULONG nError )
957
- meNotification = eNotification;
960
- if( SOUND_NOTIFY_ERROR == meNotification )
961
- mnErrorCode = nError;
965
- if( maNotifyHdl.IsSet() )
966
- maNotifyHdl.Call( this );
969
-// -----------------------------------------------------------------------
971
-void Sound::Notify()
975
-// -----------------------------------------------------------------------
977
-BOOL Sound::SetSoundName( const XubString& rSoundName )
979
- BOOL bRet( FALSE );
981
- if( !rSoundName.Len() )
986
- mnPlayTime = SOUND_PLAYALL;
988
- meNotification = SOUND_NOTIFY_SUCCESS;
990
- mbLoopMode = FALSE;
993
- mpSound->Init( rSoundName, mnSoundLen );
995
- else if( mpSound->IsValid() )
997
- INetURLObject aSoundURL( rSoundName );
998
- String aSoundName, aTmp;
999
- BOOL bValidName( FALSE );
1001
- // #106654# Accept only local sound files
1002
- if( aSoundURL.GetProtocol() == INET_PROT_FILE )
1004
- utl::LocalFileHelper::ConvertURLToPhysicalName( aSoundURL.GetMainURL( INetURLObject::NO_DECODE ), aSoundName );
1005
- bValidName = TRUE;
1007
- else if( aSoundURL.GetProtocol() == INET_PROT_NOT_VALID &&
1008
- ::utl::LocalFileHelper::ConvertPhysicalNameToURL( rSoundName, aTmp ) )
1010
- aSoundName = rSoundName;
1011
- bValidName = TRUE;
1015
- // no valid sound file name
1016
- aSoundName = String();
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 );
1024
- bRet = mpSound->Init( aSoundName, mnSoundLen );
1027
- maSoundName = rSoundName;
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 );
1037
-// -----------------------------------------------------------------------
1039
-void Sound::SetStartTime( ULONG nStartTime )
1041
- mnStartTime = nStartTime;
1044
-// -----------------------------------------------------------------------
1046
-void Sound::SetPlayTime( ULONG nPlayTime )
1048
- mnPlayTime = nPlayTime;
1051
-// -----------------------------------------------------------------------
1053
-void Sound::SetLoopMode( BOOL bLoop )
1055
- mbLoopMode = bLoop;
1058
-// -----------------------------------------------------------------------
1060
-void Sound::ClearError()
1065
-// -----------------------------------------------------------------------
1071
- if( mpSound->IsValid() && !mnErrorCode )
1073
- mpSound->Play( mnStartTime, mnPlayTime, mbLoopMode );
1080
-// -----------------------------------------------------------------------
1084
- mbPlaying = FALSE;
1086
- if( mpSound->IsValid() )
1090
-// -----------------------------------------------------------------------
1092
-void Sound::Pause()
1094
- mbPlaying = FALSE;
1096
- if( mpSound->IsValid() )
1100
-// -----------------------------------------------------------------------
1102
void Sound::Beep( SoundType eType, Window* pWindow )
1105
@@ -274,62 +80,3 @@ void Sound::Beep( SoundType eType, Windo
1107
pWindow->ImplGetFrame()->Beep( eType );
1110
-// -----------------------------------------------------------------------
1112
-void Sound::SetSoundPath( const XubString& )
1116
-// -----------------------------------------------------------------------
1118
-const XubString& Sound::GetSoundPath()
1120
- return ImplGetSVEmptyStr();
1123
-// -----------------------------------------------------------------------
1125
-BOOL Sound::IsSoundFile( const XubString& rSoundPath )
1127
- BOOL bRet = FALSE;
1129
- if( rSoundPath.Len() )
1131
- INetURLObject aSoundURL( rSoundPath );
1132
- String aSoundName;
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();
1139
- if( aSoundName.Len() )
1141
- SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aSoundName, STREAM_READ );
1145
- sal_Char aData[ 12 ];
1147
- if( ( pIStm->Read( aData, 12 ) == 12 ) && !pIStm->GetError() )
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' );
1159
- // check it the hard way
1161
- bRet = aTestSound.SetSoundName( rSoundPath );
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
1177
#ifndef _SV_SALINST_HXX
1178
#include <vcl/salinst.hxx>
1180
-#ifndef _SV_SALSOUND_HXX
1181
-#include <vcl/salsound.hxx>
1183
#ifndef _SV_SALOGL_HXX
1184
#include <vcl/salogl.hxx>
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 );
1198
-void GtkSalFrame::Beep( SoundType /*eType*/ )
1199
+void GtkSalFrame::Beep( SoundType eType )
1201
- gdk_display_beep( getGdkDisplay() );
1204
+ case SOUND_DEFAULT:
1206
+ gdk_display_beep( getGdkDisplay() );
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() {}
1227
-SvpSalSound::~SvpSalSound() {}
1228
-bool SvpSalSound::IsValid() { return true; }
1229
-bool SvpSalSound::Init( const String&, ULONG& rSoundLen )
1234
-void SvpSalSound::Play( ULONG, ULONG, bool bLoop )
1236
- m_bPlaying = true;
1237
- m_bLooping = bLoop;
1239
-void SvpSalSound::Stop()
1241
- m_bPlaying = m_bLooping = false;
1243
-void SvpSalSound::Pause()
1247
-void SvpSalSound::Continue()
1249
- m_bPaused = false;
1251
-bool SvpSalSound::IsLoopMode() const
1253
- return m_bLooping;
1255
-bool SvpSalSound::IsPlaying() const
1257
- return m_bPlaying;
1259
-bool SvpSalSound::IsPaused() const
1265
SvpSalObject::SvpSalObject()
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
1276
#ifndef _SVP_SVPDUMMIES_HXX
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();
1287
-class SvpSalSound : public SalSound
1293
- SvpSalSound() : m_bPlaying( false ), m_bLooping( false ), m_bPaused( false ) {}
1294
- virtual ~SvpSalSound();
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;
1309
class SvpSalObject : public SalObject
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
1324
-SalSound* SvpSalInstance::CreateSalSound()
1326
- return new SvpSalSound();
1329
SalTimer* SvpSalInstance::CreateSalTimer()
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();
1345
- virtual SalSound* CreateSalSound();
1347
virtual SalTimer* CreateSalTimer();
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
1358
#undef InitializeToken
1361
-/* Network Audio System */
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
1376
#define Region XLIB_Region
1377
#define Boolean XLIB_Boolean
1379
-/* fuer Network Audio System */
1380
-#define Sound XLIB_Sound
1382
#if defined __cplusplus
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();
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
1408
-/*************************************************************************
1410
- * OpenOffice.org - a multi-platform office productivity suite
1412
- * $RCSfile: salsound.h,v $
1414
- * $Revision: 1.5 $
1416
- * last change: $Author: hr $ $Date: 2007/06/27 20:42:40 $
1418
- * The Contents of this file are made available subject to
1419
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
1441
- ************************************************************************/
1443
-#ifndef _SV_SALSOUND_H
1444
-#define _SV_SALSOUND_H
1446
-#ifndef _SV_SALSOUND_HXX
1447
-#include <vcl/salsound.hxx>
1454
-namespace vcl_sal { class VSound; }
1456
-class X11SalSound : public SalSound
1458
-// public for VSound sub classes
1461
- vcl_sal::VSound* m_pVSound;
1463
- // the sound to play
1464
- ByteString m_aSoundFile;
1471
- ULONG m_nStartTime;
1472
- ULONG m_nPlayTime;
1474
- static ULONG s_nSoundState;
1476
- void changeStateStop();
1477
- void changeStatePause();
1478
- void changeStateCont();
1479
- void changeStatePlay();
1480
- void setError( ULONG );
1483
- virtual ~X11SalSound();
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;
1497
- static void Release();
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
1508
-/*************************************************************************
1510
- * OpenOffice.org - a multi-platform office productivity suite
1512
- * $RCSfile: audioconvert.cxx,v $
1514
- * $Revision: 1.3 $
1516
- * last change: $Author: obo $ $Date: 2006/09/17 12:31:15 $
1518
- * The Contents of this file are made available subject to
1519
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
1541
- ************************************************************************/
1543
-// MARKER(update_precomp.py): autogen include statement, do not remove
1544
-#include "precompiled_vcl.hxx"
1546
-#include <vsound.hxx>
1548
-using namespace vcl_sal;
1550
-#include <sunconvert.cxx>
1552
-AudioConverter::~AudioConverter()
1556
-class G721ToULawConverter : public AudioConverter
1558
- g72x_state m_aState;
1560
- G721ToULawConverter();
1561
- virtual ~G721ToULawConverter();
1563
- virtual void reset();
1564
- virtual char* convert( char* In, int nBytesIn, int& nBytesOut );
1567
-G721ToULawConverter::G721ToULawConverter()
1572
-G721ToULawConverter::~G721ToULawConverter()
1576
-void G721ToULawConverter::reset()
1578
- g72x_init_state( &m_aState );
1581
-char* G721ToULawConverter::convert(
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);
1596
-AudioConverter* AudioConverter::createG721ToULawConverter()
1598
- return new G721ToULawConverter;
1602
-class INT8ToUINT16Converter : public AudioConverter
1605
- INT8ToUINT16Converter() {}
1606
- virtual ~INT8ToUINT16Converter();
1608
- virtual void reset();
1609
- virtual char* convert( char* In, int nBytesIn, int& nBytesOut );
1612
-INT8ToUINT16Converter::~INT8ToUINT16Converter()
1616
-void INT8ToUINT16Converter::reset()
1620
-char* INT8ToUINT16Converter::convert( char* pBuffer, int nBytesIn, int& nBytesOut )
1622
- unsigned short* pShorts = new unsigned short[ nBytesIn ];
1623
- nBytesOut = 2*nBytesIn;
1625
- for( int i=0; i < nBytesIn; i++ )
1627
- signed char cByte = pBuffer[ i ];
1628
- int nValue = cByte;
1630
- pShorts[ i ] = 257*nValue;
1632
- return (char*)pShorts;
1635
-AudioConverter* AudioConverter::createINT8ToUINT16Converter()
1637
- return new INT8ToUINT16Converter();
1640
-class SwapINT16Converter : public AudioConverter
1643
- SwapINT16Converter() {}
1644
- virtual ~SwapINT16Converter();
1646
- virtual void reset();
1647
- virtual char* convert( char* In, int nBytesIn, int& nBytesOut );
1650
-SwapINT16Converter::~SwapINT16Converter()
1654
-void SwapINT16Converter::reset()
1658
-char* SwapINT16Converter::convert( char* In, int nBytesIn, int& nBytesOut )
1660
- char* pRet = new char[ nBytesOut = nBytesIn ];
1662
- for( int i = 0; i < nBytesIn; i+=2 )
1664
- pRet[ i ] = In[ i+1 ];
1665
- pRet[ i+1 ] = In[ i ];
1670
-AudioConverter* AudioConverter::createSwapINT16Converter()
1672
- return new SwapINT16Converter();
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
1681
-/*************************************************************************
1683
- * OpenOffice.org - a multi-platform office productivity suite
1685
- * $RCSfile: devaudiosound.cxx,v $
1687
- * $Revision: 1.15 $
1689
- * last change: $Author: hr $ $Date: 2007/06/27 20:45:27 $
1691
- * The Contents of this file are made available subject to
1692
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
1714
- ************************************************************************/
1716
-// MARKER(update_precomp.py): autogen include statement, do not remove
1717
-#include "precompiled_vcl.hxx"
1719
-#include <salsound.h>
1720
-#include <salimpsound.hxx>
1722
-#include <vcl/svapp.hxx>
1724
-#ifdef USE_DEVAUDIO
1726
-#include <sys/types.h>
1727
-#include <sys/stat.h>
1730
-#include <unistd.h>
1731
-#include <string.h>
1732
-#include <sys/ioctl.h>
1733
-#include <sys/audioio.h>
1736
-#ifndef _SAL_TYPES_H_
1737
-#include <sal/types.h>
1740
-using namespace vcl_sal;
1741
-using namespace vos;
1742
-using namespace osl;
1744
-int DevAudioSound::s_nDevice = -1;
1745
-DevAudioDataList DevAudioSound::s_aDataList;
1746
-osl::Mutex DevAudioSound::s_aProtector;
1747
-DevAudioSoundList DevAudioSound::s_aSounds;
1749
-static const char* getAudioDevName()
1751
- static const char* pDev = NULL;
1754
- pDev = getenv( "AUDIODEV" );
1755
- if( ! pDev || ! *pDev )
1756
- pDev = "/dev/audio";
1761
-BOOL DevAudioSound::open()
1763
- MutexGuard aGuard( s_aProtector );
1764
- if( s_nDevice == -1 )
1766
- s_nDevice = ::open( getAudioDevName(), O_WRONLY | O_NDELAY );
1767
- if( s_nDevice == -1 )
1769
- SalDbgAssert( "ERROR: could not open %s, errno=%d\n", getAudioDevName(), errno );
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 );
1781
- // sadly there is no documented reset control for /dev/audio
1782
- // ioctl( s_nDevice, SNDCTL_DSP_RESET, 0 );
1787
-void DevAudioSound::close()
1789
- MutexGuard aGuard( s_aProtector );
1790
- if( s_nDevice != -1 )
1792
- ioctl( s_nDevice, AUDIO_DRAIN, NULL );
1793
- ::close( s_nDevice );
1798
-BOOL DevAudioSound::startSound( DevAudioData* pData )
1800
- if( pData && pData->m_pSound && pData->m_pSound->m_pBuffer &&
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 );
1811
-BOOL DevAudioSound::startAU( DevAudioData* pData )
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 );
1820
- if( nDataLen == ~0 )
1821
- nDataLen = pData->m_pSound->m_aStat.st_size - nDataOffset;
1823
- pData->m_nDataLen = nDataLen;
1824
- pData->m_nStartPos = nDataOffset;
1825
- pData->m_nEndPos = pData->m_nStartPos + pData->m_nDataLen;
1827
- if( nChannels != 1 && nChannels != 2 )
1829
- SalDbgAssert( "%d Channels are not supported\n" );
1833
- audio_info_t aAudioInfo;
1834
- AUDIO_INITINFO( &aAudioInfo );
1836
- aAudioInfo.play.gain = 127;
1837
- aAudioInfo.play.channels = nChannels;
1838
- aAudioInfo.play.sample_rate = nSampleRate;
1839
- switch( nEncoding )
1842
- aAudioInfo.play.encoding = AUDIO_ENCODING_ULAW;
1845
- aAudioInfo.play.precision = 8;
1846
- aAudioInfo.play.encoding = AUDIO_ENCODING_LINEAR;
1849
- aAudioInfo.play.precision = 16;
1850
- aAudioInfo.play.encoding = AUDIO_ENCODING_LINEAR;
1853
- aAudioInfo.play.encoding = AUDIO_ENCODING_ULAW;
1854
- pData->m_pConverter = AudioConverter::createG721ToULawConverter();
1857
- SalDbgAssert( "au format %d unsupported\n", nEncoding );
1861
- if( ioctl( s_nDevice, AUDIO_SETINFO, &aAudioInfo ) )
1863
- SalDbgAssert( "ERROR: ioctl AUDIO_SETINFO failed\n" );
1867
- SalDbgAssert( "playing %d data bytes at %d bytes/s in format %d on %d channels \n", pData->m_nDataLen, nSampleRate, nEncoding, nChannels );
1871
-BOOL DevAudioSound::startRIFF( DevAudioData* pData )
1873
- int nPos = findChunk( pData, "fmt " );
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 )
1885
- SalDbgAssert( "%d Channels are not supported\n" );
1889
- int nBitsPerSample = 0;
1893
- SalDbgAssert( "unknown format\n" );
1896
- nBitsPerSample = readLEShort( pData->m_pSound->m_pBuffer + nPos + 22 );
1900
- nPos = findChunk( pData, "data" );
1903
- SalDbgAssert( "ERROR: no \"data\" chunk found\n" );
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;
1911
- audio_info_t aAudioInfo;
1912
- AUDIO_INITINFO( &aAudioInfo );
1914
- aAudioInfo.play.gain = 127;
1915
- aAudioInfo.play.channels = nChannels;
1916
- aAudioInfo.play.sample_rate = nSampleRate;
1917
- switch( nBitsPerSample )
1920
-#if defined SOLARIS && defined SPARC
1921
- aAudioInfo.play.precision = 16;
1922
- aAudioInfo.play.encoding = AUDIO_ENCODING_LINEAR;
1923
- pData->m_pConverter = AudioConverter::createINT8ToUINT16Converter();
1925
- aAudioInfo.play.precision = 8;
1926
- aAudioInfo.play.encoding = AUDIO_ENCODING_LINEAR;
1930
- aAudioInfo.play.precision = 16;
1931
- aAudioInfo.play.encoding = AUDIO_ENCODING_LINEAR;
1933
- pData->m_pConverter = AudioConverter::createSwapINT16Converter();
1937
- SalDbgAssert( "%d bits per sample is not usable\n", nBitsPerSample );
1941
- if( ioctl( s_nDevice, AUDIO_SETINFO, &aAudioInfo ) )
1943
- SalDbgAssert( "ERROR: ioctl AUDIO_SETINFO failed\n" );
1947
- SalDbgAssert( "playing %d data bytes at %d bytes/s in %d bits quality on %d channels \n", pData->m_nDataLen, nSampleRate, nBitsPerSample, nChannels );
1951
-int DevAudioSound::findChunk( DevAudioData* pData, const char* pChunk )
1953
- if( !pData || ! pData->m_pSound || ! pData->m_pSound->m_pBuffer )
1957
- while( nPos < pData->m_pSound->m_aStat.st_size )
1959
- if( ! strncmp( pData->m_pSound->m_pBuffer+nPos, pChunk, 4 ) )
1962
- // get LSB int length
1963
- nPos += readLEInt( pData->m_pSound->m_pBuffer+nPos+4 ) + 8;
1968
-short int DevAudioSound::readLEShort( const char* pBuf )
1970
- const unsigned char* pBuffer = (const unsigned char*)pBuf;
1971
- short int nRet = *pBuffer++;
1972
- nRet |= *pBuffer << 8;
1977
-ULONG DevAudioSound::readBELong( const char* pBuf )
1979
- const unsigned char* pBuffer = (const unsigned char*)pBuf;
1980
- ULONG nRet = *pBuffer++ << 24;
1981
- nRet |= *pBuffer++ << 16;
1982
- nRet |= *pBuffer++ << 8;
1988
-int DevAudioSound::readLEInt( const char* pBuf )
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;
1999
-static oslThread aThreadWorker= NULL;
2001
- void SAL_CALL DevAudioThreadWorker(void*)
2003
- DevAudioSound::run();
2007
-void DevAudioSound::run()
2009
- SalDbgAssert( "DevAudioWorker::run\n" );
2010
- DevAudioData* pData;
2015
- ResettableMutexGuard aGuard( s_aProtector );
2016
- pData = s_aDataList.Count() ? s_aDataList.GetObject( 0 ) : NULL;
2020
- bool bDataValid = true;
2021
- if( startSound( pData ) )
2023
- pData->m_nCurPos = pData->m_nStartPos;
2024
- while( pData->m_nCurPos < pData->m_nEndPos )
2026
- int nBytes = 4096;
2028
- char* pBuffer = pData->m_pSound->m_pBuffer;
2030
- if( pData->m_nCurPos + nBytes > pData->m_nEndPos )
2031
- nBytes = pData->m_nEndPos - pData->m_nCurPos;
2033
- if( pData->m_pConverter )
2036
- char* pConvBuffer = pData->m_pConverter->convert( pBuffer + pData->m_nCurPos, nBytes, nBytesOut );
2037
- write( s_nDevice, pConvBuffer, nBytesOut );
2038
- delete pConvBuffer;
2042
- nBytes = write( s_nDevice,
2043
- pBuffer + pData->m_nCurPos, nBytes );
2045
- pData->m_nCurPos += nBytes;
2050
- aVal.Nanosec = 50000000;
2051
- osl_waitThread( &aVal );
2054
- if( s_aDataList.GetObject( 0 ) != pData )
2056
- bDataValid = false;
2062
- if( pData->m_pSound->m_pSalSound->m_bLoop )
2063
- pData->m_pSound->play();
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 );
2075
- Application::PostUserEvent( LINK( pData->m_pSound, DevAudioSound, notifyErrorHdl ), (void*)SOUNDERR_INVALID_FILE );
2077
- s_aDataList.Remove( pData );
2083
- MutexGuard aGuard( s_aProtector );
2084
- osl_destroyThread( aThreadWorker );
2085
- aThreadWorker = NULL;
2088
-void DevAudioSound::append( DevAudioSound* pSound )
2090
- MutexGuard aGuard( s_aProtector );
2091
- s_aDataList.Insert( new DevAudioData( pSound ), LIST_APPEND );
2092
- if( ! aThreadWorker )
2093
- aThreadWorker = osl_createThread( DevAudioThreadWorker, NULL );
2096
-void DevAudioSound::remove( DevAudioSound* pSound )
2098
- MutexGuard aGuard( s_aProtector );
2099
- DevAudioData* pData;
2100
- for( int i = s_aDataList.Count()-1; i >= 0; i-- )
2102
- pData = s_aDataList.GetObject( i );
2103
- if( pData->m_pSound == pSound )
2105
- s_aDataList.Remove( i );
2112
-DevAudioSound::DevAudioSound( ::X11SalSound* pSound ) :
2116
- s_aSounds.Insert( this );
2119
-DevAudioSound::~DevAudioSound()
2124
- s_aSounds.Remove( this );
2127
-BOOL DevAudioSound::isValid()
2132
- if( s_nDevice == -1 )
2134
- int nTryOpen = ::open( getAudioDevName(), O_WRONLY | O_NDELAY );
2135
- if( nTryOpen == -1 )
2137
- ::close( nTryOpen );
2140
- // check for valid file format
2141
- if( ! strncmp( "RIFF", m_pBuffer, 4 ) )
2143
- DevAudioData aData( this );
2145
- // check for data chunk
2146
- if( findChunk( &aData, "data" ) == -1 )
2148
- int nPos = findChunk( &aData, "fmt " );
2152
- int nFormat = readLEShort( m_pBuffer + nPos + 8 );
2153
- int nChannels = readLEShort( m_pBuffer + nPos + 10 );
2155
- if( nChannels != 1 && nChannels != 2 )
2158
- // playable is MS-PCM only at now
2159
- if( nFormat != 1 )
2163
- else if( ! strncmp( ".snd", m_pBuffer, 4 ) )
2165
- ULONG nEncoding = readBELong( m_pBuffer + 12 );
2166
- ULONG nChannels = readBELong( m_pBuffer + 20 );
2168
- // check for playable encodings
2169
- if( nEncoding != 1 && nEncoding != 2 && nEncoding != 3 && nEncoding != 23 )
2172
- if( nChannels != 1 && nChannels != 2 )
2181
-void DevAudioSound::play()
2187
- m_pSalSound->m_bPlaying = TRUE;
2188
- m_pSalSound->m_bPaused = FALSE;
2191
-void DevAudioSound::stop()
2194
- m_pSalSound->m_bPlaying = FALSE;
2195
- m_pSalSound->m_bPaused = FALSE;
2198
-void DevAudioSound::pause()
2201
- m_pSalSound->m_bPaused = TRUE;
2204
-void DevAudioSound::cont()
2209
-IMPL_LINK( DevAudioSound, notifyStopHdl, void*, EMPTYARG )
2211
- if( s_aSounds.GetPos( this ) != LIST_ENTRY_NOTFOUND )
2213
- m_pSalSound->changeStateStop();
2218
-IMPL_LINK( DevAudioSound, notifyErrorHdl, void*, nError )
2220
- if( s_aSounds.GetPos( this ) != LIST_ENTRY_NOTFOUND )
2222
- m_pSalSound->setError( (ULONG)nError );
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 \
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
2250
$(SLO)$/wmadaptor.obj \
2251
@@ -87,22 +81,6 @@ EXCEPTIONSFILES=\
2255
-.IF "$(ENABLE_NAS)" != ""
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)
2266
-.IF "$(SYSTEM_PORTAUDIO)" == "YES"
2267
-CDEFS+=-DSYSTEM_PORTAUDIO
2271
.IF "$(WITH_LIBSN)"=="YES"
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
2281
-/*************************************************************************
2283
- * OpenOffice.org - a multi-platform office productivity suite
2285
- * $RCSfile: nassound.cxx,v $
2287
- * $Revision: 1.10 $
2289
- * last change: $Author: obo $ $Date: 2006/09/17 12:33:50 $
2291
- * The Contents of this file are made available subject to
2292
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
2314
- ************************************************************************/
2316
-// MARKER(update_precomp.py): autogen include statement, do not remove
2317
-#include "precompiled_vcl.hxx"
2318
-#include <salimpsound.hxx>
2319
-#include <salsound.h>
2323
-#define INT8 AU_INT8
2324
-#include <audio/audiolib.h>
2325
-#include <audio/soundlib.h>
2328
-#include <salunx.h>
2329
-#include <saldata.hxx>
2330
-#include <saldisp.hxx>
2332
-#include <unistd.h>
2334
-using namespace vcl_sal;
2335
-using namespace vos;
2337
-BOOL NASSound::s_bFailedOnce = FALSE;
2338
-NASSound::NASSoundList NASSound::s_aSounds;
2339
-void* NASSound::s_pServer = NULL;
2341
-void NASSound::callback( void*, void*, void* event, void* pThis )
2343
- SalDbgAssert( "NASSound::callback called\n" );
2345
- NASSound* pSound = (NASSound*)pThis;
2346
- if( s_aSounds.GetPos( pSound ) != LIST_ENTRY_NOTFOUND )
2348
- AuEvent* pEvent = (AuEvent*)event;
2349
- SalDbgAssert( " on event type %d\n", pEvent->type );
2350
- if( pSound->m_pSalSound &&
2351
- pEvent->type == AuEventTypeElementNotify )
2353
- switch( pEvent->auelementnotify.cur_state )
2357
- pSound->m_nFlowID = 0;
2358
- pSound->m_pSalSound->changeStateStop();
2361
- case AuStatePause:
2362
- pSound->m_pSalSound->changeStatePause();
2364
- case AuStateStart:
2365
- pSound->m_pSalSound->changeStateCont();
2373
- SalDbgAssert( "NASSound %p is adressed in callback but unknown !\n", pSound );
2376
-BOOL NASSound::connect()
2378
- if( ! s_pServer && ! s_bFailedOnce )
2380
- char* pServerMessage = NULL;
2381
- s_pServer = AuOpenServer( NULL, 0, NULL, 0, NULL, &pServerMessage );
2384
- SalDbgAssert( "AuOpenServer failed: %s\n",
2386
- pServerMessage : "<unknown reason>" );
2387
- AuFree( pServerMessage );
2388
- s_bFailedOnce = TRUE;
2392
- GetX11SalData()->GetLib()->Insert( AuServerConnectionNumber( (AuServer*)s_pServer ),
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() ) );
2402
- return s_pServer ? TRUE : FALSE;
2405
-void NASSound::disconnect()
2409
- GetX11SalData()->GetLib()->Remove( AuServerConnectionNumber( (AuServer*)s_pServer ) );
2410
- AuCloseServer( (AuServer*)s_pServer );
2415
-int NASSound::pending( int, void* )
2417
- return s_pServer ? AuEventsQueued( (AuServer*)s_pServer, AuEventsQueuedAlready ) : 0;
2420
-int NASSound::queued( int fd, void* pDummy )
2422
- return pending( fd, pDummy );
2425
-int NASSound::handleEvents( int, void* )
2429
- for( int i = pending(0,0); i && s_pServer; i-- )
2432
- AuNextEvent( (AuServer*)s_pServer, AuTrue, &aEvent );
2433
- AuDispatchEvent( (AuServer*)s_pServer, &aEvent );
2439
-NASSound::NASSound( ::X11SalSound* pSalSound ) :
2440
- VSound( pSalSound ),
2443
- s_aSounds.Insert( this );
2446
-NASSound::~NASSound()
2448
- s_aSounds.Remove( this );
2449
- if( s_aSounds.Count() < 1 )
2453
-void NASSound::play()
2455
- BOOL bStarted = FALSE;
2460
- if( s_pServer && m_pSalSound )
2464
- if( AuSoundPlayFromFile( (AuServer*)s_pServer,
2465
- m_pSalSound->m_aSoundFile.GetBuffer(),
2467
- AuFixedPointFromSum( 1, 0 ),
2468
- (void(*)(AuServer*,AuEventHandlerRec*,AuEvent*,void*))callback,
2476
- SalDbgAssert( "AuSoundPlayFromFile yields flow id %d and status %d\n",
2479
- AuElementState aState;
2480
- aState.flow = aID;
2481
- aState.element_num = 0;
2482
- for( int n = 0; n < 20 && ! bStarted; n++ )
2486
- aVal.Nanosec = 20000000;
2487
- osl_waitThread( &aVal );
2488
- AuHandleEvents( (AuServer*)s_pServer );
2491
- AuElementState* pState =
2492
- AuGetElementStates( (AuServer*)s_pServer,
2498
- if( pState->state == AuStateStart )
2500
- AuFreeElementStates( (AuServer*)s_pServer,
2505
- SalDbgAssert( "AuGetElementStates failed\n" );
2511
- SalDbgAssert( " sound started\n" );
2513
- SalDbgAssert( " sound failed to start\n" );
2515
- m_pSalSound->m_bPlaying = bStarted;
2521
- if( ! bStarted && m_pSalSound )
2522
- m_pSalSound->setError( SOUNDERR_INVALID_FILE );
2525
-void NASSound::stop()
2527
- if( s_pServer && m_nFlowID )
2529
- AuStopFlow( (AuServer*)s_pServer, m_nFlowID, NULL );
2534
-void NASSound::pause()
2536
- if( s_pServer && m_nFlowID )
2537
- AuPauseFlow( (AuServer*)s_pServer, m_nFlowID, NULL );
2540
-void NASSound::cont()
2542
- if( s_pServer && m_nFlowID )
2543
- AuStartFlow( (AuServer*)s_pServer, m_nFlowID, NULL );
2546
-BOOL NASSound::isValid()
2548
- if( ! m_pSalSound )
2555
- return access( m_pSalSound->m_aSoundFile.GetBuffer(), R_OK ) ? FALSE : TRUE;
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
2566
-/*************************************************************************
2568
- * OpenOffice.org - a multi-platform office productivity suite
2570
- * $RCSfile: osssound.cxx,v $
2572
- * $Revision: 1.10 $
2574
- * last change: $Author: hr $ $Date: 2007/06/27 20:46:05 $
2576
- * The Contents of this file are made available subject to
2577
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
2599
- ************************************************************************/
2601
-// MARKER(update_precomp.py): autogen include statement, do not remove
2602
-#include "precompiled_vcl.hxx"
2603
-#include <salsound.h>
2604
-#include <salimpsound.hxx>
2606
-#include <vcl/svapp.hxx>
2610
-#include <sys/types.h>
2611
-#include <sys/stat.h>
2614
-#include <unistd.h>
2615
-#include <string.h>
2616
-#include <sys/ioctl.h>
2618
-#include <linux/soundcard.h>
2620
-#include <sys/soundcard.h>
2623
-#include <osl/thread.h>
2625
-using namespace vcl_sal;
2626
-using namespace vos;
2627
-using namespace osl;
2629
-int OSSSound::s_nDevice = -1;
2630
-OSSSound::OSSDataList OSSSound::s_aDataList;
2631
-Mutex OSSSound::s_aProtector;
2632
-OSSSound::OSSSoundList OSSSound::s_aSounds;
2634
-BOOL OSSSound::open()
2636
- MutexGuard aGuard( s_aProtector );
2637
- if( s_nDevice == -1 )
2639
- s_nDevice = ::open( "/dev/dsp", O_WRONLY );
2640
- if( s_nDevice == -1 )
2642
- SalDbgAssert( "ERROR: could not open /dev/dsp, errno=%d\n", errno );
2648
- ioctl( s_nDevice, SNDCTL_DSP_RESET, 0 );
2653
-void OSSSound::close()
2655
- MutexGuard aGuard( s_aProtector );
2656
- if( s_nDevice != -1 )
2657
- ::close( s_nDevice );
2661
-BOOL OSSSound::startSound( OSSData* pData )
2663
- if( pData && pData->m_pSound && pData->m_pSound->m_pBuffer &&
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 );
2674
-BOOL OSSSound::startAU( OSSData* pData )
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 );
2683
- if( nDataLen == 0xffffffff )
2684
- nDataLen = pData->m_pSound->m_aStat.st_size - nDataOffset;
2686
- pData->m_nDataLen = nDataLen;
2687
- pData->m_nStartPos = nDataOffset;
2688
- pData->m_nEndPos = pData->m_nStartPos + pData->m_nDataLen;
2690
- if( nChannels != 1 && nChannels != 2 )
2692
- SalDbgAssert( "%d Channels are not supported\n" );
2696
- int nSystemFormat;
2697
- switch( nEncoding )
2699
- case 1: nSystemFormat = AFMT_MU_LAW;break;
2700
- case 2: nSystemFormat = AFMT_U8;break;
2701
- case 3: nSystemFormat = AFMT_S16_BE;break;
2703
- SalDbgAssert( "au format %d unsupported\n", nEncoding );
2707
- int nRealFormat = nSystemFormat;
2708
- if( ioctl( s_nDevice, SNDCTL_DSP_SETFMT, &nRealFormat )==-1 )
2710
- SalDbgAssert( "ERROR: ioctl SNDCTL_DSP_SETFMT failed\n" );
2713
- int nRealChannels = nChannels-1;
2714
- if( ioctl( s_nDevice, SNDCTL_DSP_STEREO, &nRealChannels )==-1 )
2716
- SalDbgAssert( "ERROR: ioctl SNDCTL_DSP_STEREO failed\n" );
2719
- if( nRealChannels != sal::static_int_cast<int>(nChannels-1) )
2721
- SalDbgAssert( "could not set %d channels\n", nChannels );
2725
- if( ioctl( s_nDevice, SNDCTL_DSP_SPEED, &nSampleRate ) == -1 )
2727
- SalDbgAssert( "ERROR: ioctl SNDCTL_DSP_SPEED failed\n" );
2730
- SalDbgAssert( "playing %d data bytes at %d bytes in format %d quality/s on %d channels \n", pData->m_nDataLen, nSampleRate, nEncoding, nChannels );
2734
-BOOL OSSSound::startRIFF( OSSData* pData )
2736
- int nPos = findChunk( pData, "fmt " );
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 )
2748
- SalDbgAssert( "%d Channels are not supported\n" );
2752
- int nBitsPerSample = 0;
2756
- SalDbgAssert( "unknown format\n" );
2760
- nBitsPerSample = readLEShort( pData->m_pSound->m_pBuffer + nPos + 22 );
2764
- nPos = findChunk( pData, "data" );
2767
- SalDbgAssert( "ERROR: no \"data\" chunk found\n" );
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;
2775
- int nSystemFormat;
2776
- switch( nBitsPerSample )
2778
- case 8: nSystemFormat = AFMT_U8; break;
2779
- case 16: nSystemFormat = AFMT_S16_LE; break;
2781
- SalDbgAssert( "%d bits per sample is not usable\n", nBitsPerSample );
2785
- int nRealFormat = nSystemFormat;
2786
- if( ioctl( s_nDevice, SNDCTL_DSP_SETFMT, &nRealFormat )==-1 )
2788
- SalDbgAssert( "ERROR: ioctl SNDCTL_DSP_SETFMT failed\n" );
2792
- int nRealChannels = nChannels-1;
2793
- if( ioctl( s_nDevice, SNDCTL_DSP_STEREO, &nRealChannels )==-1 )
2795
- SalDbgAssert( "ERROR: ioctl SNDCTL_DSP_STEREO failed\n" );
2798
- if( nRealChannels != nChannels-1 )
2800
- SalDbgAssert( "could not set %d channels\n", nChannels );
2805
- if( ioctl( s_nDevice, SNDCTL_DSP_SPEED, &nSampleRate ) == -1 )
2807
- SalDbgAssert( "ERROR: ioctl SNDCTL_DSP_SPEED failed\n" );
2811
- SalDbgAssert( "playing %d data bytes at %d bytes in %d bits quality/s on %d channels \n", pData->m_nDataLen, nSampleRate, nBitsPerSample, nChannels );
2815
-int OSSSound::findChunk( OSSData* pData, const char* pChunk )
2817
- if( !pData || ! pData->m_pSound || ! pData->m_pSound->m_pBuffer )
2821
- while( nPos < pData->m_pSound->m_aStat.st_size )
2823
- if( ! strncmp( pData->m_pSound->m_pBuffer+nPos, pChunk, 4 ) )
2826
- // get LSB int length
2827
- nPos += readLEInt( pData->m_pSound->m_pBuffer+nPos+4 ) + 8;
2832
-short int OSSSound::readLEShort( const char* pBuf )
2834
- const unsigned char* pBuffer = (const unsigned char*)pBuf;
2835
- short int nRet = *pBuffer++;
2836
- nRet |= *pBuffer << 8;
2841
-ULONG OSSSound::readBELong( const char* pBuf )
2843
- const unsigned char* pBuffer = (const unsigned char*)pBuf;
2844
- ULONG nRet = *pBuffer++ << 24;
2845
- nRet |= *pBuffer++ << 16;
2846
- nRet |= *pBuffer++ << 8;
2852
-int OSSSound::readLEInt( const char* pBuf )
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;
2863
-static oslThread aThreadWorker= NULL;
2865
- void SAL_CALL OSSThreadWorker(void*)
2871
-void OSSSound::run()
2873
- SalDbgAssert( "OSSWorker::run\n" );
2877
- ResettableMutexGuard aGuard( s_aProtector );
2878
- pData = s_aDataList.Count() ? s_aDataList.GetObject( 0 ) : NULL;
2885
- bool bDataValid = true;
2886
- if( startSound( pData ) )
2888
- pData->m_nCurPos = pData->m_nStartPos;
2889
- while( pData->m_nCurPos < pData->m_nEndPos )
2891
- audio_buf_info info;
2892
- ioctl( s_nDevice, SNDCTL_DSP_GETOSPACE, &info );
2893
- if( info.bytes > 0 )
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,
2902
- pData->m_nCurPos += nBytes;
2907
- aVal.Nanosec = 20000000;
2908
- osl_waitThread( &aVal );
2910
- if( s_aDataList.GetObject( 0 ) != pData )
2912
- ioctl( s_nDevice, SNDCTL_DSP_RESET, 0);
2913
- bDataValid = false;
2920
- if( pData->m_pSound->m_pSalSound->m_bLoop )
2921
- pData->m_pSound->play();
2923
- Application::PostUserEvent( LINK( pData->m_pSound, OSSSound, notifyStopHdl ), NULL );
2927
- Application::PostUserEvent( LINK( pData->m_pSound, OSSSound, notifyErrorHdl ), (void*)SOUNDERR_INVALID_FILE );
2929
- s_aDataList.Remove( pData );
2933
- MutexGuard aGuard( s_aProtector );
2934
- osl_destroyThread( aThreadWorker );
2935
- aThreadWorker = NULL;
2938
-void OSSSound::append( OSSSound* pSound )
2940
- MutexGuard aGuard( s_aProtector );
2941
- OSSData* pNew = new OSSData;
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;
2949
- s_aDataList.Insert( pNew, LIST_APPEND );
2950
- if( ! aThreadWorker )
2951
- aThreadWorker = osl_createThread( OSSThreadWorker, NULL );
2954
-void OSSSound::remove( OSSSound* pSound )
2956
- MutexGuard aGuard( s_aProtector );
2958
- for( int i = s_aDataList.Count()-1; i >= 0; i-- )
2960
- pData = s_aDataList.GetObject( i );
2961
- if( pData->m_pSound == pSound )
2963
- s_aDataList.Remove( i );
2970
-OSSSound::OSSSound( ::X11SalSound* pSound ) :
2974
- s_aSounds.Insert( this );
2977
-OSSSound::~OSSSound()
2982
- s_aSounds.Remove( this );
2985
-BOOL OSSSound::isValid()
2990
- if( s_nDevice == -1 )
2992
- int nTryOpen = ::open( "/dev/dsp", O_WRONLY | O_NONBLOCK );
2993
- if( nTryOpen == -1 )
2995
- ::close( nTryOpen );
2998
- // check for valid file format
2999
- if( ! strncmp( "RIFF", m_pBuffer, 4 ) )
3002
- aData.m_pSound = this;
3004
- // check for data chunk
3005
- if( findChunk( &aData, "data" ) == -1 )
3007
- int nPos = findChunk( &aData, "fmt " );
3011
- int nFormat = readLEShort( m_pBuffer + nPos + 8 );
3012
- int nChannels = readLEShort( m_pBuffer + nPos + 10 );
3014
- if( nChannels != 1 && nChannels != 2 )
3017
- // playable is MS-PCM only at now
3018
- if( nFormat != 1 )
3022
- else if( ! strncmp( ".snd", m_pBuffer, 4 ) )
3024
- ULONG nEncoding = readBELong( m_pBuffer + 12 );
3025
- ULONG nChannels = readBELong( m_pBuffer + 20 );
3027
- // check for playable encodings
3028
- if( nEncoding != 1 && nEncoding != 2 && nEncoding != 3 )
3031
- if( nChannels != 1 && nChannels != 2 )
3040
-void OSSSound::play()
3046
- m_pSalSound->m_bPlaying = TRUE;
3047
- m_pSalSound->m_bPaused = FALSE;
3050
-void OSSSound::stop()
3053
- m_pSalSound->m_bPlaying = FALSE;
3054
- m_pSalSound->m_bPaused = FALSE;
3057
-void OSSSound::pause()
3060
- m_pSalSound->m_bPaused = TRUE;
3063
-void OSSSound::cont()
3068
-IMPL_LINK( OSSSound, notifyStopHdl, void*, EMPTYARG )
3070
- if( s_aSounds.GetPos( this ) != LIST_ENTRY_NOTFOUND )
3072
- m_pSalSound->changeStateStop();
3077
-IMPL_LINK( OSSSound, notifyErrorHdl, void*, nError )
3079
- if( s_aSounds.GetPos( this ) != LIST_ENTRY_NOTFOUND )
3081
- m_pSalSound->setError( (ULONG)nError );
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
3094
-/*************************************************************************
3096
- * OpenOffice.org - a multi-platform office productivity suite
3098
- * $RCSfile: pasfsound.cxx,v $
3100
- * $Revision: 1.7 $
3102
- * last change: $Author: hr $ $Date: 2007/07/31 13:01:50 $
3104
- * The Contents of this file are made available subject to
3105
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
3127
-************************************************************************/
3129
-// MARKER(update_precomp.py): autogen include statement, do not remove
3130
-#include "precompiled_vcl.hxx"
3132
-#include <salsound.h>
3133
-#include <salimpsound.hxx>
3137
-#define _SV_PASFSOUND_CXX
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
3144
-#include <saldata.hxx>
3145
-#include <vcl/salinst.hxx>
3150
-using namespace vcl_sal;
3151
-using namespace vos;
3152
-using namespace osl;
3153
-using namespace rtl;
3158
- /* callback that takes data from sound file and converts it and loads it */
3160
- static int pasf_in_out_callback (void *inputBuffer, void * outputBuffer,
3161
- unsigned long framesPerBuffer, PaTimestamp outTime, void * userData )
3163
- static int pasf_in_out_callback (const void *inputBuffer, void *outputBuffer,
3164
- unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *outTime, PaStreamCallbackFlags cbFlags, void *userData )
3167
- PASFAudioData* paudio_data;
3168
- unsigned int read_count, bufoff, bytecnt;
3169
- float* buffer = (float *) outputBuffer;
3171
- /* prevent warnings for unused variables */
3173
- cbFlags = cbFlags;
3175
- inputBuffer = inputBuffer;
3176
- outTime = outTime;
3178
- /* get all other info needed from audio_data structure passed in as userData */
3179
- paudio_data = (PASFAudioData*) userData;
3181
- read_count = sf_readf_float (paudio_data->sndfile, buffer, framesPerBuffer);
3182
- if (read_count < framesPerBuffer)
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) ;
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)))
3195
- if (paudio_data->loop_count > 0) paudio_data->loop_count--;
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))
3200
- sf_seek(paudio_data->sndfile, paudio_data->start_frame, SEEK_SET);
3201
- paudio_data->frame_count = paudio_data->start_frame;
3203
- paudio_data->done_playing = 1 ;
3207
- paudio_data->frame_count = paudio_data->frame_count + framesPerBuffer;
3214
-PASFSound::PASFSound( ::X11SalSound* pSound) :
3219
- m_pData = new PASFAudioData();
3220
- if ( ! (m_pData) ) return;
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))))
3225
- // fprintf(stderr,"Error opening sound file %s\n", m_aSoundFile.GetBuffer()); fflush(stderr);
3226
- m_pData->sndfile = NULL;
3230
- // check for valid number of channels to prevent problems later
3231
- if (m_pData->sfinfo.channels < 1 || m_pData->sfinfo.channels > 2)
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;
3240
- // store information on desired settings and input buffer format away
3241
- m_pData->format = paFloat32;
3242
- m_pData->bufsize = PASF_BUFFER_LEN;
3244
- // Using the default output device for this
3246
- m_pData->device = Pa_GetDefaultOutputDeviceID();
3248
- m_pData->device = Pa_GetDefaultOutputDevice();
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 )
3255
- unsigned int bytesPerFrame = m_pData->sfinfo.channels * sizeof(float);
3256
- unsigned int framesPerBuffer = (unsigned int) (m_pData->bufsize / bytesPerFrame);
3258
- // Open an audio I/O stream for output only on the default output device
3259
- PaError err = Pa_OpenDefaultStream(
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
3267
- 0, // number of buffers, if zero then use optimal number as determined by Pa
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
3272
- if( err != paNoError ) {
3274
- sf_close(m_pData->sndfile);
3275
- m_pData->sndfile = NULL;
3280
-PASFSound::~PASFSound()
3282
- // if stream exists, stop and close it
3285
- Pa_StopStream( m_pStream );
3286
- Pa_CloseStream( m_pStream );
3289
- // clean up the PASFAudioData structure, close any open sound files
3292
- if (m_pData->sndfile)
3294
- sf_close(m_pData->sndfile);
3295
- m_pData->sndfile = NULL;
3300
- m_pSalSound = NULL;
3304
-void PASFSound::play()
3307
- BOOL bLoop = m_pSalSound->m_bLoop;
3308
- ULONG nStartTime = m_pSalSound->m_nStartTime;
3309
- ULONG nPlayTime = m_pSalSound->m_nPlayTime;
3312
- if ((m_pData) && (m_pStream))
3314
- // set the player controls
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;
3320
- // convert StartTime to frame count and seek to starting frame in sound file
3321
- m_pData->start_frame = 0;
3322
- if (nStartTime > 0)
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);
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)
3332
- ULONG nEndTime = nStartTime + nPlayTime;
3333
- m_pData->stop_frame = (unsigned long)( (double)nEndTime * m_pData->sfinfo.samplerate / 1000.0 );
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;
3340
- // FIXME?: In Play but already playing will be ignored (no error) is that right?
3342
- if (!(m_pSalSound->m_bPlaying))
3344
- PaError err = Pa_StartStream( m_pStream );
3345
- if( err != paNoError) nErr = 1;
3351
- m_pSalSound->changeStatePlay();
3354
- m_pSalSound->setError(SOUNDERR_GENERAL_ERROR);
3359
-void PASFSound::stop()
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;
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)
3375
- sf_close(m_pData->sndfile);
3376
- m_pData->sndfile = NULL;
3382
- m_pSalSound->changeStateStop();
3385
- m_pSalSound->setError(SOUNDERR_GENERAL_ERROR);
3391
-void PASFSound::pause()
3395
- PaError err = Pa_StopStream( m_pStream );
3396
- if( err == paNoError ) nErr = 0;
3401
- m_pSalSound->changeStatePause();
3404
- m_pSalSound->setError(SOUNDERR_GENERAL_ERROR);
3409
-void PASFSound::cont()
3412
- if (m_pSalSound->m_bPaused) {
3414
- PaError err = Pa_StartStream( m_pStream );
3415
- if( err == paNoError ) nErr = 0;
3421
- m_pSalSound->changeStateCont();
3424
- m_pSalSound->setError(SOUNDERR_GENERAL_ERROR);
3429
-BOOL PASFSound::isValid()
3431
- if ((m_pData) && (m_pStream)) return TRUE;
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
3446
-/*************************************************************************
3448
- * OpenOffice.org - a multi-platform office productivity suite
3450
- * $RCSfile: rptpsound.cxx,v $
3452
- * $Revision: 1.17 $
3454
- * last change: $Author: obo $ $Date: 2006/09/17 12:34:30 $
3456
- * The Contents of this file are made available subject to
3457
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
3479
- ************************************************************************/
3481
-// MARKER(update_precomp.py): autogen include statement, do not remove
3482
-#include "precompiled_vcl.hxx"
3483
-#if defined(SOLARIS) || defined(MACOSX)
3486
-#include <sys/poll.h>
3489
-#include <salsound.h>
3490
-#include <salimpsound.hxx>
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>
3499
-using namespace vcl_sal;
3500
-using namespace vos;
3501
-using namespace psp;
3503
-BOOL RPTPSound::s_bConnected = FALSE;
3504
-BOOL RPTPSound::s_bFailedOnce = FALSE;
3505
-OConnectorSocket RPTPSound::s_aConnector;
3506
-RPTPSound::RPTPSoundList RPTPSound::s_aSounds;
3508
-int RPTPSound::getFileDescriptor()
3510
- return *(int*)(oslSocket)s_aConnector;
3513
-BOOL RPTPSound::connect()
3515
- if( s_bConnected && s_aConnector.isValid() )
3518
- if( s_bFailedOnce )
3521
- s_bConnected = FALSE;
3523
- static const char* env = getenv( "AUDIOSERVER" );
3524
- static const char* portenv = env ? strchr( env, ':' ) : NULL;
3525
- static char sBuf[1024];
3527
- if( ! env && GetX11SalData() && GetX11SalData()->GetDisplay() &&
3528
- DisplayString( GetX11SalData()->GetDisplay()->GetDisplay() ) )
3530
- env = strdup( DisplayString( GetX11SalData()->GetDisplay()->GetDisplay() ) );
3531
- portenv = strchr( env, ':' );
3534
- int nPort = portenv ? atoi( portenv+1 ) : 5556;
3535
- nPort = nPort ? nPort : 5556;
3537
- strncpy( sBuf, "uninitialized", 14 );
3538
- if( env && portenv )
3540
- if( portenv != env )
3542
- strncpy( sBuf, env, portenv - env );
3543
- sBuf[ portenv - env ] = 0;
3546
- strncpy( sBuf, "localhost", 10 );
3549
- strncpy( sBuf, "localhost", 10 );
3551
- SalDbgAssert( "resolving \"%s\", env = \"%s\", portenv = \"%s\"\n",
3553
- env ? env : "<unset>",
3554
- portenv ? portenv : "<unset>"
3557
- ::rtl::OUString aHost( sBuf, strlen(sBuf), gsl_getSystemTextEncoding() );
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 )
3565
- s_bConnected = TRUE;
3567
- sendCommand( "set notify=done,pause,continue" );
3568
- GetX11SalData()->GetLib()->Insert( getFileDescriptor(),
3570
- (YieldFunc)pending,
3571
- (YieldFunc)queued,
3572
- (YieldFunc)handleEvents );
3576
- SalDbgAssert( "RPTPSound::connect to \"%s\" on port %d failed\n", sBuf, nPort );
3577
- s_bFailedOnce = TRUE;
3579
- return s_bConnected;
3582
-void RPTPSound::disconnect()
3584
- if( s_bConnected )
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" );
3594
-int RPTPSound::pending( int nFD, void* )
3596
- struct pollfd aPollfd;
3598
- aPollfd.events = POLLIN;
3600
- poll( &aPollfd, 1, 0 );
3602
- return aPollfd.revents & POLLIN ? 1 : 0;
3605
-int RPTPSound::queued( int nFD, void* pObj )
3607
- return pending( nFD, pObj );
3610
-int RPTPSound::handleEvents( int, void* )
3612
- SalDbgAssert( "RPTPSound::handleEvents\n" );
3613
- ByteString aLine = readLine();
3615
- if( aLine.GetChar( 0 ) == '@' &&
3616
- ( nPos = aLine.Search( "event=" ) ) != STRING_NOTFOUND )
3619
- RPTPSound* pSound = NULL;
3621
- ByteString aEvent = aLine.Copy( nPos+6 );
3622
- aEvent = GetCommandLineToken( 0, aEvent );
3623
- aEvent.ToLowerAscii();
3625
- if( ( nPos = aLine.Search( "id=#" ) ) != STRING_NOTFOUND )
3627
- nID = aLine.Copy( nPos+4 ).ToInt32();
3628
- pSound = getSoundById( nID );
3631
- if( pSound && pSound->m_pSalSound )
3633
- if( aEvent == "done" )
3635
- if( pSound->m_pSalSound->m_bLoop )
3638
- pSound->m_pSalSound->changeStateStop();
3640
- else if( aEvent == "pause" )
3641
- pSound->m_pSalSound->changeStatePause();
3642
- else if( aEvent == "continue" )
3643
- pSound->m_pSalSound->changeStateCont();
3649
-ByteString RPTPSound::readLine()
3651
- static char pAnswerBuffer[ 1024 ];
3653
- if( ! s_bConnected && ! connect() )
3654
- return ByteString();
3656
- memset( pAnswerBuffer, 0, sizeof( pAnswerBuffer ) );
3657
- if( s_aConnector.read( pAnswerBuffer, 1 ) == 1 )
3659
- unsigned int nTimes = 0;
3660
- unsigned int nPos = 1;
3661
- while( nTimes < 1000 && nPos < sizeof( pAnswerBuffer )-1 )
3663
- while( s_aConnector.recv( pAnswerBuffer + nPos, 1 ) == 1 &&
3664
- nPos < sizeof( pAnswerBuffer )-1 )
3667
- if( pAnswerBuffer[ nPos-2 ] == '\r' &&
3668
- pAnswerBuffer[ nPos-1 ] == '\n' )
3670
- pAnswerBuffer[ nPos-2 ] = 0;
3676
- aVal.Nanosec = 1000000;
3677
- osl_waitThread( &aVal );
3681
- SalDbgAssert( "read line \"%s\"\n", pAnswerBuffer );
3682
- return ByteString( pAnswerBuffer );
3685
-ByteString RPTPSound::sendCommand( const ByteString& rCommand )
3687
- if( ! s_bConnected && ! connect() )
3688
- return ByteString();
3690
- SalDbgAssert( "RPTPSound::sendCommand( \"%s\" )\n", rCommand.GetBuffer() );
3692
- ByteString aCommand( rCommand );
3693
- aCommand += "\r\n";
3694
- s_aConnector.write( aCommand.GetBuffer(), aCommand.Len() );
3695
- return readLine();
3698
-RPTPSound* RPTPSound::getSoundById( ULONG nID )
3700
- for( unsigned int i = 0; i < s_aSounds.Count(); i++ )
3702
- RPTPSound* pSound = s_aSounds.GetObject( i );
3703
- if( pSound->m_nID == nID )
3709
-ULONG RPTPSound::getMaxId()
3712
- for( unsigned int i = 0; i < s_aSounds.Count(); i++ )
3714
- RPTPSound* pSound = s_aSounds.GetObject( i );
3715
- if( pSound->m_nID > nID )
3716
- nID = pSound->m_nID;
3721
-RPTPSound::RPTPSound( X11SalSound* pSalSound ) :
3722
- VSound( pSalSound ),
3725
- s_aSounds.Insert( this );
3728
-RPTPSound::~RPTPSound()
3730
- s_aSounds.Remove( this );
3731
- m_pSalSound = NULL;
3733
- if( s_aSounds.Count() == 0 )
3737
-void RPTPSound::play()
3739
- if( ! m_pSalSound )
3742
- ByteString aCommand( "find sound=" );
3744
- aCommand += m_pSalSound->m_aSoundFile;
3745
- ByteString aAnswer = sendCommand( aCommand );
3746
- if( ! aAnswer.Len() || ! s_bConnected )
3748
- m_pSalSound->setError( SOUNDERR_INVALID_FILE );
3751
- if( aAnswer.GetChar( 0 ) != '+' )
3753
- // the sound is not on the server
3754
- // try to put it (does not really work with rplayd 3.3.0)
3761
- m_pSalSound->setError( SOUNDERR_INVALID_FILE );
3765
- aCommand += " sound=";
3766
- aCommand += m_pSalSound->m_aSoundFile;
3767
- aCommand += " size=";
3768
- aCommand += ByteString::CreateFromInt64((ULONG)m_aStat.st_size);
3770
- aAnswer = sendCommand( aCommand );
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
3780
- aCommand = "play ";
3781
- aCommand += m_pSalSound->m_aSoundFile;
3782
- aAnswer = sendCommand( aCommand );
3783
- if( aAnswer.GetChar( 0 ) == '+' )
3785
- int nPos = aAnswer.Search( "id=#" );
3786
- if( nPos != STRING_NOTFOUND )
3787
- m_nID = aAnswer.Copy( nPos+4 ).ToInt32();
3790
- m_pSalSound->setError( SOUNDERR_DEVICE_NOT_READY );
3792
- SalDbgAssert( "RPTPSound::play() yields id %d\n", m_nID );
3795
-void RPTPSound::stop()
3797
- ByteString aAnswer;
3800
- ByteString aCommand( "stop id=#" );
3801
- aCommand += ByteString::CreateFromInt64(m_nID);
3802
- aAnswer = sendCommand( aCommand );
3804
- if( aAnswer.GetChar( 0 ) != '+' && m_pSalSound)
3805
- m_pSalSound->setError( SOUNDERR_INVALID_FILE );
3808
-void RPTPSound::pause()
3812
- ByteString aCommand( "pause id=#" );
3813
- aCommand += ByteString::CreateFromInt64(m_nID);
3814
- sendCommand( aCommand );
3818
-void RPTPSound::cont()
3822
- ByteString aCommand( "continue id=#" );
3823
- aCommand += ByteString::CreateFromInt64(m_nID);
3824
- sendCommand( aCommand );
3828
-BOOL RPTPSound::isValid()
3830
- if( ! s_bConnected )
3832
- if( ! s_bConnected )
3835
- return stat( m_pSalSound->m_aSoundFile.GetBuffer(), &m_aStat ) ? FALSE : TRUE;
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
3845
-/*************************************************************************
3847
- * OpenOffice.org - a multi-platform office productivity suite
3849
- * $RCSfile: salimpsound.hxx,v $
3851
- * $Revision: 1.10 $
3853
- * last change: $Author: hr $ $Date: 2007/07/31 13:02:03 $
3855
- * The Contents of this file are made available subject to
3856
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
3878
- ************************************************************************/
3879
-#ifndef _VCL_SALIMPSOUND_HXX
3880
-#define _VCL_SALIMPSOUND_HXX
3882
-#include <vsound.hxx>
3884
-#include <osl/mutex.hxx>
3885
-#include <vos/socket.hxx>
3887
-#include <tools/list.hxx>
3888
-#include <tools/link.hxx>
3889
-#include <tools/gen.hxx>
3890
-#include <tools/string.hxx>
3892
-#include <vcl/sv.h>
3893
-#include <vcl/salstype.hxx>
3895
-#include <unistd.h>
3896
-#include <sys/stat.h>
3899
-#ifdef SYSTEM_PORTAUDIO
3900
-#include <portaudio.h>
3902
-#include <portaudio/portaudio.h>
3904
-#ifdef SYSTEM_SNDFILE
3905
-#include <sndfile.h>
3907
-#include <sndfile/sndfile.h>
3911
-namespace vcl_sal {
3913
-// OSS can only be used on local displays
3916
- class OSSSound : public VSound
3918
- // thread implementation
3921
- OSSSound* m_pSound;
3928
- DECLARE_LIST( OSSDataList, OSSData* )
3929
- DECLARE_LIST( OSSSoundList, OSSSound* )
3931
- static int s_nDevice;
3932
- static OSSDataList s_aDataList;
3933
- static osl::Mutex s_aProtector;
3934
- static OSSSoundList s_aSounds;
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* );
3949
- DECL_LINK( notifyStopHdl, void* );
3950
- DECL_LINK( notifyErrorHdl, void* );
3952
- virtual BOOL isValid();
3954
- OSSSound( ::X11SalSound* pSalSound );
3955
- virtual ~OSSSound();
3957
- virtual void play();
3958
- virtual void stop();
3959
- virtual void pause();
3960
- virtual void cont();
3962
- static void run(); // thread worker
3966
-// DEVAUDIO can only be used on local displays
3968
-#ifdef USE_DEVAUDIO
3969
- class DevAudioSound;
3970
- struct DevAudioData
3972
- DevAudioSound* m_pSound;
3973
- AudioConverter* m_pConverter;
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 )
3985
- { if( m_pConverter ) delete m_pConverter; }
3987
- DECLARE_LIST( DevAudioDataList, DevAudioData* )
3988
- DECLARE_LIST( DevAudioSoundList, DevAudioSound* )
3990
- class DevAudioSound : public VSound
3992
- // thread implementation
3994
- static int s_nDevice;
3995
- static DevAudioDataList s_aDataList;
3996
- static osl::Mutex s_aProtector;
3997
- static DevAudioSoundList s_aSounds;
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* );
4012
- DECL_LINK( notifyStopHdl, void* );
4013
- DECL_LINK( notifyErrorHdl, void* );
4015
- virtual BOOL isValid();
4017
- DevAudioSound( ::X11SalSound* pSalSound );
4018
- virtual ~DevAudioSound();
4020
- virtual void play();
4021
- virtual void stop();
4022
- virtual void pause();
4023
- virtual void cont();
4025
- static void run();
4030
-// Portaudio / libsndfile can only be used on local displays
4033
-#define PASF_BUFFER_LEN (8192)
4038
- PaDeviceID device;
4040
- PaDeviceIndex device;
4042
- PaSampleFormat format;
4043
- unsigned int bufsize;
4047
- unsigned long start_frame;
4048
- unsigned long stop_frame;
4049
- unsigned long frame_count;
4054
-class PASFSound : public VSound
4057
- PaStream* m_pStream;
4058
- PASFAudioData* m_pData;
4061
- virtual BOOL isValid();
4064
- PASFSound( ::X11SalSound* pSalSound );
4065
- virtual ~PASFSound();
4067
- virtual void play();
4068
- virtual void stop();
4069
- virtual void pause();
4070
- virtual void cont();
4077
-class RPTPSound : public VSound
4079
- DECLARE_LIST( RPTPSoundList, RPTPSound* )
4081
- static BOOL s_bConnected;
4082
- static NAMESPACE_VOS(OConnectorSocket) s_aConnector;
4083
- static RPTPSoundList s_aSounds;
4084
- static BOOL s_bFailedOnce;
4086
- static BOOL connect();
4087
- static void disconnect();
4088
- static ByteString readLine();
4089
- static ByteString sendCommand( const ByteString& rCommand );
4091
- static int getFileDescriptor();
4092
- static RPTPSound* getSoundById( ULONG );
4093
- static ULONG getMaxId();
4096
- static int pending( int, void* );
4097
- static int queued( int, void* );
4098
- static int handleEvents( int, void* );
4102
- virtual BOOL isValid();
4104
- RPTPSound( ::X11SalSound* pSalSound );
4106
- virtual ~RPTPSound();
4108
- virtual void play();
4109
- virtual void stop();
4110
- virtual void pause();
4111
- virtual void cont();
4116
- class NASSound : public VSound
4118
- DECLARE_LIST( NASSoundList, NASSound* )
4120
- static NASSoundList s_aSounds;
4121
- static void* s_pServer;
4122
- static BOOL s_bFailedOnce;
4124
- static BOOL connect();
4125
- static void disconnect();
4127
- static void callback( void*, void*, void*, void* );
4129
- static int pending( int, void* );
4130
- static int queued( int, void* );
4131
- static int handleEvents( int, void* );
4135
- virtual BOOL isValid();
4137
- NASSound( ::X11SalSound* pSalSound );
4139
- virtual ~NASSound();
4141
- virtual void play();
4142
- virtual void stop();
4143
- virtual void pause();
4144
- virtual void cont();
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
4159
#ifndef _SV_SALOGL_H
4162
-#ifndef _SV_SALSOUND_H
4163
-#include <salsound.h>
4166
// -------------------------------------------------------------------------
4168
@@ -145,9 +142,6 @@ extern "C"
4170
X11SalInstance::~X11SalInstance()
4172
- // deinitialize global sound resources
4173
- X11SalSound::Release();
4175
// release (possibly open) OpenGL context
4176
X11SalOpenGL::Release();
4178
@@ -323,9 +317,3 @@ SalOpenGL* X11SalInstance::CreateSalOpen
4180
return new X11SalOpenGL( pGraphics );
4183
-SalSound* X11SalInstance::CreateSalSound()
4185
- return new X11SalSound();
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
4195
-/*************************************************************************
4197
- * OpenOffice.org - a multi-platform office productivity suite
4199
- * $RCSfile: salsound2.cxx,v $
4201
- * $Revision: 1.11 $
4203
- * last change: $Author: hr $ $Date: 2007/06/27 20:47:22 $
4205
- * The Contents of this file are made available subject to
4206
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
4228
- ************************************************************************/
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>
4235
-#include <unistd.h>
4237
-#include <salunx.h>
4238
-#include <saldata.hxx>
4239
-#include <saldisp.hxx>
4241
-#include <salsound.h>
4242
-#include <vcl/salstype.hxx>
4243
-#include <salimpsound.hxx>
4245
-using namespace vcl_sal;
4247
-ULONG X11SalSound::s_nSoundState = SOUND_STATE_UNLOADED;
4249
-X11SalSound::X11SalSound() :
4250
- m_pVSound( NULL ),
4252
- m_bPlaying( false ),
4253
- m_bPaused( false ),
4254
- m_nStartTime( 0 ),
4255
- m_nPlayTime( SOUND_PLAYALL )
4257
- SalDbgAssert( "X11SalSound::X11SalSound()\n" );
4259
- // initialize the portaudio library (typically just once)
4260
- if (s_nSoundState == SOUND_STATE_UNLOADED)
4262
- PaError err = Pa_Initialize();
4263
- if( err == paNoError )
4264
- s_nSoundState = SOUND_STATE_VALID;
4266
- if (s_nSoundState != SOUND_STATE_VALID )
4267
- s_nSoundState = SOUND_STATE_INVALID;
4269
- s_nSoundState = SOUND_STATE_VALID;
4273
-X11SalSound::~X11SalSound()
4275
- SalDbgAssert( "X11SalSound::~X11SalSound()\n" );
4280
-void X11SalSound::Release()
4283
- // terminate the portaudio library
4284
- if ( s_nSoundState == SOUND_STATE_VALID ) Pa_Terminate();
4286
- s_nSoundState = SOUND_STATE_UNLOADED;
4289
-bool X11SalSound::IsValid()
4291
- return (X11SalSound::s_nSoundState == SOUND_STATE_VALID);
4295
-bool X11SalSound::Init( const String& rSoundName, ULONG& rSoundLen )
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()))
4308
- m_aSoundFile = ByteString( rSoundName, RTL_TEXTENCODING_UTF8 );
4310
- m_aSoundFile = ByteString( rSoundName, osl_getThreadTextEncoding() );
4312
- SalDbgAssert( "X11SalSound::Init( \"%s\", %d )\n", m_aSoundFile.GetBuffer(), rSoundLen );
4314
- m_pVSound = ( !m_aSoundFile.Len() || access( m_aSoundFile.GetBuffer(), R_OK ) ) ? NULL : VSound::createVSound( this );
4316
- return m_pVSound ? true : false;
4319
-void X11SalSound::Play( ULONG nStartTime, ULONG nPlayTime, bool bLoop )
4321
- SalDbgAssert( "SalSound::Play( %d, %d, %s )\n", nStartTime, nPlayTime, bLoop ? "TRUE" : "FALSE" );
4322
- if( m_bPlaying && m_pVSound )
4323
- m_pVSound->stop();
4326
- m_nStartTime = nStartTime;
4327
- m_nPlayTime = nPlayTime;
4330
- m_pVSound->play();
4333
-void X11SalSound::Stop()
4335
- SalDbgAssert( "X11SalSound::Stop()\n" );
4336
- if( m_bPlaying && m_pVSound )
4337
- m_pVSound->stop();
4340
-void X11SalSound::Pause()
4342
- if( m_bPlaying && m_pVSound )
4343
- m_pVSound->pause();
4346
-void X11SalSound::Continue()
4348
- if( m_bPaused && m_pVSound )
4349
- m_pVSound->cont();
4352
-bool X11SalSound::IsLoopMode() const
4357
-bool X11SalSound::IsPlaying() const
4359
- return m_bPlaying;
4362
-bool X11SalSound::IsPaused() const
4367
-// --------------------------------------------------
4369
-void VSound::initBuffer()
4371
- if( stat( m_pSalSound->m_aSoundFile.GetBuffer(), &m_aStat ) )
4373
- SalDbgAssert( "could not stat \"%s\"\n", m_pSalSound->m_aSoundFile.GetBuffer() );
4377
- if( ( nFile = ::open( m_pSalSound->m_aSoundFile.GetBuffer(), O_RDONLY ) ) == -1 )
4379
- SalDbgAssert( "could not open %s\n", m_pSalSound->m_aSoundFile.GetBuffer() );
4383
- m_pBuffer = (char *)mmap( NULL, m_aStat.st_size, PROT_READ, MAP_SHARED, nFile, 0 );
4385
- if( m_pBuffer == MAP_FAILED )
4387
- SalDbgAssert( "could not mmap %s\n", m_pSalSound->m_aSoundFile.GetBuffer() );
4393
-void VSound::releaseBuffer()
4397
- munmap( m_pBuffer, m_aStat.st_size );
4403
-VSound* VSound::createVSound( X11SalSound* pX11SalSound )
4405
- struct stat aStat;
4406
- if( stat( pX11SalSound->m_aSoundFile.GetBuffer(), & aStat ) )
4409
- VSound* pRet = NULL;
4411
- if( GetX11SalData()->GetDisplay()->IsLocal() )
4415
- pRet = new PASFSound( pX11SalSound );
4416
- if( pRet && ! pRet->isValid() )
4422
- SalDbgAssert( "got an PASFSound\n" );
4429
- pRet = new OSSSound( pX11SalSound );
4430
- if( pRet && ! pRet->isValid() )
4436
- SalDbgAssert( "got an OSSSound\n" );
4440
- #ifdef USE_DEVAUDIO
4443
- pRet = new DevAudioSound( pX11SalSound );
4444
- if( pRet && ! pRet->isValid() )
4450
- SalDbgAssert( "got an DevAudioSound\n" );
4458
- pRet = new NASSound( pX11SalSound );
4459
- if( pRet && ! pRet->isValid() )
4465
- SalDbgAssert( "got an AUSound\n" );
4471
- pRet = new RPTPSound( pX11SalSound );
4472
- if( pRet && ! pRet->isValid() )
4478
- SalDbgAssert( "got an RPTPSound\n" );
4484
-void X11SalSound::changeStatePlay()
4486
- SalDbgAssert( "SalSound(%p)::changeStatePlay()\n", this );
4488
- m_bPlaying = TRUE;
4489
- m_bPaused = FALSE;
4491
- CallNotifyProc( SOUND_NOTIFY_SUCCESS, SOUNDERR_SUCCESS );
4494
-void X11SalSound::changeStateStop()
4496
- SalDbgAssert( "X11SalSound(%p)::changeStateStop()\n", this );
4498
- m_bPlaying = FALSE;
4499
- m_bPaused = FALSE;
4501
- CallNotifyProc( SOUND_NOTIFY_SUCCESS, SOUNDERR_SUCCESS );
4504
-void X11SalSound::changeStatePause()
4506
- SalDbgAssert( "X11SalSound(%p)::changeStatePause()\n", this );
4508
- m_bPlaying = TRUE;
4511
- CallNotifyProc( SOUND_NOTIFY_SUCCESS, SOUNDERR_SUCCESS );
4514
-void X11SalSound::changeStateCont()
4516
- SalDbgAssert( "X11SalSound(%p)::changeStateCont()\n", this );
4518
- m_bPlaying = TRUE;
4519
- m_bPaused = FALSE;
4521
- CallNotifyProc( SOUND_NOTIFY_SUCCESS, SOUNDERR_SUCCESS );
4524
-void X11SalSound::setError( ULONG nError )
4526
- CallNotifyProc( SOUND_NOTIFY_ERROR, nError );
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
4536
-/*************************************************************************
4538
- * OpenOffice.org - a multi-platform office productivity suite
4540
- * $RCSfile: sunconvert.cxx,v $
4542
- * $Revision: 1.6 $
4544
- * last change: $Author: obo $ $Date: 2006/09/17 12:36:39 $
4546
- * The Contents of this file are made available subject to
4547
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
4569
- ************************************************************************/
4571
-// MARKER(update_precomp.py): autogen include statement, do not remove
4572
-#include "precompiled_vcl.hxx"
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) */
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.
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'. */
4596
- short a[2]; /* Coefficients of pole portion of prediction filter. */
4597
- short b[6]; /* Coefficients of zero portion of prediction filter. */
4599
- * Signs of previous two samples of a partially
4600
- * reconstructed signal.
4603
- * Previous 6 samples of the quantized difference
4604
- * signal represented in an internal floating point
4608
- * Previous 2 samples of the quantized difference
4609
- * signal represented in an internal floating point
4612
- char td; /* delayed tone detect, new in 1988 version */
4615
-/* External function definitions. */
4617
-extern void g72x_init_state(struct g72x_state *);
4618
-extern int g721_encoder(
4621
- struct g72x_state *state_ptr);
4622
-extern int g721_decoder(
4625
- struct g72x_state *state_ptr);
4626
-extern int g723_24_encoder(
4629
- struct g72x_state *state_ptr);
4630
-extern int g723_24_decoder(
4633
- struct g72x_state *state_ptr);
4634
-extern int g723_40_encoder(
4637
- struct g72x_state *state_ptr);
4638
-extern int g723_40_decoder(
4641
- struct g72x_state *state_ptr);
4643
-#endif /* !_G72X_H */
4647
- * u-law, A-law and linear PCM conversions.
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. */
4655
-static short seg_end[8] = {0xFF, 0x1FF, 0x3FF, 0x7FF,
4656
- 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF};
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};
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};
4703
- for (i = 0; i < size; i++) {
4704
- if (val <= *table++)
4711
- * linear2alaw() - Convert a 16-bit linear PCM value to 8-bit A-law
4713
- * linear2alaw() accepts an 16-bit integer and encodes it as A-law data.
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
4726
- * For further information see John C. Bellamy's Digital Telephony, 1982,
4727
- * John Wiley & Sons, pps 98-111 and 472-476.
4731
- int pcm_val) /* 2's complement (16-bit range) */
4735
- unsigned char aval;
4737
- if (pcm_val >= 0) {
4738
- mask = 0xD5; /* sign (7th) bit = 1 */
4740
- mask = 0x55; /* sign bit = 0 */
4741
- pcm_val = -pcm_val - 8;
4744
- /* Convert the scaled magnitude to segment number. */
4745
- seg = search(pcm_val, seg_end, 8);
4747
- /* Combine the sign, segment, and quantization bits. */
4749
- if (seg >= 8) /* out of range, return maximum value. */
4750
- return (0x7F ^ mask);
4752
- aval = seg << SEG_SHIFT;
4754
- aval |= (pcm_val >> 4) & QUANT_MASK;
4756
- aval |= (pcm_val >> (seg + 3)) & QUANT_MASK;
4757
- return (aval ^ mask);
4762
- * alaw2linear() - Convert an A-law value to 16-bit linear PCM
4767
- unsigned char a_val)
4774
- t = (a_val & QUANT_MASK) << 4;
4775
- seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT;
4787
- return ((a_val & SIGN_BIT) ? t : -t);
4790
-#define BIAS (0x84) /* Bias for linear code. */
4793
- * linear2ulaw() - Convert a linear PCM value to u-law
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:
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
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.
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.
4818
- * For further information see John C. Bellamy's Digital Telephony, 1982,
4819
- * John Wiley & Sons, pps 98-111 and 472-476.
4823
- int pcm_val) /* 2's complement (16-bit range) */
4827
- unsigned char uval;
4829
- /* Get the sign and the magnitude of the value. */
4830
- if (pcm_val < 0) {
4831
- pcm_val = BIAS - pcm_val;
4838
- /* Convert the scaled magnitude to segment number. */
4839
- seg = search(pcm_val, seg_end, 8);
4842
- * Combine the sign, segment, quantization bits;
4843
- * and complement the code word.
4845
- if (seg >= 8) /* out of range, return maximum value. */
4846
- return (0x7F ^ mask);
4848
- uval = (seg << 4) | ((pcm_val >> (seg + 3)) & 0xF);
4849
- return (uval ^ mask);
4855
- * ulaw2linear() - Convert a u-law value to 16-bit linear PCM
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.
4860
- * Note that this function expects to be passed the complement of the
4861
- * original code word. This is in keeping with ISDN conventions.
4865
- unsigned char u_val)
4869
- /* Complement to obtain normal u-law value. */
4873
- * Extract and bias the quantization bits. Then
4874
- * shift up by the segment number and subtract out the bias.
4876
- t = ((u_val & QUANT_MASK) << 3) + BIAS;
4877
- t <<= ((unsigned)u_val & SEG_MASK) >> SEG_SHIFT;
4879
- return ((u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS));
4882
-/* A-law to u-law conversion */
4885
- unsigned char aval)
4888
- return ((aval & 0x80) ? (0xFF ^ _a2u[aval ^ 0xD5]) :
4889
- (0x7F ^ _a2u[aval ^ 0x55]));
4892
-/* u-law to A-law conversion */
4895
- unsigned char uval)
4898
- return ((uval & 0x80) ? (0xD5 ^ (_u2a[0xFF ^ uval] - 1)) :
4899
- (0x55 ^ (_u2a[0x7F ^ uval] - 1)));
4904
- * Common routines for G.721 and G.723 conversions.
4907
-static short power2[15] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80,
4908
- 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000};
4913
- * quantizes the input val against the table of size short integers.
4914
- * It returns i if table[i - 1] <= val < table[i].
4916
- * Using linear search for simple coding.
4926
- for (i = 0; i < size; i++)
4927
- if (val < *table++)
4935
- * returns the integer product of the 14-bit integer "an" and
4936
- * "floating point" representation (4-bit exponent, 6-bit mantessa) "srn".
4943
- short anmag, anexp, anmant;
4944
- short wanexp, wanmant;
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;
4953
- wanmant = (anmant * (srn & 077) + 0x30) >> 4;
4954
- retval = (wanexp >= 0) ? ((wanmant << wanexp) & 0x7FFF) :
4955
- (wanmant >> -wanexp);
4957
- return (((an ^ srn) < 0) ? -retval : retval);
4961
- * g72x_init_state()
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.
4969
- struct g72x_state *state_ptr)
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;
4983
- for (cnta = 0; cnta < 6; cnta++) {
4984
- state_ptr->b[cnta] = 0;
4985
- state_ptr->dq[cnta] = 32;
4987
- state_ptr->td = 0;
4991
- * predictor_zero()
4993
- * computes the estimated signal from 6-zero predictor.
4998
- struct g72x_state *state_ptr)
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]);
5009
- * predictor_pole()
5011
- * computes the estimated signal from 2-pole predictor.
5016
- struct g72x_state *state_ptr)
5018
- return (fmult(state_ptr->a[1] >> 2, state_ptr->sr[1]) +
5019
- fmult(state_ptr->a[0] >> 2, state_ptr->sr[0]));
5024
- * computes the quantization step size of the adaptive quantizer.
5029
- struct g72x_state *state_ptr)
5035
- if (state_ptr->ap >= 256)
5036
- return (state_ptr->yu);
5038
- y = state_ptr->yl >> 6;
5039
- dif = state_ptr->yu - y;
5040
- al = state_ptr->ap >> 2;
5042
- y += (dif * al) >> 6;
5044
- y += (dif * al + 0x3F) >> 6;
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.
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 */
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 */
5075
- * Compute base 2 log of 'd', and store in 'dl'.
5078
- exp = quan(dqm >> 1, power2, 15);
5079
- mant = ((dqm << 7) >> exp) & 0x7F; /* Fractional portion. */
5080
- dl = (exp << 7) + mant;
5085
- * "Divide" by step size multiplier.
5087
- dln = dl - (y >> 2);
5092
- * Obtain codword i for 'd'.
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 */
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.
5111
- int sign, /* 0 for non-negative value */
5112
- int dqln, /* G.72x codeword */
5113
- int y) /* Step size multiplier */
5115
- short dql; /* Log of 'dq' magnitude */
5116
- short dex; /* Integer part of log */
5118
- short dq; /* Reconstructed difference signal sample */
5120
- dql = dqln + (y >> 2); /* ADDA */
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);
5136
- * updates the state variables for each output code
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 */
5150
- short mag, exp; /* Adaptive predictor, FLOAT A */
5151
- short a2p = 0; /* LIMC */
5152
- short a1ul; /* UPA1 */
5153
- short pks1; /* UPA2 */
5155
- char tr; /* tone/transition detector */
5156
- short ylint, thr2, dqthr;
5157
- short ylfrac, thr1;
5160
- pk0 = (dqsez < 0) ? 1 : 0; /* needed in updating predictor poles */
5162
- mag = dq & 0x7FFF; /* prediction difference magnitude */
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 */
5171
- else if (mag <= dqthr) /* supposed data, but small mag */
5172
- tr = 0; /* treated as voice */
5173
- else /* signal is data (modem) */
5177
- * Quantizer scale factor adaptation.
5180
- /* FUNCTW & FILTD & DELAY */
5181
- /* update non-steady state step size multiplier */
5182
- state_ptr->yu = y + ((wi - y) >> 5);
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;
5190
- /* FILTE & DELAY */
5191
- /* update steady state step size multiplier */
5192
- state_ptr->yl += state_ptr->yu + ((-state_ptr->yl) >> 6);
5195
- * Adaptive predictor coefficients.
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
5208
- } else { /* update a's and b's */
5209
- pks1 = pk0 ^ state_ptr->pk[0]; /* UPA2 */
5211
- /* update predictor pole a[1] */
5212
- a2p = state_ptr->a[1] - (state_ptr->a[1] >> 7);
5214
- fa1 = (pks1) ? state_ptr->a[0] : -state_ptr->a[0];
5215
- if (fa1 < -8191) /* a2p = function of fa1 */
5217
- else if (fa1 > 8191)
5222
- if (pk0 ^ state_ptr->pk[1])
5224
- if (a2p <= -12160)
5226
- else if (a2p >= 12416)
5230
- else if (a2p <= -12416)
5232
- else if (a2p >= 12160)
5238
- /* TRIGB & DELAY */
5239
- state_ptr->a[1] = a2p;
5242
- /* update predictor pole a[0] */
5243
- state_ptr->a[0] -= state_ptr->a[0] >> 8;
5246
- state_ptr->a[0] += 192;
5248
- state_ptr->a[0] -= 192;
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;
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;
5267
- state_ptr->b[cnt] -= 128;
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. */
5276
- state_ptr->dq[0] = (dq >= 0) ? 0x20 : 0xFC20;
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;
5284
- state_ptr->sr[1] = state_ptr->sr[0];
5285
- /* FLOAT B : convert sr to 4-bit exp., 6-bit mantissa f.p. */
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) {
5293
- exp = quan(mag, power2, 15);
5294
- state_ptr->sr[0] = (exp << 6) + ((mag << 6) >> exp) - 0x400;
5296
- state_ptr->sr[0] = 0xFC20;
5299
- state_ptr->pk[1] = state_ptr->pk[0];
5300
- state_ptr->pk[0] = pk0;
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;
5311
- * Adaptation speed control.
5313
- state_ptr->dms += (fi - state_ptr->dms) >> 5; /* FILTA */
5314
- state_ptr->dml += (((fi << 2) - state_ptr->dml) >> 7); /* FILTB */
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;
5326
- state_ptr->ap += (-state_ptr->ap) >> 4;
5330
- * tandem_adjust(sr, se, y, i, sign)
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.
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
5345
- * adjusted A-law or u-law compressed sample.
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 */
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 */
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);
5369
- if (id == i) { /* no adjustment on 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 */
5376
- if (imx > im) { /* sp adjusted to next lower value */
5378
- sd = (sp == 0xD5) ? 0x55 :
5379
- ((sp ^ 0x55) - 1) ^ 0x55;
5381
- sd = (sp == 0x2A) ? 0x2A :
5382
- ((sp ^ 0x55) + 1) ^ 0x55;
5384
- } else { /* sp adjusted to next higher value */
5386
- sd = (sp == 0xAA) ? 0xAA :
5387
- ((sp ^ 0x55) + 1) ^ 0x55;
5389
- sd = (sp == 0x55) ? 0xD5 :
5390
- ((sp ^ 0x55) - 1) ^ 0x55;
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 */
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 */
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);
5420
- /* ADPCM codes : 8, 9, ... F, 0, 1, ... , 6, 7 */
5421
- im = i ^ sign; /* 2's complement to biased unsigned */
5423
- if (imx > im) { /* sp adjusted to next lower value */
5425
- sd = (sp == 0xFF) ? 0x7E : sp + 1;
5427
- sd = (sp == 0) ? 0 : sp - 1;
5429
- } else { /* sp adjusted to next higher value */
5431
- sd = (sp == 0x80) ? 0x80 : sp - 1;
5433
- sd = (sp == 0x7F) ? 0xFE : sp + 1;
5443
- * g721_encoder(), g721_decoder()
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.
5454
- * The deviation from the bit level specification (lookup tables)
5455
- * preserves the bit level performance specifications.
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.
5463
-static short qtab_721[7] = {-124, 80, 178, 246, 300, 349, 400};
5465
- * Maps G.721 code word to reconstructed scale factor normalized log
5466
- * magnitude values.
5468
-static short _dqlntab_721[16] = {-2048, 4, 135, 213, 273, 323, 373, 425,
5469
- 425, 373, 323, 273, 213, 135, 4, -2048};
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};
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.
5479
-static short _fitab_721[16] = {0, 0, 0, 0x200, 0x200, 0x200, 0x600, 0xE00,
5480
- 0xE00, 0x600, 0x200, 0x200, 0x200, 0, 0, 0};
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.
5492
- struct g72x_state *state_ptr)
5494
- short sezi, se, sez; /* ACCUM */
5495
- short d; /* SUBTA */
5496
- short sr; /* ADDB */
5497
- short y; /* MIX */
5498
- short dqsez; /* ADDC */
5501
- switch (in_coding) { /* linearize input sample to 14-bit PCM */
5502
- case AUDIO_ENCODING_ALAW:
5503
- sl = alaw2linear(sl) >> 2;
5505
- case AUDIO_ENCODING_ULAW:
5506
- sl = ulaw2linear(sl) >> 2;
5508
- case AUDIO_ENCODING_LINEAR:
5509
- sl >>= 2; /* 14-bit dynamic range */
5515
- sezi = predictor_zero(state_ptr);
5517
- se = (sezi + predictor_pole(state_ptr)) >> 1; /* estimated signal */
5519
- d = sl - se; /* estimation difference */
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 */
5525
- dq = reconstruct(i & 8, _dqlntab_721[i], y); /* quantized est diff */
5527
- sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconst. signal */
5529
- dqsez = sr + sez - se; /* pole prediction diff. */
5531
- update(4, y, _witab_721[i] << 5, _fitab_721[i], dq, sr, dqsez, state_ptr);
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.
5549
- struct g72x_state *state_ptr)
5551
- short sezi, sei, sez, se; /* ACCUM */
5552
- short y; /* MIX */
5553
- short sr; /* ADDB */
5557
- i &= 0x0f; /* mask to get proper bits */
5558
- sezi = predictor_zero(state_ptr);
5560
- sei = sezi + predictor_pole(state_ptr);
5561
- se = sei >> 1; /* se = estimated signal */
5563
- y = step_size(state_ptr); /* dynamic quantizer step size */
5565
- dq = reconstruct(i & 0x08, _dqlntab_721[i], y); /* quantized diff. */
5567
- sr = (dq < 0) ? (se - (dq & 0x3FFF)) : se + dq; /* reconst. signal */
5569
- dqsez = sr - se + sez; /* pole prediction diff. */
5571
- update(4, y, _witab_721[i] << 5, _fitab_721[i], dq, sr, dqsez, state_ptr);
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 */
5589
- * g723_24_encoder(), g723_24_decoder()
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.
5599
- * Maps G.723_24 code word to reconstructed scale factor normalized log
5600
- * magnitude values.
5602
-static short _dqlntab_723_24[8] = {-2048, 135, 273, 373, 373, 273, 135, -2048};
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};
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.
5612
-static short _fitab_723_24[8] = {0, 0x200, 0x400, 0xE00, 0xE00, 0x400, 0x200, 0};
5614
-static short qtab_723_24[3] = {8, 218, 331};
5617
- * g723_24_encoder()
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.
5626
- struct g72x_state *state_ptr)
5628
- short sei, sezi, se, sez; /* ACCUM */
5629
- short d; /* SUBTA */
5630
- short y; /* MIX */
5631
- short sr; /* ADDB */
5632
- short dqsez; /* ADDC */
5635
- switch (in_coding) { /* linearize input sample to 14-bit PCM */
5636
- case AUDIO_ENCODING_ALAW:
5637
- sl = alaw2linear(sl) >> 2;
5639
- case AUDIO_ENCODING_ULAW:
5640
- sl = ulaw2linear(sl) >> 2;
5642
- case AUDIO_ENCODING_LINEAR:
5643
- sl >>= 2; /* sl of 14-bit dynamic range */
5649
- sezi = predictor_zero(state_ptr);
5651
- sei = sezi + predictor_pole(state_ptr);
5652
- se = sei >> 1; /* se = estimated signal */
5654
- d = sl - se; /* d = estimation diff. */
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. */
5661
- sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconstructed signal */
5663
- dqsez = sr + sez - se; /* pole prediction diff. */
5665
- update(3, y, _witab_723_24[i], _fitab_723_24[i], dq, sr, dqsez, state_ptr);
5671
- * g723_24_decoder()
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.
5681
- struct g72x_state *state_ptr)
5683
- short sezi, sei, sez, se; /* ACCUM */
5684
- short y; /* MIX */
5685
- short sr; /* ADDB */
5689
- i &= 0x07; /* mask to get proper bits */
5690
- sezi = predictor_zero(state_ptr);
5692
- sei = sezi + predictor_pole(state_ptr);
5693
- se = sei >> 1; /* se = estimated signal */
5695
- y = step_size(state_ptr); /* adaptive quantizer step size */
5696
- dq = reconstruct(i & 0x04, _dqlntab_723_24[i], y); /* unquantize pred diff */
5698
- sr = (dq < 0) ? (se - (dq & 0x3FFF)) : (se + dq); /* reconst. signal */
5700
- dqsez = sr - se + sez; /* pole prediction diff. */
5702
- update(3, y, _witab_723_24[i], _fitab_723_24[i], dq, sr, dqsez, state_ptr);
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 */
5720
- * g723_40_encoder(), g723_40_decoder()
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.
5728
- * The deviation from the bit level specification (lookup tables),
5729
- * preserves the bit level performance specifications.
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.
5738
- * Maps G.723_40 code word to ructeconstructed scale factor normalized log
5739
- * magnitude values.
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};
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};
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.
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};
5762
-static short qtab_723_40[15] = {-122, -16, 68, 139, 198, 250, 298, 339,
5763
- 378, 413, 445, 475, 502, 528, 553};
5766
- * g723_40_encoder()
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.
5776
- struct g72x_state *state_ptr)
5778
- short sei, sezi, se, sez; /* ACCUM */
5779
- short d; /* SUBTA */
5780
- short y; /* MIX */
5781
- short sr; /* ADDB */
5782
- short dqsez; /* ADDC */
5785
- switch (in_coding) { /* linearize input sample to 14-bit PCM */
5786
- case AUDIO_ENCODING_ALAW:
5787
- sl = alaw2linear(sl) >> 2;
5789
- case AUDIO_ENCODING_ULAW:
5790
- sl = ulaw2linear(sl) >> 2;
5792
- case AUDIO_ENCODING_LINEAR:
5793
- sl >>= 2; /* sl of 14-bit dynamic range */
5799
- sezi = predictor_zero(state_ptr);
5801
- sei = sezi + predictor_pole(state_ptr);
5802
- se = sei >> 1; /* se = estimated signal */
5804
- d = sl - se; /* d = estimation difference */
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 */
5810
- dq = reconstruct(i & 0x10, _dqlntab_723_40[i], y); /* quantized diff */
5812
- sr = (dq < 0) ? se - (dq & 0x7FFF) : se + dq; /* reconstructed signal */
5814
- dqsez = sr + sez - se; /* dqsez = pole prediction diff. */
5816
- update(5, y, _witab_723_40[i], _fitab_723_40[i], dq, sr, dqsez, state_ptr);
5822
- * g723_40_decoder()
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.
5832
- struct g72x_state *state_ptr)
5834
- short sezi, sei, sez, se; /* ACCUM */
5835
- short y; /* MIX */
5836
- short sr; /* ADDB */
5840
- i &= 0x1f; /* mask to get proper bits */
5841
- sezi = predictor_zero(state_ptr);
5843
- sei = sezi + predictor_pole(state_ptr);
5844
- se = sei >> 1; /* se = estimated signal */
5846
- y = step_size(state_ptr); /* adaptive quantizer step size */
5847
- dq = reconstruct(i & 0x10, _dqlntab_723_40[i], y); /* estimation diff. */
5849
- sr = (dq < 0) ? (se - (dq & 0x7FFF)) : (se + dq); /* reconst. signal */
5851
- dqsez = sr - se + sez; /* pole prediction diff. */
5853
- update(5, y, _witab_723_40[i], _fitab_723_40[i], dq, sr, dqsez, state_ptr);
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 */
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
5873
-/*************************************************************************
5875
- * OpenOffice.org - a multi-platform office productivity suite
5877
- * $RCSfile: vsound.hxx,v $
5879
- * $Revision: 1.11 $
5881
- * last change: $Author: hr $ $Date: 2006/06/19 19:52:31 $
5883
- * The Contents of this file are made available subject to
5884
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
5906
- ************************************************************************/
5907
-#ifndef _VCL_VSOUND_HXX
5908
-#define _VCL_VSOUND_HXX
5910
-#if (defined(LINUX)) || defined(FREEBSD)
5915
-#define USE_DEVAUDIO
5918
-#if STLPORT_VERSION>=321
5921
-#include <sys/stat.h>
5922
-#include <tools/string.hxx>
5926
-namespace vcl_sal {
5930
- VSound( ::X11SalSound* pSound ) : m_pSalSound( pSound ), m_pBuffer( NULL ) {}
5933
- ::X11SalSound* m_pSalSound;
5934
- // pointer to mmaped file
5936
- struct stat m_aStat;
5938
- void initBuffer();
5939
- void releaseBuffer();
5941
- virtual BOOL isValid() = 0;
5943
- virtual ~VSound() {}
5945
- virtual void play() = 0;
5946
- virtual void stop() = 0;
5947
- virtual void pause() = 0;
5948
- virtual void cont() = 0;
5950
- static VSound* createVSound( X11SalSound* );
5954
- // a class to convert bytestreams from one codec to another
5955
- class AudioConverter
5958
- virtual ~AudioConverter();
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;
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();
5969
- static AudioConverter* createINT8ToUINT16Converter();
5970
- static AudioConverter* createSwapINT16Converter();
5974
-#if OSL_DEBUG_LEVEL > 1
5975
-#include <stdarg.h>
5977
-inline void SalDbgAssert( const char* pFmt, ... )
5980
- va_start( ap, pFmt );
5981
- vfprintf( stderr, pFmt, ap );
5985
-inline void SalDbgAssert( const char*, ... )
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`
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)"!=""
6011
-.IF "$(ENABLE_NAS)" != ""
6012
-SHL2STDLIBS += -laudio
6013
-.IF "$(XAU_LIBS)" != ""
6014
-SHL2STDLIBS += $(XAU_LIBS)
6016
-.IF "$(OS)"=="SOLARIS"
6017
-# needed by libaudio.a
6018
-SHL2STDLIBS += -ldl -lnsl -lsocket
6022
.IF "$(GUIBASE)"=="unx"
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
6067
-/*************************************************************************
6069
- * OpenOffice.org - a multi-platform office productivity suite
6071
- * $RCSfile: salsound.h,v $
6073
- * $Revision: 1.5 $
6075
- * last change: $Author: hr $ $Date: 2007/06/27 20:55:12 $
6077
- * The Contents of this file are made available subject to
6078
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
6100
- ************************************************************************/
6102
-#ifndef _SV_SALSOUND_H
6103
-#define _SV_SALSOUND_H
6105
-#ifndef _SV_WINCOMP_HXX
6106
-#include <wincomp.hxx>
6110
-#include <tools/gen.hxx>
6112
-#ifndef _STRING_HXX
6113
-#include <tools/string.hxx>
6117
-#include <vcl/sv.h>
6120
-#include <osl/module.h>
6122
-#ifndef _SV_SALFRAME_HXX
6123
-#include <vcl/salframe.hxx>
6125
-#ifndef _SV_SALSTYPE_HXX
6126
-#include <vcl/salstype.hxx>
6128
-#ifndef _SV_SALSOUND_HXX
6129
-#include <vcl/salsound.hxx>
6136
-class WinSalSound : public SalSound
6139
- static oslModule mhMCILib;
6140
- static ULONG mnSoundState;
6141
- static void* mpMCIFnc;
6142
- ULONG mnStartTime;
6150
- void ImplSetError( DWORD nMciErr );
6151
- void ImplNotify( SoundNotification eNotification, ULONG nError );
6155
- virtual ~WinSalSound();
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;
6169
- bool ImplCreate();
6170
- void ImplDestroy();
6171
- static void Release();
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
6182
-/*************************************************************************
6184
- * OpenOffice.org - a multi-platform office productivity suite
6186
- * $RCSfile: salsound.hxx,v $
6188
- * $Revision: 1.3 $
6190
- * last change: $Author: hr $ $Date: 2007/06/27 20:55:24 $
6192
- * The Contents of this file are made available subject to
6193
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
6215
- ************************************************************************/
6217
-#ifndef _SV_SALSOUND_HXX
6218
-#define _SV_SALSOUND_HXX
6220
-#ifndef _SV_WINCOMP_HXX
6221
-#include <wincomp.hxx>
6225
-#include <tools/gen.hxx>
6227
-#ifndef _STRING_HXX
6228
-#include <tools/string.hxx>
6232
-#include <vcl/sv.h>
6235
-#ifndef _SV_SALFRAME_HXX
6236
-#include <vcl/salframe.hxx>
6238
-#ifndef _SV_SALSTYPE_HXX
6239
-#include <vcl/salstype.hxx>
6249
- static HINSTANCE mhMCILib;
6250
- static ULONG mnSoundState;
6251
- static void* mpMCIFnc;
6252
- SALSOUNDPROC mpProc;
6254
- ULONG mnStartTime;
6262
- void ImplSetError( DWORD nMciErr );
6263
- void ImplNotify( SoundNotification eNotification, ULONG nError );
6269
- BOOL ImplCreate();
6271
- void ImplDestroy();
6272
- static void Release();
6273
- static BOOL IsValid() { return( SOUND_STATE_VALID == SalSound::mnSoundState ); }
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 );
6281
- void SetNotifyProc( void* pInst, SALSOUNDPROC pProc )
6282
- { mpInst = pInst; mpProc = pProc; }
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 \
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
6311
#ifndef _SV_SALTIMER_H
6312
#include <saltimer.h>
6314
-#ifndef _SV_SALSOUND_H
6315
-#include <salsound.h>
6317
#ifndef _SV_SALATYPE_HXX
6318
#include <vcl/salatype.hxx>
6320
@@ -873,14 +870,6 @@ LRESULT CALLBACK SalComWndProc( HWND hWn
6321
delete (SalObject*)lParam;
6324
- case SAL_MSG_CREATESOUND:
6325
- nRet = ((WinSalSound*)lParam)->ImplCreate();
6328
- case SAL_MSG_DESTROYSOUND:
6329
- ((WinSalSound*)lParam)->ImplDestroy();
6333
nRet = (LRESULT)GetDCEx( (HWND)wParam, 0, DCX_CACHE );
6335
@@ -1120,13 +1109,6 @@ SalTimer* WinSalInstance::CreateSalTimer
6337
// -----------------------------------------------------------------------
6339
-SalSound* WinSalInstance::CreateSalSound()
6341
- return new WinSalSound();
6344
-// -----------------------------------------------------------------------
6346
SalOpenGL* WinSalInstance::CreateSalOpenGL( SalGraphics* pGraphics )
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
6356
-/*************************************************************************
6358
- * OpenOffice.org - a multi-platform office productivity suite
6360
- * $RCSfile: salsound.cxx,v $
6362
- * $Revision: 1.9 $
6364
- * last change: $Author: vg $ $Date: 2007/03/26 14:40:21 $
6366
- * The Contents of this file are made available subject to
6367
- * the terms of GNU Lesser General Public License Version 2.1.
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
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.
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.
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
6389
- ************************************************************************/
6391
-// MARKER(update_precomp.py): autogen include statement, do not remove
6392
-#include "precompiled_vcl.hxx"
6394
-#define INCLUDE_MMSYSTEM
6401
-#include <tools/svwin.h>
6404
-#ifndef _SV_SALDATA_HXX
6405
-#include <saldata.hxx>
6407
-#ifndef _SV_SALINST_H
6408
-#include <salinst.h>
6410
-#ifndef _SV_SALSOUND_H
6411
-#include <salsound.h>
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"
6428
-#define __MCI_CALL __stdcall
6430
-#define MCIFNC ((DWORD( __MCI_CALL * )( UINT, UINT, DWORD, DWORD )) WinSalSound::mpMCIFnc)
6432
-// -----------------
6433
-// - Statics init. -
6434
-// -----------------
6436
-oslModule WinSalSound::mhMCILib = 0;
6437
-ULONG WinSalSound::mnSoundState = SOUND_STATE_UNLOADED;
6438
-void* WinSalSound::mpMCIFnc = NULL;
6440
-// -------------------
6441
-// - Window-Callback -
6442
-// -------------------
6444
-void ImplSalHandleMCINotify( HWND hWnd, WPARAM nPar1, LPARAM )
6446
- SoundNotification eNotification = SOUND_NOTIFY_SUCCESS;
6447
- BOOL bNotify = TRUE;
6451
- case( MCI_NOTIFY_SUCCESSFUL ):
6452
- eNotification = SOUND_NOTIFY_SUCCESS;
6455
- case( MCI_NOTIFY_ABORTED ):
6456
- eNotification = SOUND_NOTIFY_ABORTED;
6459
- case( MCI_NOTIFY_FAILURE ):
6460
- eNotification = SOUND_NOTIFY_ERROR;
6468
- ((WinSalSound*)GetWindowLong( hWnd, 0 ) )->ImplNotify( eNotification, 0 );
6471
-LRESULT CALLBACK SalSoundWndProcA( HWND hWnd, UINT nMsg, WPARAM nPar1, LPARAM nPar2 )
6473
- if ( MM_MCINOTIFY == nMsg )
6474
- ImplSalHandleMCINotify( hWnd, nPar1, nPar2 );
6475
- return DefWindowProcA( hWnd, nMsg, nPar1, nPar2 );
6478
-LRESULT CALLBACK SalSoundWndProcW( HWND hWnd, UINT nMsg, WPARAM nPar1, LPARAM nPar2 )
6480
- if ( MM_MCINOTIFY == nMsg )
6481
- ImplSalHandleMCINotify( hWnd, nPar1, nPar2 );
6482
- return DefWindowProcW( hWnd, nMsg, nPar1, nPar2 );
6489
-WinSalSound::WinSalSound() :
6493
- mbPaused ( FALSE )
6497
-// ------------------------------------------------------------------------
6499
-WinSalSound::~WinSalSound()
6506
- MCI_GENERIC_PARMS aGenericParams;
6507
- aGenericParams.dwCallback = (DWORD) mhSoundWnd;
6508
- MCIFNC( mnDeviceId, MCI_CLOSE, MCI_WAIT, (DWORD)&aGenericParams );
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;
6517
- ImplSendMessage( pInst->mhComWnd, SAL_MSG_DESTROYSOUND,
6518
- 0, (LPARAM)this );
6524
-// ------------------------------------------------------------------------
6526
-void WinSalSound::ImplSetError( DWORD nMciErr )
6528
- struct aMapper { DWORD nMci; ULONG nSv; };
6530
- ULONG nError = SOUNDERR_GENERAL_ERROR;
6531
- static aMapper aErrArr[] =
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 }
6552
- for ( USHORT n=0; n < (sizeof( aErrArr ) / sizeof( aMapper ) ); n++ )
6554
- if ( aErrArr[ n ].nMci == nMciErr )
6556
- nError = aErrArr[ n ].nSv;
6562
- ImplNotify( SOUND_NOTIFY_ERROR, nError );
6565
-// ------------------------------------------------------------------------
6567
-void WinSalSound::ImplNotify( SoundNotification eNotification, ULONG nError )
6569
- if ( mbLoop && (SOUND_NOTIFY_SUCCESS == eNotification) && !nError )
6570
- Play( mnStartTime, mnPlayLen, TRUE );
6572
- CallNotifyProc( eNotification, nError );
6575
-// ------------------------------------------------------------------------
6577
-bool WinSalSound::ImplCreate()
6579
- SalData* pData = GetSalData();
6580
- bool bRet = FALSE;
6582
- if ( SOUND_STATE_UNLOADED == WinSalSound::mnSoundState )
6584
- // load library and init fncpointer
6585
- if ( aSalShlData.mbWNT )
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 )
6592
- WNDCLASSEXW aWndClass;
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 ) )
6602
- WinSalSound::mnSoundState = SOUND_STATE_VALID;
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 )
6614
- WNDCLASSEXA aWndClass;
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 ) )
6624
- WinSalSound::mnSoundState = SOUND_STATE_VALID;
6632
- if ( WinSalSound::mhMCILib )
6634
- osl_unloadModule( WinSalSound::mhMCILib );
6635
- WinSalSound::mhMCILib = NULL;
6638
- WinSalSound::mnSoundState = SOUND_STATE_INVALID;
6639
- ImplNotify( SOUND_NOTIFY_ERROR, SOUNDERR_CANNOT_LOAD_DRIVER );
6642
- else if ( SOUND_STATE_VALID == WinSalSound::mnSoundState )
6647
- // Create message window
6648
- if ( aSalShlData.mbWNT )
6650
- mhSoundWnd = CreateWindowExW( 0, SOUND_WINDOWCLASSW, L"", 0, 0, 0, 0, 0,
6651
- HWND_DESKTOP, NULL, pData->mhInst, 0 );
6655
- mhSoundWnd = CreateWindowExA( 0, SOUND_WINDOWCLASSA, "", 0, 0, 0, 0, 0,
6656
- HWND_DESKTOP, NULL, pData->mhInst, 0 );
6658
- SetWindowLong( mhSoundWnd, 0, (LONG)this );
6666
-// ------------------------------------------------------------------------
6668
-bool WinSalSound::IsValid()
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;
6675
- return (BOOL)ImplSendMessage( pInst->mhComWnd, SAL_MSG_CREATESOUND,
6676
- 0, (LPARAM)this );
6679
- return ImplCreate();
6682
-// ------------------------------------------------------------------------
6684
-void WinSalSound::ImplDestroy()
6687
- DestroyWindow( mhSoundWnd );
6691
-// ------------------------------------------------------------------------
6693
-void WinSalSound::Release()
6696
- if ( WinSalSound::mhMCILib )
6698
- osl_unloadModule( WinSalSound::mhMCILib );
6699
- WinSalSound::mhMCILib = NULL;
6702
- WinSalSound::mnSoundState = SOUND_STATE_UNLOADED;
6705
-// ------------------------------------------------------------------------
6707
-bool WinSalSound::Init( const XubString& rSoundName, ULONG& rSoundLen )
6709
- DWORD nMciErr = 0;
6712
- // clear old device
6717
- MCI_GENERIC_PARMS aGenericParams;
6718
- aGenericParams.dwCallback = (DWORD) mhSoundWnd;
6719
- nMciErr = MCIFNC( mnDeviceId, MCI_CLOSE, MCI_WAIT, (DWORD) &aGenericParams );
6723
- if ( rSoundName.Len() )
6726
- if ( aSalShlData.mbWNT )
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;
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;
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 );
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 );
6766
- rSoundLen = (ULONG)aStatus.dwReturn;
6772
- ImplSetError( nMciErr );
6774
- return (nMciErr ? false : true);
6777
-// ------------------------------------------------------------------------
6779
-void WinSalSound::Play( ULONG nStartTime, ULONG nPlayLen, bool bLoop )
6783
- DWORD nMciErr = 0;
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 );
6793
- mnStartTime = nStartTime;
6794
- mnPlayLen = nPlayLen;
6800
- MCI_PLAY_PARMS aPlayParams;
6801
- DWORD nFlags = MCI_NOTIFY;
6803
- aPlayParams.dwCallback = (DWORD)mhSoundWnd;
6807
- aPlayParams.dwFrom = nStartTime;
6808
- nFlags |= MCI_FROM;
6811
- if ( nPlayLen != SOUND_PLAYALL )
6813
- aPlayParams.dwTo = nStartTime + nPlayLen;
6817
- nMciErr = MCIFNC( mnDeviceId, MCI_PLAY, nFlags, (DWORD) &aPlayParams );
6824
- ImplSetError( nMciErr );
6827
- ImplSetError( MCIERR_INVALID_FILE );
6830
-// ------------------------------------------------------------------------
6832
-void WinSalSound::Stop()
6836
- MCI_GENERIC_PARMS aGenericParams;
6837
- aGenericParams.dwCallback = (DWORD)mhSoundWnd;
6838
- mbLoop = mbPaused = false;
6839
- MCIFNC( mnDeviceId, MCI_STOP, MCI_WAIT, (DWORD) &aGenericParams );
6843
-// ------------------------------------------------------------------------
6845
-void WinSalSound::Pause()
6849
- MCI_GENERIC_PARMS aGenericParams;
6850
- aGenericParams.dwCallback = (DWORD)mhSoundWnd;
6852
- MCIFNC( mnDeviceId, MCI_PAUSE, MCI_WAIT, (DWORD) &aGenericParams );
6856
-// ------------------------------------------------------------------------
6858
-void WinSalSound::Continue()
6860
- Play( 0, 0, mbLoop );
6863
-// ------------------------------------------------------------------------
6865
-bool WinSalSound::IsLoopMode() const
6870
-// ------------------------------------------------------------------------
6872
-bool WinSalSound::IsPlaying() const
6877
-// ------------------------------------------------------------------------
6879
-bool WinSalSound::IsPaused() const