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) {
|
int AudioPlayer::getPCMData(char *buf, int size) {
|
||||||
|
lock_guard<mutex> lck(_mtx);
|
||||||
if (_buffer.size() < size) {
|
if (_buffer.size() < size) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -121,6 +122,7 @@ int AudioPlayer::getPCMData(char *buf, int size) {
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioPlayer::inputFrame(const char *data, size_t size){
|
void AudioPlayer::inputFrame(const char *data, size_t size) {
|
||||||
|
lock_guard<mutex> lck(_mtx);
|
||||||
_buffer.append(data, size);
|
_buffer.append(data, size);
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
int _sample_rate, _channel;
|
int _sample_rate, _channel;
|
||||||
SDL_AudioFormat _format;
|
SDL_AudioFormat _format;
|
||||||
|
mutex _mtx;
|
||||||
BufferLikeString _buffer;
|
BufferLikeString _buffer;
|
||||||
SDLAudioDevice::Ptr _device;
|
SDLAudioDevice::Ptr _device;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user