mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
确保线程安全
This commit is contained in:
parent
1b674a6ac2
commit
013109796d
@ -113,6 +113,7 @@ int AudioPlayer::getPCMChannel() {
|
||||
}
|
||||
|
||||
int AudioPlayer::getPCMData(char *buf, int size) {
|
||||
lock_guard<mutex> lck(_mtx);
|
||||
if (_buffer.size() < size) {
|
||||
return 0;
|
||||
}
|
||||
@ -122,5 +123,6 @@ int AudioPlayer::getPCMData(char *buf, int size) {
|
||||
}
|
||||
|
||||
void AudioPlayer::inputFrame(const char *data, size_t size) {
|
||||
lock_guard<mutex> lck(_mtx);
|
||||
_buffer.append(data, size);
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ private:
|
||||
private:
|
||||
int _sample_rate, _channel;
|
||||
SDL_AudioFormat _format;
|
||||
mutex _mtx;
|
||||
BufferLikeString _buffer;
|
||||
SDLAudioDevice::Ptr _device;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user