alexcrichton / AudioStreamer

A streaming audio player class (AudioStreamer) for Mac OS X and iPhone.
69 stars 22 forks source link

Separating isDone #9

Closed ghost closed 12 years ago

ghost commented 12 years ago

As it stands, AudioStreamer can return yes from isDone because of 3 separate reasons: 1) AS_DONE set with no error (Same as EOF?) 2) AS_STOPPED set via [streamer stop] 3) AS_DONE set by error

For my needs, I needed to disambiguate (at least to avoid needless branching). So I stopped using isDone and added these methods:

- (BOOL)isEOF {
    return state_ == AS_DONE && ![self isError];
}

- (BOOL)isStopped {
    return state_ == AS_STOPPED;
}

- (BOOL)isError {
    if (!errorCode)
        return NO;
    else
        return YES;
}
ghost commented 12 years ago

kudos. thanks.