Skip to content

Commit

Permalink
Fix pointer to integer (to pointer) casting warnings in audioconvert.
Browse files Browse the repository at this point in the history
Don't cast a pointer to an integer, add a number to it, and then cast
it back to a pointer.  This transformation is not transparent to the
compiler, and it can lose potential optimizations chances.  Instead
cast it to a pointer to a uint8_t (width of one byte) and then do the
addition directly to the pointer.
  • Loading branch information
linuxdude42 committed Mar 27, 2023
1 parent 67833bc commit 2aa9375
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mythtv/libs/libmyth/audio/audioconvert.cpp
Expand Up @@ -699,14 +699,14 @@ int AudioConvert::Process(void* out, const void* in, int bytes, bool noclip)
if (left >= 65536)
{
s = toFloat(m_in, buffer.data(), in, buffer.size());
in = (void*)((long)in + s);
out = (void*)((long)out + fromFloat(m_out, out, buffer.data(), s));
in = static_cast<const uint8_t *>(in) + s;
out = static_cast<uint8_t *>(out) + fromFloat(m_out, out, buffer.data(), s);
left -= buffer.size();
continue;
}
s = toFloat(m_in, buffer.data(), in, left);
in = (void*)((long)in + s);
out = (void*)((long)out + fromFloat(m_out, out, buffer.data(), s));
in = static_cast<const uint8_t *>(in) + s;
out = static_cast<uint8_t *>(out) + fromFloat(m_out, out, buffer.data(), s);
left = 0;
}
return bytes * AudioOutputSettings::SampleSize(m_out) / AudioOutputSettings::SampleSize(m_in);
Expand Down

0 comments on commit 2aa9375

Please sign in to comment.