NSData or Small Socket Help
NSData or Small Socket Help
- Subject: NSData or Small Socket Help
- From: Peter <email@hidden>
- Date: Tue, 22 Apr 2003 14:41:49 -0500
Hello everyone,
I'm having difficulty sending correct data using Small Sockets and I'm
trying to figure out where my problems occur. Is it in the socket or in
the NSData objects.? (I'm using Omni Group's SoundExample application
as the basis for my application. I'm using OS X v10.2.5 and recent
tools.)
Here's the flow of my applications:
Server:
read audio data into a buffer of shorts called samples
sampleCount = fread(samples, sizeof(short), sampleCount, file);
create a NSData structure from that buffer, size N
NSData *transit;
transit = [[NSData alloc] initWithBytes:start length:(arraySize *
sizeof(short))];
send it down the socket (this is referred to as type (char *))
[mySocket write
Data:transit];
Client:
receive data in NSMutableData structure
NSMutableData *caught;
caught = [[NSMutableData alloc] initWithCapacity:(arraySize *
sizeof(short))];
bytesRead = [mySocket read
Data:caught];
copy it into a buffer of type short
short big[howManyBuffersIWant][arraySize];
[caught getBytes:big[inPt]];
from the short buffer, turn data into floats byte-by-byte (this should
not be a problem because the file playing example used this method)
When I play my sound data, it is choppy and slow. The client
application grabs the audio data from a larger buffer so I don't think
there's a time issue getting it out of there. It seems that my data is
changed.
Will my data be changed during it's transit between those two short
buffers? Does referring to it as a (char *) have an effect? I thought
that putting into back into a short buffer would take care of type
conversion issues. Am I using the NSData and NSMutableData structures
incorrectly?
I appreciate any thoughts.
Peter
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.