cwIo* : Updates to include 'decl' files in header and initial sketch of interface.
This commit is contained in:
parent
8f88355f36
commit
8b112b39fe
18
cwIo.cpp
18
cwIo.cpp
@ -3,11 +3,13 @@
|
||||
#include "cwCommonImpl.h"
|
||||
#include "cwMem.h"
|
||||
#include "cwText.h"
|
||||
#include "cwTime.h"
|
||||
#include "cwTextBuf.h"
|
||||
|
||||
#include "cwIo.h"
|
||||
|
||||
#include "cwMidi.h"
|
||||
#include "cwMidiPort.h"
|
||||
#include "cwIo.h"
|
||||
|
||||
|
||||
#include "cwObject.h"
|
||||
|
||||
@ -298,14 +300,14 @@ namespace cw
|
||||
if( r->enableFl )
|
||||
{
|
||||
// get the hardware device index
|
||||
if((r->devIdx = audio::device::deviceLabelToIndex( p->audioH, r->device)) == kInvalidIdx )
|
||||
if((r->devIdx = audio::device::labelToIndex( p->audioH, r->device)) == kInvalidIdx )
|
||||
{
|
||||
rc = cwLogError(rc,"Unable to locate the audio hardware device:'%s'.", r->device);
|
||||
goto errLabel;
|
||||
}
|
||||
|
||||
// setup the device based on the configuration
|
||||
if((rc = audio::device::deviceSetup(p->audioH,r->devIdx,r->srate,r->dspFrameCnt,_audioDeviceCallback,p)) != kOkRC )
|
||||
if((rc = audio::device::setup(p->audioH,r->devIdx,r->srate,r->dspFrameCnt,_audioDeviceCallback,p)) != kOkRC )
|
||||
{
|
||||
rc = cwLogError(rc,"Unable to setup the audio hardware device:'%s'.", r->device);
|
||||
goto errLabel;
|
||||
@ -513,7 +515,7 @@ unsigned cw::io::midiDevicePortIndex( handle_t h, unsigned devIdx, bool inputFl,
|
||||
return midi::device::portNameToIndex( p->midiH, devIdx, inputFl ? midi::kInMpFl : midi::kOutMpFl, portName );
|
||||
}
|
||||
|
||||
cw::rc_t cw::io::midiDeviceSend( handle_t h, unsigned devIdx, unsigned portIdx, midi::byte_t status, midi::byte_t d0, midi::byte_t d1 )
|
||||
cw::rc_t cw::io::midiDeviceSend( handle_t h, unsigned devIdx, unsigned portIdx, uint8_t status, uint8_t d0, uint8_t d1 )
|
||||
{
|
||||
rc_t rc = kOkRC;
|
||||
//io_t* p = _handleToPtr(h);
|
||||
@ -549,19 +551,19 @@ cw::rc_t cw::io::audioDeviceStart( handle_t h, unsigned devIdx )
|
||||
{
|
||||
io_t* p = _handleToPtr(h);
|
||||
assert( devIdx < p->audioCfgN );
|
||||
return audio::device::deviceStart( p->audioH, p->audioCfgA[ devIdx ].devIdx );
|
||||
return audio::device::start( p->audioH, p->audioCfgA[ devIdx ].devIdx );
|
||||
}
|
||||
|
||||
cw::rc_t cw::io::audioDeviceStop( handle_t h, unsigned devIdx )
|
||||
{
|
||||
io_t* p = _handleToPtr(h);
|
||||
assert( devIdx < p->audioCfgN );
|
||||
return audio::device::deviceStop( p->audioH, p->audioCfgA[ devIdx ].devIdx );
|
||||
return audio::device::stop( p->audioH, p->audioCfgA[ devIdx ].devIdx );
|
||||
}
|
||||
|
||||
bool cw::io::audioDeviceIsStarted( handle_t h, unsigned devIdx )
|
||||
{
|
||||
io_t* p = _handleToPtr(h);
|
||||
assert( devIdx < p->audioCfgN );
|
||||
return audio::device::deviceIsStarted( p->audioH, p->audioCfgA[ devIdx ].devIdx );
|
||||
return audio::device::isStarted( p->audioH, p->audioCfgA[ devIdx ].devIdx );
|
||||
}
|
||||
|
80
cwIo.h
80
cwIo.h
@ -1,6 +1,12 @@
|
||||
#ifndef cwIo_h
|
||||
#define cwIo_h
|
||||
|
||||
#include "cwTime.h"
|
||||
#include "cwMidiDecls.h"
|
||||
#include "cwSerialPortDecls.h"
|
||||
#include "cwAudioDeviceDecls.h"
|
||||
#include "cwSocketDecls.h"
|
||||
|
||||
namespace cw
|
||||
{
|
||||
namespace io
|
||||
@ -13,7 +19,7 @@ namespace cw
|
||||
kSerialTId,
|
||||
kMidiTId,
|
||||
kAudioTId,
|
||||
kNetTid,
|
||||
kSockTid,
|
||||
kWebSockTId
|
||||
};
|
||||
|
||||
@ -29,10 +35,32 @@ namespace cw
|
||||
midi::packet_t* pkt;
|
||||
} midi_msg_t;
|
||||
|
||||
typedef audio::device::sample_t sample_t;
|
||||
|
||||
typedef struct audio_msg_str
|
||||
{
|
||||
unsigned iDevIdx;
|
||||
sample_t** iBufArray;
|
||||
unsigned iBufChCnt;
|
||||
time::spec_t* iTimeStampPtr;
|
||||
|
||||
unsigned oDevIdx;
|
||||
sample_t** oBufArray;
|
||||
unsigned oBufChCnt;
|
||||
time::spec_t* oTimeStampPtr;
|
||||
|
||||
} audio_msg_t;
|
||||
|
||||
typedef struct socket_msg_str
|
||||
{
|
||||
sock::cbId_t cbId;
|
||||
unsigned userId;
|
||||
unsigned connId;
|
||||
const void* byteA;
|
||||
unsigned byteN;
|
||||
const struct sockaddr_in* srcAddr;
|
||||
} socket_msg_t;
|
||||
|
||||
typedef struct msg_str
|
||||
{
|
||||
unsigned tid;
|
||||
@ -40,6 +68,8 @@ namespace cw
|
||||
{
|
||||
const serial_msg_t* serial;
|
||||
const midi_msg_t* midi;
|
||||
const audio_msg_t audio;
|
||||
const socket_msg_t sock;
|
||||
} u;
|
||||
} msg_t;
|
||||
|
||||
@ -68,20 +98,62 @@ namespace cw
|
||||
unsigned midiDevicePortCount( handle_t h, unsigned devIdx, bool inputFl );
|
||||
const char* midiDevicePortName( handle_t h, unsigned devIdx, bool inputFl, unsigned portIdx );
|
||||
unsigned midiDevicePortIndex( handle_t h, unsigned devIdx, bool inputFl, const char* portName );
|
||||
rc_t midiDeviceSend( handle_t h, unsigned devIdx, unsigned portIdx, midi::byte_t status, midi::byte_t d0, midi::byte_t d1 );
|
||||
rc_t midiDeviceSend( handle_t h, unsigned devIdx, unsigned portIdx, uint8_t status, uint8_t d0, uint8_t d1 );
|
||||
|
||||
|
||||
unsigned audioDeviceCount( handle_t h );
|
||||
unsigned audioDeviceLabelToIndex( handle_t h, const char* label );
|
||||
const char* audioDeviceLabel( handle_t h, unsigned devIdx );
|
||||
unsigned audioDeviceChannelCount( handle_t h, unsigned devIdx, bool inputFl );
|
||||
rc_t audioDeviceSetup(
|
||||
handle_t h,
|
||||
unsigned devIdx,
|
||||
double srate,
|
||||
unsigned framesPerDeviceCycle,
|
||||
unsigned devBufBufN,
|
||||
unsigned framesPerDspCycle,
|
||||
unsigned inputFlags,
|
||||
unsigned outputFlags );
|
||||
|
||||
unsigned audioDeviceChannelCount( handle_t h, unsigned devIdx, unsigned dirFl );
|
||||
double audioDeviceSampleRate( handle_t h, unsigned devIdx );
|
||||
unsigned audioDeviceFramesPerCycle( handle_t h, unsigned devIdx, bool inputFl );
|
||||
unsigned audioDeviceFramesPerCycle( handle_t h, unsigned devIdx );
|
||||
unsigned audioDeviceChannelFlags( handle_t h, unsigned devIdx, unsigned chIdx, unsigned dirFl );
|
||||
rc_t audioDeviceChannelSetFlags(handle_t h, unsigned devidx, unsigned chIdx, unsigned dirFl, unsigned flags );
|
||||
sample_t audioDeviceChannelMeter( handle_t h, unsigned devIdx, unsigned chIdx, unsigned dirFl );
|
||||
rc_t audioDeviceChannelSetGain( handle_t h, unsigned devIdx, unsigned chIdx, unsigned dirFl, double gain );
|
||||
double audioDeviceChannelGain( handle_t h, unsigned devIdx, unsigned chIdx, unsigned dirFl );
|
||||
|
||||
rc_t audioDeviceStart( handle_t h, unsigned devIdx );
|
||||
rc_t audioDeviceStop( handle_t h, unsigned devIdx );
|
||||
bool audioDeviceIsStarted( handle_t h, unsigned devIdx );
|
||||
|
||||
|
||||
rc_t socketSetup( handle_t h, unsigned timeOutMs, unsigned recvBufByteN, unsigned maxSocketN );
|
||||
rc_t socketCreate(
|
||||
handle_t h,
|
||||
unsigned userId,
|
||||
short port,
|
||||
unsigned flags,
|
||||
const char* remoteAddr = nullptr,
|
||||
sock::portNumber_t remotePort = sock::kInvalidPortNumber,
|
||||
const char* localAddr = nullptr );
|
||||
|
||||
rc_t socketDestroy( handle_t h, unsigned userId );
|
||||
|
||||
// Send to the remote endpoint represented by connId over a connected socket.
|
||||
// If 'connId' is kInvalidId then this data is sent to all connected endpoints.
|
||||
rc_t socketSend( handle_t h, unsigned userId, unsigned connId, const void* data, unsigned dataByteN );
|
||||
|
||||
// Send a message to a specific remote node over an unconnected UDP socket.
|
||||
// Use the function initAddr() to setup the 'sockaddr_in';
|
||||
rc_t socketSend( handle_t h, unsigned userId, const void* data, unsigned dataByteCnt, const struct sockaddr_in* remoteAddr );
|
||||
rc_t socketSend( handle_t h, unsigned userId, const void* data, unsigned dataByteCnt, const char* remoteAddr, sock::portNumber_t port );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
#include "cwLog.h"
|
||||
#include "cwCommonImpl.h"
|
||||
#include "cwMem.h"
|
||||
#include "cwTime.h"
|
||||
#include "cwMidiDecls.h"
|
||||
#include "cwMidi.h"
|
||||
#include "cwIo.h"
|
||||
#include "cwIoTest.h"
|
||||
|
Loading…
Reference in New Issue
Block a user