Removed unnecessary code from utilsunx.cpp
Corrected the support for seeking in wxSoundFileStream. Added support for seeking in wxMultimediaBoard Reindentation of the code (conforming or nearly to the coding standard) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6291 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
a9c3ed030e
commit
794bcc2dea
@ -45,3 +45,4 @@ You need to move the three files included in this directory:
|
||||
- utilsunx.cpp => src/unix
|
||||
- process.cpp => src/common
|
||||
- process.h => include/wx
|
||||
- utilsexc.cpp => src/msw
|
||||
|
@ -83,6 +83,7 @@ public:
|
||||
|
||||
MMBoardTime GetPosition();
|
||||
MMBoardTime GetLength();
|
||||
void SetPosition(MMBoardTime btime);
|
||||
|
||||
bool IsStopped();
|
||||
bool IsPaused();
|
||||
@ -117,6 +118,7 @@ public:
|
||||
|
||||
MMBoardTime GetPosition();
|
||||
MMBoardTime GetLength();
|
||||
void SetPosition(MMBoardTime btime);
|
||||
|
||||
bool IsStopped();
|
||||
bool IsPaused();
|
||||
@ -229,6 +231,17 @@ MMBoardTime MMBoardSoundFile::GetPosition()
|
||||
return file_time;
|
||||
}
|
||||
|
||||
void MMBoardSoundFile::SetPosition(MMBoardTime btime)
|
||||
{
|
||||
wxUint32 itime;
|
||||
|
||||
itime = btime.seconds + btime.minutes * 60 + btime.hours;
|
||||
|
||||
m_file_stream->SetPosition(
|
||||
m_file_stream->GetSoundFormat().GetBytesFromTime(itime)
|
||||
);
|
||||
}
|
||||
|
||||
bool MMBoardSoundFile::NeedWindow()
|
||||
{
|
||||
return FALSE;
|
||||
@ -392,6 +405,10 @@ MMBoardTime MMBoardVideoFile::GetLength()
|
||||
return btime;
|
||||
}
|
||||
|
||||
void MMBoardVideoFile::SetPosition(MMBoardTime btime)
|
||||
{
|
||||
}
|
||||
|
||||
bool MMBoardVideoFile::IsStopped()
|
||||
{
|
||||
return m_video_driver->IsStopped();
|
||||
|
@ -54,6 +54,7 @@ class MMBoardFile {
|
||||
|
||||
virtual MMBoardTime GetPosition() = 0;
|
||||
virtual MMBoardTime GetLength() = 0;
|
||||
virtual void SetPosition(MMBoardTime btime) = 0;
|
||||
|
||||
virtual bool IsStopped() = 0;
|
||||
virtual bool IsPaused() = 0;
|
||||
|
@ -83,7 +83,9 @@ public:
|
||||
void OnPlay(wxCommandEvent& event);
|
||||
void OnStop(wxCommandEvent& event);
|
||||
void OnPause(wxCommandEvent& event);
|
||||
void OnEject(wxCommandEvent& event);
|
||||
void OnRefreshInfo(wxEvent& event);
|
||||
void OnSetPosition(wxCommandEvent& event);
|
||||
|
||||
void OpenVideoWindow();
|
||||
void CloseVideoWindow();
|
||||
@ -107,7 +109,6 @@ private:
|
||||
wxSizer *m_sizer;
|
||||
|
||||
wxTimer *m_refreshTimer;
|
||||
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -141,6 +142,8 @@ BEGIN_EVENT_TABLE(MMBoardFrame, wxFrame)
|
||||
EVT_BUTTON(MMBoard_PlayButton, MMBoardFrame::OnPlay)
|
||||
EVT_BUTTON(MMBoard_StopButton, MMBoardFrame::OnStop)
|
||||
EVT_BUTTON(MMBoard_PauseButton, MMBoardFrame::OnPause)
|
||||
EVT_BUTTON(MMBoard_EjectButton, MMBoardFrame::OnEject)
|
||||
EVT_SLIDER(MMBoard_PositionSlider, MMBoardFrame::OnSetPosition)
|
||||
EVT_CUSTOM(wxEVT_TIMER, MMBoard_RefreshInfo, MMBoardFrame::OnRefreshInfo)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
@ -243,20 +246,20 @@ MMBoardFrame::MMBoardFrame(const wxString& title, const wxPoint& pos, const wxSi
|
||||
SetIcon(wxICON(mondrian));
|
||||
|
||||
// create a menu bar
|
||||
wxMenu *menuFile = new wxMenu(_T(""), wxMENU_TEAROFF);
|
||||
wxMenu *menuFile = new wxMenu(wxT(""), wxMENU_TEAROFF);
|
||||
|
||||
// the "About" item should be in the help menu
|
||||
wxMenu *helpMenu = new wxMenu;
|
||||
helpMenu->Append(MMBoard_About, _T("&About...\tCtrl-A"), _T("Show about dialog"));
|
||||
helpMenu->Append(MMBoard_About, wxT("&About...\tCtrl-A"), wxT("Show about dialog"));
|
||||
|
||||
menuFile->Append(MMBoard_Open, _T("&Open\tAlt-O"), _T("Open file"));
|
||||
menuFile->Append(MMBoard_Open, wxT("&Open\tAlt-O"), wxT("Open file"));
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append(MMBoard_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));
|
||||
menuFile->Append(MMBoard_Quit, wxT("E&xit\tAlt-X"), wxT("Quit this program"));
|
||||
|
||||
// now append the freshly created menu to the menu bar...
|
||||
wxMenuBar *menuBar = new wxMenuBar();
|
||||
menuBar->Append(menuFile, _T("&File"));
|
||||
menuBar->Append(helpMenu, _T("&Help"));
|
||||
menuBar->Append(menuFile, wxT("&File"));
|
||||
menuBar->Append(helpMenu, wxT("&Help"));
|
||||
|
||||
// ... and attach this menu bar to the frame
|
||||
SetMenuBar(menuBar);
|
||||
@ -264,7 +267,7 @@ MMBoardFrame::MMBoardFrame(const wxString& title, const wxPoint& pos, const wxSi
|
||||
#if wxUSE_STATUSBAR
|
||||
// create a status bar just for fun (by default with 1 pane only)
|
||||
CreateStatusBar(3);
|
||||
SetStatusText(_T("Welcome to wxWindows!"));
|
||||
SetStatusText(wxT("Welcome to wxWindows!"));
|
||||
#endif // wxUSE_STATUSBAR
|
||||
|
||||
// Misc variables
|
||||
@ -277,6 +280,7 @@ MMBoardFrame::MMBoardFrame(const wxString& title, const wxPoint& pos, const wxSi
|
||||
wxDefaultPosition, wxSize(300, -1),
|
||||
wxSL_HORIZONTAL | wxSL_AUTOTICKS);
|
||||
m_positionSlider->SetPageSize(60); // 60 secs
|
||||
m_positionSlider->Enable(FALSE);
|
||||
|
||||
// Initialize info panel
|
||||
wxPanel *infoPanel = new wxPanel( m_panel, -1);
|
||||
@ -285,7 +289,7 @@ MMBoardFrame::MMBoardFrame(const wxString& title, const wxPoint& pos, const wxSi
|
||||
|
||||
wxBoxSizer *infoSizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_fileType = new wxStaticText(infoPanel, -1, _T(""));
|
||||
m_fileType = new wxStaticText(infoPanel, -1, wxT(""));
|
||||
wxStaticLine *line = new wxStaticLine(infoPanel, -1);
|
||||
m_infoText = new wxStaticText(infoPanel, -1, "");
|
||||
|
||||
@ -387,9 +391,9 @@ void MMBoardFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||
void MMBoardFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf( _T("wxWindows Multimedia board v1.0a, wxMMedia v2.0a:\n")
|
||||
_T("an example of the capabilities of the wxWindows multimedia classes.\n")
|
||||
_T("Copyright 1999, 2000, Guilhem Lavaux.\n"));
|
||||
msg.Printf( wxT("wxWindows Multimedia board v1.0a, wxMMedia v2.0a:\n")
|
||||
wxT("an example of the capabilities of the wxWindows multimedia classes.\n")
|
||||
wxT("Copyright 1999, 2000, Guilhem Lavaux.\n"));
|
||||
|
||||
wxMessageBox(msg, "About MMBoard", wxOK | wxICON_INFORMATION, this);
|
||||
}
|
||||
@ -430,6 +434,7 @@ void MMBoardFrame::OnOpen(wxCommandEvent& WXUNUSED(event))
|
||||
// Enable a few buttons
|
||||
m_playButton->Enable(TRUE);
|
||||
m_ejectButton->Enable(TRUE);
|
||||
m_positionSlider->Enable(TRUE);
|
||||
|
||||
if (m_opened_file->NeedWindow()) {
|
||||
OpenVideoWindow();
|
||||
@ -443,14 +448,14 @@ void MMBoardFrame::UpdateInfoText()
|
||||
wxString infotext1, infotext2;
|
||||
|
||||
if (m_opened_file) {
|
||||
infotext1 = _T("File type:\n\t");
|
||||
infotext1 += m_opened_file->GetStringType() + _T("\n");
|
||||
infotext1 = wxT("File type:\n\t");
|
||||
infotext1 += m_opened_file->GetStringType() + wxT("\n");
|
||||
|
||||
infotext2 = _T("File informations:\n\n");
|
||||
infotext2 = wxT("File informations:\n\n");
|
||||
infotext2 += m_opened_file->GetStringInformation();
|
||||
} else {
|
||||
infotext1 = _T("File type: \n\tNo file opened");
|
||||
infotext2 = _T("File informations:\nNo information\n\n\n\n\n");
|
||||
infotext1 = wxT("File type: \n\tNo file opened");
|
||||
infotext2 = wxT("File informations:\nNo information\n\n\n\n\n");
|
||||
}
|
||||
|
||||
m_fileType->SetLabel(infotext1);
|
||||
@ -465,10 +470,13 @@ void MMBoardFrame::UpdateMMedInfo()
|
||||
if (m_opened_file) {
|
||||
current = m_opened_file->GetPosition();
|
||||
length = m_opened_file->GetLength();
|
||||
} else {
|
||||
current.hours = current.minutes = current.seconds = 0;
|
||||
length = current;
|
||||
}
|
||||
|
||||
// We refresh the status bar
|
||||
temp_string.Printf("%02d:%02d / %02d:%02d", current.hours * 60 + current.minutes,
|
||||
temp_string.Printf(wxT("%02d:%02d / %02d:%02d"), current.hours * 60 + current.minutes,
|
||||
current.seconds, length.hours * 60 + length.minutes, length.seconds);
|
||||
SetStatusText(temp_string, 1);
|
||||
|
||||
@ -529,3 +537,35 @@ void MMBoardFrame::OnPause(wxCommandEvent& WXUNUSED(event))
|
||||
m_playButton->Enable(TRUE);
|
||||
m_pauseButton->Enable(FALSE);
|
||||
}
|
||||
|
||||
void MMBoardFrame::OnEject(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
m_opened_file->Stop();
|
||||
|
||||
delete m_opened_file;
|
||||
m_opened_file = NULL;
|
||||
|
||||
m_playButton->Enable(FALSE);
|
||||
m_pauseButton->Enable(FALSE);
|
||||
m_stopButton->Enable(FALSE);
|
||||
m_ejectButton->Enable(FALSE);
|
||||
m_positionSlider->Enable(FALSE);
|
||||
|
||||
UpdateInfoText();
|
||||
UpdateMMedInfo();
|
||||
}
|
||||
|
||||
void MMBoardFrame::OnSetPosition(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxUint32 itime;
|
||||
MMBoardTime btime;
|
||||
|
||||
itime = m_positionSlider->GetValue();
|
||||
btime.seconds = itime % 60;
|
||||
btime.minutes = (itime / 60) % 60;
|
||||
btime.hours = itime / 3600;
|
||||
m_opened_file->SetPosition(btime);
|
||||
|
||||
UpdateMMedInfo();
|
||||
}
|
||||
|
||||
|
@ -31,11 +31,13 @@
|
||||
wxSoundAiff::wxSoundAiff(wxInputStream& stream, wxSoundStream& io_sound)
|
||||
: wxSoundFileStream(stream, io_sound)
|
||||
{
|
||||
m_base_offset = wxInvalidOffset;
|
||||
}
|
||||
|
||||
wxSoundAiff::wxSoundAiff(wxOutputStream& stream, wxSoundStream& io_sound)
|
||||
: wxSoundFileStream(stream, io_sound)
|
||||
{
|
||||
m_base_offset = wxInvalidOffset;
|
||||
}
|
||||
|
||||
wxSoundAiff::~wxSoundAiff()
|
||||
@ -146,6 +148,7 @@ bool wxSoundAiff::PrepareToPlay()
|
||||
// m_input->SeekI(4, wxFromCurrent); // Pass an INT32
|
||||
// m_input->SeekI(len-4, wxFromCurrent); // Pass the rest
|
||||
m_input->SeekI(ssnd + 4, wxFromCurrent);
|
||||
m_base_offset = m_input->TellI();
|
||||
FinishPreparation(len - 8);
|
||||
end_headers = TRUE;
|
||||
break;
|
||||
@ -158,7 +161,7 @@ bool wxSoundAiff::PrepareToPlay()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxSoundAiff::PrepareToRecord(unsigned long time)
|
||||
bool wxSoundAiff::PrepareToRecord(wxUint32 time)
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
@ -170,6 +173,14 @@ bool wxSoundAiff::FinishRecording()
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxSoundAiff::RepositionStream(wxUint32 position)
|
||||
{
|
||||
if (m_base_offset == wxInvalidOffset)
|
||||
return FALSE;
|
||||
m_input->SeekI(m_base_offset, wxFromStart);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxUint32 wxSoundAiff::GetData(void *buffer, wxUint32 len)
|
||||
{
|
||||
return m_input->Read(buffer, len).LastRead();
|
||||
|
@ -32,11 +32,14 @@ class wxSoundAiff: public wxSoundFileStream {
|
||||
|
||||
protected:
|
||||
bool PrepareToPlay();
|
||||
bool PrepareToRecord(unsigned long time);
|
||||
bool PrepareToRecord(wxUint32 time);
|
||||
bool FinishRecording();
|
||||
bool RepositionStream(wxUint32 position);
|
||||
|
||||
wxUint32 GetData(void *buffer, wxUint32 len);
|
||||
wxUint32 PutData(const void *buffer, wxUint32 len);
|
||||
protected:
|
||||
off_t m_base_offset;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -37,7 +37,8 @@ typedef enum {
|
||||
wxSOUND_NOFORMAT,
|
||||
wxSOUND_PCM,
|
||||
wxSOUND_ULAW,
|
||||
wxSOUND_G72X
|
||||
wxSOUND_G72X,
|
||||
wxSOUND_MSADPCM
|
||||
} wxSoundFormatType;
|
||||
|
||||
// ---------------------
|
||||
|
@ -83,7 +83,9 @@ bool wxSoundRouterStream::SetSoundFormat(const wxSoundFormatBase& format)
|
||||
if (m_router)
|
||||
delete m_router;
|
||||
|
||||
// First, we try to setup the sound device
|
||||
if (m_sndio->SetSoundFormat(format)) {
|
||||
// We are lucky, it is working.
|
||||
wxSoundStream::SetSoundFormat(m_sndio->GetSoundFormat());
|
||||
return TRUE;
|
||||
}
|
||||
@ -165,7 +167,6 @@ bool wxSoundRouterStream::StopProduction()
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// wxSoundFileStream: generic reader
|
||||
// --------------------------------------------------------------------------
|
||||
@ -213,7 +214,7 @@ bool wxSoundFileStream::Play()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxSoundFileStream::Record(unsigned long time)
|
||||
bool wxSoundFileStream::Record(wxUint32 time)
|
||||
{
|
||||
if (m_state != wxSOUND_FILE_STOPPED)
|
||||
return FALSE;
|
||||
@ -346,6 +347,9 @@ wxUint32 wxSoundFileStream::SetPosition(wxUint32 new_position)
|
||||
if (!m_prepared)
|
||||
return 0;
|
||||
|
||||
if (!RepositionStream(new_position))
|
||||
return m_length-m_bytes_left;
|
||||
|
||||
if (new_position >= m_length) {
|
||||
m_bytes_left = 0;
|
||||
return m_length;
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "sndbase.h"
|
||||
#include "sndcodec.h"
|
||||
|
||||
#define wxSOUND_INFINITE_TIME ((unsigned long)-1)
|
||||
#define wxSOUND_INFINITE_TIME ((wxUint32)-1)
|
||||
|
||||
//
|
||||
// Codec router class
|
||||
@ -58,7 +58,7 @@ class wxSoundFileStream: public wxSoundStream {
|
||||
|
||||
// Usual sound file calls (Play, Stop, ...)
|
||||
bool Play();
|
||||
bool Record(unsigned long time);
|
||||
bool Record(wxUint32 time);
|
||||
bool Stop();
|
||||
bool Pause();
|
||||
bool Resume();
|
||||
@ -67,26 +67,28 @@ class wxSoundFileStream: public wxSoundStream {
|
||||
bool IsStopped() const { return m_state == wxSOUND_FILE_STOPPED; }
|
||||
bool IsPaused() const { return m_state == wxSOUND_FILE_PAUSED; }
|
||||
|
||||
// A user should not call these two functions. Several things must be done before calling them.
|
||||
// A user should not call these two functions.
|
||||
// Several things must be done before calling them.
|
||||
// Users should use Play(), ...
|
||||
bool StartProduction(int evt);
|
||||
bool StopProduction();
|
||||
|
||||
// These three functions deals with the length, the position in the sound file.
|
||||
// All the values are expressed in bytes. If you need the values expressed in terms of
|
||||
// time, you have to use GetSoundFormat().GetTimeFromBytes(...)
|
||||
// All the values are expressed in bytes. If you need the values expressed
|
||||
// in terms of time, you have to use GetSoundFormat().GetTimeFromBytes(...)
|
||||
wxUint32 GetLength();
|
||||
wxUint32 GetPosition();
|
||||
wxUint32 SetPosition(wxUint32 new_position);
|
||||
|
||||
// These two functions use the sound format specified by GetSoundFormat(). All samples
|
||||
// must be encoded in that format.
|
||||
// These two functions use the sound format specified by GetSoundFormat().
|
||||
// All samples must be encoded in that format.
|
||||
wxSoundStream& Read(void *buffer, wxUint32 len);
|
||||
wxSoundStream& Write(const void *buffer, wxUint32 len);
|
||||
|
||||
// This function set the sound format of the file. !! It must be used only when you are
|
||||
// in output mode (concerning the file) !! If you are in input mode (concerning the file)
|
||||
// You can't use this function to modify the format of the samples returned by Read() !
|
||||
// This function set the sound format of the file. !! It must be used only
|
||||
// when you are in output mode (concerning the file) !! If you are in
|
||||
// input mode (concerning the file) you can't use this function to modify
|
||||
// the format of the samples returned by Read() !
|
||||
// For this action, you must use wxSoundRouterStream applied to wxSoundFileStream.
|
||||
bool SetSoundFormat(const wxSoundFormatBase& format);
|
||||
|
||||
@ -94,8 +96,8 @@ class wxSoundFileStream: public wxSoundStream {
|
||||
// a player (But also in some other case).
|
||||
virtual wxString GetCodecName() const;
|
||||
|
||||
// You should use this function to test whether this file codec can read the stream you passed
|
||||
// to it.
|
||||
// You should use this function to test whether this file codec can read
|
||||
// the stream you passed to it.
|
||||
virtual bool CanRead() { return FALSE; }
|
||||
|
||||
protected:
|
||||
@ -110,8 +112,9 @@ class wxSoundFileStream: public wxSoundStream {
|
||||
|
||||
protected:
|
||||
virtual bool PrepareToPlay() = 0;
|
||||
virtual bool PrepareToRecord(unsigned long time) = 0;
|
||||
virtual bool PrepareToRecord(wxUint32 time) = 0;
|
||||
virtual bool FinishRecording() = 0;
|
||||
virtual bool RepositionStream(wxUint32 position) = 0;
|
||||
void FinishPreparation(wxUint32 len);
|
||||
|
||||
virtual wxUint32 GetData(void *buffer, wxUint32 len) = 0;
|
||||
|
@ -10,6 +10,10 @@
|
||||
#endif
|
||||
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#endif
|
||||
|
||||
#include "sndbase.h"
|
||||
#include "sndfile.h"
|
||||
#include "sndpcm.h"
|
||||
@ -84,6 +88,7 @@ wxSoundStreamUlaw::~wxSoundStreamUlaw()
|
||||
|
||||
wxSoundStream& wxSoundStreamUlaw::Read(void *buffer, wxUint32 len)
|
||||
{
|
||||
// TODO
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
#pragma interface "sndulaw.h"
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include "sndcodec.h"
|
||||
#include "sndbase.h"
|
||||
|
||||
@ -27,6 +26,9 @@ class WXDLLEXPORT wxSoundFormatUlaw: public wxSoundFormatBase {
|
||||
void SetSampleRate(wxUint32 srate);
|
||||
wxUint32 GetSampleRate() const;
|
||||
|
||||
void SetChannels(wxUint8 channels);
|
||||
wxUint8 GetChannels() const;
|
||||
|
||||
wxSoundFormatType GetType() const { return wxSOUND_ULAW; }
|
||||
wxSoundFormatBase *Clone() const;
|
||||
|
||||
|
@ -37,11 +37,13 @@
|
||||
wxSoundWave::wxSoundWave(wxInputStream& stream, wxSoundStream& io_sound)
|
||||
: wxSoundFileStream(stream, io_sound)
|
||||
{
|
||||
m_base_offset = wxInvalidOffset;
|
||||
}
|
||||
|
||||
wxSoundWave::wxSoundWave(wxOutputStream& stream, wxSoundStream& io_sound)
|
||||
: wxSoundFileStream(stream, io_sound)
|
||||
{
|
||||
m_base_offset = wxInvalidOffset;
|
||||
}
|
||||
|
||||
wxSoundWave::~wxSoundWave()
|
||||
@ -60,6 +62,8 @@ bool wxSoundWave::CanRead()
|
||||
wxUint32 len, signature1, signature2;
|
||||
m_snderror = wxSOUND_NOERR;
|
||||
|
||||
// Test the main signatures:
|
||||
// "RIFF"
|
||||
FAIL_WITH(m_input->Read(&signature1, 4).LastRead() != 4, wxSOUND_INVSTRM);
|
||||
|
||||
if (wxUINT32_SWAP_ON_BE(signature1) != RIFF_SIGNATURE) {
|
||||
@ -67,14 +71,18 @@ bool wxSoundWave::CanRead()
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Pass the global length
|
||||
m_input->Read(&len, 4);
|
||||
FAIL_WITH(m_input->LastRead() != 4, wxSOUND_INVSTRM);
|
||||
|
||||
// Get the second signature
|
||||
FAIL_WITH(m_input->Read(&signature2, 4).LastRead() != 4, wxSOUND_INVSTRM);
|
||||
// Ungetch all
|
||||
m_input->Ungetch(&signature2, 4);
|
||||
m_input->Ungetch(&len, 4);
|
||||
m_input->Ungetch(&signature1, 4);
|
||||
|
||||
// Test the second signature
|
||||
if (wxUINT32_SWAP_ON_BE(signature2) != WAVE_SIGNATURE)
|
||||
return FALSE;
|
||||
|
||||
@ -127,6 +135,7 @@ bool wxSoundWave::PrepareToPlay()
|
||||
wxDataInputStream data(*m_input);
|
||||
data.BigEndianOrdered(FALSE);
|
||||
|
||||
// Get the first signature
|
||||
FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM);
|
||||
FAIL_WITH(wxUINT32_SWAP_ON_BE(signature) != RIFF_SIGNATURE, wxSOUND_INVSTRM);
|
||||
// "RIFF"
|
||||
@ -135,11 +144,13 @@ bool wxSoundWave::PrepareToPlay()
|
||||
FAIL_WITH(m_input->LastRead() != 4, wxSOUND_INVSTRM);
|
||||
// dummy len
|
||||
|
||||
// Get the second signature
|
||||
FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM);
|
||||
FAIL_WITH(wxUINT32_SWAP_ON_BE(signature) != WAVE_SIGNATURE, wxSOUND_INVSTRM);
|
||||
// "WAVE"
|
||||
|
||||
end_headers = FALSE;
|
||||
// Chunk loop
|
||||
while (!end_headers) {
|
||||
FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM);
|
||||
|
||||
@ -151,16 +162,17 @@ bool wxSoundWave::PrepareToPlay()
|
||||
wxUint16 format, channels, byte_p_spl, bits_p_spl;
|
||||
wxUint32 sample_fq, byte_p_sec;
|
||||
|
||||
// Get the common parameters
|
||||
data >> format >> channels >> sample_fq
|
||||
>> byte_p_sec >> byte_p_spl >> bits_p_spl;
|
||||
|
||||
switch (format) {
|
||||
case 0x01:
|
||||
case 0x01: // PCM
|
||||
if (!HandleOutputPCM(data, channels, sample_fq,
|
||||
byte_p_sec, byte_p_spl, bits_p_spl))
|
||||
return FALSE;
|
||||
break;
|
||||
case 0x40:
|
||||
case 0x40: // G721
|
||||
if (!HandleOutputG721(data, channels, sample_fq,
|
||||
byte_p_sec, byte_p_spl, bits_p_spl))
|
||||
return FALSE;
|
||||
@ -172,10 +184,12 @@ bool wxSoundWave::PrepareToPlay()
|
||||
break;
|
||||
}
|
||||
case DATA_SIGNATURE: // "data"
|
||||
m_base_offset = m_input->TellI();
|
||||
end_headers = TRUE;
|
||||
FinishPreparation(len);
|
||||
break;
|
||||
default:
|
||||
// We pass the chunk
|
||||
m_input->SeekI(len, wxFromCurrent);
|
||||
break;
|
||||
}
|
||||
@ -237,7 +251,7 @@ wxSoundFormatBase *wxSoundWave::HandleInputG72X(wxDataOutputStream& data)
|
||||
return g72x;
|
||||
}
|
||||
|
||||
bool wxSoundWave::PrepareToRecord(unsigned long time)
|
||||
bool wxSoundWave::PrepareToRecord(wxUint32 time)
|
||||
{
|
||||
#define WRITE_SIGNATURE(s,sig) \
|
||||
signature = sig; \
|
||||
@ -293,6 +307,7 @@ FAIL_WITH(s->Write(&signature, 4).LastWrite() != 4, wxSOUND_INVSTRM);
|
||||
|
||||
data << (fmt_data.GetSize() + m_sndformat->GetBytesFromTime(time));
|
||||
|
||||
// We, finally, copy the header block to the output stream
|
||||
{
|
||||
char *out_buf;
|
||||
out_buf = new char[fmt_data.GetSize()];
|
||||
@ -321,6 +336,14 @@ bool wxSoundWave::FinishRecording()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxSoundWave::RepositionStream(wxUint32 position)
|
||||
{
|
||||
if (m_base_offset == wxInvalidOffset)
|
||||
return FALSE;
|
||||
m_input->SeekI(m_base_offset, wxFromStart);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxUint32 wxSoundWave::GetData(void *buffer, wxUint32 len)
|
||||
{
|
||||
return m_input->Read(buffer, len).LastRead();
|
||||
|
@ -34,8 +34,9 @@ class wxSoundWave: public wxSoundFileStream {
|
||||
|
||||
protected:
|
||||
bool PrepareToPlay();
|
||||
bool PrepareToRecord(unsigned long time);
|
||||
bool PrepareToRecord(wxUint32 time);
|
||||
bool FinishRecording();
|
||||
bool RepositionStream(wxUint32 position);
|
||||
|
||||
wxUint32 GetData(void *buffer, wxUint32 len);
|
||||
wxUint32 PutData(const void *buffer, wxUint32 len);
|
||||
@ -48,6 +49,9 @@ class wxSoundWave: public wxSoundFileStream {
|
||||
wxUint16 byte_p_spl, wxUint16 bits_p_spl);
|
||||
wxSoundFormatBase *HandleInputPCM(wxDataOutputStream& data);
|
||||
wxSoundFormatBase *HandleInputG72X(wxDataOutputStream& data);
|
||||
|
||||
protected:
|
||||
off_t m_base_offset;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -286,8 +286,6 @@ class wxProcessFileInputStream: public wxInputStream {
|
||||
|
||||
protected:
|
||||
size_t OnSysRead(void *buffer, size_t bufsize);
|
||||
off_t OnSysSeek(off_t seek, wxSeekMode mode);
|
||||
off_t OnSysTell() const;
|
||||
|
||||
protected:
|
||||
int m_fd;
|
||||
@ -300,8 +298,6 @@ class wxProcessFileOutputStream: public wxOutputStream {
|
||||
|
||||
protected:
|
||||
size_t OnSysWrite(const void *buffer, size_t bufsize);
|
||||
off_t OnSysSeek(off_t seek, wxSeekMode mode);
|
||||
off_t OnSysTell() const;
|
||||
|
||||
protected:
|
||||
int m_fd;
|
||||
@ -332,18 +328,6 @@ size_t wxProcessFileInputStream::OnSysRead(void *buffer, size_t bufsize)
|
||||
return ret;
|
||||
}
|
||||
|
||||
off_t wxProcessFileInputStream::OnSysSeek(off_t WXUNUSED(seek),
|
||||
wxSeekMode WXUNUSED(mode))
|
||||
{
|
||||
return wxInvalidOffset;
|
||||
}
|
||||
|
||||
off_t wxProcessFileInputStream::OnSysTell() const
|
||||
{
|
||||
return wxInvalidOffset;
|
||||
}
|
||||
|
||||
|
||||
wxProcessFileOutputStream::wxProcessFileOutputStream(int fd)
|
||||
{
|
||||
m_fd = fd;
|
||||
@ -367,17 +351,6 @@ size_t wxProcessFileOutputStream::OnSysWrite(const void *buffer, size_t bufsize)
|
||||
return ret;
|
||||
}
|
||||
|
||||
off_t wxProcessFileOutputStream::OnSysSeek(off_t WXUNUSED(seek),
|
||||
wxSeekMode WXUNUSED(mode))
|
||||
{
|
||||
return wxInvalidOffset;
|
||||
}
|
||||
|
||||
off_t wxProcessFileOutputStream::OnSysTell() const
|
||||
{
|
||||
return wxInvalidOffset;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
long wxExecute(wxChar **argv,
|
||||
|
Loading…
Reference in New Issue
Block a user