# MTByteBuffer

Inherits from: MTBuffer

An MTByteBuffer is a thread-safe, flow-controlled, fixed-size byte buffer. In other words, it is a concrete subclass of MTBuffer where each abstract frame is one byte. It is intended to be used as a producer/consumer conduit for arbitrary, byte-oriented data where each of producer and consumer may be batch-oriented or time-constrained.

## Method Types

- Creating instances
  - - initWithCapacity:
- Working with attributes
  - - capacity
  - - count
- Working with data
  - - flush
  - - readToBytes:count:waitForData:
  - - writeFromBytes:count:waitForRoom:

## Instance Methods

### capacity

`- (unsigned) capacity`
Returns the number of bytes the receiver can hold.

### count

`- (unsigned) count`
Returns the number of bytes currently stored in the receiver.

### flush

`- (void) flush`
Empties the receiver.

### initWithCapacity:

`- (id) initWithCapacity:(unsigned)capacity`
Initializes a newly allocated buffer with space for capacity bytes. This is the designated initializer.

### readToBytes:count:waitForData:

`- (unsigned) readToBytes:(void *)theBytes count:(unsigned)count waitForData:(Boolean)wait`
Copies up to count bytes from the receiver into theBytes. If wait is `NO`, then a maximum of [receiver count] bytes will be copied immediately. If wait is `YES`, then exactly count bytes will be copied, and this method will pause if necessary until enough data has been written into the buffer by writeFromBytes:count:waitForRoom: to supply the request. Returns the number of bytes copied.

### writeFromBytes:count:waitForRoom:

`- (unsigned) writeFromBytes:(void *)theBytes count:(unsigned)count waitForRoom:(Boolean)wait`
Copies up to count bytes from theBytes into the receiver. If wait is `NO`, then a maximum of capacity minus [receiver count] bytes will be copied immediately. If wait is `YES`, then exactly count bytes will be copied, and this method will pause if necessary until enough room has been made in the buffer by readToBytes:count:waitForData: to accommodate the request. Returns the number of bytes copied.

Mike > Mac OS X > MTCoreAudio.framework > MTByteBuffer