• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSData or Small Socket Help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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 writeData:transit];

Client:
receive data in NSMutableData structure
NSMutableData *caught;
caught = [[NSMutableData alloc] initWithCapacity:(arraySize * sizeof(short))];
bytesRead = [mySocket readData: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
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: RE: Re : Validation of IP Address
  • Next by Date: Remote Access Connected Configuration
  • Previous by thread: Re: Obtaining Ethernet link speed
  • Next by thread: Remote Access Connected Configuration
  • Index(es):
    • Date
    • Thread