X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4d6306eb4da8cdac4b5dee9784959672c233eec8..2356708db31b737c6eae53c2316b642aa5a2e68d:/utils/wxMMedia/sndfrmt.cpp?ds=sidebyside diff --git a/utils/wxMMedia/sndfrmt.cpp b/utils/wxMMedia/sndfrmt.cpp index fb933b4be9..fc9aa77654 100644 --- a/utils/wxMMedia/sndfrmt.cpp +++ b/utils/wxMMedia/sndfrmt.cpp @@ -1,10 +1,18 @@ +//////////////////////////////////////////////////////////////////////////////// +// Name: sndfrmt.cpp +// Purpose: wxMMedia +// Author: Guilhem Lavaux +// Created: 1998 +// Updated: December 1998 +// Copyright: (C) 1997, 1998, Guilhem Lavaux +// License: wxWindows license +//////////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ #pragma implementation "sndfrmt.h" #endif #include "sndsnd.h" #include "sndfrmt.h" #include "sndpcm.h" -#include // ---------------------------------------------------------------------------- // wxSoundDataFormat @@ -21,6 +29,19 @@ wxSoundDataFormat::wxSoundDataFormat() m_codcreate = TRUE; } +wxSoundDataFormat::wxSoundDataFormat(const wxSoundDataFormat& format) +{ + m_srate = format.m_srate; + m_bps = format.m_bps; + m_channels = format.m_channels; + m_codno = format.m_codno; + m_sign = format.m_sign; + m_byteorder = format.m_byteorder; + m_codchange = FALSE; + m_codcreate = TRUE; + m_codec = NULL; +} + wxSoundDataFormat::~wxSoundDataFormat() { wxDELETE(m_codec); @@ -62,13 +83,14 @@ wxSoundCodec *wxSoundDataFormat::GetCodec() return NULL; if (m_codchange) - wxDELETEA(m_codec); + wxDELETE(m_codec); if (m_codec) return m_codec; m_codchange = FALSE; m_codec = wxSoundCodec::Get(m_codno); + CodecChange(); return m_codec; } @@ -84,12 +106,15 @@ void wxSoundDataFormat::CodecChange() case WXSOUND_PCM: { wxSoundPcmCodec *pcm_codec = (wxSoundPcmCodec *)codec; - pcm_codec->SetBits(m_bps); - pcm_codec->SetByteOrder(m_byteorder); - pcm_codec->SetSign(m_sign); + pcm_codec->m_orig_format.SetSampleRate(m_srate); + pcm_codec->m_orig_format.SetBps(m_bps); + pcm_codec->m_orig_format.SetChannels(m_channels); + pcm_codec->m_orig_format.SetByteOrder(m_byteorder); + pcm_codec->m_orig_format.SetSign(m_sign); break; } default: + codec->InitWith(*this); break; } } @@ -126,19 +151,19 @@ bool wxSoundDataFormat::operator ==(const wxSoundDataFormat& format) const // ---------------------------------------------------------------------------- #include "sndpcm.h" -//#include "sndadpcm.h" +#include "sndadpcm.h" //#include "sndalaw.h" #include "sndmulaw.h" static wxClassInfo *l_sound_formats[] = { NULL, CLASSINFO(wxSoundPcmCodec), - NULL, // CLASSINFO(wxSoundAdpcmCodec), + CLASSINFO(wxSoundAdpcmCodec), NULL, NULL, NULL, NULL, // CLASSINFO(wxSoundAlawCodec), - NULL // CLASSINFO(wxSoundMulawCodec) + CLASSINFO(wxSoundMulawCodec) }; static int l_nb_formats = WXSIZEOF(l_sound_formats); @@ -148,10 +173,13 @@ wxSoundCodec::wxSoundCodec() m_in_sound = NULL; m_out_sound = NULL; m_init = TRUE; + m_chain_codec = NULL; } wxSoundCodec::~wxSoundCodec() { + if (m_mode != WAITING) + ExitMode(); } void wxSoundCodec::InitIO(const wxSoundDataFormat& format) @@ -159,13 +187,13 @@ void wxSoundCodec::InitIO(const wxSoundDataFormat& format) m_io_format = format; } -void wxSoundCodec::InitMode(int mode) +void wxSoundCodec::InitMode(ModeType mode) { wxStreamBuffer *buf_snd; - m_mode = (mode == 0) ? ENCODING : DECODING; + m_mode = mode; if (!m_chain_codec) { - if (mode == ENCODING) { + if (m_mode == ENCODING) { m_out_sound = new wxStreamBuffer(*this, wxStreamBuffer::write); m_out_sound->SetBufferIO(1024); } else { @@ -206,6 +234,7 @@ void wxSoundCodec::ExitMode() m_out_sound = m_chain_codec->GetOutStream(); } } + m_mode = WAITING; } bool wxSoundCodec::ChainCodecBefore(wxSoundDataFormat& format)