1 /*
2 * Copyright 1993 Network Computing Devices, Inc.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name Network Computing Devices, Inc. not be
9 * used in advertising or publicity pertaining to distribution of this
10 * software without specific, written prior permission.
11 *
12 * THIS SOFTWARE IS PROVIDED 'AS-IS'. NETWORK COMPUTING DEVICES, INC.,
13 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
14 * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
15 * PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL NETWORK
16 * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
17 * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
18 * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
19 * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 *
22 * $NCDId: @(#)CrBucket.c,v 1.3 1993/08/13 20:51:21 greg Exp $
23 */
24
25 #include "Alibint.h"
26
27 AuBucketID
AuCreateBucket(AuServer * aud,AuUint32 format,AuUint32 num_tracks,AuUint32 access,AuUint32 sample_rate,AuUint32 num_samples,AuString * description,AuStatus * ret_status)28 AuCreateBucket(
29 AuServer *aud,
30 AuUint32 format,
31 AuUint32 num_tracks,
32 AuUint32 access,
33 AuUint32 sample_rate,
34 AuUint32 num_samples,
35 AuString *description,
36 AuStatus *ret_status
37 )
38 {
39 auResourceReq *req;
40 auBucketAttributes b;
41 AuBucketID bucket = AuAllocID(aud);
42
43 if (ret_status)
44 *ret_status = AuSuccess;
45
46 b.common.value_mask = AuCompBucketAllMasks &
47 ~(AuCompCommonKindMask | AuCompCommonUseMask);
48 b.common.id = bucket;
49 b.common.format = format;
50 b.common.num_tracks = num_tracks;
51 b.common.access = access;
52
53 if (description)
54 {
55 b.common.description.type = description->type;
56 b.common.description.len = description->len;
57 }
58 else
59 {
60 b.common.description.type = AuStringLatin1;
61 b.common.description.len = 0;
62 }
63
64 b.bucket.sample_rate = sample_rate;
65 b.bucket.num_samples = num_samples;
66
67 _AuLockServer();
68 _AuGetResReq(CreateBucket, bucket, req, aud);
69
70 req->length += (SIZEOF(auBucketAttributes) +
71 PAD4(b.common.description.len)) >> 2;
72
73 _AuData(aud, (char *) &b, SIZEOF(auBucketAttributes));
74
75 if (b.common.description.len)
76 _AuData(aud, description->data, b.common.description.len);
77
78 if (!_AuIfRoundTrip(aud, ret_status))
79 bucket = AuNone;
80
81 _AuUnlockServer();
82 _AuSyncHandle(aud);
83
84 return bucket;
85 }
86