mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 16:20:11 -04:00
*** empty log message ***
This commit is contained in:
parent
3270809f9b
commit
aeb400fc59
@ -48,3 +48,23 @@ INLINE bool Downloader::
|
|||||||
is_download_enabled(void) const {
|
is_download_enabled(void) const {
|
||||||
return _download_enabled;
|
return _download_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Downloader::change_buffer_size
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE bool Downloader::
|
||||||
|
change_buffer_size(int size) {
|
||||||
|
if (size == _buffer_size)
|
||||||
|
return true;
|
||||||
|
nassertr(size > 0, false);
|
||||||
|
#ifdef HAVE_IPC
|
||||||
|
_buffer_lock.lock();
|
||||||
|
#endif
|
||||||
|
_new_buffer_size = size;
|
||||||
|
#ifdef HAVE_IPC
|
||||||
|
_buffer_lock.unlock();
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -93,6 +93,8 @@ init(PT(Buffer) buffer) {
|
|||||||
_download_enabled = true;
|
_download_enabled = true;
|
||||||
// We need to flush after every write in case we're interrupted
|
// We need to flush after every write in case we're interrupted
|
||||||
_dest_stream.setf(ios::unitbuf, 0);
|
_dest_stream.setf(ios::unitbuf, 0);
|
||||||
|
_buffer_size = _buffer->get_length();
|
||||||
|
_new_buffer_size = 0;
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
WSAData mydata;
|
WSAData mydata;
|
||||||
@ -207,19 +209,6 @@ disconnect_from_server(void) {
|
|||||||
_connected = false;
|
_connected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: Downloader::change_buffer_size
|
|
||||||
// Access: Public
|
|
||||||
// Description:
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
void Downloader::
|
|
||||||
change_buffer_size(int size) {
|
|
||||||
if (_buffer->get_length() == size)
|
|
||||||
return;
|
|
||||||
_buffer.clear();
|
|
||||||
_buffer = new Buffer(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Downloader::request_download
|
// Function: Downloader::request_download
|
||||||
// Access: Public
|
// Access: Public
|
||||||
@ -526,7 +515,7 @@ download(const string &file_name, Filename file_dest,
|
|||||||
|
|
||||||
// Ensure we have enough room in the buffer to download read_size
|
// Ensure we have enough room in the buffer to download read_size
|
||||||
// If we don't have enough room, write the buffer to disk
|
// If we don't have enough room, write the buffer to disk
|
||||||
if (status._bytes_in_buffer + read_size > downloader_buffer_size) {
|
if (status._bytes_in_buffer + read_size > _buffer_size) {
|
||||||
if (downloader_cat.is_debug())
|
if (downloader_cat.is_debug())
|
||||||
downloader_cat.debug()
|
downloader_cat.debug()
|
||||||
<< "Downloader::download() - Flushing buffer" << endl;
|
<< "Downloader::download() - Flushing buffer" << endl;
|
||||||
@ -758,6 +747,22 @@ write_to_disk(DownloadStatus &status) {
|
|||||||
|
|
||||||
status.reset();
|
status.reset();
|
||||||
|
|
||||||
|
// Now see if we need to adjust the buffer size
|
||||||
|
if (_new_buffer_size > 0) {
|
||||||
|
#ifdef HAVE_IPC
|
||||||
|
_buffer_lock.lock();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_buffer.clear();
|
||||||
|
_buffer = new Buffer(_new_buffer_size);
|
||||||
|
_buffer_size = _new_buffer_size;
|
||||||
|
_new_buffer_size = 0;
|
||||||
|
|
||||||
|
#ifdef HAVE_IPC
|
||||||
|
_buffer_lock.unlock();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,12 +46,11 @@ PUBLISHED:
|
|||||||
int last_byte, int total_bytes,
|
int last_byte, int total_bytes,
|
||||||
bool partial_content = true);
|
bool partial_content = true);
|
||||||
|
|
||||||
void change_buffer_size(int size);
|
|
||||||
|
|
||||||
INLINE void set_bandwidth(float bytes);
|
INLINE void set_bandwidth(float bytes);
|
||||||
INLINE float get_bandwidth(void) const;
|
INLINE float get_bandwidth(void) const;
|
||||||
INLINE void enable_download(bool val);
|
INLINE void enable_download(bool val);
|
||||||
INLINE bool is_download_enabled(void) const;
|
INLINE bool is_download_enabled(void) const;
|
||||||
|
INLINE bool change_buffer_size(int size);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class DownloadStatus {
|
class DownloadStatus {
|
||||||
@ -100,6 +99,7 @@ private:
|
|||||||
|
|
||||||
#ifdef HAVE_IPC
|
#ifdef HAVE_IPC
|
||||||
mutex _bandwidth_frequency_lock;
|
mutex _bandwidth_frequency_lock;
|
||||||
|
mutex _buffer_lock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int _socket;
|
int _socket;
|
||||||
@ -107,6 +107,8 @@ private:
|
|||||||
float _bandwidth;
|
float _bandwidth;
|
||||||
bool _download_enabled;
|
bool _download_enabled;
|
||||||
ofstream _dest_stream;
|
ofstream _dest_stream;
|
||||||
|
int _new_buffer_size;
|
||||||
|
int _buffer_size;
|
||||||
|
|
||||||
string _server_name;
|
string _server_name;
|
||||||
struct sockaddr_in _sin;
|
struct sockaddr_in _sin;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user