cwAudioDevice.h/cpp : Changes to support audio device file.

Add deviceIsAsync(), deveiceExecute() to driver.
Added cbDevIdx to deviceSetup().
Added execute(),realTimeReport()
This commit is contained in:
kevin 2023-02-14 20:46:41 -05:00
parent 844a103d69
commit d3b2dec511
2 changed files with 32 additions and 4 deletions

View File

@ -168,7 +168,7 @@ cw::rc_t cw::audio::device::setup( handle_t h, unsigned devIdx, double sr, unsi
{
drv_t* d;
if((d = _indexToDriver(h,devIdx)) != nullptr )
return d->drv->deviceSetup( d->drv, devIdx - d->begIdx, sr, frmPerCycle, cb, cbData );
return d->drv->deviceSetup( d->drv, devIdx - d->begIdx, sr, frmPerCycle, cb, cbData, devIdx );
return kInvalidArgRC;
}
@ -203,6 +203,17 @@ void cw::audio::device::realTimeReport( handle_t h, unsigned devIdx )
d->drv->deviceRealTimeReport( d->drv, devIdx - d->begIdx );
}
cw::rc_t cw::audio::device::execute( handle_t h, unsigned devIdx )
{
rc_t rc = kOkRC;
drv_t* d;
if((d = _indexToDriver(h,devIdx)) != nullptr )
rc = d->drv->deviceExecute( d->drv, devIdx - d->begIdx );
return rc;
}
void cw::audio::device::report( handle_t h )
{
for(unsigned i=0; i<count(h); ++i)
@ -215,3 +226,13 @@ void cw::audio::device::report( handle_t h )
}
}
void cw::audio::device::realTimeReport( handle_t h )
{
for(unsigned i=0; i<count(h); ++i)
{
realTimeReport(h,i);
}
}

View File

@ -58,10 +58,12 @@ namespace cw
unsigned (*deviceChannelCount)( struct driver_str* drvArg, unsigned devIdx, bool inputFl );
double (*deviceSampleRate)( struct driver_str* drvArg, unsigned devIdx );
unsigned (*deviceFramesPerCycle)( struct driver_str* drvArg, unsigned devIdx, bool inputFl );
rc_t (*deviceSetup)( struct driver_str* drvArg, unsigned devIdx, double sr, unsigned frmPerCycle, cbFunc_t cb, void* cbData );
rc_t (*deviceSetup)( struct driver_str* drvArg, unsigned devIdx, double sr, unsigned frmPerCycle, cbFunc_t cb, void* cbData, unsigned cbDevIdx );
rc_t (*deviceStart)( struct driver_str* drvArg, unsigned devIdx );
rc_t (*deviceStop)( struct driver_str* drvArg, unsigned devIdx );
bool (*deviceIsStarted)( struct driver_str* drvArg, unsigned devIdx );
bool (*deviceIsAsync)( struct driver_str* drvArg, unsigned devIdx );
rc_t (*deviceExecute)( struct driver_str* drvArg, unsigned devIdx );
void (*deviceRealTimeReport)( struct driver_str* drvArg, unsigned devIdx );
} driver_t;
@ -78,6 +80,8 @@ namespace cw
unsigned channelCount( handle_t h, unsigned devIdx, bool inputFl );
double sampleRate( handle_t h, unsigned devIdx );
unsigned framesPerCycle( handle_t h, unsigned devIdx, bool inputFl );
bool isAsync( handle_t h, unsigned devIdx );
// Configure a device.
// All devices must be setup before they are started.
@ -102,7 +106,10 @@ namespace cw
bool isStarted( handle_t h, unsigned devIdx );
void realTimeReport( handle_t h, unsigned devIdx );
rc_t execute( handle_t h, unsigned devIdx );
void report( handle_t h );
void realTimeReport( handle_t h );
}
}
}