MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / stopStream

Method stopStream

examples/TinyAudio/RtAudio.cpp:1639–1684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1637}
1638
1639void 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
1681unlock:
1682 if (result == noErr) return;
1683 error(RtAudioError::SYSTEM_ERROR);
1684}
1685
1686void RtApiCore ::abortStream(void)
1687{

Callers 6

coreStopStreamFunction · 0.45
jackStopStreamFunction · 0.45
asioStopStreamFunction · 0.45
sampleRateChangedFunction · 0.45
stopWasapiThreadMethod · 0.45
callbackEventMethod · 0.45

Calls 7

errorFunction · 0.85
getAsioErrorStringFunction · 0.85
getErrorStringFunction · 0.85
strMethod · 0.80
writeFunction · 0.50
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected