| 1637 | } |
| 1638 | |
| 1639 | void RtApiCore ::stopStream(void) |
| 1640 | { |
| 1641 | verifyStream(); |
| 1642 | if (stream_.state == STREAM_STOPPED) |
| 1643 | { |
| 1644 | errorText_ = "RtApiCore::stopStream(): the stream is already stopped!"; |
| 1645 | error(RtAudioError::WARNING); |
| 1646 | return; |
| 1647 | } |
| 1648 | |
| 1649 | OSStatus result = noErr; |
| 1650 | CoreHandle *handle = (CoreHandle *)stream_.apiHandle; |
| 1651 | if (stream_.mode == OUTPUT || stream_.mode == DUPLEX) |
| 1652 | { |
| 1653 | if (handle->drainCounter == 0) |
| 1654 | { |
| 1655 | handle->drainCounter = 2; |
| 1656 | pthread_cond_wait(&handle->condition, &stream_.mutex); // block until signaled |
| 1657 | } |
| 1658 | |
| 1659 | result = AudioDeviceStop(handle->id[0], callbackHandler); |
| 1660 | if (result != noErr) |
| 1661 | { |
| 1662 | errorStream_ << "RtApiCore::stopStream: system error (" << getErrorCode(result) << ") stopping callback procedure on device (" << stream_.device[0] << ")."; |
| 1663 | errorText_ = errorStream_.str(); |
| 1664 | goto unlock; |
| 1665 | } |
| 1666 | } |
| 1667 | |
| 1668 | if (stream_.mode == INPUT || (stream_.mode == DUPLEX && stream_.device[0] != stream_.device[1])) |
| 1669 | { |
| 1670 | result = AudioDeviceStop(handle->id[1], callbackHandler); |
| 1671 | if (result != noErr) |
| 1672 | { |
| 1673 | errorStream_ << "RtApiCore::stopStream: system error (" << getErrorCode(result) << ") stopping input callback procedure on device (" << stream_.device[1] << ")."; |
| 1674 | errorText_ = errorStream_.str(); |
| 1675 | goto unlock; |
| 1676 | } |
| 1677 | } |
| 1678 | |
| 1679 | stream_.state = STREAM_STOPPED; |
| 1680 | |
| 1681 | unlock: |
| 1682 | if (result == noErr) return; |
| 1683 | error(RtAudioError::SYSTEM_ERROR); |
| 1684 | } |
| 1685 | |
| 1686 | void RtApiCore ::abortStream(void) |
| 1687 | { |
no test coverage detected