mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 23:13:00 +02:00
streamts: Fix const-correctness issues in Send() and write_packet()
- Change Send() parameter from unsigned char* to const unsigned char*.
- Update write_packet() to accept const uint8_t*.
- Fix invalid conversion error with GCC 14.
Confirmed working by building generic neutrino with GCC 14.
Origin commit data
------------------
Branch: ni/coolstream
Commit: 19cb83d8db
Author: Thilo Graf <dbt@novatux.de>
Date: 2025-03-10 (Mon, 10 Mar 2025)
------------------
This commit was generated by Migit
This commit is contained in:
@@ -113,48 +113,35 @@ bool CStreamInstance::Stop()
|
||||
running = false;
|
||||
return (OpenThreads::Thread::join() == 0);
|
||||
}
|
||||
|
||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(61, 1, 100)
|
||||
bool CStreamInstance::Send(ssize_t r, const unsigned char *_buf)
|
||||
#else
|
||||
bool CStreamInstance::Send(ssize_t r, unsigned char * _buf)
|
||||
#endif
|
||||
{
|
||||
// lock fds for thread-safety
|
||||
// OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
|
||||
stream_fds_t cfds;
|
||||
mutex.lock();
|
||||
cfds = fds;
|
||||
mutex.unlock();
|
||||
|
||||
int flags = 0;
|
||||
if (cfds.size() > 1)
|
||||
flags = MSG_DONTWAIT;
|
||||
|
||||
// iterate through all client sockets
|
||||
for (auto it = cfds.begin(); it != cfds.end(); ++it)
|
||||
{
|
||||
for (stream_fds_t::iterator it = cfds.begin(); it != cfds.end(); ++it) {
|
||||
int i = 10;
|
||||
|
||||
// use a const pointer here to avoid conversion errors
|
||||
const unsigned char *b = _buf ? _buf : buf;
|
||||
ssize_t count = r;
|
||||
|
||||
do
|
||||
{
|
||||
// 'send' takes a const void*, so no cast needed
|
||||
do {
|
||||
int ret = send(*it, b, count, flags);
|
||||
if (ret > 0)
|
||||
{
|
||||
b += ret; // move pointer further
|
||||
count -= ret; // reduce remaining bytes
|
||||
if (ret > 0) {
|
||||
b += ret;
|
||||
count -= ret;
|
||||
}
|
||||
} while ((count > 0) && (i-- > 0));
|
||||
|
||||
// if count didn't drop to zero, there was some error
|
||||
if (count)
|
||||
printf("CStreamInstance::%s: send error, fd %d: (%zd from %zd)\n", __FUNCTION__, *it, r - count, r);
|
||||
|
||||
printf("send err, fd %d: (%zd from %zd)\n", *it, r-count, r);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user