MCPcopy Create free account
hub / github.com/LabSound/LabSound / stopStream

Method stopStream

src/backends/RtAudio/RtAudio.cpp:1721–1768  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1719}
1720
1721void RtApiCore ::stopStream(void)
1722{
1723 verifyStream();
1724 if (stream_.state == STREAM_STOPPED)
1725 {
1726 errorText_ = "RtApiCore::stopStream(): the stream is already stopped!";
1727 error(RtAudioError::WARNING);
1728 return;
1729 }
1730
1731 OSStatus result = noErr;
1732 CoreHandle * handle = (CoreHandle *) stream_.apiHandle;
1733 if (stream_.mode == OUTPUT || stream_.mode == DUPLEX)
1734 {
1735
1736 if (handle->drainCounter == 0)
1737 {
1738 handle->drainCounter = 2;
1739 pthread_cond_wait(&handle->condition, &stream_.mutex); // block until signaled
1740 }
1741
1742 result = AudioDeviceStop(handle->id[0], callbackHandler);
1743 if (result != noErr)
1744 {
1745 errorStream_ << "RtApiCore::stopStream: system error (" << getErrorCode(result) << ") stopping callback procedure on device (" << stream_.device[0] << ").";
1746 errorText_ = errorStream_.str();
1747 goto unlock;
1748 }
1749 }
1750
1751 if (stream_.mode == INPUT || (stream_.mode == DUPLEX && stream_.device[0] != stream_.device[1]))
1752 {
1753
1754 result = AudioDeviceStop(handle->id[1], callbackHandler);
1755 if (result != noErr)
1756 {
1757 errorStream_ << "RtApiCore::stopStream: system error (" << getErrorCode(result) << ") stopping input callback procedure on device (" << stream_.device[1] << ").";
1758 errorText_ = errorStream_.str();
1759 goto unlock;
1760 }
1761 }
1762
1763 stream_.state = STREAM_STOPPED;
1764
1765unlock:
1766 if (result == noErr) return;
1767 error(RtAudioError::SYSTEM_ERROR);
1768}
1769
1770void RtApiCore ::abortStream(void)
1771{

Callers 6

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

Calls 2

getAsioErrorStringFunction · 0.85
getErrorStringFunction · 0.85

Tested by

no test coverage detected