Media kit: Suppress -Werror=class-memaccess
* Add media_format::Clear(), media_format::Unflatten(). * Replace memset() with media_format::Clear() * Replace memcpy() with media_format::Unflatten() Fix #14156 Change-Id: I38ebc2de4915b954a15b6f4f6b40d016506910e5
This commit is contained in:
parent
8547d09e97
commit
12ed45b60f
@ -604,6 +604,9 @@ public:
|
|||||||
const void* MetaData() const;
|
const void* MetaData() const;
|
||||||
int32 MetaDataSize() const;
|
int32 MetaDataSize() const;
|
||||||
|
|
||||||
|
void Unflatten(const char *flatBuffer);
|
||||||
|
void Clear();
|
||||||
|
|
||||||
media_format();
|
media_format();
|
||||||
media_format(const media_format& other);
|
media_format(const media_format& other);
|
||||||
~media_format();
|
~media_format();
|
||||||
|
@ -558,8 +558,8 @@ AddOnManager::_RegisterEncoder(EncoderPlugin* plugin, const entry_ref& ref)
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
memset(&info.codecInfo, 0, sizeof(media_codec_info));
|
memset(&info.codecInfo, 0, sizeof(media_codec_info));
|
||||||
memset(&info.intputFormat, 0, sizeof(media_format));
|
info.intputFormat.Clear();
|
||||||
memset(&info.outputFormat, 0, sizeof(media_format));
|
info.outputFormat.Clear();
|
||||||
if (plugin->RegisterNextEncoder(&cookie,
|
if (plugin->RegisterNextEncoder(&cookie,
|
||||||
&info.codecInfo, &info.formatFamily, &info.intputFormat,
|
&info.codecInfo, &info.formatFamily, &info.intputFormat,
|
||||||
&info.outputFormat) != B_OK) {
|
&info.outputFormat) != B_OK) {
|
||||||
|
@ -442,11 +442,13 @@ dormant_flavor_info::Unflatten(type_code c, const void *buffer, ssize_t size)
|
|||||||
if (!in_formats)
|
if (!in_formats)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
// TODO: we should not!!! make flat copies of media_format
|
// TODO: we should not!!! make flat copies of media_format
|
||||||
memcpy(const_cast<media_format *>(in_formats), buf,
|
for (int32 i = 0; i < count; i++) {
|
||||||
count * sizeof(media_format));
|
const_cast<media_format*>
|
||||||
|
(&in_formats[i])->Unflatten(buf);
|
||||||
|
buf += sizeof(media_format); // TODO: not save
|
||||||
|
}
|
||||||
in_format_count = count;
|
in_format_count = count;
|
||||||
}
|
}
|
||||||
buf += count * sizeof(media_format); // TODO: not save
|
|
||||||
}
|
}
|
||||||
|
|
||||||
count = *(int32*)buf; buf += sizeof(int32);
|
count = *(int32*)buf; buf += sizeof(int32);
|
||||||
@ -458,11 +460,13 @@ dormant_flavor_info::Unflatten(type_code c, const void *buffer, ssize_t size)
|
|||||||
if (!out_formats)
|
if (!out_formats)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
// TODO: we should not!!! make flat copies of media_format
|
// TODO: we should not!!! make flat copies of media_format
|
||||||
memcpy(const_cast<media_format *>(out_formats), buf,
|
for (int32 i = 0; i < count; i++) {
|
||||||
count * sizeof(media_format));
|
const_cast<media_format*>
|
||||||
|
(&out_formats[i])->Unflatten(buf);
|
||||||
|
buf += sizeof(media_format); // TODO: not save
|
||||||
|
}
|
||||||
out_format_count = count;
|
out_format_count = count;
|
||||||
}
|
}
|
||||||
buf += count * sizeof(media_format); // TODO: not save
|
|
||||||
}
|
}
|
||||||
|
|
||||||
node_info = *(dormant_node_info*)buf; buf += sizeof(dormant_node_info);
|
node_info = *(dormant_node_info*)buf; buf += sizeof(dormant_node_info);
|
||||||
|
@ -832,17 +832,34 @@ media_format::MetaDataSize() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
media_format::media_format()
|
void
|
||||||
|
media_format::Unflatten(const char *flatBuffer)
|
||||||
|
{
|
||||||
|
// TODO: we should not!!! make flat copies of media_format
|
||||||
|
memcpy(this, flatBuffer, sizeof(*this));
|
||||||
|
meta_data = NULL;
|
||||||
|
meta_data_area = B_BAD_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
media_format::Clear()
|
||||||
{
|
{
|
||||||
memset(this, 0x00, sizeof(*this));
|
memset(this, 0x00, sizeof(*this));
|
||||||
|
meta_data = NULL;
|
||||||
meta_data_area = B_BAD_VALUE;
|
meta_data_area = B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
media_format::media_format()
|
||||||
|
{
|
||||||
|
this->Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
media_format::media_format(const media_format& other)
|
media_format::media_format(const media_format& other)
|
||||||
{
|
{
|
||||||
memset(this, 0x00, sizeof(*this));
|
this->Clear();
|
||||||
meta_data_area = B_BAD_VALUE;
|
|
||||||
*this = other;
|
*this = other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +96,7 @@ MediaExtractor::_Init(BDataIO* source, int32 flags)
|
|||||||
fStreamInfo[i].chunkCache
|
fStreamInfo[i].chunkCache
|
||||||
= new ChunkCache(fExtractorWaitSem, kMaxCacheBytes);
|
= new ChunkCache(fExtractorWaitSem, kMaxCacheBytes);
|
||||||
fStreamInfo[i].lastChunk = NULL;
|
fStreamInfo[i].lastChunk = NULL;
|
||||||
memset(&fStreamInfo[i].encodedFormat, 0,
|
fStreamInfo[i].encodedFormat.Clear();
|
||||||
sizeof(fStreamInfo[i].encodedFormat));
|
|
||||||
|
|
||||||
if (fStreamInfo[i].chunkCache->InitCheck() != B_OK) {
|
if (fStreamInfo[i].chunkCache->InitCheck() != B_OK) {
|
||||||
fInitStatus = B_NO_MEMORY;
|
fInitStatus = B_NO_MEMORY;
|
||||||
|
@ -489,7 +489,7 @@ BMediaFormats::GetFormatFor(const media_format_description& description,
|
|||||||
meta_format::CompareDescriptions);
|
meta_format::CompareDescriptions);
|
||||||
TRACE("meta format == %p\n", metaFormat);
|
TRACE("meta format == %p\n", metaFormat);
|
||||||
if (metaFormat == NULL) {
|
if (metaFormat == NULL) {
|
||||||
memset(_format, 0, sizeof(*_format)); // clear to widlcard
|
_format->Clear(); // clear to widlcard
|
||||||
return B_MEDIA_BAD_FORMAT;
|
return B_MEDIA_BAD_FORMAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3236,7 +3236,7 @@ BMediaRoster::GetFormatFor(const media_input& input, media_format* _format,
|
|||||||
status_t rv;
|
status_t rv;
|
||||||
|
|
||||||
request.dest = input.destination;
|
request.dest = input.destination;
|
||||||
memset(&request.format, 0, sizeof(request.format)); // wildcard
|
request.format.Clear(); // wildcard
|
||||||
|
|
||||||
rv = QueryPort(input.destination.port, CONSUMER_ACCEPT_FORMAT, &request,
|
rv = QueryPort(input.destination.port, CONSUMER_ACCEPT_FORMAT, &request,
|
||||||
sizeof(request), &reply, sizeof(reply));
|
sizeof(request), &reply, sizeof(reply));
|
||||||
|
@ -135,7 +135,7 @@ void
|
|||||||
BTrackReader::SetToTrack(BMediaTrack *track)
|
BTrackReader::SetToTrack(BMediaTrack *track)
|
||||||
{
|
{
|
||||||
media_format fmt;
|
media_format fmt;
|
||||||
memset(&fmt, 0, sizeof(fmt)); //wildcard
|
fmt.Clear(); //wildcard
|
||||||
memcpy(&fmt.u.raw_audio, &fFormat, sizeof(fFormat));
|
memcpy(&fmt.u.raw_audio, &fFormat, sizeof(fFormat));
|
||||||
fmt.type = B_MEDIA_RAW_AUDIO;
|
fmt.type = B_MEDIA_RAW_AUDIO;
|
||||||
//try to find a output format
|
//try to find a output format
|
||||||
|
Loading…
Reference in New Issue
Block a user