]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/os2/wave.cpp
Added a few modifiers to wxSiserItem
[wxWidgets.git] / src / os2 / wave.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wave.cpp
3// Purpose: wxWave class implementation: optional
4// Author: David Webster
5// Modified by:
6// Created: 10/17/99
7// RCS-ID: $Id$
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifndef WX_PRECOMP
16#include "wx/wx.h"
17#endif
18
19#include "wx/file.h"
20#include "wx/os2/wave.h"
21#include "wx/os2/private.h"
22
23#ifdef RECT
24 #undef RECT
25#endif
26#include <mmio.h>
27#include <mmsystem.h>
28
29wxWave::wxWave()
30 : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
31{
32}
33
34wxWave::wxWave(const wxString& sFileName, bool isResource)
35 : m_waveData(NULL), m_waveLength(0), m_isResource(isResource)
36{
37 Create(sFileName, isResource);
38}
39
40wxWave::wxWave(int size, const wxByte* data)
41 : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
42{
43 Create(size, data);
44}
45
46wxWave::~wxWave()
47{
48 Free();
49}
50
51bool wxWave::Create(const wxString& fileName, bool isResource)
52{
53 Free();
54
55 if (isResource)
56 {
57 m_isResource = TRUE;
58// TODO:
59/*
60 HRSRC hresInfo;
61#ifdef _UNICODE
62 hresInfo = ::FindResourceW((HMODULE) wxhInstance, fileName, wxT("WAVE"));
63#else
64 hresInfo = ::FindResourceA((HMODULE) wxhInstance, fileName, wxT("WAVE"));
65#endif
66 if (!hresInfo)
67 return FALSE;
68
69 HGLOBAL waveData = ::LoadResource((HMODULE) wxhInstance, hresInfo);
70
71 if (waveData)
72 {
73 m_waveData= (wxByte*)::LockResource(waveData);
74 m_waveLength = (int) ::SizeofResource((HMODULE) wxhInstance, hresInfo);
75 }
76
77 return (m_waveData ? TRUE : FALSE);
78*/
79 return FALSE;
80 }
81 else
82 {
83 m_isResource = FALSE;
84
85 wxFile fileWave;
86 if (!fileWave.Open(fileName, wxFile::read))
87 return FALSE;
88
89 m_waveLength = (int) fileWave.Length();
90// TODO:
91/*
92 m_waveData = (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
93 if (!m_waveData)
94 return FALSE;
95
96 fileWave.Read(m_waveData, m_waveLength);
97*/
98 return TRUE;
99 }
100}
101
102bool wxWave::Create(int size, const wxByte* data)
103{
104 Free();
105 m_isResource = FALSE;
106 m_waveLength=size;
107 m_waveData = NULL; // (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
108 if (!m_waveData)
109 return FALSE;
110
111 for (int i=0; i<size; i++) m_waveData[i] = data[i];
112 return TRUE;
113}
114
115bool wxWave::Play(bool async, bool looped) const
116{
117 if (!IsOk())
118 return FALSE;
119// TODO:
120/*
121 return ( ::PlaySound((LPCTSTR)m_waveData, NULL, SND_MEMORY |
122 SND_NODEFAULT | (async ? SND_ASYNC : SND_SYNC) | (looped ? (SND_LOOP | SND_ASYNC) : 0)) != 0 );
123*/
124 return FALSE;
125}
126
127bool wxWave::Free()
128{
129 if (m_waveData)
130 {
131// HGLOBAL waveData = ::GlobalHandle(m_waveData);
132
133// TODO:
134/*
135 if (waveData)
136 {
137 if (m_isResource)
138 ::FreeResource(waveData);
139 else
140 {
141 ::GlobalUnlock(waveData);
142 ::GlobalFree(waveData);
143 }
144
145 m_waveData = NULL;
146 m_waveLength = 0;
147 return TRUE;
148 }
149*/
150 }
151 return FALSE;
152}
153