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 "cwCommonImpl.h"
|
||||||
#include "cwMem.h"
|
#include "cwMem.h"
|
||||||
#include "cwText.h"
|
#include "cwText.h"
|
||||||
#include "cwTime.h"
|
|
||||||
#include "cwTextBuf.h"
|
#include "cwTextBuf.h"
|
||||||
|
|
||||||
|
#include "cwIo.h"
|
||||||
|
|
||||||
#include "cwMidi.h"
|
#include "cwMidi.h"
|
||||||
#include "cwMidiPort.h"
|
#include "cwMidiPort.h"
|
||||||
#include "cwIo.h"
|
|
||||||
|
|
||||||
#include "cwObject.h"
|
#include "cwObject.h"
|
||||||
|
|
||||||
@ -298,14 +300,14 @@ namespace cw
|
|||||||
if( r->enableFl )
|
if( r->enableFl )
|
||||||
{
|
{
|
||||||
// get the hardware device index
|
// 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);
|
rc = cwLogError(rc,"Unable to locate the audio hardware device:'%s'.", r->device);
|
||||||
goto errLabel;
|
goto errLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup the device based on the configuration
|
// 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);
|
rc = cwLogError(rc,"Unable to setup the audio hardware device:'%s'.", r->device);
|
||||||
goto errLabel;
|
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 );
|
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;
|
rc_t rc = kOkRC;
|
||||||
//io_t* p = _handleToPtr(h);
|
//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);
|
io_t* p = _handleToPtr(h);
|
||||||
assert( devIdx < p->audioCfgN );
|
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 )
|
cw::rc_t cw::io::audioDeviceStop( handle_t h, unsigned devIdx )
|
||||||
{
|
{
|
||||||
io_t* p = _handleToPtr(h);
|
io_t* p = _handleToPtr(h);
|
||||||
assert( devIdx < p->audioCfgN );
|
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 )
|
bool cw::io::audioDeviceIsStarted( handle_t h, unsigned devIdx )
|
||||||
{
|
{
|
||||||
io_t* p = _handleToPtr(h);
|
io_t* p = _handleToPtr(h);
|
||||||
assert( devIdx < p->audioCfgN );
|
assert( devIdx < p->audioCfgN );
|
||||||
return audio::device::deviceIsStarted( p->audioH, p->audioCfgA[ devIdx ].devIdx );
|
return audio::device::isStarted( p->audioH, p->audioCfgA[ devIdx ].devIdx );
|
||||||
}
|
}
|
||||||
|
84
cwIo.h
84
cwIo.h
@ -1,6 +1,12 @@
|
|||||||
#ifndef cwIo_h
|
#ifndef cwIo_h
|
||||||
#define cwIo_h
|
#define cwIo_h
|
||||||
|
|
||||||
|
#include "cwTime.h"
|
||||||
|
#include "cwMidiDecls.h"
|
||||||
|
#include "cwSerialPortDecls.h"
|
||||||
|
#include "cwAudioDeviceDecls.h"
|
||||||
|
#include "cwSocketDecls.h"
|
||||||
|
|
||||||
namespace cw
|
namespace cw
|
||||||
{
|
{
|
||||||
namespace io
|
namespace io
|
||||||
@ -13,7 +19,7 @@ namespace cw
|
|||||||
kSerialTId,
|
kSerialTId,
|
||||||
kMidiTId,
|
kMidiTId,
|
||||||
kAudioTId,
|
kAudioTId,
|
||||||
kNetTid,
|
kSockTid,
|
||||||
kWebSockTId
|
kWebSockTId
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -29,17 +35,41 @@ namespace cw
|
|||||||
midi::packet_t* pkt;
|
midi::packet_t* pkt;
|
||||||
} midi_msg_t;
|
} midi_msg_t;
|
||||||
|
|
||||||
|
typedef audio::device::sample_t sample_t;
|
||||||
|
|
||||||
typedef struct audio_msg_str
|
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;
|
} 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
|
typedef struct msg_str
|
||||||
{
|
{
|
||||||
unsigned tid;
|
unsigned tid;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
const serial_msg_t* serial;
|
const serial_msg_t* serial;
|
||||||
const midi_msg_t* midi;
|
const midi_msg_t* midi;
|
||||||
|
const audio_msg_t audio;
|
||||||
|
const socket_msg_t sock;
|
||||||
} u;
|
} u;
|
||||||
} msg_t;
|
} msg_t;
|
||||||
|
|
||||||
@ -68,20 +98,62 @@ namespace cw
|
|||||||
unsigned midiDevicePortCount( handle_t h, unsigned devIdx, bool inputFl );
|
unsigned midiDevicePortCount( handle_t h, unsigned devIdx, bool inputFl );
|
||||||
const char* midiDevicePortName( handle_t h, unsigned devIdx, bool inputFl, unsigned portIdx );
|
const char* midiDevicePortName( handle_t h, unsigned devIdx, bool inputFl, unsigned portIdx );
|
||||||
unsigned midiDevicePortIndex( handle_t h, unsigned devIdx, bool inputFl, const char* portName );
|
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 audioDeviceCount( handle_t h );
|
||||||
unsigned audioDeviceLabelToIndex( handle_t h, const char* label );
|
unsigned audioDeviceLabelToIndex( handle_t h, const char* label );
|
||||||
const char* audioDeviceLabel( handle_t h, unsigned devIdx );
|
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 );
|
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 audioDeviceStart( handle_t h, unsigned devIdx );
|
||||||
rc_t audioDeviceStop( handle_t h, unsigned devIdx );
|
rc_t audioDeviceStop( handle_t h, unsigned devIdx );
|
||||||
bool audioDeviceIsStarted( 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 "cwLog.h"
|
||||||
#include "cwCommonImpl.h"
|
#include "cwCommonImpl.h"
|
||||||
#include "cwMem.h"
|
#include "cwMem.h"
|
||||||
|
#include "cwTime.h"
|
||||||
|
#include "cwMidiDecls.h"
|
||||||
#include "cwMidi.h"
|
#include "cwMidi.h"
|
||||||
#include "cwIo.h"
|
#include "cwIo.h"
|
||||||
#include "cwIoTest.h"
|
#include "cwIoTest.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user