Inserted "stdio catch" in wxExecute. The activation is controlled by wxProcess.
Completed some TODO in wxMMedia (wxSoundUlaw, ...) Reworked the PCM converted: it should be simpler to add converters now and it is cleaner. Implemented status information in wxVideoWindows but it doesn't work on my Win98SE (UNSUPPORTED_FUNCTION) Changed *ERR into *ERROR Added a TODO: we must detect the best format in wxSoundWindows git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6311 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
wxSoundFormatUlaw::wxSoundFormatUlaw()
|
||||
: m_srate(22050)
|
||||
: m_srate(22050), m_channels(1)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,40 +35,51 @@ wxSoundFormatUlaw::~wxSoundFormatUlaw()
|
||||
|
||||
void wxSoundFormatUlaw::SetSampleRate(wxUint32 srate)
|
||||
{
|
||||
m_srate = srate;
|
||||
m_srate = srate;
|
||||
}
|
||||
|
||||
wxUint32 wxSoundFormatUlaw::GetSampleRate() const
|
||||
{
|
||||
return m_srate;
|
||||
return m_srate;
|
||||
}
|
||||
|
||||
wxUint8 wxSoundFormatUlaw::GetChannels() const
|
||||
{
|
||||
return m_channels;
|
||||
}
|
||||
|
||||
void wxSoundFormatUlaw::SetChannels(wxUint8 nchannels)
|
||||
{
|
||||
m_channels = nchannels;
|
||||
}
|
||||
|
||||
wxSoundFormatBase *wxSoundFormatUlaw::Clone() const
|
||||
{
|
||||
wxSoundFormatUlaw *ulaw = new wxSoundFormatUlaw();
|
||||
|
||||
ulaw->m_srate = m_srate;
|
||||
return ulaw;
|
||||
wxSoundFormatUlaw *ulaw = new wxSoundFormatUlaw();
|
||||
|
||||
ulaw->m_srate = m_srate;
|
||||
ulaw->m_channels = m_channels;
|
||||
return ulaw;
|
||||
}
|
||||
|
||||
wxUint32 wxSoundFormatUlaw::GetTimeFromBytes(wxUint32 bytes) const
|
||||
{
|
||||
return (bytes / m_srate);
|
||||
return (bytes / m_srate);
|
||||
}
|
||||
|
||||
wxUint32 wxSoundFormatUlaw::GetBytesFromTime(wxUint32 time) const
|
||||
{
|
||||
return time * m_srate;
|
||||
return time * m_srate;
|
||||
}
|
||||
|
||||
bool wxSoundFormatUlaw::operator !=(const wxSoundFormatBase& frmt2) const
|
||||
{
|
||||
wxSoundFormatUlaw *ulaw = (wxSoundFormatUlaw *)&frmt2;
|
||||
|
||||
if (frmt2.GetType() != wxSOUND_ULAW)
|
||||
return TRUE;
|
||||
|
||||
return (ulaw->m_srate != m_srate);
|
||||
wxSoundFormatUlaw *ulaw = (wxSoundFormatUlaw *)&frmt2;
|
||||
|
||||
if (frmt2.GetType() != wxSOUND_ULAW)
|
||||
return TRUE;
|
||||
|
||||
return (ulaw->m_srate != m_srate);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -88,58 +99,82 @@ wxSoundStreamUlaw::~wxSoundStreamUlaw()
|
||||
|
||||
wxSoundStream& wxSoundStreamUlaw::Read(void *buffer, wxUint32 len)
|
||||
{
|
||||
// TODO
|
||||
return *this;
|
||||
wxUint16 *old_linear;
|
||||
register wxUint16 *linear_buffer;
|
||||
register const wxUint8 *ulaw_buffer;
|
||||
register wxUint32 countdown;
|
||||
|
||||
old_linear = linear_buffer = new wxUint16[len*2];
|
||||
ulaw_buffer = (const wxUint8 *)buffer;
|
||||
|
||||
m_router->Read(linear_buffer, len * 2);
|
||||
|
||||
m_lastcount = countdown = m_router->GetLastAccess() / 2;
|
||||
m_snderror = m_router->GetError();
|
||||
if (m_snderror != wxSOUND_NOERROR)
|
||||
return *this;
|
||||
|
||||
while (countdown > 0) {
|
||||
*linear_buffer++ = ulaw2linear(*ulaw_buffer++);
|
||||
countdown--;
|
||||
}
|
||||
|
||||
delete[] old_linear;
|
||||
|
||||
return *m_router;
|
||||
}
|
||||
|
||||
wxSoundStream& wxSoundStreamUlaw::Write(const void *buffer, wxUint32 len)
|
||||
{
|
||||
wxUint16 *old_linear;
|
||||
register wxUint16 *linear_buffer;
|
||||
register const wxUint8 *ulaw_buffer;
|
||||
register wxUint32 countdown = len;
|
||||
|
||||
old_linear = linear_buffer = new wxUint16[len*2];
|
||||
ulaw_buffer = (const wxUint8 *)buffer;
|
||||
|
||||
while (countdown != 0) {
|
||||
*linear_buffer++ = ulaw2linear(*ulaw_buffer++);
|
||||
countdown--;
|
||||
}
|
||||
|
||||
m_router->Write(old_linear, len * 2);
|
||||
|
||||
delete[] old_linear;
|
||||
|
||||
return *m_router;
|
||||
wxUint16 *old_linear;
|
||||
register wxUint16 *linear_buffer;
|
||||
register const wxUint8 *ulaw_buffer;
|
||||
register wxUint32 countdown = len;
|
||||
|
||||
old_linear = linear_buffer = new wxUint16[len*2];
|
||||
ulaw_buffer = (const wxUint8 *)buffer;
|
||||
|
||||
while (countdown > 0) {
|
||||
*linear_buffer++ = ulaw2linear(*ulaw_buffer++);
|
||||
countdown--;
|
||||
}
|
||||
|
||||
m_router->Write(old_linear, len * 2);
|
||||
|
||||
delete[] old_linear;
|
||||
|
||||
return *m_router;
|
||||
}
|
||||
|
||||
wxUint32 wxSoundStreamUlaw::GetBestSize() const
|
||||
{
|
||||
return m_sndio->GetBestSize() / 2;
|
||||
return m_sndio->GetBestSize() / 2;
|
||||
}
|
||||
|
||||
bool wxSoundStreamUlaw::SetSoundFormat(const wxSoundFormatBase& format)
|
||||
{
|
||||
if (format.GetType() != wxSOUND_ULAW) {
|
||||
m_snderror = wxSOUND_INVFRMT;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
wxSoundFormatPcm pcm;
|
||||
wxSoundFormatUlaw *ulaw;
|
||||
|
||||
wxSoundStreamCodec::SetSoundFormat(format);
|
||||
|
||||
ulaw = (wxSoundFormatUlaw *)m_sndformat;
|
||||
|
||||
pcm.SetSampleRate(ulaw->GetSampleRate());
|
||||
pcm.SetBPS(16);
|
||||
pcm.SetChannels(1);
|
||||
pcm.Signed(TRUE);
|
||||
pcm.SetOrder(wxBYTE_ORDER);
|
||||
|
||||
m_router->SetSoundFormat(pcm);
|
||||
|
||||
return TRUE;
|
||||
if (format.GetType() != wxSOUND_ULAW) {
|
||||
m_snderror = wxSOUND_INVFRMT;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// As the codec only support 16 bits, Mono we must use a wxSoundRouter to filter the data and
|
||||
// to translate them to a format supported by the sound card.
|
||||
|
||||
wxSoundFormatPcm pcm;
|
||||
wxSoundFormatUlaw *ulaw;
|
||||
|
||||
wxSoundStreamCodec::SetSoundFormat(format);
|
||||
|
||||
ulaw = (wxSoundFormatUlaw *)m_sndformat;
|
||||
|
||||
pcm.SetSampleRate(ulaw->GetSampleRate());
|
||||
pcm.SetBPS(16);
|
||||
pcm.SetChannels(ulaw->GetChannels());
|
||||
pcm.Signed(TRUE);
|
||||
pcm.SetOrder(wxBYTE_ORDER);
|
||||
|
||||
m_router->SetSoundFormat(pcm);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user