1998-11-09 13:37:38 -05:00
|
|
|
// /////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: sndfrag.h
|
|
|
|
// Purpose: wxMMedia
|
|
|
|
// Author: Guilhem Lavaux
|
|
|
|
// Created: 1997
|
|
|
|
// Updated: 1998
|
|
|
|
// Copyright: (C) 1997, 1998, Guilhem Lavaux
|
|
|
|
// License: wxWindows license
|
|
|
|
// /////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef __SND_frag_H__
|
|
|
|
#define __SND_frag_H__
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WX_PRECOMP
|
|
|
|
#include "wx_prec.h"
|
|
|
|
#else
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
#include "sndsnd.h"
|
|
|
|
|
|
|
|
///
|
|
|
|
class wxFragmentBuffer {
|
|
|
|
protected:
|
|
|
|
wxSound *m_iodrv;
|
|
|
|
|
|
|
|
///
|
|
|
|
wxUint8 m_maxoq, m_maxiq;
|
|
|
|
|
|
|
|
///
|
|
|
|
typedef enum {
|
|
|
|
wxBUFFER_FREE,
|
|
|
|
wxBUFFER_FFILLED,
|
1999-02-14 12:46:47 -05:00
|
|
|
wxBUFFER_TOFREE,
|
|
|
|
wxBUFFER_PLAYING
|
1998-11-09 13:37:38 -05:00
|
|
|
} BufState;
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
typedef struct {
|
1999-02-14 12:46:47 -05:00
|
|
|
// Local stream buffer for this fragment.
|
|
|
|
wxStreamBuffer *sndbuf;
|
|
|
|
// Data the driver would like to pass to the callback.
|
1998-11-09 13:37:38 -05:00
|
|
|
char *user_data;
|
1999-02-14 12:46:47 -05:00
|
|
|
// Buffers included in this fragment.
|
1998-11-09 13:37:38 -05:00
|
|
|
wxList *buffers;
|
1999-02-14 12:46:47 -05:00
|
|
|
// State of the fragment.
|
1998-11-09 13:37:38 -05:00
|
|
|
BufState state;
|
|
|
|
} wxFragBufPtr;
|
|
|
|
protected:
|
1999-02-14 12:46:47 -05:00
|
|
|
//
|
1998-11-09 13:37:38 -05:00
|
|
|
wxFragBufPtr *m_optrs, *m_iptrs;
|
1999-02-14 12:46:47 -05:00
|
|
|
//
|
1998-11-09 13:37:38 -05:00
|
|
|
wxFragBufPtr *m_lstoptrs, *m_lstiptrs;
|
1999-02-14 12:46:47 -05:00
|
|
|
//
|
1998-11-09 13:37:38 -05:00
|
|
|
bool m_buf2free, m_dontq, m_freeing;
|
1999-02-14 12:46:47 -05:00
|
|
|
//
|
1998-12-23 13:16:19 -05:00
|
|
|
wxSoundDataFormat m_drvformat;
|
1998-11-09 13:37:38 -05:00
|
|
|
public:
|
|
|
|
wxFragmentBuffer(wxSound& io_drv);
|
|
|
|
virtual ~wxFragmentBuffer();
|
|
|
|
|
1999-02-14 12:46:47 -05:00
|
|
|
// These functions initializes the fragments. They must initialize
|
|
|
|
// m_lstoptrs, m_lstiptrs, m_maxoq, m_maxiq.
|
1998-11-09 13:37:38 -05:00
|
|
|
virtual void AllocIOBuffer() = 0;
|
|
|
|
virtual void FreeIOBuffer() = 0;
|
|
|
|
|
|
|
|
void AbortBuffer(wxSndBuffer *buf);
|
|
|
|
|
1999-02-14 12:46:47 -05:00
|
|
|
// Find a free (or partly free) fragment.
|
1998-11-09 13:37:38 -05:00
|
|
|
wxFragBufPtr *FindFreeBuffer(wxFragBufPtr *list, wxUint8 max_queue);
|
1999-02-14 12:46:47 -05:00
|
|
|
// Add this sound buffer to an "OUTPUT" fragment.
|
1998-11-09 13:37:38 -05:00
|
|
|
bool NotifyOutputBuffer(wxSndBuffer *buf);
|
1999-02-14 12:46:47 -05:00
|
|
|
// Add this sound buffer to an "INPUT" fragment.
|
1998-11-09 13:37:38 -05:00
|
|
|
bool NotifyInputBuffer(wxSndBuffer *buf);
|
|
|
|
|
1999-02-14 12:46:47 -05:00
|
|
|
// Called when a fragment is finished.
|
1998-11-09 13:37:38 -05:00
|
|
|
void OnBufferFinished(wxFragBufPtr *ptr);
|
|
|
|
|
1999-02-14 12:46:47 -05:00
|
|
|
// Called when a fragment is full and it should be flushed in the sound card.
|
1998-11-09 13:37:38 -05:00
|
|
|
virtual bool OnBufferFilled(wxFragBufPtr *ptr, wxSndMode mode) = 0;
|
|
|
|
|
|
|
|
inline wxSndBuffer *LastBuffer() {
|
|
|
|
wxNode *node = m_iodrv->m_buffers.Last();
|
|
|
|
|
|
|
|
if (!node) return NULL;
|
|
|
|
return (wxSndBuffer *)node->Data();
|
|
|
|
}
|
|
|
|
inline wxSndBuffer *FirstBuffer() {
|
|
|
|
wxNode *node = m_iodrv->m_buffers.First();
|
|
|
|
|
|
|
|
if (!node) return NULL;
|
|
|
|
return (wxSndBuffer *)node->Data();
|
|
|
|
}
|
|
|
|
protected:
|
|
|
|
void FreeBufToFree(bool force = FALSE);
|
|
|
|
void ClearBuffer(wxFragBufPtr *ptr);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|