typedef struct _wxSoundInternal wxSoundInternal;
typedef struct _wxSoundInfoHeader wxSoundInfoHeader;
-extern char wxCanvasClassName[];
+extern const wxChar *wxCanvasClassName;
wxList *wxSoundHandleList = NULL;
m_production_started = FALSE;
m_internal = new wxSoundInternal;
+ if (!m_internal) {
+ m_snderror = wxSOUND_MEMERR;
+ m_internal = NULL;
+ return;
+ }
m_snderror = wxSOUND_NOERR;
// Setup defaults
m_internal->m_input_enabled = FALSE;
m_internal->m_output_enabled = FALSE;
+ m_waiting_for = FALSE;
+
if (!OpenDevice(wxSOUND_OUTPUT))
return;
wxSoundStreamWin::~wxSoundStreamWin()
{
- if (m_production_started)
- StopProduction();
- DestroySndWindow();
+ if (m_internal) {
+ if (m_production_started)
+ StopProduction();
+ DestroySndWindow();
- delete m_internal;
+ delete m_internal;
+ }
}
LRESULT APIENTRY _EXPORT _wxSoundHandlerWndProc(HWND hWnd, UINT message,
return FALSE;
}
- m_current_frag_in = WXSOUND_MAX_QUEUE-1;
- m_input_frag_in = 0;
+ m_current_frag_in = WXSOUND_MAX_QUEUE-1;
+ m_input_frag_in = 0;
m_internal->m_input_enabled = TRUE;
}
void wxSoundStreamWin::CloseDevice()
{
if (m_internal->m_output_enabled) {
- m_internal->m_output_enabled = FALSE;
- waveOutReset(m_internal->m_devout);
FreeHeaders(wxSOUND_OUTPUT);
+ m_internal->m_output_enabled = FALSE;
waveOutClose(m_internal->m_devout);
}
if (m_internal->m_input_enabled) {
- m_internal->m_input_enabled = FALSE;
- waveInReset(m_internal->m_devin);
FreeHeaders(wxSOUND_INPUT);
+ m_internal->m_input_enabled = FALSE;
waveInClose(m_internal->m_devin);
}
}
header->dwUser = (DWORD)info;
header->dwFlags = WHDR_DONE;
-
// "Prepare" the header
if (mode == wxSOUND_INPUT) {
MMRESULT result;
memset(info->m_data + info->m_position, 0, info->m_size);
AddToQueue(info);
}
+ }
+ if (m_waiting_for) {
+ // PROBLEM //
return;
}
-
+ m_waiting_for = TRUE;
// Else, we wait for its termination
while (info->m_playing || info->m_recording)
wxYield();
+ m_waiting_for = FALSE;
}
// -------------------------------------------------------------------------
info = m_headers_play[m_output_frag_out];
ClearHeader(info);
m_queue_filled = FALSE;
- OnSoundEvent(wxSOUND_OUTPUT);
+ if (!m_waiting_for)
+ OnSoundEvent(wxSOUND_OUTPUT);
} else {
if (!m_internal->m_input_enabled)
return;
- m_input_frag_in = (m_input_frag_in + 1) % WXSOUND_MAX_QUEUE;
m_headers_rec[m_input_frag_in]->m_recording = FALSE;
- OnSoundEvent(wxSOUND_INPUT);
+ m_input_frag_in = (m_input_frag_in + 1) % WXSOUND_MAX_QUEUE;
+ if (!m_waiting_for)
+ OnSoundEvent(wxSOUND_INPUT);
m_queue_filled = FALSE;
}
}
// -------------------------------------------------------------------------
bool wxSoundStreamWin::StartProduction(int evt)
{
+ if (!m_internal)
+ return FALSE;
+
if ((m_internal->m_output_enabled && (evt & wxSOUND_OUTPUT)) ||
(m_internal->m_input_enabled && (evt & wxSOUND_INPUT)))
CloseDevice();
m_queue_filled = FALSE;
// Send a dummy event to start.
if (evt & wxSOUND_OUTPUT)
- OnSoundEvent(evt);
+ OnSoundEvent(wxSOUND_OUTPUT);
if (evt & wxSOUND_INPUT) {
int i;
// -------------------------------------------------------------------------
bool wxSoundStreamWin::StopProduction()
{
- if (m_internal->m_input_enabled)
- waveInStop(m_internal->m_devin);
+ if (!m_production_started)
+ return FALSE;
m_production_started = FALSE;
CloseDevice();