mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
work around MSVC bug in set_metadata()
This commit is contained in:
@@ -168,12 +168,26 @@ namespace FLAC {
|
|||||||
bool File::set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks)
|
bool File::set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks)
|
||||||
{
|
{
|
||||||
FLAC__ASSERT(is_valid());
|
FLAC__ASSERT(is_valid());
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
// MSVC++ can't handle:
|
||||||
|
// ::FLAC__StreamMetadata *m[num_blocks];
|
||||||
|
// so we do this ugly workaround
|
||||||
|
::FLAC__StreamMetadata **m = new ::FLAC__StreamMetadata*[num_blocks];
|
||||||
|
#else
|
||||||
::FLAC__StreamMetadata *m[num_blocks];
|
::FLAC__StreamMetadata *m[num_blocks];
|
||||||
|
#endif
|
||||||
for(unsigned i = 0; i < num_blocks; i++) {
|
for(unsigned i = 0; i < num_blocks; i++) {
|
||||||
// we can get away with this since we know the encoder will only correct the is_last flags
|
// we can get away with this since we know the encoder will only correct the is_last flags
|
||||||
m[i] = const_cast< ::FLAC__StreamMetadata*>((::FLAC__StreamMetadata*)metadata[i]);
|
m[i] = const_cast< ::FLAC__StreamMetadata*>((::FLAC__StreamMetadata*)metadata[i]);
|
||||||
}
|
}
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
// complete the hack
|
||||||
|
const bool ok = (bool)::FLAC__file_encoder_set_metadata(encoder_, m, num_blocks);
|
||||||
|
delete [] m;
|
||||||
|
return ok;
|
||||||
|
#else
|
||||||
return (bool)::FLAC__file_encoder_set_metadata(encoder_, m, num_blocks);
|
return (bool)::FLAC__file_encoder_set_metadata(encoder_, m, num_blocks);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::set_filename(const char *value)
|
bool File::set_filename(const char *value)
|
||||||
|
|||||||
@@ -168,12 +168,26 @@ namespace FLAC {
|
|||||||
bool SeekableStream::set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks)
|
bool SeekableStream::set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks)
|
||||||
{
|
{
|
||||||
FLAC__ASSERT(is_valid());
|
FLAC__ASSERT(is_valid());
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
// MSVC++ can't handle:
|
||||||
|
// ::FLAC__StreamMetadata *m[num_blocks];
|
||||||
|
// so we do this ugly workaround
|
||||||
|
::FLAC__StreamMetadata **m = new ::FLAC__StreamMetadata*[num_blocks];
|
||||||
|
#else
|
||||||
::FLAC__StreamMetadata *m[num_blocks];
|
::FLAC__StreamMetadata *m[num_blocks];
|
||||||
|
#endif
|
||||||
for(unsigned i = 0; i < num_blocks; i++) {
|
for(unsigned i = 0; i < num_blocks; i++) {
|
||||||
// we can get away with this since we know the encoder will only correct the is_last flags
|
// we can get away with this since we know the encoder will only correct the is_last flags
|
||||||
m[i] = const_cast< ::FLAC__StreamMetadata*>((::FLAC__StreamMetadata*)metadata[i]);
|
m[i] = const_cast< ::FLAC__StreamMetadata*>((::FLAC__StreamMetadata*)metadata[i]);
|
||||||
}
|
}
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
// complete the hack
|
||||||
|
const bool ok = (bool)::FLAC__seekable_stream_encoder_set_metadata(encoder_, m, num_blocks);
|
||||||
|
delete [] m;
|
||||||
|
return ok;
|
||||||
|
#else
|
||||||
return (bool)::FLAC__seekable_stream_encoder_set_metadata(encoder_, m, num_blocks);
|
return (bool)::FLAC__seekable_stream_encoder_set_metadata(encoder_, m, num_blocks);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SeekableStream::State SeekableStream::get_state() const
|
SeekableStream::State SeekableStream::get_state() const
|
||||||
|
|||||||
@@ -169,12 +169,26 @@ namespace FLAC {
|
|||||||
bool Stream::set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks)
|
bool Stream::set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks)
|
||||||
{
|
{
|
||||||
FLAC__ASSERT(is_valid());
|
FLAC__ASSERT(is_valid());
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
// MSVC++ can't handle:
|
||||||
|
// ::FLAC__StreamMetadata *m[num_blocks];
|
||||||
|
// so we do this ugly workaround
|
||||||
|
::FLAC__StreamMetadata **m = new ::FLAC__StreamMetadata*[num_blocks];
|
||||||
|
#else
|
||||||
::FLAC__StreamMetadata *m[num_blocks];
|
::FLAC__StreamMetadata *m[num_blocks];
|
||||||
|
#endif
|
||||||
for(unsigned i = 0; i < num_blocks; i++) {
|
for(unsigned i = 0; i < num_blocks; i++) {
|
||||||
// we can get away with this since we know the encoder will only correct the is_last flags
|
// we can get away with this since we know the encoder will only correct the is_last flags
|
||||||
m[i] = const_cast< ::FLAC__StreamMetadata*>((::FLAC__StreamMetadata*)metadata[i]);
|
m[i] = const_cast< ::FLAC__StreamMetadata*>((::FLAC__StreamMetadata*)metadata[i]);
|
||||||
}
|
}
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
// complete the hack
|
||||||
|
const bool ok = (bool)::FLAC__stream_encoder_set_metadata(encoder_, m, num_blocks);
|
||||||
|
delete [] m;
|
||||||
|
return ok;
|
||||||
|
#else
|
||||||
return (bool)::FLAC__stream_encoder_set_metadata(encoder_, m, num_blocks);
|
return (bool)::FLAC__stream_encoder_set_metadata(encoder_, m, num_blocks);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream::State Stream::get_state() const
|
Stream::State Stream::get_state() const
|
||||||
|
|||||||
Reference in New Issue
Block a user