-1, TRUE/true, FALSE/false and tabs replacements.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27838 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -125,7 +125,7 @@ class WXDLLIMPEXP_MMEDIA wxSoundStream {
|
|||||||
// Returns the best size for IO calls
|
// Returns the best size for IO calls
|
||||||
virtual wxUint32 GetBestSize() const { return 1024; }
|
virtual wxUint32 GetBestSize() const { return 1024; }
|
||||||
|
|
||||||
// SetSoundFormat returns TRUE when the format can be handled.
|
// SetSoundFormat returns true when the format can be handled.
|
||||||
virtual bool SetSoundFormat(const wxSoundFormatBase& format);
|
virtual bool SetSoundFormat(const wxSoundFormatBase& format);
|
||||||
|
|
||||||
// GetSoundFormat returns the current sound format.
|
// GetSoundFormat returns the current sound format.
|
||||||
@@ -146,7 +146,7 @@ class WXDLLIMPEXP_MMEDIA wxSoundStream {
|
|||||||
wxUint32 GetLastAccess() const { return m_lastcount; }
|
wxUint32 GetLastAccess() const { return m_lastcount; }
|
||||||
|
|
||||||
// This is only useful for device (I think).
|
// This is only useful for device (I think).
|
||||||
virtual bool QueueFilled() const { return TRUE; }
|
virtual bool QueueFilled() const { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Current sound format
|
// Current sound format
|
||||||
|
@@ -98,7 +98,7 @@ public:
|
|||||||
|
|
||||||
// You should use this function to test whether this file codec can read
|
// You should use this function to test whether this file codec can read
|
||||||
// the stream you passed to it.
|
// the stream you passed to it.
|
||||||
virtual bool CanRead() { return FALSE; }
|
virtual bool CanRead() { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxSoundRouterStream m_codec;
|
wxSoundRouterStream m_codec;
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
class wxSoundFormatPcm : public wxSoundFormatBase {
|
class wxSoundFormatPcm : public wxSoundFormatBase {
|
||||||
public:
|
public:
|
||||||
wxSoundFormatPcm(wxUint32 srate = 22500, wxUint8 bps = 8,
|
wxSoundFormatPcm(wxUint32 srate = 22500, wxUint8 bps = 8,
|
||||||
wxUint16 channels = 2, bool sign = TRUE,
|
wxUint16 channels = 2, bool sign = true,
|
||||||
int order = wxLITTLE_ENDIAN);
|
int order = wxLITTLE_ENDIAN);
|
||||||
~wxSoundFormatPcm();
|
~wxSoundFormatPcm();
|
||||||
|
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
// Created: 1997
|
// Created: 1997
|
||||||
// Updated: 1998
|
// Updated: 1998
|
||||||
// Copyright: (C) 1997, 1998, Guilhem Lavaux
|
// Copyright: (C) 1997, 1998, Guilhem Lavaux
|
||||||
// CVS: $Id$
|
// CVS: $Id$
|
||||||
// License: wxWindows license
|
// License: wxWindows license
|
||||||
// /////////////////////////////////////////////////////////////////////////////
|
// /////////////////////////////////////////////////////////////////////////////
|
||||||
/* Real -*- C++ -*- */
|
/* Real -*- C++ -*- */
|
||||||
@@ -68,7 +68,7 @@ public:
|
|||||||
// Dtor
|
// Dtor
|
||||||
virtual ~wxVideoBaseDriver();
|
virtual ~wxVideoBaseDriver();
|
||||||
|
|
||||||
// Usual functions ... They all return FALSE in case of errors.
|
// Usual functions ... They all return false in case of errors.
|
||||||
virtual bool Play() = 0;
|
virtual bool Play() = 0;
|
||||||
virtual bool Stop() = 0;
|
virtual bool Stop() = 0;
|
||||||
virtual bool Pause() = 0;
|
virtual bool Pause() = 0;
|
||||||
@@ -79,7 +79,7 @@ public:
|
|||||||
virtual bool GetSize(wxSize& size) const = 0;
|
virtual bool GetSize(wxSize& size) const = 0;
|
||||||
|
|
||||||
// Test the capability of the driver to handle the specified type
|
// Test the capability of the driver to handle the specified type
|
||||||
virtual bool IsCapable(wxVideoType WXUNUSED(v_type)) const { return FALSE; }
|
virtual bool IsCapable(wxVideoType WXUNUSED(v_type)) const { return false; }
|
||||||
|
|
||||||
// Return the video codec name
|
// Return the video codec name
|
||||||
virtual wxString GetMovieCodec() const = 0;
|
virtual wxString GetMovieCodec() const = 0;
|
||||||
|
@@ -245,7 +245,7 @@ void MMBoardSoundFile::SetPosition(MMBoardTime btime)
|
|||||||
|
|
||||||
bool MMBoardSoundFile::NeedWindow()
|
bool MMBoardSoundFile::NeedWindow()
|
||||||
{
|
{
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MMBoardSoundFile::SetWindow(wxWindow *WXUNUSED(window))
|
void MMBoardSoundFile::SetWindow(wxWindow *WXUNUSED(window))
|
||||||
@@ -310,17 +310,17 @@ wxString MMBoardSoundFile::GetStringInformation()
|
|||||||
case wxSOUND_PCM: {
|
case wxSOUND_PCM: {
|
||||||
wxSoundFormatPcm *pcm_format = (wxSoundFormatPcm *)format;
|
wxSoundFormatPcm *pcm_format = (wxSoundFormatPcm *)format;
|
||||||
|
|
||||||
info += wxString::Format(wxT("PCM %s %s\n"),
|
info += wxString::Format(wxT("PCM %s %s\n"),
|
||||||
pcm_format->Signed() ? wxT("signed") : wxT("unsigned"),
|
pcm_format->Signed() ? wxT("signed") : wxT("unsigned"),
|
||||||
pcm_format->GetOrder() == wxLITTLE_ENDIAN ? wxT("little endian") : wxT("big endian"));
|
pcm_format->GetOrder() == wxLITTLE_ENDIAN ? wxT("little endian") : wxT("big endian"));
|
||||||
info += wxString::Format(wxT("Sampling rate: %d\n")
|
info += wxString::Format(wxT("Sampling rate: %d\n")
|
||||||
wxT("Bits per sample: %d\n")
|
wxT("Bits per sample: %d\n")
|
||||||
wxT("Number of channels: %d\n"),
|
wxT("Number of channels: %d\n"),
|
||||||
pcm_format->GetSampleRate(),
|
pcm_format->GetSampleRate(),
|
||||||
pcm_format->GetBPS(),
|
pcm_format->GetBPS(),
|
||||||
pcm_format->GetChannels());
|
pcm_format->GetChannels());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxSOUND_MSADPCM: {
|
case wxSOUND_MSADPCM: {
|
||||||
wxSoundFormatMSAdpcm *adpcm_format = (wxSoundFormatMSAdpcm *)format;
|
wxSoundFormatMSAdpcm *adpcm_format = (wxSoundFormatMSAdpcm *)format;
|
||||||
@@ -334,13 +334,13 @@ wxString MMBoardSoundFile::GetStringInformation()
|
|||||||
}
|
}
|
||||||
case wxSOUND_ULAW: {
|
case wxSOUND_ULAW: {
|
||||||
wxSoundFormatUlaw *ulaw_format = (wxSoundFormatUlaw *)format;
|
wxSoundFormatUlaw *ulaw_format = (wxSoundFormatUlaw *)format;
|
||||||
info += wxT("ULAW\n");
|
info += wxT("ULAW\n");
|
||||||
info += wxString::Format(wxT("Sampling rate: %d\n"), ulaw_format->GetSampleRate());
|
info += wxString::Format(wxT("Sampling rate: %d\n"), ulaw_format->GetSampleRate());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
info += wxT("Unknown");
|
info += wxT("Unknown");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
@@ -375,7 +375,7 @@ MMBoardVideoFile::~MMBoardVideoFile()
|
|||||||
|
|
||||||
bool MMBoardVideoFile::NeedWindow()
|
bool MMBoardVideoFile::NeedWindow()
|
||||||
{
|
{
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MMBoardVideoFile::SetWindow(wxWindow *window)
|
void MMBoardVideoFile::SetWindow(wxWindow *window)
|
||||||
|
@@ -284,7 +284,7 @@ MMBoardFrame::MMBoardFrame(const wxString& title, const wxPoint& pos, const wxSi
|
|||||||
|
|
||||||
// Initialize main slider
|
// Initialize main slider
|
||||||
m_positionSlider = new wxSlider( m_panel, MMBoard_PositionSlider, 0, 0, 60,
|
m_positionSlider = new wxSlider( m_panel, MMBoard_PositionSlider, 0, 0, 60,
|
||||||
wxDefaultPosition, wxSize(300, -1),
|
wxDefaultPosition, wxSize(300, wxDefaultSize.y),
|
||||||
wxSL_HORIZONTAL | wxSL_AUTOTICKS);
|
wxSL_HORIZONTAL | wxSL_AUTOTICKS);
|
||||||
m_positionSlider->SetPageSize(60); // 60 secs
|
m_positionSlider->SetPageSize(60); // 60 secs
|
||||||
m_positionSlider->Disable();
|
m_positionSlider->Disable();
|
||||||
|
@@ -80,7 +80,7 @@ void wxCDAudioLinux::OpenDevice(const wxString& dev_name)
|
|||||||
struct cdrom_tocentry entry, old_entry;
|
struct cdrom_tocentry entry, old_entry;
|
||||||
struct cdrom_tochdr diskinf;
|
struct cdrom_tochdr diskinf;
|
||||||
struct cdrom_msf0 *msf = &entry.cdte_addr.msf,
|
struct cdrom_msf0 *msf = &entry.cdte_addr.msf,
|
||||||
*old_msf = &old_entry.cdte_addr.msf;
|
*old_msf = &old_entry.cdte_addr.msf;
|
||||||
wxCDtime *the_track;
|
wxCDtime *the_track;
|
||||||
wxCDtime tot_tm;
|
wxCDtime tot_tm;
|
||||||
wxUint8 nb_tracks, i;
|
wxUint8 nb_tracks, i;
|
||||||
|
@@ -46,7 +46,7 @@
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxCDAudioWin, wxCDAudio)
|
IMPLEMENT_DYNAMIC_CLASS(wxCDAudioWin, wxCDAudio)
|
||||||
|
|
||||||
wxCDAudioWin::wxCDAudioWin(void)
|
wxCDAudioWin::wxCDAudioWin(void)
|
||||||
: wxCDAudio(), m_trksize(NULL), m_trkpos(NULL), m_toc(NULL), m_ok(TRUE)
|
: wxCDAudio(), m_trksize(NULL), m_trkpos(NULL), m_toc(NULL), m_ok(true)
|
||||||
{
|
{
|
||||||
MCI_OPEN_PARMS open_struct;
|
MCI_OPEN_PARMS open_struct;
|
||||||
MCI_SET_PARMS set_struct;
|
MCI_SET_PARMS set_struct;
|
||||||
@@ -56,7 +56,7 @@ wxCDAudioWin::wxCDAudioWin(void)
|
|||||||
DWORD ret = mciSendCommand((MCIDEVICEID)NULL, MCI_OPEN, MCI_OPEN_TYPE,
|
DWORD ret = mciSendCommand((MCIDEVICEID)NULL, MCI_OPEN, MCI_OPEN_TYPE,
|
||||||
(DWORD)&open_struct);
|
(DWORD)&open_struct);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
m_ok = FALSE;
|
m_ok = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_internal->dev_id = open_struct.wDeviceID;
|
m_internal->dev_id = open_struct.wDeviceID;
|
||||||
@@ -150,7 +150,7 @@ bool wxCDAudioWin::Play(const wxCDtime& beg_time, const wxCDtime& end_time)
|
|||||||
MCI_PLAY_PARMS play_struct;
|
MCI_PLAY_PARMS play_struct;
|
||||||
|
|
||||||
if (!m_ok)
|
if (!m_ok)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
tmsf = MCI_MAKE_TMSF(beg_time.track, beg_time.min,
|
tmsf = MCI_MAKE_TMSF(beg_time.track, beg_time.min,
|
||||||
beg_time.sec, 0);
|
beg_time.sec, 0);
|
||||||
@@ -160,13 +160,13 @@ bool wxCDAudioWin::Play(const wxCDtime& beg_time, const wxCDtime& end_time)
|
|||||||
play_struct.dwTo = tmsf;
|
play_struct.dwTo = tmsf;
|
||||||
|
|
||||||
mciSendCommand(m_internal->dev_id, MCI_PLAY, 0, (DWORD)&play_struct);
|
mciSendCommand(m_internal->dev_id, MCI_PLAY, 0, (DWORD)&play_struct);
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxCDAudioWin::Pause(void)
|
bool wxCDAudioWin::Pause(void)
|
||||||
{
|
{
|
||||||
if (!m_ok)
|
if (!m_ok)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return (mciSendCommand(m_internal->dev_id, MCI_PAUSE, 0, 0) == 0);
|
return (mciSendCommand(m_internal->dev_id, MCI_PAUSE, 0, 0) == 0);
|
||||||
}
|
}
|
||||||
@@ -174,7 +174,7 @@ bool wxCDAudioWin::Pause(void)
|
|||||||
bool wxCDAudioWin::Resume(void)
|
bool wxCDAudioWin::Resume(void)
|
||||||
{
|
{
|
||||||
if (!m_ok)
|
if (!m_ok)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return (mciSendCommand(m_internal->dev_id, MCI_RESUME, 0, 0) == 0);
|
return (mciSendCommand(m_internal->dev_id, MCI_RESUME, 0, 0) == 0);
|
||||||
}
|
}
|
||||||
|
@@ -31,65 +31,65 @@
|
|||||||
*
|
*
|
||||||
* u-law, A-law and linear PCM conversions.
|
* u-law, A-law and linear PCM conversions.
|
||||||
*/
|
*/
|
||||||
#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */
|
#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */
|
||||||
#define QUANT_MASK (0xf) /* Quantization field mask. */
|
#define QUANT_MASK (0xf) /* Quantization field mask. */
|
||||||
#define NSEGS (8) /* Number of A-law segments. */
|
#define NSEGS (8) /* Number of A-law segments. */
|
||||||
#define SEG_SHIFT (4) /* Left shift for segment number. */
|
#define SEG_SHIFT (4) /* Left shift for segment number. */
|
||||||
#define SEG_MASK (0x70) /* Segment field mask. */
|
#define SEG_MASK (0x70) /* Segment field mask. */
|
||||||
|
|
||||||
static short seg_end[8] = {0xFF, 0x1FF, 0x3FF, 0x7FF,
|
static short seg_end[8] = {0xFF, 0x1FF, 0x3FF, 0x7FF,
|
||||||
0xFFF, 0x1FFF, 0x3FFF, 0x7FFF};
|
0xFFF, 0x1FFF, 0x3FFF, 0x7FFF};
|
||||||
|
|
||||||
/* copy from CCITT G.711 specifications */
|
/* copy from CCITT G.711 specifications */
|
||||||
unsigned char _u2a[128] = { /* u- to A-law conversions */
|
unsigned char _u2a[128] = { /* u- to A-law conversions */
|
||||||
1, 1, 2, 2, 3, 3, 4, 4,
|
1, 1, 2, 2, 3, 3, 4, 4,
|
||||||
5, 5, 6, 6, 7, 7, 8, 8,
|
5, 5, 6, 6, 7, 7, 8, 8,
|
||||||
9, 10, 11, 12, 13, 14, 15, 16,
|
9, 10, 11, 12, 13, 14, 15, 16,
|
||||||
17, 18, 19, 20, 21, 22, 23, 24,
|
17, 18, 19, 20, 21, 22, 23, 24,
|
||||||
25, 27, 29, 31, 33, 34, 35, 36,
|
25, 27, 29, 31, 33, 34, 35, 36,
|
||||||
37, 38, 39, 40, 41, 42, 43, 44,
|
37, 38, 39, 40, 41, 42, 43, 44,
|
||||||
46, 48, 49, 50, 51, 52, 53, 54,
|
46, 48, 49, 50, 51, 52, 53, 54,
|
||||||
55, 56, 57, 58, 59, 60, 61, 62,
|
55, 56, 57, 58, 59, 60, 61, 62,
|
||||||
64, 65, 66, 67, 68, 69, 70, 71,
|
64, 65, 66, 67, 68, 69, 70, 71,
|
||||||
72, 73, 74, 75, 76, 77, 78, 79,
|
72, 73, 74, 75, 76, 77, 78, 79,
|
||||||
81, 82, 83, 84, 85, 86, 87, 88,
|
81, 82, 83, 84, 85, 86, 87, 88,
|
||||||
89, 90, 91, 92, 93, 94, 95, 96,
|
89, 90, 91, 92, 93, 94, 95, 96,
|
||||||
97, 98, 99, 100, 101, 102, 103, 104,
|
97, 98, 99, 100, 101, 102, 103, 104,
|
||||||
105, 106, 107, 108, 109, 110, 111, 112,
|
105, 106, 107, 108, 109, 110, 111, 112,
|
||||||
113, 114, 115, 116, 117, 118, 119, 120,
|
113, 114, 115, 116, 117, 118, 119, 120,
|
||||||
121, 122, 123, 124, 125, 126, 127, 128};
|
121, 122, 123, 124, 125, 126, 127, 128};
|
||||||
|
|
||||||
unsigned char _a2u[128] = { /* A- to u-law conversions */
|
unsigned char _a2u[128] = { /* A- to u-law conversions */
|
||||||
1, 3, 5, 7, 9, 11, 13, 15,
|
1, 3, 5, 7, 9, 11, 13, 15,
|
||||||
16, 17, 18, 19, 20, 21, 22, 23,
|
16, 17, 18, 19, 20, 21, 22, 23,
|
||||||
24, 25, 26, 27, 28, 29, 30, 31,
|
24, 25, 26, 27, 28, 29, 30, 31,
|
||||||
32, 32, 33, 33, 34, 34, 35, 35,
|
32, 32, 33, 33, 34, 34, 35, 35,
|
||||||
36, 37, 38, 39, 40, 41, 42, 43,
|
36, 37, 38, 39, 40, 41, 42, 43,
|
||||||
44, 45, 46, 47, 48, 48, 49, 49,
|
44, 45, 46, 47, 48, 48, 49, 49,
|
||||||
50, 51, 52, 53, 54, 55, 56, 57,
|
50, 51, 52, 53, 54, 55, 56, 57,
|
||||||
58, 59, 60, 61, 62, 63, 64, 64,
|
58, 59, 60, 61, 62, 63, 64, 64,
|
||||||
65, 66, 67, 68, 69, 70, 71, 72,
|
65, 66, 67, 68, 69, 70, 71, 72,
|
||||||
73, 74, 75, 76, 77, 78, 79, 79,
|
73, 74, 75, 76, 77, 78, 79, 79,
|
||||||
80, 81, 82, 83, 84, 85, 86, 87,
|
80, 81, 82, 83, 84, 85, 86, 87,
|
||||||
88, 89, 90, 91, 92, 93, 94, 95,
|
88, 89, 90, 91, 92, 93, 94, 95,
|
||||||
96, 97, 98, 99, 100, 101, 102, 103,
|
96, 97, 98, 99, 100, 101, 102, 103,
|
||||||
104, 105, 106, 107, 108, 109, 110, 111,
|
104, 105, 106, 107, 108, 109, 110, 111,
|
||||||
112, 113, 114, 115, 116, 117, 118, 119,
|
112, 113, 114, 115, 116, 117, 118, 119,
|
||||||
120, 121, 122, 123, 124, 125, 126, 127};
|
120, 121, 122, 123, 124, 125, 126, 127};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
search(
|
search(
|
||||||
int val,
|
int val,
|
||||||
short *table,
|
short *table,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
if (val <= *table++)
|
if (val <= *table++)
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
return (size);
|
return (size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -97,50 +97,50 @@ search(
|
|||||||
*
|
*
|
||||||
* linear2alaw() accepts an 16-bit integer and encodes it as A-law data.
|
* linear2alaw() accepts an 16-bit integer and encodes it as A-law data.
|
||||||
*
|
*
|
||||||
* Linear Input Code Compressed Code
|
* Linear Input Code Compressed Code
|
||||||
* ------------------------ ---------------
|
* ------------------------ ---------------
|
||||||
* 0000000wxyza 000wxyz
|
* 0000000wxyza 000wxyz
|
||||||
* 0000001wxyza 001wxyz
|
* 0000001wxyza 001wxyz
|
||||||
* 000001wxyzab 010wxyz
|
* 000001wxyzab 010wxyz
|
||||||
* 00001wxyzabc 011wxyz
|
* 00001wxyzabc 011wxyz
|
||||||
* 0001wxyzabcd 100wxyz
|
* 0001wxyzabcd 100wxyz
|
||||||
* 001wxyzabcde 101wxyz
|
* 001wxyzabcde 101wxyz
|
||||||
* 01wxyzabcdef 110wxyz
|
* 01wxyzabcdef 110wxyz
|
||||||
* 1wxyzabcdefg 111wxyz
|
* 1wxyzabcdefg 111wxyz
|
||||||
*
|
*
|
||||||
* For further information see John C. Bellamy's Digital Telephony, 1982,
|
* For further information see John C. Bellamy's Digital Telephony, 1982,
|
||||||
* John Wiley & Sons, pps 98-111 and 472-476.
|
* John Wiley & Sons, pps 98-111 and 472-476.
|
||||||
*/
|
*/
|
||||||
unsigned char
|
unsigned char
|
||||||
linear2alaw(
|
linear2alaw(
|
||||||
int pcm_val) /* 2's complement (16-bit range) */
|
int pcm_val) /* 2's complement (16-bit range) */
|
||||||
{
|
{
|
||||||
int mask;
|
int mask;
|
||||||
int seg;
|
int seg;
|
||||||
unsigned char aval;
|
unsigned char aval;
|
||||||
|
|
||||||
if (pcm_val >= 0) {
|
if (pcm_val >= 0) {
|
||||||
mask = 0xD5; /* sign (7th) bit = 1 */
|
mask = 0xD5; /* sign (7th) bit = 1 */
|
||||||
} else {
|
} else {
|
||||||
mask = 0x55; /* sign bit = 0 */
|
mask = 0x55; /* sign bit = 0 */
|
||||||
pcm_val = -pcm_val - 8;
|
pcm_val = -pcm_val - 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the scaled magnitude to segment number. */
|
/* Convert the scaled magnitude to segment number. */
|
||||||
seg = search(pcm_val, seg_end, 8);
|
seg = search(pcm_val, seg_end, 8);
|
||||||
|
|
||||||
/* Combine the sign, segment, and quantization bits. */
|
/* Combine the sign, segment, and quantization bits. */
|
||||||
|
|
||||||
if (seg >= 8) /* out of range, return maximum value. */
|
if (seg >= 8) /* out of range, return maximum value. */
|
||||||
return (0x7F ^ mask);
|
return (0x7F ^ mask);
|
||||||
else {
|
else {
|
||||||
aval = seg << SEG_SHIFT;
|
aval = seg << SEG_SHIFT;
|
||||||
if (seg < 2)
|
if (seg < 2)
|
||||||
aval |= (pcm_val >> 4) & QUANT_MASK;
|
aval |= (pcm_val >> 4) & QUANT_MASK;
|
||||||
else
|
else
|
||||||
aval |= (pcm_val >> (seg + 3)) & QUANT_MASK;
|
aval |= (pcm_val >> (seg + 3)) & QUANT_MASK;
|
||||||
return (aval ^ mask);
|
return (aval ^ mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -149,30 +149,30 @@ linear2alaw(
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
alaw2linear(
|
alaw2linear(
|
||||||
unsigned char a_val)
|
unsigned char a_val)
|
||||||
{
|
{
|
||||||
int t;
|
int t;
|
||||||
int seg;
|
int seg;
|
||||||
|
|
||||||
a_val ^= 0x55;
|
a_val ^= 0x55;
|
||||||
|
|
||||||
t = (a_val & QUANT_MASK) << 4;
|
t = (a_val & QUANT_MASK) << 4;
|
||||||
seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT;
|
seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT;
|
||||||
switch (seg) {
|
switch (seg) {
|
||||||
case 0:
|
case 0:
|
||||||
t += 8;
|
t += 8;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
t += 0x108;
|
t += 0x108;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
t += 0x108;
|
t += 0x108;
|
||||||
t <<= seg - 1;
|
t <<= seg - 1;
|
||||||
}
|
}
|
||||||
return ((a_val & SIGN_BIT) ? t : -t);
|
return ((a_val & SIGN_BIT) ? t : -t);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BIAS (0x84) /* Bias for linear code. */
|
#define BIAS (0x84) /* Bias for linear code. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* linear2ulaw() - Convert a linear PCM value to u-law
|
* linear2ulaw() - Convert a linear PCM value to u-law
|
||||||
@@ -181,16 +181,16 @@ alaw2linear(
|
|||||||
* is biased by adding 33 which shifts the encoding range from (0 - 8158) to
|
* is biased by adding 33 which shifts the encoding range from (0 - 8158) to
|
||||||
* (33 - 8191). The result can be seen in the following encoding table:
|
* (33 - 8191). The result can be seen in the following encoding table:
|
||||||
*
|
*
|
||||||
* Biased Linear Input Code Compressed Code
|
* Biased Linear Input Code Compressed Code
|
||||||
* ------------------------ ---------------
|
* ------------------------ ---------------
|
||||||
* 00000001wxyza 000wxyz
|
* 00000001wxyza 000wxyz
|
||||||
* 0000001wxyzab 001wxyz
|
* 0000001wxyzab 001wxyz
|
||||||
* 000001wxyzabc 010wxyz
|
* 000001wxyzabc 010wxyz
|
||||||
* 00001wxyzabcd 011wxyz
|
* 00001wxyzabcd 011wxyz
|
||||||
* 0001wxyzabcde 100wxyz
|
* 0001wxyzabcde 100wxyz
|
||||||
* 001wxyzabcdef 101wxyz
|
* 001wxyzabcdef 101wxyz
|
||||||
* 01wxyzabcdefg 110wxyz
|
* 01wxyzabcdefg 110wxyz
|
||||||
* 1wxyzabcdefgh 111wxyz
|
* 1wxyzabcdefgh 111wxyz
|
||||||
*
|
*
|
||||||
* Each biased linear code has a leading 1 which identifies the segment
|
* Each biased linear code has a leading 1 which identifies the segment
|
||||||
* number. The value of the segment number is equal to 7 minus the number
|
* number. The value of the segment number is equal to 7 minus the number
|
||||||
@@ -205,34 +205,34 @@ alaw2linear(
|
|||||||
*/
|
*/
|
||||||
unsigned char
|
unsigned char
|
||||||
linear2ulaw(
|
linear2ulaw(
|
||||||
int pcm_val) /* 2's complement (16-bit range) */
|
int pcm_val) /* 2's complement (16-bit range) */
|
||||||
{
|
{
|
||||||
int mask;
|
int mask;
|
||||||
int seg;
|
int seg;
|
||||||
unsigned char uval;
|
unsigned char uval;
|
||||||
|
|
||||||
/* Get the sign and the magnitude of the value. */
|
/* Get the sign and the magnitude of the value. */
|
||||||
if (pcm_val < 0) {
|
if (pcm_val < 0) {
|
||||||
pcm_val = BIAS - pcm_val;
|
pcm_val = BIAS - pcm_val;
|
||||||
mask = 0x7F;
|
mask = 0x7F;
|
||||||
} else {
|
} else {
|
||||||
pcm_val += BIAS;
|
pcm_val += BIAS;
|
||||||
mask = 0xFF;
|
mask = 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the scaled magnitude to segment number. */
|
/* Convert the scaled magnitude to segment number. */
|
||||||
seg = search(pcm_val, seg_end, 8);
|
seg = search(pcm_val, seg_end, 8);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Combine the sign, segment, quantization bits;
|
* Combine the sign, segment, quantization bits;
|
||||||
* and complement the code word.
|
* and complement the code word.
|
||||||
*/
|
*/
|
||||||
if (seg >= 8) /* out of range, return maximum value. */
|
if (seg >= 8) /* out of range, return maximum value. */
|
||||||
return (0x7F ^ mask);
|
return (0x7F ^ mask);
|
||||||
else {
|
else {
|
||||||
uval = (seg << 4) | ((pcm_val >> (seg + 3)) & 0xF);
|
uval = (seg << 4) | ((pcm_val >> (seg + 3)) & 0xF);
|
||||||
return (uval ^ mask);
|
return (uval ^ mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,39 +247,39 @@ linear2ulaw(
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
ulaw2linear(
|
ulaw2linear(
|
||||||
unsigned char u_val)
|
unsigned char u_val)
|
||||||
{
|
{
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
/* Complement to obtain normal u-law value. */
|
/* Complement to obtain normal u-law value. */
|
||||||
u_val = ~u_val;
|
u_val = ~u_val;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Extract and bias the quantization bits. Then
|
* Extract and bias the quantization bits. Then
|
||||||
* shift up by the segment number and subtract out the bias.
|
* shift up by the segment number and subtract out the bias.
|
||||||
*/
|
*/
|
||||||
t = ((u_val & QUANT_MASK) << 3) + BIAS;
|
t = ((u_val & QUANT_MASK) << 3) + BIAS;
|
||||||
t <<= ((unsigned)u_val & SEG_MASK) >> SEG_SHIFT;
|
t <<= ((unsigned)u_val & SEG_MASK) >> SEG_SHIFT;
|
||||||
|
|
||||||
return ((u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS));
|
return ((u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A-law to u-law conversion */
|
/* A-law to u-law conversion */
|
||||||
unsigned char
|
unsigned char
|
||||||
alaw2ulaw(
|
alaw2ulaw(
|
||||||
unsigned char aval)
|
unsigned char aval)
|
||||||
{
|
{
|
||||||
aval &= 0xff;
|
aval &= 0xff;
|
||||||
return ((aval & 0x80) ? (0xFF ^ _a2u[aval ^ 0xD5]) :
|
return ((aval & 0x80) ? (0xFF ^ _a2u[aval ^ 0xD5]) :
|
||||||
(0x7F ^ _a2u[aval ^ 0x55]));
|
(0x7F ^ _a2u[aval ^ 0x55]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* u-law to A-law conversion */
|
/* u-law to A-law conversion */
|
||||||
unsigned char
|
unsigned char
|
||||||
ulaw2alaw(
|
ulaw2alaw(
|
||||||
unsigned char uval)
|
unsigned char uval)
|
||||||
{
|
{
|
||||||
uval &= 0xff;
|
uval &= 0xff;
|
||||||
return ((uval & 0x80) ? (0xD5 ^ (_u2a[0xFF ^ uval] - 1)) :
|
return ((uval & 0x80) ? (0xD5 ^ (_u2a[0xFF ^ uval] - 1)) :
|
||||||
(0x55 ^ (_u2a[0x7F ^ uval] - 1)));
|
(0x55 ^ (_u2a[0x7F ^ uval] - 1)));
|
||||||
}
|
}
|
||||||
|
@@ -57,19 +57,19 @@ static short qtab_721[7] = {-124, 80, 178, 246, 300, 349, 400};
|
|||||||
* Maps G.721 code word to reconstructed scale factor normalized log
|
* Maps G.721 code word to reconstructed scale factor normalized log
|
||||||
* magnitude values.
|
* magnitude values.
|
||||||
*/
|
*/
|
||||||
static short _dqlntab[16] = {-2048, 4, 135, 213, 273, 323, 373, 425,
|
static short _dqlntab[16] = {-2048, 4, 135, 213, 273, 323, 373, 425,
|
||||||
425, 373, 323, 273, 213, 135, 4, -2048};
|
425, 373, 323, 273, 213, 135, 4, -2048};
|
||||||
|
|
||||||
/* Maps G.721 code word to log of scale factor multiplier. */
|
/* Maps G.721 code word to log of scale factor multiplier. */
|
||||||
static short _witab[16] = {-12, 18, 41, 64, 112, 198, 355, 1122,
|
static short _witab[16] = {-12, 18, 41, 64, 112, 198, 355, 1122,
|
||||||
1122, 355, 198, 112, 64, 41, 18, -12};
|
1122, 355, 198, 112, 64, 41, 18, -12};
|
||||||
/*
|
/*
|
||||||
* Maps G.721 code words to a set of values whose long and short
|
* Maps G.721 code words to a set of values whose long and short
|
||||||
* term averages are computed and then compared to give an indication
|
* term averages are computed and then compared to give an indication
|
||||||
* how stationary (steady state) the signal is.
|
* how stationary (steady state) the signal is.
|
||||||
*/
|
*/
|
||||||
static short _fitab[16] = {0, 0, 0, 0x200, 0x200, 0x200, 0x600, 0xE00,
|
static short _fitab[16] = {0, 0, 0, 0x200, 0x200, 0x200, 0x600, 0xE00,
|
||||||
0xE00, 0x600, 0x200, 0x200, 0x200, 0, 0, 0};
|
0xE00, 0x600, 0x200, 0x200, 0x200, 0, 0, 0};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* g721_encoder()
|
* g721_encoder()
|
||||||
@@ -79,50 +79,50 @@ static short _fitab[16] = {0, 0, 0, 0x200, 0x200, 0x200, 0x600, 0xE00,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
g721_encoder(
|
g721_encoder(
|
||||||
int sl,
|
int sl,
|
||||||
int in_coding,
|
int in_coding,
|
||||||
struct g72x_state *state_ptr)
|
struct g72x_state *state_ptr)
|
||||||
{
|
{
|
||||||
short sezi, se, sez; /* ACCUM */
|
short sezi, se, sez; /* ACCUM */
|
||||||
short d; /* SUBTA */
|
short d; /* SUBTA */
|
||||||
short sr; /* ADDB */
|
short sr; /* ADDB */
|
||||||
short y; /* MIX */
|
short y; /* MIX */
|
||||||
short dqsez; /* ADDC */
|
short dqsez; /* ADDC */
|
||||||
short dq, i;
|
short dq, i;
|
||||||
|
|
||||||
switch (in_coding) { /* linearize input sample to 14-bit PCM */
|
switch (in_coding) { /* linearize input sample to 14-bit PCM */
|
||||||
case AUDIO_ENCODING_ALAW:
|
case AUDIO_ENCODING_ALAW:
|
||||||
sl = alaw2linear(sl) >> 2;
|
sl = alaw2linear(sl) >> 2;
|
||||||
break;
|
break;
|
||||||
case AUDIO_ENCODING_ULAW:
|
case AUDIO_ENCODING_ULAW:
|
||||||
sl = ulaw2linear(sl) >> 2;
|
sl = ulaw2linear(sl) >> 2;
|
||||||
break;
|
break;
|
||||||
case AUDIO_ENCODING_LINEAR:
|
case AUDIO_ENCODING_LINEAR:
|
||||||
sl = ((short)sl) >> 2; /* 14-bit dynamic range */
|
sl = ((short)sl) >> 2; /* 14-bit dynamic range */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sezi = predictor_zero(state_ptr);
|
sezi = predictor_zero(state_ptr);
|
||||||
sez = sezi >> 1;
|
sez = sezi >> 1;
|
||||||
se = (sezi + predictor_pole(state_ptr)) >> 1; /* estimated signal */
|
se = (sezi + predictor_pole(state_ptr)) >> 1; /* estimated signal */
|
||||||
|
|
||||||
d = sl - se; /* estimation difference */
|
d = sl - se; /* estimation difference */
|
||||||
|
|
||||||
/* quantize the prediction difference */
|
/* quantize the prediction difference */
|
||||||
y = step_size(state_ptr); /* quantizer step size */
|
y = step_size(state_ptr); /* quantizer step size */
|
||||||
i = quantize(d, y, qtab_721, 7); /* i = ADPCM code */
|
i = quantize(d, y, qtab_721, 7); /* i = ADPCM code */
|
||||||
|
|
||||||
dq = reconstruct(i & 8, _dqlntab[i], y); /* quantized est diff */
|
dq = reconstruct(i & 8, _dqlntab[i], y); /* quantized est diff */
|
||||||
|
|
||||||
sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconst. signal */
|
sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconst. signal */
|
||||||
|
|
||||||
dqsez = sr + sez - se; /* pole prediction diff. */
|
dqsez = sr + sez - se; /* pole prediction diff. */
|
||||||
|
|
||||||
update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr);
|
update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr);
|
||||||
|
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -136,40 +136,40 @@ g721_encoder(
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
g721_decoder(
|
g721_decoder(
|
||||||
int i,
|
int i,
|
||||||
int out_coding,
|
int out_coding,
|
||||||
struct g72x_state *state_ptr)
|
struct g72x_state *state_ptr)
|
||||||
{
|
{
|
||||||
short sezi, sei, sez, se; /* ACCUM */
|
short sezi, sei, sez, se; /* ACCUM */
|
||||||
short y; /* MIX */
|
short y; /* MIX */
|
||||||
short sr; /* ADDB */
|
short sr; /* ADDB */
|
||||||
short dq;
|
short dq;
|
||||||
short dqsez;
|
short dqsez;
|
||||||
|
|
||||||
i &= 0x0f; /* mask to get proper bits */
|
i &= 0x0f; /* mask to get proper bits */
|
||||||
sezi = predictor_zero(state_ptr);
|
sezi = predictor_zero(state_ptr);
|
||||||
sez = sezi >> 1;
|
sez = sezi >> 1;
|
||||||
sei = sezi + predictor_pole(state_ptr);
|
sei = sezi + predictor_pole(state_ptr);
|
||||||
se = sei >> 1; /* se = estimated signal */
|
se = sei >> 1; /* se = estimated signal */
|
||||||
|
|
||||||
y = step_size(state_ptr); /* dynamic quantizer step size */
|
y = step_size(state_ptr); /* dynamic quantizer step size */
|
||||||
|
|
||||||
dq = reconstruct(i & 0x08, _dqlntab[i], y); /* quantized diff. */
|
dq = reconstruct(i & 0x08, _dqlntab[i], y); /* quantized diff. */
|
||||||
|
|
||||||
sr = (dq < 0) ? (se - (dq & 0x3FFF)) : se + dq; /* reconst. signal */
|
sr = (dq < 0) ? (se - (dq & 0x3FFF)) : se + dq; /* reconst. signal */
|
||||||
|
|
||||||
dqsez = sr - se + sez; /* pole prediction diff. */
|
dqsez = sr - se + sez; /* pole prediction diff. */
|
||||||
|
|
||||||
update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr);
|
update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr);
|
||||||
|
|
||||||
switch (out_coding) {
|
switch (out_coding) {
|
||||||
case AUDIO_ENCODING_ALAW:
|
case AUDIO_ENCODING_ALAW:
|
||||||
return (tandem_adjust_alaw(sr, se, y, i, 8, qtab_721));
|
return (tandem_adjust_alaw(sr, se, y, i, 8, qtab_721));
|
||||||
case AUDIO_ENCODING_ULAW:
|
case AUDIO_ENCODING_ULAW:
|
||||||
return (tandem_adjust_ulaw(sr, se, y, i, 8, qtab_721));
|
return (tandem_adjust_ulaw(sr, se, y, i, 8, qtab_721));
|
||||||
case AUDIO_ENCODING_LINEAR:
|
case AUDIO_ENCODING_LINEAR:
|
||||||
return (sr << 2); /* sr was 14-bit dynamic range */
|
return (sr << 2); /* sr was 14-bit dynamic range */
|
||||||
default:
|
default:
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,17 +44,17 @@
|
|||||||
* Maps G.723_24 code word to reconstructed scale factor normalized log
|
* Maps G.723_24 code word to reconstructed scale factor normalized log
|
||||||
* magnitude values.
|
* magnitude values.
|
||||||
*/
|
*/
|
||||||
static short _dqlntab[8] = {-2048, 135, 273, 373, 373, 273, 135, -2048};
|
static short _dqlntab[8] = {-2048, 135, 273, 373, 373, 273, 135, -2048};
|
||||||
|
|
||||||
/* Maps G.723_24 code word to log of scale factor multiplier. */
|
/* Maps G.723_24 code word to log of scale factor multiplier. */
|
||||||
static short _witab[8] = {-128, 960, 4384, 18624, 18624, 4384, 960, -128};
|
static short _witab[8] = {-128, 960, 4384, 18624, 18624, 4384, 960, -128};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Maps G.723_24 code words to a set of values whose long and short
|
* Maps G.723_24 code words to a set of values whose long and short
|
||||||
* term averages are computed and then compared to give an indication
|
* term averages are computed and then compared to give an indication
|
||||||
* how stationary (steady state) the signal is.
|
* how stationary (steady state) the signal is.
|
||||||
*/
|
*/
|
||||||
static short _fitab[8] = {0, 0x200, 0x400, 0xE00, 0xE00, 0x400, 0x200, 0};
|
static short _fitab[8] = {0, 0x200, 0x400, 0xE00, 0xE00, 0x400, 0x200, 0};
|
||||||
|
|
||||||
static short qtab_723_24[3] = {8, 218, 331};
|
static short qtab_723_24[3] = {8, 218, 331};
|
||||||
|
|
||||||
@@ -66,50 +66,50 @@ static short qtab_723_24[3] = {8, 218, 331};
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
g723_24_encoder(
|
g723_24_encoder(
|
||||||
int sl,
|
int sl,
|
||||||
int in_coding,
|
int in_coding,
|
||||||
struct g72x_state *state_ptr)
|
struct g72x_state *state_ptr)
|
||||||
{
|
{
|
||||||
short sei, sezi, se, sez; /* ACCUM */
|
short sei, sezi, se, sez; /* ACCUM */
|
||||||
short d; /* SUBTA */
|
short d; /* SUBTA */
|
||||||
short y; /* MIX */
|
short y; /* MIX */
|
||||||
short sr; /* ADDB */
|
short sr; /* ADDB */
|
||||||
short dqsez; /* ADDC */
|
short dqsez; /* ADDC */
|
||||||
short dq, i;
|
short dq, i;
|
||||||
|
|
||||||
switch (in_coding) { /* linearize input sample to 14-bit PCM */
|
switch (in_coding) { /* linearize input sample to 14-bit PCM */
|
||||||
case AUDIO_ENCODING_ALAW:
|
case AUDIO_ENCODING_ALAW:
|
||||||
sl = alaw2linear(sl) >> 2;
|
sl = alaw2linear(sl) >> 2;
|
||||||
break;
|
break;
|
||||||
case AUDIO_ENCODING_ULAW:
|
case AUDIO_ENCODING_ULAW:
|
||||||
sl = ulaw2linear(sl) >> 2;
|
sl = ulaw2linear(sl) >> 2;
|
||||||
break;
|
break;
|
||||||
case AUDIO_ENCODING_LINEAR:
|
case AUDIO_ENCODING_LINEAR:
|
||||||
sl = ((short)sl) >> 2; /* sl of 14-bit dynamic range */
|
sl = ((short)sl) >> 2; /* sl of 14-bit dynamic range */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sezi = predictor_zero(state_ptr);
|
sezi = predictor_zero(state_ptr);
|
||||||
sez = sezi >> 1;
|
sez = sezi >> 1;
|
||||||
sei = sezi + predictor_pole(state_ptr);
|
sei = sezi + predictor_pole(state_ptr);
|
||||||
se = sei >> 1; /* se = estimated signal */
|
se = sei >> 1; /* se = estimated signal */
|
||||||
|
|
||||||
d = sl - se; /* d = estimation diff. */
|
d = sl - se; /* d = estimation diff. */
|
||||||
|
|
||||||
/* quantize prediction difference d */
|
/* quantize prediction difference d */
|
||||||
y = step_size(state_ptr); /* quantizer step size */
|
y = step_size(state_ptr); /* quantizer step size */
|
||||||
i = quantize(d, y, qtab_723_24, 3); /* i = ADPCM code */
|
i = quantize(d, y, qtab_723_24, 3); /* i = ADPCM code */
|
||||||
dq = reconstruct(i & 4, _dqlntab[i], y); /* quantized diff. */
|
dq = reconstruct(i & 4, _dqlntab[i], y); /* quantized diff. */
|
||||||
|
|
||||||
sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconstructed signal */
|
sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconstructed signal */
|
||||||
|
|
||||||
dqsez = sr + sez - se; /* pole prediction diff. */
|
dqsez = sr + sez - se; /* pole prediction diff. */
|
||||||
|
|
||||||
update(3, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr);
|
update(3, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr);
|
||||||
|
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -121,39 +121,39 @@ g723_24_encoder(
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
g723_24_decoder(
|
g723_24_decoder(
|
||||||
int i,
|
int i,
|
||||||
int out_coding,
|
int out_coding,
|
||||||
struct g72x_state *state_ptr)
|
struct g72x_state *state_ptr)
|
||||||
{
|
{
|
||||||
short sezi, sei, sez, se; /* ACCUM */
|
short sezi, sei, sez, se; /* ACCUM */
|
||||||
short y; /* MIX */
|
short y; /* MIX */
|
||||||
short sr; /* ADDB */
|
short sr; /* ADDB */
|
||||||
short dq;
|
short dq;
|
||||||
short dqsez;
|
short dqsez;
|
||||||
|
|
||||||
i &= 0x07; /* mask to get proper bits */
|
i &= 0x07; /* mask to get proper bits */
|
||||||
sezi = predictor_zero(state_ptr);
|
sezi = predictor_zero(state_ptr);
|
||||||
sez = sezi >> 1;
|
sez = sezi >> 1;
|
||||||
sei = sezi + predictor_pole(state_ptr);
|
sei = sezi + predictor_pole(state_ptr);
|
||||||
se = sei >> 1; /* se = estimated signal */
|
se = sei >> 1; /* se = estimated signal */
|
||||||
|
|
||||||
y = step_size(state_ptr); /* adaptive quantizer step size */
|
y = step_size(state_ptr); /* adaptive quantizer step size */
|
||||||
dq = reconstruct(i & 0x04, _dqlntab[i], y); /* unquantize pred diff */
|
dq = reconstruct(i & 0x04, _dqlntab[i], y); /* unquantize pred diff */
|
||||||
|
|
||||||
sr = (dq < 0) ? (se - (dq & 0x3FFF)) : (se + dq); /* reconst. signal */
|
sr = (dq < 0) ? (se - (dq & 0x3FFF)) : (se + dq); /* reconst. signal */
|
||||||
|
|
||||||
dqsez = sr - se + sez; /* pole prediction diff. */
|
dqsez = sr - se + sez; /* pole prediction diff. */
|
||||||
|
|
||||||
update(3, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr);
|
update(3, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr);
|
||||||
|
|
||||||
switch (out_coding) {
|
switch (out_coding) {
|
||||||
case AUDIO_ENCODING_ALAW:
|
case AUDIO_ENCODING_ALAW:
|
||||||
return (tandem_adjust_alaw(sr, se, y, i, 4, qtab_723_24));
|
return (tandem_adjust_alaw(sr, se, y, i, 4, qtab_723_24));
|
||||||
case AUDIO_ENCODING_ULAW:
|
case AUDIO_ENCODING_ULAW:
|
||||||
return (tandem_adjust_ulaw(sr, se, y, i, 4, qtab_723_24));
|
return (tandem_adjust_ulaw(sr, se, y, i, 4, qtab_723_24));
|
||||||
case AUDIO_ENCODING_LINEAR:
|
case AUDIO_ENCODING_LINEAR:
|
||||||
return (sr << 2); /* sr was of 14-bit dynamic range */
|
return (sr << 2); /* sr was of 14-bit dynamic range */
|
||||||
default:
|
default:
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -52,29 +52,29 @@
|
|||||||
* Maps G.723_40 code word to ructeconstructed scale factor normalized log
|
* Maps G.723_40 code word to ructeconstructed scale factor normalized log
|
||||||
* magnitude values.
|
* magnitude values.
|
||||||
*/
|
*/
|
||||||
static short _dqlntab[32] = {-2048, -66, 28, 104, 169, 224, 274, 318,
|
static short _dqlntab[32] = {-2048, -66, 28, 104, 169, 224, 274, 318,
|
||||||
358, 395, 429, 459, 488, 514, 539, 566,
|
358, 395, 429, 459, 488, 514, 539, 566,
|
||||||
566, 539, 514, 488, 459, 429, 395, 358,
|
566, 539, 514, 488, 459, 429, 395, 358,
|
||||||
318, 274, 224, 169, 104, 28, -66, -2048};
|
318, 274, 224, 169, 104, 28, -66, -2048};
|
||||||
|
|
||||||
/* Maps G.723_40 code word to log of scale factor multiplier. */
|
/* Maps G.723_40 code word to log of scale factor multiplier. */
|
||||||
static short _witab[32] = {448, 448, 768, 1248, 1280, 1312, 1856, 3200,
|
static short _witab[32] = {448, 448, 768, 1248, 1280, 1312, 1856, 3200,
|
||||||
4512, 5728, 7008, 8960, 11456, 14080, 16928, 22272,
|
4512, 5728, 7008, 8960, 11456, 14080, 16928, 22272,
|
||||||
22272, 16928, 14080, 11456, 8960, 7008, 5728, 4512,
|
22272, 16928, 14080, 11456, 8960, 7008, 5728, 4512,
|
||||||
3200, 1856, 1312, 1280, 1248, 768, 448, 448};
|
3200, 1856, 1312, 1280, 1248, 768, 448, 448};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Maps G.723_40 code words to a set of values whose long and short
|
* Maps G.723_40 code words to a set of values whose long and short
|
||||||
* term averages are computed and then compared to give an indication
|
* term averages are computed and then compared to give an indication
|
||||||
* how stationary (steady state) the signal is.
|
* how stationary (steady state) the signal is.
|
||||||
*/
|
*/
|
||||||
static short _fitab[32] = {0, 0, 0, 0, 0, 0x200, 0x200, 0x200,
|
static short _fitab[32] = {0, 0, 0, 0, 0, 0x200, 0x200, 0x200,
|
||||||
0x200, 0x200, 0x400, 0x600, 0x800, 0xA00, 0xC00, 0xC00,
|
0x200, 0x200, 0x400, 0x600, 0x800, 0xA00, 0xC00, 0xC00,
|
||||||
0xC00, 0xC00, 0xA00, 0x800, 0x600, 0x400, 0x200, 0x200,
|
0xC00, 0xC00, 0xA00, 0x800, 0x600, 0x400, 0x200, 0x200,
|
||||||
0x200, 0x200, 0x200, 0, 0, 0, 0, 0};
|
0x200, 0x200, 0x200, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
static short qtab_723_40[15] = {-122, -16, 68, 139, 198, 250, 298, 339,
|
static short qtab_723_40[15] = {-122, -16, 68, 139, 198, 250, 298, 339,
|
||||||
378, 413, 445, 475, 502, 528, 553};
|
378, 413, 445, 475, 502, 528, 553};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* g723_40_encoder()
|
* g723_40_encoder()
|
||||||
@@ -85,51 +85,51 @@ static short qtab_723_40[15] = {-122, -16, 68, 139, 198, 250, 298, 339,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
g723_40_encoder(
|
g723_40_encoder(
|
||||||
int sl,
|
int sl,
|
||||||
int in_coding,
|
int in_coding,
|
||||||
struct g72x_state *state_ptr)
|
struct g72x_state *state_ptr)
|
||||||
{
|
{
|
||||||
short sei, sezi, se, sez; /* ACCUM */
|
short sei, sezi, se, sez; /* ACCUM */
|
||||||
short d; /* SUBTA */
|
short d; /* SUBTA */
|
||||||
short y; /* MIX */
|
short y; /* MIX */
|
||||||
short sr; /* ADDB */
|
short sr; /* ADDB */
|
||||||
short dqsez; /* ADDC */
|
short dqsez; /* ADDC */
|
||||||
short dq, i;
|
short dq, i;
|
||||||
|
|
||||||
switch (in_coding) { /* linearize input sample to 14-bit PCM */
|
switch (in_coding) { /* linearize input sample to 14-bit PCM */
|
||||||
case AUDIO_ENCODING_ALAW:
|
case AUDIO_ENCODING_ALAW:
|
||||||
sl = alaw2linear(sl) >> 2;
|
sl = alaw2linear(sl) >> 2;
|
||||||
break;
|
break;
|
||||||
case AUDIO_ENCODING_ULAW:
|
case AUDIO_ENCODING_ULAW:
|
||||||
sl = ulaw2linear(sl) >> 2;
|
sl = ulaw2linear(sl) >> 2;
|
||||||
break;
|
break;
|
||||||
case AUDIO_ENCODING_LINEAR:
|
case AUDIO_ENCODING_LINEAR:
|
||||||
sl = ((short) sl) >> 2; /* sl of 14-bit dynamic range */
|
sl = ((short) sl) >> 2; /* sl of 14-bit dynamic range */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sezi = predictor_zero(state_ptr);
|
sezi = predictor_zero(state_ptr);
|
||||||
sez = sezi >> 1;
|
sez = sezi >> 1;
|
||||||
sei = sezi + predictor_pole(state_ptr);
|
sei = sezi + predictor_pole(state_ptr);
|
||||||
se = sei >> 1; /* se = estimated signal */
|
se = sei >> 1; /* se = estimated signal */
|
||||||
|
|
||||||
d = sl - se; /* d = estimation difference */
|
d = sl - se; /* d = estimation difference */
|
||||||
|
|
||||||
/* quantize prediction difference */
|
/* quantize prediction difference */
|
||||||
y = step_size(state_ptr); /* adaptive quantizer step size */
|
y = step_size(state_ptr); /* adaptive quantizer step size */
|
||||||
i = quantize(d, y, qtab_723_40, 15); /* i = ADPCM code */
|
i = quantize(d, y, qtab_723_40, 15); /* i = ADPCM code */
|
||||||
|
|
||||||
dq = reconstruct(i & 0x10, _dqlntab[i], y); /* quantized diff */
|
dq = reconstruct(i & 0x10, _dqlntab[i], y); /* quantized diff */
|
||||||
|
|
||||||
sr = (dq < 0) ? se - (dq & 0x7FFF) : se + dq; /* reconstructed signal */
|
sr = (dq < 0) ? se - (dq & 0x7FFF) : se + dq; /* reconstructed signal */
|
||||||
|
|
||||||
dqsez = sr + sez - se; /* dqsez = pole prediction diff. */
|
dqsez = sr + sez - se; /* dqsez = pole prediction diff. */
|
||||||
|
|
||||||
update(5, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr);
|
update(5, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr);
|
||||||
|
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -141,39 +141,39 @@ g723_40_encoder(
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
g723_40_decoder(
|
g723_40_decoder(
|
||||||
int i,
|
int i,
|
||||||
int out_coding,
|
int out_coding,
|
||||||
struct g72x_state *state_ptr)
|
struct g72x_state *state_ptr)
|
||||||
{
|
{
|
||||||
short sezi, sei, sez, se; /* ACCUM */
|
short sezi, sei, sez, se; /* ACCUM */
|
||||||
short y; /* MIX */
|
short y; /* MIX */
|
||||||
short sr; /* ADDB */
|
short sr; /* ADDB */
|
||||||
short dq;
|
short dq;
|
||||||
short dqsez;
|
short dqsez;
|
||||||
|
|
||||||
i &= 0x1f; /* mask to get proper bits */
|
i &= 0x1f; /* mask to get proper bits */
|
||||||
sezi = predictor_zero(state_ptr);
|
sezi = predictor_zero(state_ptr);
|
||||||
sez = sezi >> 1;
|
sez = sezi >> 1;
|
||||||
sei = sezi + predictor_pole(state_ptr);
|
sei = sezi + predictor_pole(state_ptr);
|
||||||
se = sei >> 1; /* se = estimated signal */
|
se = sei >> 1; /* se = estimated signal */
|
||||||
|
|
||||||
y = step_size(state_ptr); /* adaptive quantizer step size */
|
y = step_size(state_ptr); /* adaptive quantizer step size */
|
||||||
dq = reconstruct(i & 0x10, _dqlntab[i], y); /* estimation diff. */
|
dq = reconstruct(i & 0x10, _dqlntab[i], y); /* estimation diff. */
|
||||||
|
|
||||||
sr = (dq < 0) ? (se - (dq & 0x7FFF)) : (se + dq); /* reconst. signal */
|
sr = (dq < 0) ? (se - (dq & 0x7FFF)) : (se + dq); /* reconst. signal */
|
||||||
|
|
||||||
dqsez = sr - se + sez; /* pole prediction diff. */
|
dqsez = sr - se + sez; /* pole prediction diff. */
|
||||||
|
|
||||||
update(5, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr);
|
update(5, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr);
|
||||||
|
|
||||||
switch (out_coding) {
|
switch (out_coding) {
|
||||||
case AUDIO_ENCODING_ALAW:
|
case AUDIO_ENCODING_ALAW:
|
||||||
return (tandem_adjust_alaw(sr, se, y, i, 0x10, qtab_723_40));
|
return (tandem_adjust_alaw(sr, se, y, i, 0x10, qtab_723_40));
|
||||||
case AUDIO_ENCODING_ULAW:
|
case AUDIO_ENCODING_ULAW:
|
||||||
return (tandem_adjust_ulaw(sr, se, y, i, 0x10, qtab_723_40));
|
return (tandem_adjust_ulaw(sr, se, y, i, 0x10, qtab_723_40));
|
||||||
case AUDIO_ENCODING_LINEAR:
|
case AUDIO_ENCODING_LINEAR:
|
||||||
return (sr << 2); /* sr was of 14-bit dynamic range */
|
return (sr << 2); /* sr was of 14-bit dynamic range */
|
||||||
default:
|
default:
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
#include "wx/mmedia/internal/g72x.h"
|
#include "wx/mmedia/internal/g72x.h"
|
||||||
|
|
||||||
static short power2[15] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80,
|
static short power2[15] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80,
|
||||||
0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000};
|
0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* quan()
|
* quan()
|
||||||
@@ -47,16 +47,16 @@ static short power2[15] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80,
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
quan(
|
quan(
|
||||||
int val,
|
int val,
|
||||||
short *table,
|
short *table,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
if (val < *table++)
|
if (val < *table++)
|
||||||
break;
|
break;
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char quan2_tab[65536];
|
static char quan2_tab[65536];
|
||||||
@@ -65,42 +65,42 @@ static int init_tabs_done = 0;
|
|||||||
|
|
||||||
inline char quan2 (unsigned short val)
|
inline char quan2 (unsigned short val)
|
||||||
{
|
{
|
||||||
return quan2_tab[val];
|
return quan2_tab[val];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline short base2 (unsigned short val)
|
inline short base2 (unsigned short val)
|
||||||
{
|
{
|
||||||
return base2_tab[val];
|
return base2_tab[val];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_quan2_tab (void)
|
static void init_quan2_tab (void)
|
||||||
{
|
{
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
for (i = 0; i < 65536; i++) {
|
for (i = 0; i < 65536; i++) {
|
||||||
quan2_tab[i] = quan (i, power2, 15);
|
quan2_tab[i] = quan (i, power2, 15);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_base2_tab (void)
|
static void init_base2_tab (void)
|
||||||
{
|
{
|
||||||
long i;
|
long i;
|
||||||
short exp;
|
short exp;
|
||||||
|
|
||||||
for (i = 0; i < 65536; i++) {
|
for (i = 0; i < 65536; i++) {
|
||||||
exp = quan2 (short (i));
|
exp = quan2 (short (i));
|
||||||
base2_tab[i] = short ((exp << 6) + ((i << 6) >> exp));
|
base2_tab[i] = short ((exp << 6) + ((i << 6) >> exp));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_tabs (void)
|
static void init_tabs (void)
|
||||||
{
|
{
|
||||||
if (init_tabs_done) return;
|
if (init_tabs_done) return;
|
||||||
|
|
||||||
init_quan2_tab();
|
init_quan2_tab();
|
||||||
init_base2_tab();
|
init_base2_tab();
|
||||||
|
|
||||||
init_tabs_done = 1;
|
init_tabs_done = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -111,24 +111,24 @@ static void init_tabs (void)
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
fmult(
|
fmult(
|
||||||
int an,
|
int an,
|
||||||
int srn)
|
int srn)
|
||||||
{
|
{
|
||||||
short anmag, anexp, anmant;
|
short anmag, anexp, anmant;
|
||||||
short wanexp, wanmant;
|
short wanexp, wanmant;
|
||||||
short retval;
|
short retval;
|
||||||
|
|
||||||
anmag = (an > 0) ? an : ((-an) & 0x1FFF);
|
anmag = (an > 0) ? an : ((-an) & 0x1FFF);
|
||||||
anexp = quan2(anmag) - 6;
|
anexp = quan2(anmag) - 6;
|
||||||
anmant = (anmag == 0) ? 32 :
|
anmant = (anmag == 0) ? 32 :
|
||||||
(anexp >= 0) ? anmag >> anexp : anmag << -anexp;
|
(anexp >= 0) ? anmag >> anexp : anmag << -anexp;
|
||||||
wanexp = anexp + ((srn >> 6) & 0xF) - 13;
|
wanexp = anexp + ((srn >> 6) & 0xF) - 13;
|
||||||
|
|
||||||
wanmant = (anmant * (srn & 077) + 0x30) >> 4;
|
wanmant = (anmant * (srn & 077) + 0x30) >> 4;
|
||||||
retval = (wanexp >= 0) ? ((wanmant << wanexp) & 0x7FFF) :
|
retval = (wanexp >= 0) ? ((wanmant << wanexp) & 0x7FFF) :
|
||||||
(wanmant >> -wanexp);
|
(wanmant >> -wanexp);
|
||||||
|
|
||||||
return (((an ^ srn) < 0) ? -retval : retval);
|
return (((an ^ srn) < 0) ? -retval : retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -140,27 +140,27 @@ fmult(
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
g72x_init_state(
|
g72x_init_state(
|
||||||
struct g72x_state *state_ptr)
|
struct g72x_state *state_ptr)
|
||||||
{
|
{
|
||||||
int cnta;
|
int cnta;
|
||||||
|
|
||||||
init_tabs ();
|
init_tabs ();
|
||||||
|
|
||||||
state_ptr->yl = 34816;
|
state_ptr->yl = 34816;
|
||||||
state_ptr->yu = 544;
|
state_ptr->yu = 544;
|
||||||
state_ptr->dms = 0;
|
state_ptr->dms = 0;
|
||||||
state_ptr->dml = 0;
|
state_ptr->dml = 0;
|
||||||
state_ptr->ap = 0;
|
state_ptr->ap = 0;
|
||||||
for (cnta = 0; cnta < 2; cnta++) {
|
for (cnta = 0; cnta < 2; cnta++) {
|
||||||
state_ptr->a[cnta] = 0;
|
state_ptr->a[cnta] = 0;
|
||||||
state_ptr->pk[cnta] = 0;
|
state_ptr->pk[cnta] = 0;
|
||||||
state_ptr->sr[cnta] = 32;
|
state_ptr->sr[cnta] = 32;
|
||||||
}
|
}
|
||||||
for (cnta = 0; cnta < 6; cnta++) {
|
for (cnta = 0; cnta < 6; cnta++) {
|
||||||
state_ptr->b[cnta] = 0;
|
state_ptr->b[cnta] = 0;
|
||||||
state_ptr->dq[cnta] = 32;
|
state_ptr->dq[cnta] = 32;
|
||||||
}
|
}
|
||||||
state_ptr->td = 0;
|
state_ptr->td = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -171,15 +171,15 @@ g72x_init_state(
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
predictor_zero(
|
predictor_zero(
|
||||||
struct g72x_state *state_ptr)
|
struct g72x_state *state_ptr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int sezi;
|
int sezi;
|
||||||
|
|
||||||
sezi = fmult(state_ptr->b[0] >> 2, state_ptr->dq[0]);
|
sezi = fmult(state_ptr->b[0] >> 2, state_ptr->dq[0]);
|
||||||
for (i = 1; i < 6; i++) /* ACCUM */
|
for (i = 1; i < 6; i++) /* ACCUM */
|
||||||
sezi += fmult(state_ptr->b[i] >> 2, state_ptr->dq[i]);
|
sezi += fmult(state_ptr->b[i] >> 2, state_ptr->dq[i]);
|
||||||
return (sezi);
|
return (sezi);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* predictor_pole()
|
* predictor_pole()
|
||||||
@@ -189,10 +189,10 @@ predictor_zero(
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
predictor_pole(
|
predictor_pole(
|
||||||
struct g72x_state *state_ptr)
|
struct g72x_state *state_ptr)
|
||||||
{
|
{
|
||||||
return (fmult(state_ptr->a[1] >> 2, state_ptr->sr[1]) +
|
return (fmult(state_ptr->a[1] >> 2, state_ptr->sr[1]) +
|
||||||
fmult(state_ptr->a[0] >> 2, state_ptr->sr[0]));
|
fmult(state_ptr->a[0] >> 2, state_ptr->sr[0]));
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* step_size()
|
* step_size()
|
||||||
@@ -202,24 +202,24 @@ predictor_pole(
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
step_size(
|
step_size(
|
||||||
struct g72x_state *state_ptr)
|
struct g72x_state *state_ptr)
|
||||||
{
|
{
|
||||||
int y;
|
int y;
|
||||||
int dif;
|
int dif;
|
||||||
int al;
|
int al;
|
||||||
|
|
||||||
if (state_ptr->ap >= 256)
|
if (state_ptr->ap >= 256)
|
||||||
return (state_ptr->yu);
|
return (state_ptr->yu);
|
||||||
else {
|
else {
|
||||||
y = state_ptr->yl >> 6;
|
y = state_ptr->yl >> 6;
|
||||||
dif = state_ptr->yu - y;
|
dif = state_ptr->yu - y;
|
||||||
al = state_ptr->ap >> 2;
|
al = state_ptr->ap >> 2;
|
||||||
if (dif > 0)
|
if (dif > 0)
|
||||||
y += (dif * al) >> 6;
|
y += (dif * al) >> 6;
|
||||||
else if (dif < 0)
|
else if (dif < 0)
|
||||||
y += (dif * al + 0x3F) >> 6;
|
y += (dif * al + 0x3F) >> 6;
|
||||||
return (y);
|
return (y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -233,47 +233,47 @@ step_size(
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
quantize(
|
quantize(
|
||||||
int d, /* Raw difference signal sample */
|
int d, /* Raw difference signal sample */
|
||||||
int y, /* Step size multiplier */
|
int y, /* Step size multiplier */
|
||||||
short *table, /* quantization table */
|
short *table, /* quantization table */
|
||||||
int size) /* table size of short integers */
|
int size) /* table size of short integers */
|
||||||
{
|
{
|
||||||
short dqm; /* Magnitude of 'd' */
|
short dqm; /* Magnitude of 'd' */
|
||||||
short exp; /* Integer part of base 2 log of 'd' */
|
short exp; /* Integer part of base 2 log of 'd' */
|
||||||
short mant; /* Fractional part of base 2 log */
|
short mant; /* Fractional part of base 2 log */
|
||||||
short dl; /* Log of magnitude of 'd' */
|
short dl; /* Log of magnitude of 'd' */
|
||||||
short dln; /* Step size scale factor normalized log */
|
short dln; /* Step size scale factor normalized log */
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* LOG
|
* LOG
|
||||||
*
|
*
|
||||||
* Compute base 2 log of 'd', and store in 'dl'.
|
* Compute base 2 log of 'd', and store in 'dl'.
|
||||||
*/
|
*/
|
||||||
dqm = abs(d);
|
dqm = abs(d);
|
||||||
exp = quan2(dqm >> 1);
|
exp = quan2(dqm >> 1);
|
||||||
mant = ((dqm << 7) >> exp) & 0x7F; /* Fractional portion. */
|
mant = ((dqm << 7) >> exp) & 0x7F; /* Fractional portion. */
|
||||||
dl = (exp << 7) + mant;
|
dl = (exp << 7) + mant;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SUBTB
|
* SUBTB
|
||||||
*
|
*
|
||||||
* "Divide" by step size multiplier.
|
* "Divide" by step size multiplier.
|
||||||
*/
|
*/
|
||||||
dln = dl - (y >> 2);
|
dln = dl - (y >> 2);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* QUAN
|
* QUAN
|
||||||
*
|
*
|
||||||
* Obtain codword i for 'd'.
|
* Obtain codword i for 'd'.
|
||||||
*/
|
*/
|
||||||
i = quan(dln, table, size);
|
i = quan(dln, table, size);
|
||||||
if (d < 0) /* take 1's complement of i */
|
if (d < 0) /* take 1's complement of i */
|
||||||
return ((size << 1) + 1 - i);
|
return ((size << 1) + 1 - i);
|
||||||
else if (i == 0) /* take 1's complement of 0 */
|
else if (i == 0) /* take 1's complement of 0 */
|
||||||
return ((size << 1) + 1); /* new in 1988 */
|
return ((size << 1) + 1); /* new in 1988 */
|
||||||
else
|
else
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* reconstruct()
|
* reconstruct()
|
||||||
@@ -284,25 +284,25 @@ quantize(
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
reconstruct(
|
reconstruct(
|
||||||
int sign, /* 0 for non-negative value */
|
int sign, /* 0 for non-negative value */
|
||||||
int dqln, /* G.72x codeword */
|
int dqln, /* G.72x codeword */
|
||||||
int y) /* Step size multiplier */
|
int y) /* Step size multiplier */
|
||||||
{
|
{
|
||||||
short dql; /* Log of 'dq' magnitude */
|
short dql; /* Log of 'dq' magnitude */
|
||||||
short dex; /* Integer part of log */
|
short dex; /* Integer part of log */
|
||||||
short dqt;
|
short dqt;
|
||||||
short dq; /* Reconstructed difference signal sample */
|
short dq; /* Reconstructed difference signal sample */
|
||||||
|
|
||||||
dql = dqln + (y >> 2); /* ADDA */
|
dql = dqln + (y >> 2); /* ADDA */
|
||||||
|
|
||||||
if (dql < 0) {
|
if (dql < 0) {
|
||||||
return ((sign) ? -0x8000 : 0);
|
return ((sign) ? -0x8000 : 0);
|
||||||
} else { /* ANTILOG */
|
} else { /* ANTILOG */
|
||||||
dex = (dql >> 7) & 15;
|
dex = (dql >> 7) & 15;
|
||||||
dqt = 128 + (dql & 127);
|
dqt = 128 + (dql & 127);
|
||||||
dq = (dqt << 7) >> (14 - dex);
|
dq = (dqt << 7) >> (14 - dex);
|
||||||
return ((sign) ? (dq - 0x8000) : dq);
|
return ((sign) ? (dq - 0x8000) : dq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -313,189 +313,189 @@ reconstruct(
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
update(
|
update(
|
||||||
int code_size, /* distinguish 723_40 with others */
|
int code_size, /* distinguish 723_40 with others */
|
||||||
int y, /* quantizer step size */
|
int y, /* quantizer step size */
|
||||||
int wi, /* scale factor multiplier */
|
int wi, /* scale factor multiplier */
|
||||||
int fi, /* for long/short term energies */
|
int fi, /* for long/short term energies */
|
||||||
int dq, /* quantized prediction difference */
|
int dq, /* quantized prediction difference */
|
||||||
int sr, /* reconstructed signal */
|
int sr, /* reconstructed signal */
|
||||||
int dqsez, /* difference from 2-pole predictor */
|
int dqsez, /* difference from 2-pole predictor */
|
||||||
struct g72x_state *state_ptr) /* coder state pointer */
|
struct g72x_state *state_ptr) /* coder state pointer */
|
||||||
{
|
{
|
||||||
int cnt;
|
int cnt;
|
||||||
short mag; /* Adaptive predictor, FLOAT A */
|
short mag; /* Adaptive predictor, FLOAT A */
|
||||||
short a2p; /* LIMC */
|
short a2p; /* LIMC */
|
||||||
short a1ul; /* UPA1 */
|
short a1ul; /* UPA1 */
|
||||||
short pks1; /* UPA2 */
|
short pks1; /* UPA2 */
|
||||||
short fa1;
|
short fa1;
|
||||||
char tr; /* tone/transition detector */
|
char tr; /* tone/transition detector */
|
||||||
short ylint, thr2, dqthr;
|
short ylint, thr2, dqthr;
|
||||||
short ylfrac, thr1;
|
short ylfrac, thr1;
|
||||||
short pk0;
|
short pk0;
|
||||||
|
|
||||||
pk0 = (dqsez < 0) ? 1 : 0; /* needed in updating predictor poles */
|
pk0 = (dqsez < 0) ? 1 : 0; /* needed in updating predictor poles */
|
||||||
|
|
||||||
mag = dq & 0x7FFF; /* prediction difference magnitude */
|
mag = dq & 0x7FFF; /* prediction difference magnitude */
|
||||||
/* TRANS */
|
/* TRANS */
|
||||||
ylint = short (state_ptr->yl >> 15); /* exponent part of yl */
|
ylint = short (state_ptr->yl >> 15); /* exponent part of yl */
|
||||||
ylfrac = (state_ptr->yl >> 10) & 0x1F; /* fractional part of yl */
|
ylfrac = (state_ptr->yl >> 10) & 0x1F; /* fractional part of yl */
|
||||||
thr1 = (32 + ylfrac) << ylint; /* threshold */
|
thr1 = (32 + ylfrac) << ylint; /* threshold */
|
||||||
thr2 = (ylint > 9) ? 31 << 10 : thr1; /* limit thr2 to 31 << 10 */
|
thr2 = (ylint > 9) ? 31 << 10 : thr1; /* limit thr2 to 31 << 10 */
|
||||||
dqthr = (thr2 + (thr2 >> 1)) >> 1; /* dqthr = 0.75 * thr2 */
|
dqthr = (thr2 + (thr2 >> 1)) >> 1; /* dqthr = 0.75 * thr2 */
|
||||||
if (state_ptr->td == 0) /* signal supposed voice */
|
if (state_ptr->td == 0) /* signal supposed voice */
|
||||||
tr = 0;
|
tr = 0;
|
||||||
else if (mag <= dqthr) /* supposed data, but small mag */
|
else if (mag <= dqthr) /* supposed data, but small mag */
|
||||||
tr = 0; /* treated as voice */
|
tr = 0; /* treated as voice */
|
||||||
else /* signal is data (modem) */
|
else /* signal is data (modem) */
|
||||||
tr = 1;
|
tr = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Quantizer scale factor adaptation.
|
* Quantizer scale factor adaptation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* FUNCTW & FILTD & DELAY */
|
/* FUNCTW & FILTD & DELAY */
|
||||||
/* update non-steady state step size multiplier */
|
/* update non-steady state step size multiplier */
|
||||||
state_ptr->yu = y + ((wi - y) >> 5);
|
state_ptr->yu = y + ((wi - y) >> 5);
|
||||||
|
|
||||||
/* LIMB */
|
/* LIMB */
|
||||||
if (state_ptr->yu < 544) /* 544 <= yu <= 5120 */
|
if (state_ptr->yu < 544) /* 544 <= yu <= 5120 */
|
||||||
state_ptr->yu = 544;
|
state_ptr->yu = 544;
|
||||||
else if (state_ptr->yu > 5120)
|
else if (state_ptr->yu > 5120)
|
||||||
state_ptr->yu = 5120;
|
state_ptr->yu = 5120;
|
||||||
|
|
||||||
/* FILTE & DELAY */
|
/* FILTE & DELAY */
|
||||||
/* update steady state step size multiplier */
|
/* update steady state step size multiplier */
|
||||||
state_ptr->yl += state_ptr->yu + ((-state_ptr->yl) >> 6);
|
state_ptr->yl += state_ptr->yu + ((-state_ptr->yl) >> 6);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Adaptive predictor coefficients.
|
* Adaptive predictor coefficients.
|
||||||
*/
|
*/
|
||||||
if (tr == 1) { /* reset a's and b's for modem signal */
|
if (tr == 1) { /* reset a's and b's for modem signal */
|
||||||
state_ptr->a[0] = 0;
|
state_ptr->a[0] = 0;
|
||||||
state_ptr->a[1] = 0;
|
state_ptr->a[1] = 0;
|
||||||
state_ptr->b[0] = 0;
|
state_ptr->b[0] = 0;
|
||||||
state_ptr->b[1] = 0;
|
state_ptr->b[1] = 0;
|
||||||
state_ptr->b[2] = 0;
|
state_ptr->b[2] = 0;
|
||||||
state_ptr->b[3] = 0;
|
state_ptr->b[3] = 0;
|
||||||
state_ptr->b[4] = 0;
|
state_ptr->b[4] = 0;
|
||||||
state_ptr->b[5] = 0;
|
state_ptr->b[5] = 0;
|
||||||
|
|
||||||
a2p = 0; /* eliminate Compiler Warnings */
|
a2p = 0; /* eliminate Compiler Warnings */
|
||||||
} else { /* update a's and b's */
|
} else { /* update a's and b's */
|
||||||
pks1 = pk0 ^ state_ptr->pk[0]; /* UPA2 */
|
pks1 = pk0 ^ state_ptr->pk[0]; /* UPA2 */
|
||||||
|
|
||||||
/* update predictor pole a[1] */
|
/* update predictor pole a[1] */
|
||||||
a2p = state_ptr->a[1] - (state_ptr->a[1] >> 7);
|
a2p = state_ptr->a[1] - (state_ptr->a[1] >> 7);
|
||||||
if (dqsez != 0) {
|
if (dqsez != 0) {
|
||||||
fa1 = (pks1) ? state_ptr->a[0] : -state_ptr->a[0];
|
fa1 = (pks1) ? state_ptr->a[0] : -state_ptr->a[0];
|
||||||
if (fa1 < -8191) /* a2p = function of fa1 */
|
if (fa1 < -8191) /* a2p = function of fa1 */
|
||||||
a2p -= 0x100;
|
a2p -= 0x100;
|
||||||
else if (fa1 > 8191)
|
else if (fa1 > 8191)
|
||||||
a2p += 0xFF;
|
a2p += 0xFF;
|
||||||
else
|
else
|
||||||
a2p += fa1 >> 5;
|
a2p += fa1 >> 5;
|
||||||
|
|
||||||
if (pk0 ^ state_ptr->pk[1])
|
if (pk0 ^ state_ptr->pk[1])
|
||||||
/* LIMC */
|
/* LIMC */
|
||||||
if (a2p <= -12160)
|
if (a2p <= -12160)
|
||||||
a2p = -12288;
|
a2p = -12288;
|
||||||
else if (a2p >= 12416)
|
else if (a2p >= 12416)
|
||||||
a2p = 12288;
|
a2p = 12288;
|
||||||
else
|
else
|
||||||
a2p -= 0x80;
|
a2p -= 0x80;
|
||||||
else if (a2p <= -12416)
|
else if (a2p <= -12416)
|
||||||
a2p = -12288;
|
a2p = -12288;
|
||||||
else if (a2p >= 12160)
|
else if (a2p >= 12160)
|
||||||
a2p = 12288;
|
a2p = 12288;
|
||||||
else
|
else
|
||||||
a2p += 0x80;
|
a2p += 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TRIGB & DELAY */
|
/* TRIGB & DELAY */
|
||||||
state_ptr->a[1] = a2p;
|
state_ptr->a[1] = a2p;
|
||||||
|
|
||||||
/* UPA1 */
|
/* UPA1 */
|
||||||
/* update predictor pole a[0] */
|
/* update predictor pole a[0] */
|
||||||
state_ptr->a[0] -= state_ptr->a[0] >> 8;
|
state_ptr->a[0] -= state_ptr->a[0] >> 8;
|
||||||
if (dqsez != 0)
|
if (dqsez != 0)
|
||||||
if (pks1 == 0)
|
if (pks1 == 0)
|
||||||
state_ptr->a[0] += 192;
|
state_ptr->a[0] += 192;
|
||||||
else
|
else
|
||||||
state_ptr->a[0] -= 192;
|
state_ptr->a[0] -= 192;
|
||||||
|
|
||||||
/* LIMD */
|
/* LIMD */
|
||||||
a1ul = 15360 - a2p;
|
a1ul = 15360 - a2p;
|
||||||
if (state_ptr->a[0] < -a1ul)
|
if (state_ptr->a[0] < -a1ul)
|
||||||
state_ptr->a[0] = -a1ul;
|
state_ptr->a[0] = -a1ul;
|
||||||
else if (state_ptr->a[0] > a1ul)
|
else if (state_ptr->a[0] > a1ul)
|
||||||
state_ptr->a[0] = a1ul;
|
state_ptr->a[0] = a1ul;
|
||||||
|
|
||||||
/* UPB : update predictor zeros b[6] */
|
/* UPB : update predictor zeros b[6] */
|
||||||
for (cnt = 0; cnt < 6; cnt++) {
|
for (cnt = 0; cnt < 6; cnt++) {
|
||||||
if (code_size == 5) /* for 40Kbps G.723 */
|
if (code_size == 5) /* for 40Kbps G.723 */
|
||||||
state_ptr->b[cnt] -= state_ptr->b[cnt] >> 9;
|
state_ptr->b[cnt] -= state_ptr->b[cnt] >> 9;
|
||||||
else /* for G.721 and 24Kbps G.723 */
|
else /* for G.721 and 24Kbps G.723 */
|
||||||
state_ptr->b[cnt] -= state_ptr->b[cnt] >> 8;
|
state_ptr->b[cnt] -= state_ptr->b[cnt] >> 8;
|
||||||
if (dq & 0x7FFF) { /* XOR */
|
if (dq & 0x7FFF) { /* XOR */
|
||||||
if ((dq ^ state_ptr->dq[cnt]) >= 0)
|
if ((dq ^ state_ptr->dq[cnt]) >= 0)
|
||||||
state_ptr->b[cnt] += 128;
|
state_ptr->b[cnt] += 128;
|
||||||
else
|
else
|
||||||
state_ptr->b[cnt] -= 128;
|
state_ptr->b[cnt] -= 128;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (cnt = 5; cnt > 0; cnt--)
|
for (cnt = 5; cnt > 0; cnt--)
|
||||||
state_ptr->dq[cnt] = state_ptr->dq[cnt-1];
|
state_ptr->dq[cnt] = state_ptr->dq[cnt-1];
|
||||||
/* FLOAT A : convert dq[0] to 4-bit exp, 6-bit mantissa f.p. */
|
/* FLOAT A : convert dq[0] to 4-bit exp, 6-bit mantissa f.p. */
|
||||||
if (mag == 0) {
|
if (mag == 0) {
|
||||||
state_ptr->dq[0] = (dq >= 0) ? 0x20 : 0xFC20;
|
state_ptr->dq[0] = (dq >= 0) ? 0x20 : 0xFC20;
|
||||||
} else {
|
} else {
|
||||||
state_ptr->dq[0] = (dq >= 0) ?
|
state_ptr->dq[0] = (dq >= 0) ?
|
||||||
base2 (mag) : base2 (mag) - 0x400;
|
base2 (mag) : base2 (mag) - 0x400;
|
||||||
}
|
}
|
||||||
|
|
||||||
state_ptr->sr[1] = state_ptr->sr[0];
|
state_ptr->sr[1] = state_ptr->sr[0];
|
||||||
/* FLOAT B : convert sr to 4-bit exp., 6-bit mantissa f.p. */
|
/* FLOAT B : convert sr to 4-bit exp., 6-bit mantissa f.p. */
|
||||||
if (sr == 0) {
|
if (sr == 0) {
|
||||||
state_ptr->sr[0] = 0x20;
|
state_ptr->sr[0] = 0x20;
|
||||||
} else if (sr > 0) {
|
} else if (sr > 0) {
|
||||||
state_ptr->sr[0] = base2(sr);
|
state_ptr->sr[0] = base2(sr);
|
||||||
} else if (sr > -32768) {
|
} else if (sr > -32768) {
|
||||||
mag = -sr;
|
mag = -sr;
|
||||||
state_ptr->sr[0] = base2(mag) - 0x400;
|
state_ptr->sr[0] = base2(mag) - 0x400;
|
||||||
} else
|
} else
|
||||||
state_ptr->sr[0] = short (0xFC20);
|
state_ptr->sr[0] = short (0xFC20);
|
||||||
|
|
||||||
/* DELAY A */
|
/* DELAY A */
|
||||||
state_ptr->pk[1] = state_ptr->pk[0];
|
state_ptr->pk[1] = state_ptr->pk[0];
|
||||||
state_ptr->pk[0] = pk0;
|
state_ptr->pk[0] = pk0;
|
||||||
|
|
||||||
/* TONE */
|
/* TONE */
|
||||||
if (tr == 1) /* this sample has been treated as data */
|
if (tr == 1) /* this sample has been treated as data */
|
||||||
state_ptr->td = 0; /* next one will be treated as voice */
|
state_ptr->td = 0; /* next one will be treated as voice */
|
||||||
else if (a2p < -11776) /* small sample-to-sample correlation */
|
else if (a2p < -11776) /* small sample-to-sample correlation */
|
||||||
state_ptr->td = 1; /* signal may be data */
|
state_ptr->td = 1; /* signal may be data */
|
||||||
else /* signal is voice */
|
else /* signal is voice */
|
||||||
state_ptr->td = 0;
|
state_ptr->td = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Adaptation speed control.
|
* Adaptation speed control.
|
||||||
*/
|
*/
|
||||||
state_ptr->dms += (fi - state_ptr->dms) >> 5; /* FILTA */
|
state_ptr->dms += (fi - state_ptr->dms) >> 5; /* FILTA */
|
||||||
state_ptr->dml += (((fi << 2) - state_ptr->dml) >> 7); /* FILTB */
|
state_ptr->dml += (((fi << 2) - state_ptr->dml) >> 7); /* FILTB */
|
||||||
|
|
||||||
if (tr == 1)
|
if (tr == 1)
|
||||||
state_ptr->ap = 256;
|
state_ptr->ap = 256;
|
||||||
else if (y < 1536) /* SUBTC */
|
else if (y < 1536) /* SUBTC */
|
||||||
state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
|
state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
|
||||||
else if (state_ptr->td == 1)
|
else if (state_ptr->td == 1)
|
||||||
state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
|
state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
|
||||||
else if (abs((state_ptr->dms << 2) - state_ptr->dml) >=
|
else if (abs((state_ptr->dms << 2) - state_ptr->dml) >=
|
||||||
(state_ptr->dml >> 3))
|
(state_ptr->dml >> 3))
|
||||||
state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
|
state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
|
||||||
else
|
else
|
||||||
state_ptr->ap += (-state_ptr->ap) >> 4;
|
state_ptr->ap += (-state_ptr->ap) >> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -507,103 +507,103 @@ update(
|
|||||||
* is adjusted by one level of A-law or u-law codes.
|
* is adjusted by one level of A-law or u-law codes.
|
||||||
*
|
*
|
||||||
* Input:
|
* Input:
|
||||||
* sr decoder output linear PCM sample,
|
* sr decoder output linear PCM sample,
|
||||||
* se predictor estimate sample,
|
* se predictor estimate sample,
|
||||||
* y quantizer step size,
|
* y quantizer step size,
|
||||||
* i decoder input code,
|
* i decoder input code,
|
||||||
* sign sign bit of code i
|
* sign sign bit of code i
|
||||||
*
|
*
|
||||||
* Return:
|
* Return:
|
||||||
* adjusted A-law or u-law compressed sample.
|
* adjusted A-law or u-law compressed sample.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
tandem_adjust_alaw(
|
tandem_adjust_alaw(
|
||||||
int sr, /* decoder output linear PCM sample */
|
int sr, /* decoder output linear PCM sample */
|
||||||
int se, /* predictor estimate sample */
|
int se, /* predictor estimate sample */
|
||||||
int y, /* quantizer step size */
|
int y, /* quantizer step size */
|
||||||
int i, /* decoder input code */
|
int i, /* decoder input code */
|
||||||
int sign,
|
int sign,
|
||||||
short *qtab)
|
short *qtab)
|
||||||
{
|
{
|
||||||
unsigned char sp; /* A-law compressed 8-bit code */
|
unsigned char sp; /* A-law compressed 8-bit code */
|
||||||
short dx; /* prediction error */
|
short dx; /* prediction error */
|
||||||
char id; /* quantized prediction error */
|
char id; /* quantized prediction error */
|
||||||
int sd; /* adjusted A-law decoded sample value */
|
int sd; /* adjusted A-law decoded sample value */
|
||||||
int im; /* biased magnitude of i */
|
int im; /* biased magnitude of i */
|
||||||
int imx; /* biased magnitude of id */
|
int imx; /* biased magnitude of id */
|
||||||
|
|
||||||
if (sr <= -32768)
|
if (sr <= -32768)
|
||||||
sr = -1;
|
sr = -1;
|
||||||
sp = linear2alaw((sr >> 1) << 3); /* short to A-law compression */
|
sp = linear2alaw((sr >> 1) << 3); /* short to A-law compression */
|
||||||
dx = (alaw2linear(sp) >> 2) - se; /* 16-bit prediction error */
|
dx = (alaw2linear(sp) >> 2) - se; /* 16-bit prediction error */
|
||||||
id = quantize(dx, y, qtab, sign - 1);
|
id = quantize(dx, y, qtab, sign - 1);
|
||||||
|
|
||||||
if (id == i) { /* no adjustment on sp */
|
if (id == i) { /* no adjustment on sp */
|
||||||
return (sp);
|
return (sp);
|
||||||
} else { /* sp adjustment needed */
|
} else { /* sp adjustment needed */
|
||||||
/* ADPCM codes : 8, 9, ... F, 0, 1, ... , 6, 7 */
|
/* ADPCM codes : 8, 9, ... F, 0, 1, ... , 6, 7 */
|
||||||
im = i ^ sign; /* 2's complement to biased unsigned */
|
im = i ^ sign; /* 2's complement to biased unsigned */
|
||||||
imx = id ^ sign;
|
imx = id ^ sign;
|
||||||
|
|
||||||
if (imx > im) { /* sp adjusted to next lower value */
|
if (imx > im) { /* sp adjusted to next lower value */
|
||||||
if (sp & 0x80) {
|
if (sp & 0x80) {
|
||||||
sd = (sp == 0xD5) ? 0x55 :
|
sd = (sp == 0xD5) ? 0x55 :
|
||||||
((sp ^ 0x55) - 1) ^ 0x55;
|
((sp ^ 0x55) - 1) ^ 0x55;
|
||||||
} else {
|
} else {
|
||||||
sd = (sp == 0x2A) ? 0x2A :
|
sd = (sp == 0x2A) ? 0x2A :
|
||||||
((sp ^ 0x55) + 1) ^ 0x55;
|
((sp ^ 0x55) + 1) ^ 0x55;
|
||||||
}
|
}
|
||||||
} else { /* sp adjusted to next higher value */
|
} else { /* sp adjusted to next higher value */
|
||||||
if (sp & 0x80)
|
if (sp & 0x80)
|
||||||
sd = (sp == 0xAA) ? 0xAA :
|
sd = (sp == 0xAA) ? 0xAA :
|
||||||
((sp ^ 0x55) + 1) ^ 0x55;
|
((sp ^ 0x55) + 1) ^ 0x55;
|
||||||
else
|
else
|
||||||
sd = (sp == 0x55) ? 0xD5 :
|
sd = (sp == 0x55) ? 0xD5 :
|
||||||
((sp ^ 0x55) - 1) ^ 0x55;
|
((sp ^ 0x55) - 1) ^ 0x55;
|
||||||
}
|
}
|
||||||
return (sd);
|
return (sd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
tandem_adjust_ulaw(
|
tandem_adjust_ulaw(
|
||||||
int sr, /* decoder output linear PCM sample */
|
int sr, /* decoder output linear PCM sample */
|
||||||
int se, /* predictor estimate sample */
|
int se, /* predictor estimate sample */
|
||||||
int y, /* quantizer step size */
|
int y, /* quantizer step size */
|
||||||
int i, /* decoder input code */
|
int i, /* decoder input code */
|
||||||
int sign,
|
int sign,
|
||||||
short *qtab)
|
short *qtab)
|
||||||
{
|
{
|
||||||
unsigned char sp; /* u-law compressed 8-bit code */
|
unsigned char sp; /* u-law compressed 8-bit code */
|
||||||
short dx; /* prediction error */
|
short dx; /* prediction error */
|
||||||
char id; /* quantized prediction error */
|
char id; /* quantized prediction error */
|
||||||
int sd; /* adjusted u-law decoded sample value */
|
int sd; /* adjusted u-law decoded sample value */
|
||||||
int im; /* biased magnitude of i */
|
int im; /* biased magnitude of i */
|
||||||
int imx; /* biased magnitude of id */
|
int imx; /* biased magnitude of id */
|
||||||
|
|
||||||
if (sr <= -32768)
|
if (sr <= -32768)
|
||||||
sr = 0;
|
sr = 0;
|
||||||
sp = linear2ulaw(sr << 2); /* short to u-law compression */
|
sp = linear2ulaw(sr << 2); /* short to u-law compression */
|
||||||
dx = (ulaw2linear(sp) >> 2) - se; /* 16-bit prediction error */
|
dx = (ulaw2linear(sp) >> 2) - se; /* 16-bit prediction error */
|
||||||
id = quantize(dx, y, qtab, sign - 1);
|
id = quantize(dx, y, qtab, sign - 1);
|
||||||
if (id == i) {
|
if (id == i) {
|
||||||
return (sp);
|
return (sp);
|
||||||
} else {
|
} else {
|
||||||
/* ADPCM codes : 8, 9, ... F, 0, 1, ... , 6, 7 */
|
/* ADPCM codes : 8, 9, ... F, 0, 1, ... , 6, 7 */
|
||||||
im = i ^ sign; /* 2's complement to biased unsigned */
|
im = i ^ sign; /* 2's complement to biased unsigned */
|
||||||
imx = id ^ sign;
|
imx = id ^ sign;
|
||||||
if (imx > im) { /* sp adjusted to next lower value */
|
if (imx > im) { /* sp adjusted to next lower value */
|
||||||
if (sp & 0x80)
|
if (sp & 0x80)
|
||||||
sd = (sp == 0xFF) ? 0x7E : sp + 1;
|
sd = (sp == 0xFF) ? 0x7E : sp + 1;
|
||||||
else
|
else
|
||||||
sd = (sp == 0) ? 0 : sp - 1;
|
sd = (sp == 0) ? 0 : sp - 1;
|
||||||
|
|
||||||
} else { /* sp adjusted to next higher value */
|
} else { /* sp adjusted to next higher value */
|
||||||
if (sp & 0x80)
|
if (sp & 0x80)
|
||||||
sd = (sp == 0x80) ? 0x80 : sp - 1;
|
sd = (sp == 0x80) ? 0x80 : sp - 1;
|
||||||
else
|
else
|
||||||
sd = (sp == 0x7F) ? 0xFE : sp + 1;
|
sd = (sp == 0x7F) ? 0xFE : sp + 1;
|
||||||
}
|
}
|
||||||
return (sd);
|
return (sd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -63,25 +63,25 @@ bool wxSoundAiff::CanRead()
|
|||||||
wxUint32 signature1, signature2, len;
|
wxUint32 signature1, signature2, len;
|
||||||
|
|
||||||
if (m_input->Read(&signature1, 4).LastRead() != 4)
|
if (m_input->Read(&signature1, 4).LastRead() != 4)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (wxUINT32_SWAP_ON_BE(signature1) != FORM_SIGNATURE) {
|
if (wxUINT32_SWAP_ON_BE(signature1) != FORM_SIGNATURE) {
|
||||||
m_input->Ungetch(&signature1, 4);
|
m_input->Ungetch(&signature1, 4);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_input->Read(&len, 4);
|
m_input->Read(&len, 4);
|
||||||
if (m_input->LastRead() != 4) {
|
if (m_input->LastRead() != 4) {
|
||||||
m_input->Ungetch(&len, m_input->LastRead());
|
m_input->Ungetch(&len, m_input->LastRead());
|
||||||
m_input->Ungetch(&signature1, 4);
|
m_input->Ungetch(&signature1, 4);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_input->Read(&signature2, 4).LastRead() != 4) {
|
if (m_input->Read(&signature2, 4).LastRead() != 4) {
|
||||||
m_input->Ungetch(&signature2, m_input->LastRead());
|
m_input->Ungetch(&signature2, m_input->LastRead());
|
||||||
m_input->Ungetch(&len, 4);
|
m_input->Ungetch(&len, 4);
|
||||||
m_input->Ungetch(&signature1, 4);
|
m_input->Ungetch(&signature1, 4);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_input->Ungetch(&signature2, 4);
|
m_input->Ungetch(&signature2, 4);
|
||||||
@@ -91,12 +91,12 @@ bool wxSoundAiff::CanRead()
|
|||||||
if (
|
if (
|
||||||
wxUINT32_SWAP_ON_BE(signature2) != AIFF_SIGNATURE &&
|
wxUINT32_SWAP_ON_BE(signature2) != AIFF_SIGNATURE &&
|
||||||
wxUINT32_SWAP_ON_BE(signature2) != AIFC_SIGNATURE)
|
wxUINT32_SWAP_ON_BE(signature2) != AIFC_SIGNATURE)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FAIL_WITH(condition, err) if (condition) { m_snderror = err; return FALSE; }
|
#define FAIL_WITH(condition, err) if (condition) { m_snderror = err; return false; }
|
||||||
|
|
||||||
bool wxSoundAiff::PrepareToPlay()
|
bool wxSoundAiff::PrepareToPlay()
|
||||||
{
|
{
|
||||||
@@ -106,11 +106,11 @@ bool wxSoundAiff::PrepareToPlay()
|
|||||||
|
|
||||||
if (!m_input) {
|
if (!m_input) {
|
||||||
m_snderror = wxSOUND_INVSTRM;
|
m_snderror = wxSOUND_INVSTRM;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
m_snderror = wxSOUND_NOERROR;
|
m_snderror = wxSOUND_NOERROR;
|
||||||
|
|
||||||
data.BigEndianOrdered(TRUE);
|
data.BigEndianOrdered(true);
|
||||||
|
|
||||||
FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM);
|
FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM);
|
||||||
FAIL_WITH(wxUINT32_SWAP_ON_BE(signature) != FORM_SIGNATURE, wxSOUND_INVSTRM);
|
FAIL_WITH(wxUINT32_SWAP_ON_BE(signature) != FORM_SIGNATURE, wxSOUND_INVSTRM);
|
||||||
@@ -127,7 +127,7 @@ bool wxSoundAiff::PrepareToPlay()
|
|||||||
wxUINT32_SWAP_ON_BE(signature) != AIFC_SIGNATURE, wxSOUND_INVSTRM);
|
wxUINT32_SWAP_ON_BE(signature) != AIFC_SIGNATURE, wxSOUND_INVSTRM);
|
||||||
// "AIFF" / "AIFC"
|
// "AIFF" / "AIFC"
|
||||||
|
|
||||||
end_headers = FALSE;
|
end_headers = false;
|
||||||
while (!end_headers) {
|
while (!end_headers) {
|
||||||
FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM);
|
FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM);
|
||||||
|
|
||||||
@@ -148,11 +148,11 @@ bool wxSoundAiff::PrepareToPlay()
|
|||||||
sndformat.SetSampleRate((wxUint32) srate);
|
sndformat.SetSampleRate((wxUint32) srate);
|
||||||
sndformat.SetBPS(bps);
|
sndformat.SetBPS(bps);
|
||||||
sndformat.SetChannels(channels);
|
sndformat.SetChannels(channels);
|
||||||
sndformat.Signed(FALSE);
|
sndformat.Signed(false);
|
||||||
sndformat.SetOrder(wxBIG_ENDIAN);
|
sndformat.SetOrder(wxBIG_ENDIAN);
|
||||||
|
|
||||||
if (!SetSoundFormat(sndformat))
|
if (!SetSoundFormat(sndformat))
|
||||||
return FALSE;
|
return false;
|
||||||
// We pass all data left
|
// We pass all data left
|
||||||
m_input->SeekI(len-18, wxFromCurrent);
|
m_input->SeekI(len-18, wxFromCurrent);
|
||||||
break;
|
break;
|
||||||
@@ -165,7 +165,7 @@ bool wxSoundAiff::PrepareToPlay()
|
|||||||
m_base_offset = m_input->TellI();
|
m_base_offset = m_input->TellI();
|
||||||
// len-8 bytes of samples
|
// len-8 bytes of samples
|
||||||
FinishPreparation(len - 8);
|
FinishPreparation(len - 8);
|
||||||
end_headers = TRUE;
|
end_headers = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -173,28 +173,28 @@ bool wxSoundAiff::PrepareToPlay()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundAiff::PrepareToRecord(wxUint32 WXUNUSED(time))
|
bool wxSoundAiff::PrepareToRecord(wxUint32 WXUNUSED(time))
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundAiff::FinishRecording()
|
bool wxSoundAiff::FinishRecording()
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundAiff::RepositionStream(wxUint32 WXUNUSED(position))
|
bool wxSoundAiff::RepositionStream(wxUint32 WXUNUSED(position))
|
||||||
{
|
{
|
||||||
// If the stream is not seekable "TellI() returns wxInvalidOffset" we cannot reposition stream
|
// If the stream is not seekable "TellI() returns wxInvalidOffset" we cannot reposition stream
|
||||||
if (m_base_offset == wxInvalidOffset)
|
if (m_base_offset == wxInvalidOffset)
|
||||||
return FALSE;
|
return false;
|
||||||
m_input->SeekI(m_base_offset, wxFromStart);
|
m_input->SeekI(m_base_offset, wxFromStart);
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxUint32 wxSoundAiff::GetData(void *buffer, wxUint32 len)
|
wxUint32 wxSoundAiff::GetData(void *buffer, wxUint32 len)
|
||||||
|
@@ -72,7 +72,7 @@ wxSoundStream::~wxSoundStream()
|
|||||||
// important function of the wxSoundStream class. It prepares the stream to
|
// important function of the wxSoundStream class. It prepares the stream to
|
||||||
// receive or send the data in a strict format. Normally, the sound stream
|
// receive or send the data in a strict format. Normally, the sound stream
|
||||||
// should be ready to accept any format it is asked to manage but in certain
|
// should be ready to accept any format it is asked to manage but in certain
|
||||||
// cases, it really cannot: in that case it returns FALSE. To have more
|
// cases, it really cannot: in that case it returns false. To have more
|
||||||
// details in the functionnalities of SetSoundFormat see
|
// details in the functionnalities of SetSoundFormat see
|
||||||
// wxSoundRouterStream::SetSoundFormat()
|
// wxSoundRouterStream::SetSoundFormat()
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@@ -84,7 +84,7 @@ bool wxSoundStream::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
|
|
||||||
// create a new one by cloning the format passed in parameter
|
// create a new one by cloning the format passed in parameter
|
||||||
m_sndformat = format.Clone();
|
m_sndformat = format.Clone();
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -279,11 +279,11 @@ bool wxSoundStreamPcm::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
if (m_sndio->SetSoundFormat(format)) {
|
if (m_sndio->SetSoundFormat(format)) {
|
||||||
m_function_out = NULL;
|
m_function_out = NULL;
|
||||||
m_function_in = NULL;
|
m_function_in = NULL;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
if (format.GetType() != wxSOUND_PCM) {
|
if (format.GetType() != wxSOUND_PCM) {
|
||||||
m_snderror = wxSOUND_INVFRMT;
|
m_snderror = wxSOUND_INVFRMT;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
if (m_sndformat)
|
if (m_sndformat)
|
||||||
delete m_sndformat;
|
delete m_sndformat;
|
||||||
@@ -300,11 +300,11 @@ bool wxSoundStreamPcm::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
|
|
||||||
src_rate = pcm_format->GetSampleRate();
|
src_rate = pcm_format->GetSampleRate();
|
||||||
dst_rate = pcm_format2->GetSampleRate();
|
dst_rate = pcm_format2->GetSampleRate();
|
||||||
m_needResampling = TRUE;
|
m_needResampling = true;
|
||||||
if (src_rate < dst_rate)
|
if (src_rate < dst_rate)
|
||||||
m_expandSamples = TRUE;
|
m_expandSamples = true;
|
||||||
else
|
else
|
||||||
m_expandSamples = FALSE;
|
m_expandSamples = false;
|
||||||
m_pitch = (src_rate << FLOATBITS) / dst_rate;
|
m_pitch = (src_rate << FLOATBITS) / dst_rate;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -327,7 +327,7 @@ bool wxSoundStreamPcm::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// TODO: Add something here: error, log, ...
|
// TODO: Add something here: error, log, ...
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
switch (pcm_format2->GetBPS()) {
|
switch (pcm_format2->GetBPS()) {
|
||||||
case 8:
|
case 8:
|
||||||
@@ -338,7 +338,7 @@ bool wxSoundStreamPcm::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// TODO: Add something here: error, log, ...
|
// TODO: Add something here: error, log, ...
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pcm_format2->Signed() != pcm_format->Signed())
|
if (pcm_format2->Signed() != pcm_format->Signed())
|
||||||
@@ -399,7 +399,7 @@ bool wxSoundStreamPcm::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
wxUnusedVar( SetSoundFormatReturn );
|
wxUnusedVar( SetSoundFormatReturn );
|
||||||
|
|
||||||
m_sndformat = new_format;
|
m_sndformat = new_format;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxUint32 wxSoundStreamPcm::GetWriteSize(wxUint32 len) const
|
wxUint32 wxSoundStreamPcm::GetWriteSize(wxUint32 len) const
|
||||||
|
@@ -62,7 +62,7 @@ wxSoundStreamESD::wxSoundStreamESD(const wxString& hostname)
|
|||||||
wxSoundFormatPcm pcm_default;
|
wxSoundFormatPcm pcm_default;
|
||||||
|
|
||||||
// First, we make some basic test: is there ESD on this computer ?
|
// First, we make some basic test: is there ESD on this computer ?
|
||||||
m_esd_ok = FALSE;
|
m_esd_ok = false;
|
||||||
|
|
||||||
if (hostname.IsNull())
|
if (hostname.IsNull())
|
||||||
m_fd_output = esd_play_stream(ESD_PLAY | ESD_STREAM, 22050,
|
m_fd_output = esd_play_stream(ESD_PLAY | ESD_STREAM, 22050,
|
||||||
@@ -86,9 +86,9 @@ wxSoundStreamESD::wxSoundStreamESD(const wxString& hostname)
|
|||||||
|
|
||||||
// Initialize some variable
|
// Initialize some variable
|
||||||
m_snderror = wxSOUND_NOERROR;
|
m_snderror = wxSOUND_NOERROR;
|
||||||
m_esd_stop = TRUE;
|
m_esd_stop = true;
|
||||||
m_q_filled = TRUE;
|
m_q_filled = true;
|
||||||
m_esd_ok = TRUE;
|
m_esd_ok = true;
|
||||||
m_fd_output= -1;
|
m_fd_output= -1;
|
||||||
m_fd_input = -1;
|
m_fd_input = -1;
|
||||||
#endif // defined HAVE_ESD_H
|
#endif // defined HAVE_ESD_H
|
||||||
@@ -154,7 +154,7 @@ wxSoundStream& wxSoundStreamESD::Write(const void *buffer, wxUint32 len)
|
|||||||
else
|
else
|
||||||
m_snderror = wxSOUND_NOERROR;
|
m_snderror = wxSOUND_NOERROR;
|
||||||
|
|
||||||
m_q_filled = TRUE;
|
m_q_filled = true;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
#endif // defined HAVE_ESD_H
|
#endif // defined HAVE_ESD_H
|
||||||
@@ -168,18 +168,18 @@ bool wxSoundStreamESD::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
{
|
{
|
||||||
#ifndef HAVE_ESD_H
|
#ifndef HAVE_ESD_H
|
||||||
m_snderror = wxSOUND_INVDEV;
|
m_snderror = wxSOUND_INVDEV;
|
||||||
return FALSE;
|
return false;
|
||||||
#else
|
#else
|
||||||
wxSoundFormatPcm *pcm_format;
|
wxSoundFormatPcm *pcm_format;
|
||||||
|
|
||||||
if (format.GetType() != wxSOUND_PCM) {
|
if (format.GetType() != wxSOUND_PCM) {
|
||||||
m_snderror = wxSOUND_INVFRMT;
|
m_snderror = wxSOUND_INVFRMT;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_esd_ok) {
|
if (!m_esd_ok) {
|
||||||
m_snderror = wxSOUND_INVDEV;
|
m_snderror = wxSOUND_INVDEV;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_sndformat)
|
if (m_sndformat)
|
||||||
@@ -188,7 +188,7 @@ bool wxSoundStreamESD::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
m_sndformat = format.Clone();
|
m_sndformat = format.Clone();
|
||||||
if (!m_sndformat) {
|
if (!m_sndformat) {
|
||||||
m_snderror = wxSOUND_MEMERROR;
|
m_snderror = wxSOUND_MEMERROR;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
pcm_format = (wxSoundFormatPcm *)m_sndformat;
|
pcm_format = (wxSoundFormatPcm *)m_sndformat;
|
||||||
|
|
||||||
@@ -198,9 +198,9 @@ bool wxSoundStreamESD::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
m_snderror = wxSOUND_NOERROR;
|
m_snderror = wxSOUND_NOERROR;
|
||||||
if (*pcm_format != format) {
|
if (*pcm_format != format) {
|
||||||
m_snderror = wxSOUND_NOEXACT;
|
m_snderror = wxSOUND_NOEXACT;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return true;
|
||||||
#endif // defined HAVE_ESD_H
|
#endif // defined HAVE_ESD_H
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ static void _wxSound_OSS_CBack(gpointer data, int source,
|
|||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
void wxSoundStreamESD::WakeUpEvt(int evt)
|
void wxSoundStreamESD::WakeUpEvt(int evt)
|
||||||
{
|
{
|
||||||
m_q_filled = FALSE;
|
m_q_filled = false;
|
||||||
OnSoundEvent(evt);
|
OnSoundEvent(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,14 +245,14 @@ bool wxSoundStreamESD::StartProduction(int evt)
|
|||||||
{
|
{
|
||||||
#ifndef HAVE_ESD_H
|
#ifndef HAVE_ESD_H
|
||||||
m_snderror = wxSOUND_INVDEV;
|
m_snderror = wxSOUND_INVDEV;
|
||||||
return FALSE;
|
return false;
|
||||||
#else
|
#else
|
||||||
wxSoundFormatPcm *pcm;
|
wxSoundFormatPcm *pcm;
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
|
|
||||||
if (!m_esd_ok) {
|
if (!m_esd_ok) {
|
||||||
m_snderror = wxSOUND_INVDEV;
|
m_snderror = wxSOUND_INVDEV;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_esd_stop)
|
if (!m_esd_stop)
|
||||||
@@ -286,10 +286,10 @@ bool wxSoundStreamESD::StartProduction(int evt)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_esd_stop = FALSE;
|
m_esd_stop = false;
|
||||||
m_q_filled = FALSE;
|
m_q_filled = false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
#endif // defined HAVE_ESD_H
|
#endif // defined HAVE_ESD_H
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,10 +300,10 @@ bool wxSoundStreamESD::StopProduction()
|
|||||||
{
|
{
|
||||||
#ifndef HAVE_ESD_H
|
#ifndef HAVE_ESD_H
|
||||||
m_snderror = wxSOUND_INVDEV;
|
m_snderror = wxSOUND_INVDEV;
|
||||||
return FALSE;
|
return false;
|
||||||
#else
|
#else
|
||||||
if (m_esd_stop)
|
if (m_esd_stop)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (m_fd_input != -1) {
|
if (m_fd_input != -1) {
|
||||||
esd_close(m_fd_input);
|
esd_close(m_fd_input);
|
||||||
@@ -320,9 +320,9 @@ bool wxSoundStreamESD::StopProduction()
|
|||||||
|
|
||||||
m_fd_input = -1;
|
m_fd_input = -1;
|
||||||
m_fd_output= -1;
|
m_fd_output= -1;
|
||||||
m_esd_stop = TRUE;
|
m_esd_stop = true;
|
||||||
m_q_filled = TRUE;
|
m_q_filled = true;
|
||||||
return TRUE;
|
return true;
|
||||||
#endif // defined HAVE_ESD_H
|
#endif // defined HAVE_ESD_H
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,7 +350,7 @@ void wxSoundStreamESD::DetectBest(wxSoundFormatPcm *pcm)
|
|||||||
best_pcm.SetBPS(8);
|
best_pcm.SetBPS(8);
|
||||||
|
|
||||||
best_pcm.SetOrder(wxLITTLE_ENDIAN);
|
best_pcm.SetOrder(wxLITTLE_ENDIAN);
|
||||||
best_pcm.Signed(TRUE);
|
best_pcm.Signed(true);
|
||||||
|
|
||||||
// Finally recopy the new format
|
// Finally recopy the new format
|
||||||
*pcm = best_pcm;
|
*pcm = best_pcm;
|
||||||
|
@@ -78,7 +78,7 @@ wxSoundStream& wxSoundRouterStream::Write(const void *buffer, wxUint32 len)
|
|||||||
// sound driver using the specified format. If this fails, it uses personnal
|
// sound driver using the specified format. If this fails, it uses personnal
|
||||||
// codec converters: for the moment there is a PCM converter (PCM to PCM:
|
// codec converters: for the moment there is a PCM converter (PCM to PCM:
|
||||||
// with optional resampling, ...), an ULAW converter (ULAW to PCM), a G72X
|
// with optional resampling, ...), an ULAW converter (ULAW to PCM), a G72X
|
||||||
// converter (G72X to PCM). If nothing works, it returns FALSE.
|
// converter (G72X to PCM). If nothing works, it returns false.
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
bool wxSoundRouterStream::SetSoundFormat(const wxSoundFormatBase& format)
|
bool wxSoundRouterStream::SetSoundFormat(const wxSoundFormatBase& format)
|
||||||
{
|
{
|
||||||
@@ -89,12 +89,12 @@ bool wxSoundRouterStream::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
if (m_sndio->SetSoundFormat(format)) {
|
if (m_sndio->SetSoundFormat(format)) {
|
||||||
// We are lucky, it is working.
|
// We are lucky, it is working.
|
||||||
wxSoundStream::SetSoundFormat(m_sndio->GetSoundFormat());
|
wxSoundStream::SetSoundFormat(m_sndio->GetSoundFormat());
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(format.GetType()) {
|
switch(format.GetType()) {
|
||||||
case wxSOUND_NOFORMAT:
|
case wxSOUND_NOFORMAT:
|
||||||
return FALSE;
|
return false;
|
||||||
case wxSOUND_PCM:
|
case wxSOUND_PCM:
|
||||||
m_router = new wxSoundStreamPcm(*m_sndio);
|
m_router = new wxSoundStreamPcm(*m_sndio);
|
||||||
m_router->SetSoundFormat(format);
|
m_router->SetSoundFormat(format);
|
||||||
@@ -112,11 +112,11 @@ bool wxSoundRouterStream::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
m_router->SetSoundFormat(format);
|
m_router->SetSoundFormat(format);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
wxSoundStream::SetSoundFormat(m_router->GetSoundFormat());
|
wxSoundStream::SetSoundFormat(m_router->GetSoundFormat());
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@@ -139,19 +139,19 @@ bool wxSoundRouterStream::StartProduction(int evt)
|
|||||||
{
|
{
|
||||||
if (!m_router) {
|
if (!m_router) {
|
||||||
if (m_sndio->StartProduction(evt))
|
if (m_sndio->StartProduction(evt))
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
m_snderror = m_sndio->GetError();
|
m_snderror = m_sndio->GetError();
|
||||||
m_lastcount = m_sndio->GetLastAccess();
|
m_lastcount = m_sndio->GetLastAccess();
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_router->StartProduction(evt))
|
if (m_router->StartProduction(evt))
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
m_snderror = m_router->GetError();
|
m_snderror = m_router->GetError();
|
||||||
m_lastcount = m_router->GetLastAccess();
|
m_lastcount = m_router->GetLastAccess();
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@@ -161,19 +161,19 @@ bool wxSoundRouterStream::StopProduction()
|
|||||||
{
|
{
|
||||||
if (!m_router) {
|
if (!m_router) {
|
||||||
if (m_sndio->StopProduction())
|
if (m_sndio->StopProduction())
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
m_snderror = m_sndio->GetError();
|
m_snderror = m_sndio->GetError();
|
||||||
m_lastcount = m_sndio->GetLastAccess();
|
m_lastcount = m_sndio->GetLastAccess();
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_router->StopProduction())
|
if (m_router->StopProduction())
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
m_snderror = m_router->GetError();
|
m_snderror = m_router->GetError();
|
||||||
m_lastcount = m_router->GetLastAccess();
|
m_lastcount = m_router->GetLastAccess();
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@@ -187,7 +187,7 @@ wxSoundFileStream::wxSoundFileStream(wxInputStream& stream,
|
|||||||
{
|
{
|
||||||
m_length = 0;
|
m_length = 0;
|
||||||
m_bytes_left = 0;
|
m_bytes_left = 0;
|
||||||
m_prepared = FALSE;
|
m_prepared = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSoundFileStream::wxSoundFileStream(wxOutputStream& stream,
|
wxSoundFileStream::wxSoundFileStream(wxOutputStream& stream,
|
||||||
@@ -197,7 +197,7 @@ wxSoundFileStream::wxSoundFileStream(wxOutputStream& stream,
|
|||||||
{
|
{
|
||||||
m_length = 0;
|
m_length = 0;
|
||||||
m_bytes_left = 0;
|
m_bytes_left = 0;
|
||||||
m_prepared = FALSE;
|
m_prepared = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSoundFileStream::~wxSoundFileStream()
|
wxSoundFileStream::~wxSoundFileStream()
|
||||||
@@ -209,51 +209,51 @@ wxSoundFileStream::~wxSoundFileStream()
|
|||||||
bool wxSoundFileStream::Play()
|
bool wxSoundFileStream::Play()
|
||||||
{
|
{
|
||||||
if (m_state != wxSOUND_FILE_STOPPED)
|
if (m_state != wxSOUND_FILE_STOPPED)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (!m_prepared)
|
if (!m_prepared)
|
||||||
if (!PrepareToPlay())
|
if (!PrepareToPlay())
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_state = wxSOUND_FILE_PLAYING;
|
m_state = wxSOUND_FILE_PLAYING;
|
||||||
|
|
||||||
if (!StartProduction(wxSOUND_OUTPUT))
|
if (!StartProduction(wxSOUND_OUTPUT))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundFileStream::Record(wxUint32 time)
|
bool wxSoundFileStream::Record(wxUint32 time)
|
||||||
{
|
{
|
||||||
if (m_state != wxSOUND_FILE_STOPPED)
|
if (m_state != wxSOUND_FILE_STOPPED)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (!PrepareToRecord(time))
|
if (!PrepareToRecord(time))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
FinishPreparation(m_sndformat->GetBytesFromTime(time));
|
FinishPreparation(m_sndformat->GetBytesFromTime(time));
|
||||||
|
|
||||||
m_state = wxSOUND_FILE_RECORDING;
|
m_state = wxSOUND_FILE_RECORDING;
|
||||||
if (!StartProduction(wxSOUND_INPUT))
|
if (!StartProduction(wxSOUND_INPUT))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundFileStream::Stop()
|
bool wxSoundFileStream::Stop()
|
||||||
{
|
{
|
||||||
if (m_state == wxSOUND_FILE_STOPPED)
|
if (m_state == wxSOUND_FILE_STOPPED)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (!StopProduction())
|
if (!StopProduction())
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_prepared = FALSE;
|
m_prepared = false;
|
||||||
|
|
||||||
if (m_state == wxSOUND_FILE_RECORDING)
|
if (m_state == wxSOUND_FILE_RECORDING)
|
||||||
if (!FinishRecording()) {
|
if (!FinishRecording()) {
|
||||||
m_state = wxSOUND_FILE_STOPPED;
|
m_state = wxSOUND_FILE_STOPPED;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_input)
|
if (m_input)
|
||||||
@@ -263,35 +263,35 @@ bool wxSoundFileStream::Stop()
|
|||||||
m_output->SeekO(0, wxFromStart);
|
m_output->SeekO(0, wxFromStart);
|
||||||
|
|
||||||
m_state = wxSOUND_FILE_STOPPED;
|
m_state = wxSOUND_FILE_STOPPED;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundFileStream::Pause()
|
bool wxSoundFileStream::Pause()
|
||||||
{
|
{
|
||||||
if (m_state == wxSOUND_FILE_PAUSED || m_state == wxSOUND_FILE_STOPPED)
|
if (m_state == wxSOUND_FILE_PAUSED || m_state == wxSOUND_FILE_STOPPED)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (!StopProduction())
|
if (!StopProduction())
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_oldstate = m_state;
|
m_oldstate = m_state;
|
||||||
m_state = wxSOUND_FILE_PAUSED;
|
m_state = wxSOUND_FILE_PAUSED;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundFileStream::Resume()
|
bool wxSoundFileStream::Resume()
|
||||||
{
|
{
|
||||||
if (m_state == wxSOUND_FILE_PLAYING || m_state == wxSOUND_FILE_RECORDING ||
|
if (m_state == wxSOUND_FILE_PLAYING || m_state == wxSOUND_FILE_RECORDING ||
|
||||||
m_state == wxSOUND_FILE_STOPPED)
|
m_state == wxSOUND_FILE_STOPPED)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (!StartProduction( (m_oldstate == wxSOUND_FILE_PLAYING) ?
|
if (!StartProduction( (m_oldstate == wxSOUND_FILE_PLAYING) ?
|
||||||
wxSOUND_OUTPUT : wxSOUND_INPUT))
|
wxSOUND_OUTPUT : wxSOUND_INPUT))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_state = m_oldstate;
|
m_state = m_oldstate;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSoundStream& wxSoundFileStream::Read(void *buffer, wxUint32 len)
|
wxSoundStream& wxSoundFileStream::Read(void *buffer, wxUint32 len)
|
||||||
@@ -321,9 +321,9 @@ bool wxSoundFileStream::StartProduction(int evt)
|
|||||||
m_sndio->SetEventHandler(this);
|
m_sndio->SetEventHandler(this);
|
||||||
|
|
||||||
if (!m_codec.StartProduction(evt))
|
if (!m_codec.StartProduction(evt))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundFileStream::StopProduction()
|
bool wxSoundFileStream::StopProduction()
|
||||||
@@ -334,7 +334,7 @@ bool wxSoundFileStream::StopProduction()
|
|||||||
void wxSoundFileStream::FinishPreparation(wxUint32 len)
|
void wxSoundFileStream::FinishPreparation(wxUint32 len)
|
||||||
{
|
{
|
||||||
m_bytes_left = m_length = len;
|
m_bytes_left = m_length = len;
|
||||||
m_prepared = TRUE;
|
m_prepared = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxSoundFileStream::GetCodecName() const
|
wxString wxSoundFileStream::GetCodecName() const
|
||||||
|
@@ -104,7 +104,7 @@ bool wxSoundFormatG72X::operator !=(const wxSoundFormatBase& frmt2) const
|
|||||||
wxSoundFormatG72X *g72x = (wxSoundFormatG72X *)&frmt2;
|
wxSoundFormatG72X *g72x = (wxSoundFormatG72X *)&frmt2;
|
||||||
|
|
||||||
if (frmt2.GetType() != wxSOUND_G72X)
|
if (frmt2.GetType() != wxSOUND_G72X)
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
return (g72x->m_srate != m_srate || g72x->m_g72x_type != m_g72x_type);
|
return (g72x->m_srate != m_srate || g72x->m_g72x_type != m_g72x_type);
|
||||||
}
|
}
|
||||||
@@ -196,7 +196,7 @@ bool wxSoundStreamG72X::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
{
|
{
|
||||||
if (format.GetType() != wxSOUND_G72X) {
|
if (format.GetType() != wxSOUND_G72X) {
|
||||||
m_snderror = wxSOUND_INVFRMT;
|
m_snderror = wxSOUND_INVFRMT;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSoundFormatPcm pcm;
|
wxSoundFormatPcm pcm;
|
||||||
@@ -210,7 +210,7 @@ bool wxSoundStreamG72X::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
pcm.SetSampleRate(g72x->GetSampleRate());
|
pcm.SetSampleRate(g72x->GetSampleRate());
|
||||||
pcm.SetBPS(16);
|
pcm.SetBPS(16);
|
||||||
pcm.SetChannels(1); // Only mono supported
|
pcm.SetChannels(1); // Only mono supported
|
||||||
pcm.Signed(TRUE);
|
pcm.Signed(true);
|
||||||
pcm.SetOrder(wxBYTE_ORDER);
|
pcm.SetOrder(wxBYTE_ORDER);
|
||||||
|
|
||||||
// Look for the correct codec to use and set its bit width
|
// Look for the correct codec to use and set its bit width
|
||||||
@@ -235,7 +235,7 @@ bool wxSoundStreamG72X::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
// Let the router finish the work
|
// Let the router finish the work
|
||||||
m_router->SetSoundFormat(pcm);
|
m_router->SetSoundFormat(pcm);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BYTE_SIZE 8
|
#define BYTE_SIZE 8
|
||||||
|
@@ -130,7 +130,7 @@ bool wxSoundFormatMSAdpcm::operator !=(const wxSoundFormatBase& frmt2) const
|
|||||||
const wxSoundFormatMSAdpcm *adpcm = (const wxSoundFormatMSAdpcm *)&frmt2;
|
const wxSoundFormatMSAdpcm *adpcm = (const wxSoundFormatMSAdpcm *)&frmt2;
|
||||||
|
|
||||||
if (frmt2.GetType() != wxSOUND_MSADPCM)
|
if (frmt2.GetType() != wxSOUND_MSADPCM)
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
return (adpcm->m_srate != m_srate) && (adpcm->m_nchannels != m_nchannels);
|
return (adpcm->m_srate != m_srate) && (adpcm->m_nchannels != m_nchannels);
|
||||||
}
|
}
|
||||||
@@ -143,8 +143,8 @@ wxSoundStreamMSAdpcm::wxSoundStreamMSAdpcm(wxSoundStream& sndio)
|
|||||||
{
|
{
|
||||||
// PCM converter
|
// PCM converter
|
||||||
m_router = new wxSoundRouterStream(sndio);
|
m_router = new wxSoundRouterStream(sndio);
|
||||||
m_got_header = FALSE;
|
m_got_header = false;
|
||||||
m_stereo = FALSE;
|
m_stereo = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSoundStreamMSAdpcm::~wxSoundStreamMSAdpcm()
|
wxSoundStreamMSAdpcm::~wxSoundStreamMSAdpcm()
|
||||||
@@ -354,7 +354,7 @@ bool wxSoundStreamMSAdpcm::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
{
|
{
|
||||||
if (format.GetType() != wxSOUND_MSADPCM) {
|
if (format.GetType() != wxSOUND_MSADPCM) {
|
||||||
m_snderror = wxSOUND_INVFRMT;
|
m_snderror = wxSOUND_INVFRMT;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSoundFormatPcm pcm;
|
wxSoundFormatPcm pcm;
|
||||||
@@ -369,13 +369,13 @@ bool wxSoundStreamMSAdpcm::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
|
|
||||||
if (!ncoefs) {
|
if (!ncoefs) {
|
||||||
wxLogError(wxT("Number of ADPCM coefficients must be non null"));
|
wxLogError(wxT("Number of ADPCM coefficients must be non null"));
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pcm.SetSampleRate(adpcm->GetSampleRate());
|
pcm.SetSampleRate(adpcm->GetSampleRate());
|
||||||
pcm.SetBPS(16);
|
pcm.SetBPS(16);
|
||||||
pcm.SetChannels(adpcm->GetChannels());
|
pcm.SetChannels(adpcm->GetChannels());
|
||||||
pcm.Signed(TRUE);
|
pcm.Signed(true);
|
||||||
pcm.SetOrder(wxBYTE_ORDER);
|
pcm.SetOrder(wxBYTE_ORDER);
|
||||||
|
|
||||||
m_stereo = (adpcm->GetChannels() == 2);
|
m_stereo = (adpcm->GetChannels() == 2);
|
||||||
@@ -384,6 +384,6 @@ bool wxSoundStreamMSAdpcm::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
|
|
||||||
m_router->SetSoundFormat(pcm);
|
m_router->SetSoundFormat(pcm);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@ wxSoundStreamOSS::wxSoundStreamOSS(const wxString& dev_name)
|
|||||||
m_fd = open(dev_name.mb_str(), O_WRONLY);
|
m_fd = open(dev_name.mb_str(), O_WRONLY);
|
||||||
if (m_fd == -1) {
|
if (m_fd == -1) {
|
||||||
// OSS not found
|
// OSS not found
|
||||||
m_oss_ok = FALSE;
|
m_oss_ok = false;
|
||||||
m_snderror = wxSOUND_INVDEV;
|
m_snderror = wxSOUND_INVDEV;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -59,9 +59,9 @@ wxSoundStreamOSS::wxSoundStreamOSS(const wxString& dev_name)
|
|||||||
// Close OSS
|
// Close OSS
|
||||||
close(m_fd);
|
close(m_fd);
|
||||||
|
|
||||||
m_oss_ok = TRUE;
|
m_oss_ok = true;
|
||||||
m_oss_stop = TRUE;
|
m_oss_stop = true;
|
||||||
m_q_filled = TRUE;
|
m_q_filled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSoundStreamOSS::~wxSoundStreamOSS()
|
wxSoundStreamOSS::~wxSoundStreamOSS()
|
||||||
@@ -86,7 +86,7 @@ wxSoundStream& wxSoundStreamOSS::Read(void *buffer, wxUint32 len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_lastcount = (wxUint32)ret = read(m_fd, buffer, len);
|
m_lastcount = (wxUint32)ret = read(m_fd, buffer, len);
|
||||||
m_q_filled = TRUE;
|
m_q_filled = true;
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
m_snderror = wxSOUND_IOERROR;
|
m_snderror = wxSOUND_IOERROR;
|
||||||
@@ -107,7 +107,7 @@ wxSoundStream& wxSoundStreamOSS::Write(const void *buffer, wxUint32 len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = write(m_fd, buffer, len);
|
ret = write(m_fd, buffer, len);
|
||||||
m_q_filled = TRUE;
|
m_q_filled = true;
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
m_lastcount = 0;
|
m_lastcount = 0;
|
||||||
@@ -127,12 +127,12 @@ bool wxSoundStreamOSS::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
|
|
||||||
if (format.GetType() != wxSOUND_PCM) {
|
if (format.GetType() != wxSOUND_PCM) {
|
||||||
m_snderror = wxSOUND_INVFRMT;
|
m_snderror = wxSOUND_INVFRMT;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_oss_ok) {
|
if (!m_oss_ok) {
|
||||||
m_snderror = wxSOUND_INVDEV;
|
m_snderror = wxSOUND_INVDEV;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_sndformat)
|
if (m_sndformat)
|
||||||
@@ -141,7 +141,7 @@ bool wxSoundStreamOSS::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
m_sndformat = format.Clone();
|
m_sndformat = format.Clone();
|
||||||
if (!m_sndformat) {
|
if (!m_sndformat) {
|
||||||
m_snderror = wxSOUND_MEMERROR;
|
m_snderror = wxSOUND_MEMERROR;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
pcm_format = (wxSoundFormatPcm *)m_sndformat;
|
pcm_format = (wxSoundFormatPcm *)m_sndformat;
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ bool wxSoundStreamOSS::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
m_fd = open(m_devname.mb_str(), O_WRONLY);
|
m_fd = open(m_devname.mb_str(), O_WRONLY);
|
||||||
if (m_fd == -1) {
|
if (m_fd == -1) {
|
||||||
m_snderror = wxSOUND_INVDEV;
|
m_snderror = wxSOUND_INVDEV;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,10 +176,10 @@ bool wxSoundStreamOSS::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
m_snderror = wxSOUND_NOERROR;
|
m_snderror = wxSOUND_NOERROR;
|
||||||
if (*pcm_format != format) {
|
if (*pcm_format != format) {
|
||||||
m_snderror = wxSOUND_NOEXACT;
|
m_snderror = wxSOUND_NOEXACT;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundStreamOSS::SetupFormat(wxSoundFormatPcm *pcm_format)
|
bool wxSoundStreamOSS::SetupFormat(wxSoundFormatPcm *pcm_format)
|
||||||
@@ -217,34 +217,34 @@ bool wxSoundStreamOSS::SetupFormat(wxSoundFormatPcm *pcm_format)
|
|||||||
switch (tmp) {
|
switch (tmp) {
|
||||||
case AFMT_U8:
|
case AFMT_U8:
|
||||||
pcm_format->SetBPS(8);
|
pcm_format->SetBPS(8);
|
||||||
pcm_format->Signed(FALSE);
|
pcm_format->Signed(false);
|
||||||
break;
|
break;
|
||||||
case AFMT_S8:
|
case AFMT_S8:
|
||||||
pcm_format->SetBPS(8);
|
pcm_format->SetBPS(8);
|
||||||
pcm_format->Signed(TRUE);
|
pcm_format->Signed(true);
|
||||||
break;
|
break;
|
||||||
case AFMT_U16_LE:
|
case AFMT_U16_LE:
|
||||||
pcm_format->SetBPS(16);
|
pcm_format->SetBPS(16);
|
||||||
pcm_format->Signed(FALSE);
|
pcm_format->Signed(false);
|
||||||
pcm_format->SetOrder(wxLITTLE_ENDIAN);
|
pcm_format->SetOrder(wxLITTLE_ENDIAN);
|
||||||
break;
|
break;
|
||||||
case AFMT_U16_BE:
|
case AFMT_U16_BE:
|
||||||
pcm_format->SetBPS(16);
|
pcm_format->SetBPS(16);
|
||||||
pcm_format->Signed(FALSE);
|
pcm_format->Signed(false);
|
||||||
pcm_format->SetOrder(wxBIG_ENDIAN);
|
pcm_format->SetOrder(wxBIG_ENDIAN);
|
||||||
break;
|
break;
|
||||||
case AFMT_S16_LE:
|
case AFMT_S16_LE:
|
||||||
pcm_format->SetBPS(16);
|
pcm_format->SetBPS(16);
|
||||||
pcm_format->Signed(TRUE);
|
pcm_format->Signed(true);
|
||||||
pcm_format->SetOrder(wxLITTLE_ENDIAN);
|
pcm_format->SetOrder(wxLITTLE_ENDIAN);
|
||||||
break;
|
break;
|
||||||
case AFMT_S16_BE:
|
case AFMT_S16_BE:
|
||||||
pcm_format->SetBPS(16);
|
pcm_format->SetBPS(16);
|
||||||
pcm_format->Signed(TRUE);
|
pcm_format->Signed(true);
|
||||||
pcm_format->SetOrder(wxBIG_ENDIAN);
|
pcm_format->SetOrder(wxBIG_ENDIAN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
@@ -268,7 +268,7 @@ static void _wxSound_OSS_CBack(gpointer data, int source,
|
|||||||
|
|
||||||
void wxSoundStreamOSS::WakeUpEvt(int evt)
|
void wxSoundStreamOSS::WakeUpEvt(int evt)
|
||||||
{
|
{
|
||||||
m_q_filled = FALSE;
|
m_q_filled = false;
|
||||||
OnSoundEvent(evt);
|
OnSoundEvent(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,7 +282,7 @@ bool wxSoundStreamOSS::StartProduction(int evt)
|
|||||||
old_frmt = m_sndformat->Clone();
|
old_frmt = m_sndformat->Clone();
|
||||||
if (!old_frmt) {
|
if (!old_frmt) {
|
||||||
m_snderror = wxSOUND_MEMERROR;
|
m_snderror = wxSOUND_MEMERROR;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt == wxSOUND_OUTPUT)
|
if (evt == wxSOUND_OUTPUT)
|
||||||
@@ -292,7 +292,7 @@ bool wxSoundStreamOSS::StartProduction(int evt)
|
|||||||
|
|
||||||
if (m_fd == -1) {
|
if (m_fd == -1) {
|
||||||
m_snderror = wxSOUND_INVDEV;
|
m_snderror = wxSOUND_INVDEV;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSoundFormat(*old_frmt);
|
SetSoundFormat(*old_frmt);
|
||||||
@@ -314,25 +314,25 @@ bool wxSoundStreamOSS::StartProduction(int evt)
|
|||||||
|
|
||||||
ioctl(m_fd, SNDCTL_DSP_SETTRIGGER, &trig);
|
ioctl(m_fd, SNDCTL_DSP_SETTRIGGER, &trig);
|
||||||
|
|
||||||
m_oss_stop = FALSE;
|
m_oss_stop = false;
|
||||||
m_q_filled = FALSE;
|
m_q_filled = false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundStreamOSS::StopProduction()
|
bool wxSoundStreamOSS::StopProduction()
|
||||||
{
|
{
|
||||||
if (m_oss_stop)
|
if (m_oss_stop)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
gdk_input_remove(m_tag);
|
gdk_input_remove(m_tag);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
close(m_fd);
|
close(m_fd);
|
||||||
m_oss_stop = TRUE;
|
m_oss_stop = true;
|
||||||
m_q_filled = TRUE;
|
m_q_filled = true;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundStreamOSS::QueueFilled() const
|
bool wxSoundStreamOSS::QueueFilled() const
|
||||||
@@ -375,12 +375,12 @@ void wxSoundStreamOSS::DetectBest(wxSoundFormatPcm *pcm)
|
|||||||
// It supports signed samples
|
// It supports signed samples
|
||||||
if (pcm->Signed() &&
|
if (pcm->Signed() &&
|
||||||
((fmt_mask & (AFMT_S16_LE | AFMT_S16_BE | AFMT_S8)) != 0))
|
((fmt_mask & (AFMT_S16_LE | AFMT_S16_BE | AFMT_S8)) != 0))
|
||||||
best_pcm.Signed(TRUE);
|
best_pcm.Signed(true);
|
||||||
|
|
||||||
// It supports unsigned samples
|
// It supports unsigned samples
|
||||||
if (!pcm->Signed() &&
|
if (!pcm->Signed() &&
|
||||||
((fmt_mask & (AFMT_U16_LE | AFMT_U16_BE | AFMT_U8)) != 0))
|
((fmt_mask & (AFMT_U16_LE | AFMT_U16_BE | AFMT_U8)) != 0))
|
||||||
best_pcm.Signed(FALSE);
|
best_pcm.Signed(false);
|
||||||
|
|
||||||
// Finally recopy the new format
|
// Finally recopy the new format
|
||||||
*pcm = best_pcm;
|
*pcm = best_pcm;
|
||||||
|
@@ -88,7 +88,7 @@ bool wxSoundFormatPcm::operator!=(const wxSoundFormatBase& format) const
|
|||||||
wxSoundFormatPcm *format2 = (wxSoundFormatPcm *)&format;
|
wxSoundFormatPcm *format2 = (wxSoundFormatPcm *)&format;
|
||||||
|
|
||||||
if (format.GetType() != wxSOUND_PCM)
|
if (format.GetType() != wxSOUND_PCM)
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
return ( (m_srate != format2->m_srate) ||
|
return ( (m_srate != format2->m_srate) ||
|
||||||
(m_bps != format2->m_bps) ||
|
(m_bps != format2->m_bps) ||
|
||||||
|
@@ -82,7 +82,7 @@ bool wxSoundFormatUlaw::operator !=(const wxSoundFormatBase& frmt2) const
|
|||||||
wxSoundFormatUlaw *ulaw = (wxSoundFormatUlaw *)&frmt2;
|
wxSoundFormatUlaw *ulaw = (wxSoundFormatUlaw *)&frmt2;
|
||||||
|
|
||||||
if (frmt2.GetType() != wxSOUND_ULAW)
|
if (frmt2.GetType() != wxSOUND_ULAW)
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
return (ulaw->m_srate != m_srate);
|
return (ulaw->m_srate != m_srate);
|
||||||
}
|
}
|
||||||
@@ -160,7 +160,7 @@ bool wxSoundStreamUlaw::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
{
|
{
|
||||||
if (format.GetType() != wxSOUND_ULAW) {
|
if (format.GetType() != wxSOUND_ULAW) {
|
||||||
m_snderror = wxSOUND_INVFRMT;
|
m_snderror = wxSOUND_INVFRMT;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// As the codec only support 16 bits, Mono we must use a wxSoundRouter
|
// As the codec only support 16 bits, Mono we must use a wxSoundRouter
|
||||||
@@ -177,10 +177,10 @@ bool wxSoundStreamUlaw::SetSoundFormat(const wxSoundFormatBase& format)
|
|||||||
pcm.SetSampleRate(ulaw->GetSampleRate());
|
pcm.SetSampleRate(ulaw->GetSampleRate());
|
||||||
pcm.SetBPS(16);
|
pcm.SetBPS(16);
|
||||||
pcm.SetChannels(ulaw->GetChannels());
|
pcm.SetChannels(ulaw->GetChannels());
|
||||||
pcm.Signed(TRUE);
|
pcm.Signed(true);
|
||||||
pcm.SetOrder(wxBYTE_ORDER);
|
pcm.SetOrder(wxBYTE_ORDER);
|
||||||
|
|
||||||
m_router->SetSoundFormat(pcm);
|
m_router->SetSoundFormat(pcm);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -64,7 +64,7 @@ wxString wxSoundWave::GetCodecName() const
|
|||||||
return wxString(wxT("wxSoundWave codec"));
|
return wxString(wxT("wxSoundWave codec"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FAIL_WITH(condition, err) if (condition) { m_snderror = err; return FALSE; }
|
#define FAIL_WITH(condition, err) if (condition) { m_snderror = err; return false; }
|
||||||
|
|
||||||
bool wxSoundWave::CanRead()
|
bool wxSoundWave::CanRead()
|
||||||
{
|
{
|
||||||
@@ -77,7 +77,7 @@ bool wxSoundWave::CanRead()
|
|||||||
|
|
||||||
if (wxUINT32_SWAP_ON_BE(signature1) != RIFF_SIGNATURE) {
|
if (wxUINT32_SWAP_ON_BE(signature1) != RIFF_SIGNATURE) {
|
||||||
m_input->Ungetch(&signature1, 4);
|
m_input->Ungetch(&signature1, 4);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass the global length
|
// Pass the global length
|
||||||
@@ -93,9 +93,9 @@ bool wxSoundWave::CanRead()
|
|||||||
|
|
||||||
// Test the second signature
|
// Test the second signature
|
||||||
if (wxUINT32_SWAP_ON_BE(signature2) != WAVE_SIGNATURE)
|
if (wxUINT32_SWAP_ON_BE(signature2) != WAVE_SIGNATURE)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundWave::HandleOutputPCM(wxDataInputStream& WXUNUSED(data), wxUint32 len,
|
bool wxSoundWave::HandleOutputPCM(wxDataInputStream& WXUNUSED(data), wxUint32 len,
|
||||||
@@ -108,15 +108,15 @@ bool wxSoundWave::HandleOutputPCM(wxDataInputStream& WXUNUSED(data), wxUint32 le
|
|||||||
sndformat.SetSampleRate(sample_fq);
|
sndformat.SetSampleRate(sample_fq);
|
||||||
sndformat.SetBPS(bits_p_spl);
|
sndformat.SetBPS(bits_p_spl);
|
||||||
sndformat.SetChannels(channels);
|
sndformat.SetChannels(channels);
|
||||||
sndformat.Signed(TRUE);
|
sndformat.Signed(true);
|
||||||
sndformat.SetOrder(wxLITTLE_ENDIAN);
|
sndformat.SetOrder(wxLITTLE_ENDIAN);
|
||||||
|
|
||||||
if (!SetSoundFormat(sndformat))
|
if (!SetSoundFormat(sndformat))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_input->SeekI(len, wxFromCurrent);
|
m_input->SeekI(len, wxFromCurrent);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundWave::HandleOutputMSADPCM(wxDataInputStream& data, wxUint32 len,
|
bool wxSoundWave::HandleOutputMSADPCM(wxDataInputStream& data, wxUint32 len,
|
||||||
@@ -150,13 +150,13 @@ bool wxSoundWave::HandleOutputMSADPCM(wxDataInputStream& data, wxUint32 len,
|
|||||||
delete[] coefs[1];
|
delete[] coefs[1];
|
||||||
|
|
||||||
if (!SetSoundFormat(sndformat))
|
if (!SetSoundFormat(sndformat))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
len -= coefs_len*4 + 4;
|
len -= coefs_len*4 + 4;
|
||||||
|
|
||||||
m_input->SeekI(len, wxFromCurrent);
|
m_input->SeekI(len, wxFromCurrent);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundWave::HandleOutputG721(wxDataInputStream& WXUNUSED(data), wxUint32 len,
|
bool wxSoundWave::HandleOutputG721(wxDataInputStream& WXUNUSED(data), wxUint32 len,
|
||||||
@@ -170,11 +170,11 @@ bool wxSoundWave::HandleOutputG721(wxDataInputStream& WXUNUSED(data), wxUint32 l
|
|||||||
sndformat.SetG72XType(wxSOUND_G721);
|
sndformat.SetG72XType(wxSOUND_G721);
|
||||||
|
|
||||||
if (!SetSoundFormat(sndformat))
|
if (!SetSoundFormat(sndformat))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_input->SeekI(len, wxFromCurrent);
|
m_input->SeekI(len, wxFromCurrent);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundWave::PrepareToPlay()
|
bool wxSoundWave::PrepareToPlay()
|
||||||
@@ -184,11 +184,11 @@ bool wxSoundWave::PrepareToPlay()
|
|||||||
|
|
||||||
if (!m_input) {
|
if (!m_input) {
|
||||||
m_snderror = wxSOUND_INVSTRM;
|
m_snderror = wxSOUND_INVSTRM;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataInputStream data(*m_input);
|
wxDataInputStream data(*m_input);
|
||||||
data.BigEndianOrdered(FALSE);
|
data.BigEndianOrdered(false);
|
||||||
|
|
||||||
// Get the first signature
|
// Get the first signature
|
||||||
FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM);
|
FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM);
|
||||||
@@ -205,7 +205,7 @@ bool wxSoundWave::PrepareToPlay()
|
|||||||
FAIL_WITH(wxUINT32_SWAP_ON_BE(signature) != WAVE_SIGNATURE, wxSOUND_INVSTRM);
|
FAIL_WITH(wxUINT32_SWAP_ON_BE(signature) != WAVE_SIGNATURE, wxSOUND_INVSTRM);
|
||||||
// "WAVE"
|
// "WAVE"
|
||||||
|
|
||||||
end_headers = FALSE;
|
end_headers = false;
|
||||||
// Chunk loop
|
// Chunk loop
|
||||||
while (!end_headers) {
|
while (!end_headers) {
|
||||||
FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM);
|
FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM);
|
||||||
@@ -228,31 +228,31 @@ bool wxSoundWave::PrepareToPlay()
|
|||||||
if (!HandleOutputPCM(data, len, channels, sample_fq,
|
if (!HandleOutputPCM(data, len, channels, sample_fq,
|
||||||
byte_p_sec, byte_p_spl,
|
byte_p_sec, byte_p_spl,
|
||||||
bits_p_spl))
|
bits_p_spl))
|
||||||
return FALSE;
|
return false;
|
||||||
break;
|
break;
|
||||||
case 0x02: // MS ADPCM
|
case 0x02: // MS ADPCM
|
||||||
if (!HandleOutputMSADPCM(data, len,
|
if (!HandleOutputMSADPCM(data, len,
|
||||||
channels, sample_fq,
|
channels, sample_fq,
|
||||||
byte_p_sec, byte_p_spl,
|
byte_p_sec, byte_p_spl,
|
||||||
bits_p_spl))
|
bits_p_spl))
|
||||||
return FALSE;
|
return false;
|
||||||
break;
|
break;
|
||||||
case 0x40: // G721
|
case 0x40: // G721
|
||||||
if (!HandleOutputG721(data, len,
|
if (!HandleOutputG721(data, len,
|
||||||
channels, sample_fq,
|
channels, sample_fq,
|
||||||
byte_p_sec, byte_p_spl,
|
byte_p_sec, byte_p_spl,
|
||||||
bits_p_spl))
|
bits_p_spl))
|
||||||
return FALSE;
|
return false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
m_snderror = wxSOUND_NOCODEC;
|
m_snderror = wxSOUND_NOCODEC;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DATA_SIGNATURE: // "data"
|
case DATA_SIGNATURE: // "data"
|
||||||
m_base_offset = m_input->TellI();
|
m_base_offset = m_input->TellI();
|
||||||
end_headers = TRUE;
|
end_headers = true;
|
||||||
FinishPreparation(len);
|
FinishPreparation(len);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -261,7 +261,7 @@ bool wxSoundWave::PrepareToPlay()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSoundFormatBase *wxSoundWave::HandleInputPCM(wxDataOutputStream& data)
|
wxSoundFormatBase *wxSoundWave::HandleInputPCM(wxDataOutputStream& data)
|
||||||
@@ -282,7 +282,7 @@ wxSoundFormatBase *wxSoundWave::HandleInputPCM(wxDataOutputStream& data)
|
|||||||
byte_p_sec = pcm->GetBytesFromTime(1);
|
byte_p_sec = pcm->GetBytesFromTime(1);
|
||||||
format = 0x01;
|
format = 0x01;
|
||||||
|
|
||||||
pcm->Signed(TRUE);
|
pcm->Signed(true);
|
||||||
pcm->SetOrder(wxLITTLE_ENDIAN);
|
pcm->SetOrder(wxLITTLE_ENDIAN);
|
||||||
|
|
||||||
data << format << channels << sample_fq
|
data << format << channels << sample_fq
|
||||||
@@ -330,14 +330,14 @@ FAIL_WITH(s->Write(&signature, 4).LastWrite() != 4, wxSOUND_INVSTRM);
|
|||||||
|
|
||||||
if (!m_output) {
|
if (!m_output) {
|
||||||
m_snderror = wxSOUND_INVSTRM;
|
m_snderror = wxSOUND_INVSTRM;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataOutputStream data(*m_output);
|
wxDataOutputStream data(*m_output);
|
||||||
wxDataOutputStream fmt_d_data(fmt_data);
|
wxDataOutputStream fmt_d_data(fmt_data);
|
||||||
|
|
||||||
data.BigEndianOrdered(FALSE);
|
data.BigEndianOrdered(false);
|
||||||
fmt_d_data.BigEndianOrdered(FALSE);
|
fmt_d_data.BigEndianOrdered(false);
|
||||||
|
|
||||||
WRITE_SIGNATURE(m_output, RIFF_SIGNATURE);
|
WRITE_SIGNATURE(m_output, RIFF_SIGNATURE);
|
||||||
|
|
||||||
@@ -359,14 +359,14 @@ FAIL_WITH(s->Write(&signature, 4).LastWrite() != 4, wxSOUND_INVSTRM);
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
m_snderror = wxSOUND_NOCODEC;
|
m_snderror = wxSOUND_NOCODEC;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FAIL_WITH(!frmt, wxSOUND_NOCODEC);
|
FAIL_WITH(!frmt, wxSOUND_NOCODEC);
|
||||||
|
|
||||||
if (!SetSoundFormat(*frmt)) {
|
if (!SetSoundFormat(*frmt)) {
|
||||||
delete frmt;
|
delete frmt;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete frmt;
|
delete frmt;
|
||||||
@@ -387,28 +387,28 @@ FAIL_WITH(s->Write(&signature, 4).LastWrite() != 4, wxSOUND_INVSTRM);
|
|||||||
|
|
||||||
WRITE_SIGNATURE(m_output, DATA_SIGNATURE);
|
WRITE_SIGNATURE(m_output, DATA_SIGNATURE);
|
||||||
data.Write32(m_sndformat->GetBytesFromTime(time));
|
data.Write32(m_sndformat->GetBytesFromTime(time));
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundWave::FinishRecording()
|
bool wxSoundWave::FinishRecording()
|
||||||
{
|
{
|
||||||
if (m_output->SeekO(0, wxFromStart) == wxInvalidOffset)
|
if (m_output->SeekO(0, wxFromStart) == wxInvalidOffset)
|
||||||
// We can't but there is no error.
|
// We can't but there is no error.
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
if (m_bytes_left == 0)
|
if (m_bytes_left == 0)
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
// TODO: Update headers when we stop before the specified time (if possible)
|
// TODO: Update headers when we stop before the specified time (if possible)
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSoundWave::RepositionStream(wxUint32 WXUNUSED(position))
|
bool wxSoundWave::RepositionStream(wxUint32 WXUNUSED(position))
|
||||||
{
|
{
|
||||||
if (m_base_offset == wxInvalidOffset)
|
if (m_base_offset == wxInvalidOffset)
|
||||||
return FALSE;
|
return false;
|
||||||
m_input->SeekI(m_base_offset, wxFromStart);
|
m_input->SeekI(m_base_offset, wxFromStart);
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxUint32 wxSoundWave::GetData(void *buffer, wxUint32 len)
|
wxUint32 wxSoundWave::GetData(void *buffer, wxUint32 len)
|
||||||
|
@@ -80,7 +80,7 @@ wxSoundStreamWin::wxSoundStreamWin()
|
|||||||
{
|
{
|
||||||
wxSoundFormatPcm pcm;
|
wxSoundFormatPcm pcm;
|
||||||
|
|
||||||
m_production_started = FALSE;
|
m_production_started = false;
|
||||||
m_internal = new wxSoundInternal;
|
m_internal = new wxSoundInternal;
|
||||||
if (!m_internal) {
|
if (!m_internal) {
|
||||||
m_snderror = wxSOUND_MEMERROR;
|
m_snderror = wxSOUND_MEMERROR;
|
||||||
@@ -93,10 +93,10 @@ wxSoundStreamWin::wxSoundStreamWin()
|
|||||||
CreateSndWindow();
|
CreateSndWindow();
|
||||||
SetSoundFormat(pcm);
|
SetSoundFormat(pcm);
|
||||||
|
|
||||||
m_internal->m_input_enabled = FALSE;
|
m_internal->m_input_enabled = false;
|
||||||
m_internal->m_output_enabled = FALSE;
|
m_internal->m_output_enabled = false;
|
||||||
|
|
||||||
m_waiting_for = FALSE;
|
m_waiting_for = false;
|
||||||
|
|
||||||
if (!OpenDevice(wxSOUND_OUTPUT)) {
|
if (!OpenDevice(wxSOUND_OUTPUT)) {
|
||||||
m_snderror = wxSOUND_NOERROR; //next call to OpenDevice won't do this
|
m_snderror = wxSOUND_NOERROR; //next call to OpenDevice won't do this
|
||||||
@@ -157,7 +157,7 @@ void wxSoundStreamWin::CreateSndWindow()
|
|||||||
// NB: class name must be kept in sync with wxCanvasClassName in
|
// NB: class name must be kept in sync with wxCanvasClassName in
|
||||||
// src/msw/app.cpp!
|
// src/msw/app.cpp!
|
||||||
m_internal->m_sndWin = ::CreateWindow(wxT("wxWindowClass"), NULL, 0,
|
m_internal->m_sndWin = ::CreateWindow(wxT("wxWindowClass"), NULL, 0,
|
||||||
0, 0, 0, 0, NULL, (HMENU) NULL,
|
0, 0, 0, 0, NULL, (HMENU) NULL,
|
||||||
wxGetInstance(), NULL);
|
wxGetInstance(), NULL);
|
||||||
|
|
||||||
GetLastError();
|
GetLastError();
|
||||||
@@ -199,7 +199,7 @@ bool wxSoundStreamWin::OpenDevice(int mode)
|
|||||||
|
|
||||||
if (!m_sndformat) {
|
if (!m_sndformat) {
|
||||||
m_snderror = wxSOUND_INVFRMT;
|
m_snderror = wxSOUND_INVFRMT;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pcm = (wxSoundFormatPcm *)m_sndformat;
|
pcm = (wxSoundFormatPcm *)m_sndformat;
|
||||||
@@ -225,13 +225,13 @@ bool wxSoundStreamWin::OpenDevice(int mode)
|
|||||||
|
|
||||||
if (result != MMSYSERR_NOERROR) {
|
if (result != MMSYSERR_NOERROR) {
|
||||||
m_snderror = wxSOUND_INVDEV;
|
m_snderror = wxSOUND_INVDEV;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_output_frag_out = WXSOUND_MAX_QUEUE-1;
|
m_output_frag_out = WXSOUND_MAX_QUEUE-1;
|
||||||
m_current_frag_out = 0;
|
m_current_frag_out = 0;
|
||||||
|
|
||||||
m_internal->m_output_enabled = TRUE;
|
m_internal->m_output_enabled = true;
|
||||||
}
|
}
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// Open the driver for Input operation
|
// Open the driver for Input operation
|
||||||
@@ -246,29 +246,29 @@ bool wxSoundStreamWin::OpenDevice(int mode)
|
|||||||
|
|
||||||
if (result != MMSYSERR_NOERROR) {
|
if (result != MMSYSERR_NOERROR) {
|
||||||
m_snderror = wxSOUND_INVDEV;
|
m_snderror = wxSOUND_INVDEV;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_current_frag_in = WXSOUND_MAX_QUEUE-1;
|
m_current_frag_in = WXSOUND_MAX_QUEUE-1;
|
||||||
m_input_frag_in = 0;
|
m_input_frag_in = 0;
|
||||||
|
|
||||||
m_internal->m_input_enabled = TRUE;
|
m_internal->m_input_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode & wxSOUND_OUTPUT) {
|
if (mode & wxSOUND_OUTPUT) {
|
||||||
if (!AllocHeaders(wxSOUND_OUTPUT)) {
|
if (!AllocHeaders(wxSOUND_OUTPUT)) {
|
||||||
CloseDevice();
|
CloseDevice();
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mode & wxSOUND_INPUT) {
|
if (mode & wxSOUND_INPUT) {
|
||||||
if (!AllocHeaders(wxSOUND_INPUT)) {
|
if (!AllocHeaders(wxSOUND_INPUT)) {
|
||||||
CloseDevice();
|
CloseDevice();
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@@ -279,13 +279,13 @@ void wxSoundStreamWin::CloseDevice()
|
|||||||
{
|
{
|
||||||
if (m_internal->m_output_enabled) {
|
if (m_internal->m_output_enabled) {
|
||||||
FreeHeaders(wxSOUND_OUTPUT);
|
FreeHeaders(wxSOUND_OUTPUT);
|
||||||
m_internal->m_output_enabled = FALSE;
|
m_internal->m_output_enabled = false;
|
||||||
waveOutClose(m_internal->m_devout);
|
waveOutClose(m_internal->m_devout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_internal->m_input_enabled) {
|
if (m_internal->m_input_enabled) {
|
||||||
FreeHeaders(wxSOUND_INPUT);
|
FreeHeaders(wxSOUND_INPUT);
|
||||||
m_internal->m_input_enabled = FALSE;
|
m_internal->m_input_enabled = false;
|
||||||
waveInClose(m_internal->m_devin);
|
waveInClose(m_internal->m_devin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -381,8 +381,8 @@ wxSoundInfoHeader *wxSoundStreamWin::AllocHeader(int mode)
|
|||||||
// AllocHeaders() allocates WXSOUND_MAX_QUEUE (= 128) blocks for an operation
|
// AllocHeaders() allocates WXSOUND_MAX_QUEUE (= 128) blocks for an operation
|
||||||
// queue. It uses AllocHeader() for each element.
|
// queue. It uses AllocHeader() for each element.
|
||||||
//
|
//
|
||||||
// Once it has allocated all blocks, it returns TRUE and if an error occured
|
// Once it has allocated all blocks, it returns true and if an error occured
|
||||||
// it returns FALSE.
|
// it returns false.
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
bool wxSoundStreamWin::AllocHeaders(int mode)
|
bool wxSoundStreamWin::AllocHeaders(int mode)
|
||||||
{
|
{
|
||||||
@@ -400,10 +400,10 @@ bool wxSoundStreamWin::AllocHeaders(int mode)
|
|||||||
headers[i] = AllocHeader(mode);
|
headers[i] = AllocHeader(mode);
|
||||||
if (!headers[i]) {
|
if (!headers[i]) {
|
||||||
FreeHeaders(mode);
|
FreeHeaders(mode);
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@@ -482,11 +482,11 @@ void wxSoundStreamWin::WaitFor(wxSoundInfoHeader *info)
|
|||||||
// PROBLEM //
|
// PROBLEM //
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_waiting_for = TRUE;
|
m_waiting_for = true;
|
||||||
// Else, we wait for its termination
|
// Else, we wait for its termination
|
||||||
while (info->m_playing || info->m_recording)
|
while (info->m_playing || info->m_recording)
|
||||||
wxYield();
|
wxYield();
|
||||||
m_waiting_for = FALSE;
|
m_waiting_for = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@@ -508,18 +508,18 @@ bool wxSoundStreamWin::AddToQueue(wxSoundInfoHeader *info)
|
|||||||
result = waveInAddBuffer(m_internal->m_devin,
|
result = waveInAddBuffer(m_internal->m_devin,
|
||||||
info->m_header, sizeof(WAVEHDR));
|
info->m_header, sizeof(WAVEHDR));
|
||||||
if (result == MMSYSERR_NOERROR)
|
if (result == MMSYSERR_NOERROR)
|
||||||
info->m_recording = TRUE;
|
info->m_recording = true;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return false;
|
||||||
} else if (info->m_mode == wxSOUND_OUTPUT) {
|
} else if (info->m_mode == wxSOUND_OUTPUT) {
|
||||||
result = waveOutWrite(m_internal->m_devout,
|
result = waveOutWrite(m_internal->m_devout,
|
||||||
info->m_header, sizeof(WAVEHDR));
|
info->m_header, sizeof(WAVEHDR));
|
||||||
if (result == MMSYSERR_NOERROR)
|
if (result == MMSYSERR_NOERROR)
|
||||||
info->m_playing = TRUE;
|
info->m_playing = true;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@@ -530,8 +530,8 @@ bool wxSoundStreamWin::AddToQueue(wxSoundInfoHeader *info)
|
|||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
void wxSoundStreamWin::ClearHeader(wxSoundInfoHeader *info)
|
void wxSoundStreamWin::ClearHeader(wxSoundInfoHeader *info)
|
||||||
{
|
{
|
||||||
info->m_playing = FALSE;
|
info->m_playing = false;
|
||||||
info->m_recording = FALSE;
|
info->m_recording = false;
|
||||||
info->m_position = 0;
|
info->m_position = 0;
|
||||||
info->m_size = GetBestSize();
|
info->m_size = GetBestSize();
|
||||||
}
|
}
|
||||||
@@ -552,7 +552,7 @@ wxSoundInfoHeader *wxSoundStreamWin::NextFragmentOutput()
|
|||||||
WaitFor(m_headers_play[m_current_frag_out]);
|
WaitFor(m_headers_play[m_current_frag_out]);
|
||||||
}
|
}
|
||||||
if (m_current_frag_out == m_output_frag_out)
|
if (m_current_frag_out == m_output_frag_out)
|
||||||
m_queue_filled = TRUE;
|
m_queue_filled = true;
|
||||||
return m_headers_play[m_current_frag_out];
|
return m_headers_play[m_current_frag_out];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -612,7 +612,7 @@ wxSoundInfoHeader *wxSoundStreamWin::NextFragmentInput()
|
|||||||
|
|
||||||
// We reached the writer position: the queue is full.
|
// We reached the writer position: the queue is full.
|
||||||
if (m_current_frag_in == m_input_frag_in)
|
if (m_current_frag_in == m_input_frag_in)
|
||||||
m_queue_filled = TRUE;
|
m_queue_filled = true;
|
||||||
|
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
@@ -672,7 +672,7 @@ void wxSoundStreamWin::NotifyDoneBuffer(wxUint32 WXUNUSED(dev_handle), int flag)
|
|||||||
info = m_headers_play[m_output_frag_out];
|
info = m_headers_play[m_output_frag_out];
|
||||||
// Clear header to tell the system the buffer is free now
|
// Clear header to tell the system the buffer is free now
|
||||||
ClearHeader(info);
|
ClearHeader(info);
|
||||||
m_queue_filled = FALSE;
|
m_queue_filled = false;
|
||||||
if (!m_waiting_for)
|
if (!m_waiting_for)
|
||||||
// Try to requeue a new buffer.
|
// Try to requeue a new buffer.
|
||||||
OnSoundEvent(wxSOUND_OUTPUT);
|
OnSoundEvent(wxSOUND_OUTPUT);
|
||||||
@@ -681,12 +681,12 @@ void wxSoundStreamWin::NotifyDoneBuffer(wxUint32 WXUNUSED(dev_handle), int flag)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Recording completed
|
// Recording completed
|
||||||
m_headers_rec[m_input_frag_in]->m_recording = FALSE;
|
m_headers_rec[m_input_frag_in]->m_recording = false;
|
||||||
// Queue pointer: writer
|
// Queue pointer: writer
|
||||||
m_input_frag_in = (m_input_frag_in + 1) % WXSOUND_MAX_QUEUE;
|
m_input_frag_in = (m_input_frag_in + 1) % WXSOUND_MAX_QUEUE;
|
||||||
if (!m_waiting_for)
|
if (!m_waiting_for)
|
||||||
OnSoundEvent(wxSOUND_INPUT);
|
OnSoundEvent(wxSOUND_INPUT);
|
||||||
m_queue_filled = FALSE;
|
m_queue_filled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -705,17 +705,17 @@ bool wxSoundStreamWin::SetSoundFormat(const wxSoundFormatBase& base)
|
|||||||
bool wxSoundStreamWin::StartProduction(int evt)
|
bool wxSoundStreamWin::StartProduction(int evt)
|
||||||
{
|
{
|
||||||
if (!m_internal)
|
if (!m_internal)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if ((m_internal->m_output_enabled && (evt & wxSOUND_OUTPUT)) ||
|
if ((m_internal->m_output_enabled && (evt & wxSOUND_OUTPUT)) ||
|
||||||
(m_internal->m_input_enabled && (evt & wxSOUND_INPUT)))
|
(m_internal->m_input_enabled && (evt & wxSOUND_INPUT)))
|
||||||
CloseDevice();
|
CloseDevice();
|
||||||
|
|
||||||
if (!OpenDevice(evt))
|
if (!OpenDevice(evt))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_production_started = TRUE;
|
m_production_started = true;
|
||||||
m_queue_filled = FALSE;
|
m_queue_filled = false;
|
||||||
// Send a dummy event to start.
|
// Send a dummy event to start.
|
||||||
if (evt & wxSOUND_OUTPUT)
|
if (evt & wxSOUND_OUTPUT)
|
||||||
OnSoundEvent(wxSOUND_OUTPUT);
|
OnSoundEvent(wxSOUND_OUTPUT);
|
||||||
@@ -728,7 +728,7 @@ bool wxSoundStreamWin::StartProduction(int evt)
|
|||||||
waveInStart(m_internal->m_devin);
|
waveInStart(m_internal->m_devin);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@@ -738,13 +738,13 @@ bool wxSoundStreamWin::StopProduction()
|
|||||||
{
|
{
|
||||||
if (!m_production_started) {
|
if (!m_production_started) {
|
||||||
m_snderror = wxSOUND_NOTSTARTED;
|
m_snderror = wxSOUND_NOTSTARTED;
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_snderror = wxSOUND_NOERROR;
|
m_snderror = wxSOUND_NOERROR;
|
||||||
m_production_started = FALSE;
|
m_production_started = false;
|
||||||
CloseDevice();
|
CloseDevice();
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@@ -771,7 +771,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxSoundWinModule, wxModule)
|
|||||||
|
|
||||||
bool wxSoundWinModule::OnInit() {
|
bool wxSoundWinModule::OnInit() {
|
||||||
wxSoundHandleList = new wxList(wxKEY_INTEGER);
|
wxSoundHandleList = new wxList(wxKEY_INTEGER);
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSoundWinModule::OnExit() {
|
void wxSoundWinModule::OnExit() {
|
||||||
|
@@ -50,7 +50,7 @@ wxVideoBaseDriver::~wxVideoBaseDriver()
|
|||||||
bool wxVideoBaseDriver::AttachOutput(wxWindow& output)
|
bool wxVideoBaseDriver::AttachOutput(wxWindow& output)
|
||||||
{
|
{
|
||||||
m_video_output = &output;
|
m_video_output = &output;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxVideoBaseDriver::DetachOutput()
|
void wxVideoBaseDriver::DetachOutput()
|
||||||
@@ -62,11 +62,11 @@ void wxVideoBaseDriver::DetachOutput()
|
|||||||
|
|
||||||
wxFrame *wxVideoCreateFrame(wxVideoBaseDriver *vid_drv)
|
wxFrame *wxVideoCreateFrame(wxVideoBaseDriver *vid_drv)
|
||||||
{
|
{
|
||||||
wxFrame *frame = new wxFrame(NULL, -1, _("Video Output"), wxDefaultPosition, wxSize(100, 100));
|
wxFrame *frame = new wxFrame(NULL, wxID_ANY, _("Video Output"), wxDefaultPosition, wxSize(100, 100));
|
||||||
wxWindow *vid_out = new wxWindow(frame, -1, wxPoint(0, 0), wxSize(300, 300));
|
wxWindow *vid_out = new wxWindow(frame, wxID_ANY, wxPoint(0, 0), wxSize(300, 300));
|
||||||
|
|
||||||
frame->Layout();
|
frame->Layout();
|
||||||
frame->Show(TRUE);
|
frame->Show(true);
|
||||||
|
|
||||||
vid_drv->AttachOutput(*vid_out);
|
vid_drv->AttachOutput(*vid_out);
|
||||||
vid_drv->Play();
|
vid_drv->Play();
|
||||||
|
@@ -49,10 +49,10 @@ wxVideoWindows::wxVideoWindows(wxInputStream& str)
|
|||||||
: wxVideoBaseDriver(str)
|
: wxVideoBaseDriver(str)
|
||||||
{
|
{
|
||||||
m_internal = new wxVIDWinternal;
|
m_internal = new wxVIDWinternal;
|
||||||
m_remove_file = TRUE;
|
m_remove_file = true;
|
||||||
m_filename = wxGetTempFileName(_T("wxvid"));
|
m_filename = wxGetTempFileName(_T("wxvid"));
|
||||||
m_paused = FALSE;
|
m_paused = false;
|
||||||
m_stopped = TRUE;
|
m_stopped = true;
|
||||||
m_frameRate = 1.0;
|
m_frameRate = 1.0;
|
||||||
|
|
||||||
wxFileOutputStream temp_file(m_filename);
|
wxFileOutputStream temp_file(m_filename);
|
||||||
@@ -65,10 +65,10 @@ wxVideoWindows::wxVideoWindows(const wxString& filename)
|
|||||||
: wxVideoBaseDriver(filename)
|
: wxVideoBaseDriver(filename)
|
||||||
{
|
{
|
||||||
m_internal = new wxVIDWinternal;
|
m_internal = new wxVIDWinternal;
|
||||||
m_remove_file = FALSE;
|
m_remove_file = false;
|
||||||
m_filename = filename;
|
m_filename = filename;
|
||||||
m_paused = FALSE;
|
m_paused = false;
|
||||||
m_stopped = TRUE;
|
m_stopped = true;
|
||||||
m_frameRate = 1.0;
|
m_frameRate = 1.0;
|
||||||
OpenFile();
|
OpenFile();
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ void wxVideoWindows::OpenFile()
|
|||||||
openStruct.hWndParent = 0;
|
openStruct.hWndParent = 0;
|
||||||
|
|
||||||
mciSendCommand(0, MCI_OPEN,
|
mciSendCommand(0, MCI_OPEN,
|
||||||
MCI_OPEN_ELEMENT|MCI_DGV_OPEN_PARENT|MCI_OPEN_TYPE|MCI_DGV_OPEN_32BIT,
|
MCI_OPEN_ELEMENT|MCI_DGV_OPEN_PARENT|MCI_OPEN_TYPE|MCI_DGV_OPEN_32BIT,
|
||||||
(DWORD)(LPVOID)&openStruct);
|
(DWORD)(LPVOID)&openStruct);
|
||||||
m_internal->m_dev_id = openStruct.wDeviceID;
|
m_internal->m_dev_id = openStruct.wDeviceID;
|
||||||
|
|
||||||
@@ -122,16 +122,16 @@ void wxVideoWindows::OpenFile()
|
|||||||
bool wxVideoWindows::Pause()
|
bool wxVideoWindows::Pause()
|
||||||
{
|
{
|
||||||
if (m_paused || m_stopped)
|
if (m_paused || m_stopped)
|
||||||
return TRUE;
|
return true;
|
||||||
m_paused = TRUE;
|
m_paused = true;
|
||||||
return (mciSendCommand(m_internal->m_dev_id, MCI_PAUSE, MCI_WAIT, 0) == 0);
|
return (mciSendCommand(m_internal->m_dev_id, MCI_PAUSE, MCI_WAIT, 0) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoWindows::Resume()
|
bool wxVideoWindows::Resume()
|
||||||
{
|
{
|
||||||
if (!m_paused || m_stopped)
|
if (!m_paused || m_stopped)
|
||||||
return TRUE;
|
return true;
|
||||||
m_paused = FALSE;
|
m_paused = false;
|
||||||
return (mciSendCommand(m_internal->m_dev_id, MCI_RESUME, 0, 0) == 0);
|
return (mciSendCommand(m_internal->m_dev_id, MCI_RESUME, 0, 0) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,12 +149,12 @@ bool wxVideoWindows::GetSize(wxSize& size) const
|
|||||||
{
|
{
|
||||||
size.SetWidth(200);
|
size.SetWidth(200);
|
||||||
size.SetHeight(200);
|
size.SetHeight(200);
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoWindows::SetSize(wxSize WXUNUSED(size))
|
bool wxVideoWindows::SetSize(wxSize WXUNUSED(size))
|
||||||
{
|
{
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoWindows::IsCapable(wxVideoType v_type) const
|
bool wxVideoWindows::IsCapable(wxVideoType v_type) const
|
||||||
@@ -167,12 +167,12 @@ bool wxVideoWindows::AttachOutput(wxWindow& output)
|
|||||||
MCI_DGV_WINDOW_PARMS win_struct;
|
MCI_DGV_WINDOW_PARMS win_struct;
|
||||||
|
|
||||||
if (!wxVideoBaseDriver::AttachOutput(output))
|
if (!wxVideoBaseDriver::AttachOutput(output))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
win_struct.hWnd = (HWND)output.GetHWND();
|
win_struct.hWnd = (HWND)output.GetHWND();
|
||||||
mciSendCommand(m_internal->m_dev_id, MCI_WINDOW,
|
mciSendCommand(m_internal->m_dev_id, MCI_WINDOW,
|
||||||
MCI_DGV_WINDOW_HWND, (DWORD)(LPVOID)&win_struct);
|
MCI_DGV_WINDOW_HWND, (DWORD)(LPVOID)&win_struct);
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxVideoWindows::DetachOutput()
|
void wxVideoWindows::DetachOutput()
|
||||||
@@ -183,14 +183,14 @@ void wxVideoWindows::DetachOutput()
|
|||||||
|
|
||||||
win_struct.hWnd = 0;
|
win_struct.hWnd = 0;
|
||||||
mciSendCommand(m_internal->m_dev_id, MCI_WINDOW,
|
mciSendCommand(m_internal->m_dev_id, MCI_WINDOW,
|
||||||
MCI_DGV_WINDOW_HWND, (DWORD)(LPVOID)&win_struct);
|
MCI_DGV_WINDOW_HWND, (DWORD)(LPVOID)&win_struct);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoWindows::Play()
|
bool wxVideoWindows::Play()
|
||||||
{
|
{
|
||||||
if (!m_stopped)
|
if (!m_stopped)
|
||||||
return FALSE;
|
return false;
|
||||||
m_stopped = FALSE;
|
m_stopped = false;
|
||||||
return (mciSendCommand(m_internal->m_dev_id, MCI_PLAY, 0, NULL) == 0);
|
return (mciSendCommand(m_internal->m_dev_id, MCI_PLAY, 0, NULL) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,10 +199,10 @@ bool wxVideoWindows::Stop()
|
|||||||
MCI_SEEK_PARMS seekStruct;
|
MCI_SEEK_PARMS seekStruct;
|
||||||
|
|
||||||
if (m_stopped)
|
if (m_stopped)
|
||||||
return FALSE;
|
return false;
|
||||||
m_stopped = TRUE;
|
m_stopped = true;
|
||||||
if (::mciSendCommand(m_internal->m_dev_id, MCI_STOP, MCI_WAIT, NULL) != 0)
|
if (::mciSendCommand(m_internal->m_dev_id, MCI_STOP, MCI_WAIT, NULL) != 0)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
seekStruct.dwCallback = 0;
|
seekStruct.dwCallback = 0;
|
||||||
seekStruct.dwTo = 0;
|
seekStruct.dwTo = 0;
|
||||||
|
@@ -77,14 +77,14 @@ wxVideoXANIMProcess::wxVideoXANIMProcess(wxVideoXANIM *xanim)
|
|||||||
|
|
||||||
void wxVideoXANIMProcess::OnTerminate(int WXUNUSED(pid), int WXUNUSED(status))
|
void wxVideoXANIMProcess::OnTerminate(int WXUNUSED(pid), int WXUNUSED(status))
|
||||||
{
|
{
|
||||||
m_vid_xanim->m_xanim_started = FALSE;
|
m_vid_xanim->m_xanim_started = false;
|
||||||
m_vid_xanim->OnFinished();
|
m_vid_xanim->OnFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxVideoXANIMOutput::wxVideoXANIMOutput()
|
wxVideoXANIMOutput::wxVideoXANIMOutput()
|
||||||
: wxProcess(NULL, -1)
|
: wxProcess(NULL, wxID_ANY)
|
||||||
{
|
{
|
||||||
m_terminated = FALSE;
|
m_terminated = false;
|
||||||
Redirect();
|
Redirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ bool wxVideoXANIMOutput::IsTerminated() const
|
|||||||
|
|
||||||
void wxVideoXANIMOutput::OnTerminate(int pid, int status)
|
void wxVideoXANIMOutput::OnTerminate(int pid, int status)
|
||||||
{
|
{
|
||||||
m_terminated = TRUE;
|
m_terminated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@@ -106,10 +106,10 @@ wxVideoXANIM::wxVideoXANIM()
|
|||||||
{
|
{
|
||||||
m_internal = new wxXANIMinternal;
|
m_internal = new wxXANIMinternal;
|
||||||
m_xanim_detector = new wxVideoXANIMProcess(this);
|
m_xanim_detector = new wxVideoXANIMProcess(this);
|
||||||
m_xanim_started = FALSE;
|
m_xanim_started = false;
|
||||||
m_paused = FALSE;
|
m_paused = false;
|
||||||
m_filename = wxEmptyString;
|
m_filename = wxEmptyString;
|
||||||
m_remove_file = FALSE;
|
m_remove_file = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxVideoXANIM::wxVideoXANIM(wxInputStream& str)
|
wxVideoXANIM::wxVideoXANIM(wxInputStream& str)
|
||||||
@@ -117,13 +117,13 @@ wxVideoXANIM::wxVideoXANIM(wxInputStream& str)
|
|||||||
{
|
{
|
||||||
m_internal = new wxXANIMinternal;
|
m_internal = new wxXANIMinternal;
|
||||||
m_xanim_detector = new wxVideoXANIMProcess(this);
|
m_xanim_detector = new wxVideoXANIMProcess(this);
|
||||||
m_xanim_started = FALSE;
|
m_xanim_started = false;
|
||||||
m_paused = FALSE;
|
m_paused = false;
|
||||||
m_size[0] = 0;
|
m_size[0] = 0;
|
||||||
m_size[1] = 0;
|
m_size[1] = 0;
|
||||||
|
|
||||||
m_filename = wxGetTempFileName(_T("vidxa"));
|
m_filename = wxGetTempFileName(_T("vidxa"));
|
||||||
m_remove_file = TRUE;
|
m_remove_file = true;
|
||||||
wxFileOutputStream fout(m_filename);
|
wxFileOutputStream fout(m_filename);
|
||||||
|
|
||||||
fout << str;
|
fout << str;
|
||||||
@@ -135,11 +135,11 @@ wxVideoXANIM::wxVideoXANIM(const wxString& filename)
|
|||||||
{
|
{
|
||||||
m_internal = new wxXANIMinternal;
|
m_internal = new wxXANIMinternal;
|
||||||
m_xanim_detector = new wxVideoXANIMProcess(this);
|
m_xanim_detector = new wxVideoXANIMProcess(this);
|
||||||
m_xanim_started = FALSE;
|
m_xanim_started = false;
|
||||||
m_paused = FALSE;
|
m_paused = false;
|
||||||
|
|
||||||
m_filename = filename;
|
m_filename = filename;
|
||||||
m_remove_file = FALSE;
|
m_remove_file = false;
|
||||||
m_size[0] = 0;
|
m_size[0] = 0;
|
||||||
m_size[1] = 0;
|
m_size[1] = 0;
|
||||||
|
|
||||||
@@ -163,42 +163,42 @@ wxVideoXANIM::~wxVideoXANIM()
|
|||||||
bool wxVideoXANIM::Play()
|
bool wxVideoXANIM::Play()
|
||||||
{
|
{
|
||||||
if (!m_paused && m_xanim_started)
|
if (!m_paused && m_xanim_started)
|
||||||
return TRUE;
|
return true;
|
||||||
if (!m_video_output) {
|
if (!m_video_output) {
|
||||||
wxVideoCreateFrame(this);
|
wxVideoCreateFrame(this);
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The movie starts with xanim
|
// The movie starts with xanim
|
||||||
if (RestartXANIM()) {
|
if (RestartXANIM()) {
|
||||||
m_paused = FALSE;
|
m_paused = false;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::Pause()
|
bool wxVideoXANIM::Pause()
|
||||||
{
|
{
|
||||||
if (!m_paused && SendCommand(" ")) {
|
if (!m_paused && SendCommand(" ")) {
|
||||||
m_paused = TRUE;
|
m_paused = true;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::Resume()
|
bool wxVideoXANIM::Resume()
|
||||||
{
|
{
|
||||||
if (m_paused && SendCommand(" ")) {
|
if (m_paused && SendCommand(" ")) {
|
||||||
m_paused = FALSE;
|
m_paused = false;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::Stop()
|
bool wxVideoXANIM::Stop()
|
||||||
{
|
{
|
||||||
if (!m_xanim_started)
|
if (!m_xanim_started)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
SendCommand("q");
|
SendCommand("q");
|
||||||
|
|
||||||
@@ -207,9 +207,9 @@ bool wxVideoXANIM::Stop()
|
|||||||
wxYield();
|
wxYield();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_paused = FALSE;
|
m_paused = false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@@ -218,18 +218,18 @@ bool wxVideoXANIM::Stop()
|
|||||||
bool wxVideoXANIM::SetSize(wxSize size)
|
bool wxVideoXANIM::SetSize(wxSize size)
|
||||||
{
|
{
|
||||||
if (!m_video_output)
|
if (!m_video_output)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
m_video_output->SetSize(size.GetWidth(), size.GetHeight());
|
m_video_output->SetSize(size.GetWidth(), size.GetHeight());
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::GetSize(wxSize& size) const
|
bool wxVideoXANIM::GetSize(wxSize& size) const
|
||||||
{
|
{
|
||||||
if (m_size[0] == 0)
|
if (m_size[0] == 0)
|
||||||
return FALSE;
|
return false;
|
||||||
size.Set(m_size[0], m_size[1]);
|
size.Set(m_size[0], m_size[1]);
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@@ -238,11 +238,11 @@ bool wxVideoXANIM::GetSize(wxSize& size) const
|
|||||||
bool wxVideoXANIM::IsCapable(wxVideoType v_type) const
|
bool wxVideoXANIM::IsCapable(wxVideoType v_type) const
|
||||||
{
|
{
|
||||||
if (v_type == wxVIDEO_MSAVI || v_type == wxVIDEO_MPEG ||
|
if (v_type == wxVIDEO_MSAVI || v_type == wxVIDEO_MPEG ||
|
||||||
v_type == wxVIDEO_QT || v_type == wxVIDEO_GIF || v_type == wxVIDEO_JMOV ||
|
v_type == wxVIDEO_QT || v_type == wxVIDEO_GIF || v_type == wxVIDEO_JMOV ||
|
||||||
v_type == wxVIDEO_FLI || v_type == wxVIDEO_IFF || v_type == wxVIDEO_SGI)
|
v_type == wxVIDEO_FLI || v_type == wxVIDEO_IFF || v_type == wxVIDEO_SGI)
|
||||||
return TRUE;
|
return true;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@@ -314,16 +314,16 @@ bool wxVideoXANIM::IsStopped() const
|
|||||||
bool wxVideoXANIM::AttachOutput(wxWindow& out)
|
bool wxVideoXANIM::AttachOutput(wxWindow& out)
|
||||||
{
|
{
|
||||||
if (!wxVideoBaseDriver::AttachOutput(out))
|
if (!wxVideoBaseDriver::AttachOutput(out))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxVideoXANIM::DetachOutput()
|
void wxVideoXANIM::DetachOutput()
|
||||||
{
|
{
|
||||||
SendCommand("q");
|
SendCommand("q");
|
||||||
m_xanim_started = FALSE;
|
m_xanim_started = false;
|
||||||
m_paused = FALSE;
|
m_paused = false;
|
||||||
|
|
||||||
wxVideoBaseDriver::DetachOutput();
|
wxVideoBaseDriver::DetachOutput();
|
||||||
}
|
}
|
||||||
@@ -332,29 +332,29 @@ void wxVideoXANIM::DetachOutput()
|
|||||||
// Lowlevel XAnim controller
|
// Lowlevel XAnim controller
|
||||||
|
|
||||||
bool wxVideoXANIM::SendCommand(const char *command, char **ret,
|
bool wxVideoXANIM::SendCommand(const char *command, char **ret,
|
||||||
wxUint32 *size)
|
wxUint32 *size)
|
||||||
{
|
{
|
||||||
if (!m_xanim_started)
|
if (!m_xanim_started)
|
||||||
if (!RestartXANIM())
|
if (!RestartXANIM())
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// Send a command to XAnim through X11 Property
|
// Send a command to XAnim through X11 Property
|
||||||
XChangeProperty(m_internal->xanim_dpy, m_internal->xanim_window,
|
XChangeProperty(m_internal->xanim_dpy, m_internal->xanim_window,
|
||||||
m_internal->xanim_atom,
|
m_internal->xanim_atom,
|
||||||
XA_STRING, 8, PropModeReplace, (unsigned char *)command,
|
XA_STRING, 8, PropModeReplace, (unsigned char *)command,
|
||||||
strlen(command));
|
strlen(command));
|
||||||
XFlush(m_internal->xanim_dpy);
|
XFlush(m_internal->xanim_dpy);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
int prop_format;
|
int prop_format;
|
||||||
Atom prop_type;
|
Atom prop_type;
|
||||||
unsigned long extra;
|
unsigned long extra;
|
||||||
|
|
||||||
XGetWindowProperty(m_internal->xanim_dpy, m_internal->xanim_window,
|
XGetWindowProperty(m_internal->xanim_dpy, m_internal->xanim_window,
|
||||||
m_internal->xanim_ret, 0, 16, True, AnyPropertyType,
|
m_internal->xanim_ret, 0, 16, True, AnyPropertyType,
|
||||||
&prop_type, &prop_format, (unsigned long *)size,
|
&prop_type, &prop_format, (unsigned long *)size,
|
||||||
&extra, (unsigned char **)ret);
|
&extra, (unsigned char **)ret);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::CollectInfo()
|
bool wxVideoXANIM::CollectInfo()
|
||||||
@@ -366,8 +366,8 @@ bool wxVideoXANIM::CollectInfo()
|
|||||||
xanimProcess = new wxVideoXANIMOutput;
|
xanimProcess = new wxVideoXANIMOutput;
|
||||||
xanim_command = wxT("xanim +v +Zv -Ae ");
|
xanim_command = wxT("xanim +v +Zv -Ae ");
|
||||||
xanim_command += m_filename;
|
xanim_command += m_filename;
|
||||||
if (!wxExecute(xanim_command, FALSE, xanimProcess))
|
if (!wxExecute(xanim_command, false, xanimProcess))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
wxInputStream *infoStream = xanimProcess->GetInputStream();
|
wxInputStream *infoStream = xanimProcess->GetInputStream();
|
||||||
wxString totalOutput;
|
wxString totalOutput;
|
||||||
@@ -443,7 +443,7 @@ i = my_long;
|
|||||||
|
|
||||||
delete xanimProcess;
|
delete xanimProcess;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxVideoXANIM::RestartXANIM()
|
bool wxVideoXANIM::RestartXANIM()
|
||||||
@@ -458,10 +458,10 @@ bool wxVideoXANIM::RestartXANIM()
|
|||||||
bool xanim_chg_size;
|
bool xanim_chg_size;
|
||||||
|
|
||||||
if (!m_video_output || m_xanim_started)
|
if (!m_video_output || m_xanim_started)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// Check if we can change the size of the window dynamicly
|
// Check if we can change the size of the window dynamicly
|
||||||
xanim_chg_size = TRUE;
|
xanim_chg_size = true;
|
||||||
// Get current display
|
// Get current display
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
m_internal->xanim_dpy = gdk_display;
|
m_internal->xanim_dpy = gdk_display;
|
||||||
@@ -472,27 +472,27 @@ bool wxVideoXANIM::RestartXANIM()
|
|||||||
#endif
|
#endif
|
||||||
// Get the XANIM atom
|
// Get the XANIM atom
|
||||||
m_internal->xanim_atom = XInternAtom(m_internal->xanim_dpy,
|
m_internal->xanim_atom = XInternAtom(m_internal->xanim_dpy,
|
||||||
"XANIM_PROPERTY", False);
|
"XANIM_PROPERTY", False);
|
||||||
|
|
||||||
// Build the command
|
// Build the command
|
||||||
xanim_command.Printf(wxT("xanim -Zr +Ze +Sr +f +W%d +f +q "
|
xanim_command.Printf(wxT("xanim -Zr +Ze +Sr +f +W%d +f +q "
|
||||||
"+Av70 %s %s"), m_internal->xanim_window,
|
"+Av70 %s %s"), m_internal->xanim_window,
|
||||||
(xanim_chg_size) ? _T("") : _T(""),
|
(xanim_chg_size) ? _T("") : _T(""),
|
||||||
WXSTRINGCAST m_filename);
|
WXSTRINGCAST m_filename);
|
||||||
|
|
||||||
// Execute it
|
// Execute it
|
||||||
if (!wxExecute(xanim_command, FALSE, m_xanim_detector))
|
if (!wxExecute(xanim_command, false, m_xanim_detector))
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// Wait for XAnim to be ready
|
// Wait for XAnim to be ready
|
||||||
nitems = 0;
|
nitems = 0;
|
||||||
m_xanim_started = TRUE;
|
m_xanim_started = true;
|
||||||
while (nitems == 0 && m_xanim_started) {
|
while (nitems == 0 && m_xanim_started) {
|
||||||
ret = XGetWindowProperty(m_internal->xanim_dpy, m_internal->xanim_window,
|
ret = XGetWindowProperty(m_internal->xanim_dpy, m_internal->xanim_window,
|
||||||
m_internal->xanim_atom,
|
m_internal->xanim_atom,
|
||||||
0, 4, False, AnyPropertyType, &prop_type,
|
0, 4, False, AnyPropertyType, &prop_type,
|
||||||
&prop_format, &nitems, &extra,
|
&prop_format, &nitems, &extra,
|
||||||
(unsigned char **)&prop);
|
(unsigned char **)&prop);
|
||||||
wxYield();
|
wxYield();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,7 +507,7 @@ bool wxVideoXANIM::RestartXANIM()
|
|||||||
// Very useful ! Actually it "should" sends a SETSIZE event to XAnim
|
// Very useful ! Actually it "should" sends a SETSIZE event to XAnim
|
||||||
// FIXME: This event is not sent !!
|
// FIXME: This event is not sent !!
|
||||||
|
|
||||||
m_paused = FALSE;
|
m_paused = false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user