Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ReadStreamClientCallBack(CFReadStreamRef stream,
- CFStreamEventType type,
- void* clientCallBackInfo) {
- BMHttpAudioStreamManager *manager = (__bridge BMHttpAudioStreamManager*) clientCallBackInfo;
- [manager readStreamClientCallBackWithData:stream withType:type];
- }
- - (void) readStreamClientCallBackWithData:(CFReadStreamRef) stream
- withType:(CFStreamEventType) type {
- if(type == kCFStreamEventHasBytesAvailable) {
- UInt8 buffer[2048];
- CFIndex bytesRead = CFReadStreamRead(stream, buffer, sizeof(buffer));
- if (bytesRead < 0) {
- //nothing
- }
- // If zero bytes were read, wait for the EOF to come.
- else if (bytesRead) {
- // parse the data. this will call MyPropertyListenerProc and MyPacketsProc
- // AudioFileStreamParseBytes function called when you have data to pass to the parser.
- // Send the data to the parser sequentially and, if possible, without gaps.
- OSStatus err = AudioFileStreamParseBytes(_audioData->audioFileStream, bytesRead, buffer, 0);
- /* This is what I had before, before I changed it to work 10.13.14
- OSStatus err = AudioFileStreamParseBytes(((AudioData *) audioData)->audioFileStream, bytesRead, buffer, 0);
- */
- if (err) PRINTERROR("AudioFileStreamParseBytes");
- }
- }
- }
- function that calls the above:
- if (!CFReadStreamSetClient(stream8, kNetworkEvents, ReadStreamClientCallBack, &ctxt)) {...}
Advertisement
Add Comment
Please, Sign In to add comment