本文整理汇总了C++中Audio::buffered方法的典型用法代码示例。如果您正苦于以下问题:C++ Audio::buffered方法的具体用法?C++ Audio::buffered怎么用?C++ Audio::buffered使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Audio
的用法示例。
在下文中一共展示了Audio::buffered方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: devdirread
static long
audioread(Chan *c, void *a, long n, vlong off)
{
Audiochan *ac;
Audio *adev;
long (*fn)(Audio *, void *, long, vlong);
ac = c->aux;
adev = ac->adev;
fn = nil;
switch((ulong)c->qid.path){
case Qdir:
audiodir[Qaudio].length = adev->buffered ? adev->buffered(adev) : 0;
return devdirread(c, a, n, audiodir, nelem(audiodir), devgen);
case Qaudio:
fn = adev->read;
break;
case Qaudiostat:
fn = adev->status;
break;
case Qvolume:
fn = adev->volread;
break;
}
if(fn == nil)
error(Egreg);
eqlock(ac);
if(waserror()){
qunlock(ac);
nexterror();
}
switch((ulong)c->qid.path){
case Qaudiostat:
case Qvolume:
/* generate the text on first read */
if(ac->data == nil || off == 0){
long l;
ac->data = nil;
l = fn(adev, ac->buf, sizeof(ac->buf)-1, 0);
if(l < 0)
l = 0;
ac->buf[l] = 0;
ac->data = ac->buf;
}
/* then serve all requests from buffer */
n = readstr(off, a, n, ac->data);
break;
default:
n = fn(adev, a, n, off);
}
qunlock(ac);
poperror();
return n;
}
示例2: devstat
static int
audiostat(Chan *c, uchar *dp, int n)
{
Audiochan *ac;
Audio *adev;
ac = c->aux;
adev = ac->adev;
if((ulong)c->qid.path == Qaudio)
audiodir[Qaudio].length = adev->buffered ? adev->buffered(adev) : 0;
return devstat(c, dp, n, audiodir, nelem(audiodir), devgen);
}