-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathPacketClientPrimed.m
54 lines (44 loc) · 1.29 KB
/
PacketClientPrimed.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//
// PacketClientPrimed.m
// Snap
//
// Created by Abdullah Bakhach on 10/3/12.
// Copyright (c) 2012 Hollance. All rights reserved.
//
#import "PacketClientPrimed.h"
#import "NSData+SnapAdditions.h"
#import "AudioStreamer.h"
@implementation PacketClientPrimed
@synthesize profiler = _profiler;
+ (id)packetWithData:(NSData *)data
{
size_t offset = PACKET_HEADER_SIZE;
NSMutableArray *profiler = [NSMutableArray arrayWithCapacity:kNumAQBufs];
for (int t = 0; t < kNumAQBufs; ++t)
{
[profiler insertObject:[NSNumber numberWithDouble:
[[NSData dataWithBytes:(void *)([data bytes] + offset) length:sizeof(double)] rw_double64]]
atIndex:t];
offset +=sizeof(double);
}
return [[self class] packetWithProfiler:profiler];
}
+ (id)packetWithProfiler:(NSMutableArray *)profiler
{
return [[[self class] alloc] initWithProfiler:profiler];
}
- (id)initWithProfiler:(NSMutableArray *)profiler
{
if ((self = [super initWithType:PacketTypeClientPrimed]))
{
self.profiler = profiler;
}
return self;
}
- (void)addPayloadToData:(NSMutableData *)data
{
[self.profiler enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
[data rw_appendDouble64:[obj doubleValue]];
}];
}
@end