nsstream

Playing Raw pcm audio data coming from NSStream

两盒软妹~` 提交于 2019-11-27 17:03:08
问题 I am trying to play the pcm data from NSInputStream. Can anyone provide me the right approach or code to do so. I got the Audio in StreamHasData event with following code. uint8_t bytes[self.audioStreamReadMaxLength]; UInt32 length = [audioStream readData:bytes maxLength:self.audioStreamReadMaxLength]; Now how can i play bytes audio data in iphone? 回答1: I worked on a similar problem, and I in the end solved it. Here is the basic of what I did. I am using a library for the sockets The below

NSStream and Sockets, NSStreamDelegate methods not being called

爷,独闯天下 提交于 2019-11-27 05:13:29
问题 I've followed the guide Setting Up Socket Streams and have effectively duplicated that code in my class. No matter what I try the delegate methods just don't seem to get called. In the header file I have (basically): @interface myClass : NSObject <NSStreamDelegate> { NSInputStream *inputStream; NSOutputStream *outputStream; } - (void)connect; @end; The connect method: - (void)connect { CFReadStreamRef readStream; CFWriteStreamRef writeStream; CFStreamCreatePairWithSocketToHost

Objective-C: Reading a file line by line

戏子无情 提交于 2019-11-26 03:17:58
问题 What is the appropriate way of dealing with large text files in Objective-C? Let\'s say I need to read each line separately and want to treat each line as an NSString. What is the most efficient way of doing this? One solution is using the NSString method: + (id)stringWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding)enc error:(NSError **)error and then split the lines with a newline separator, and then iterate over the elements in the array. However, this seems fairly