diff --git a/src/add-ons/media/plugins/ogg/OggSpeexStream.cpp b/src/add-ons/media/plugins/ogg/OggSpeexStream.cpp index b31b359668..6fa90c5a97 100644 --- a/src/add-ons/media/plugins/ogg/OggSpeexStream.cpp +++ b/src/add-ons/media/plugins/ogg/OggSpeexStream.cpp @@ -93,14 +93,9 @@ OggSpeexStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration, media_format_description description = speex_description(); BMediaFormats formats; result = formats.InitCheck(); - if (result != B_OK) { - return result; + if (result == B_OK) { + result = formats.GetFormatFor(description, format); } - if (!formats.Lock()) { - return B_ERROR; - } - result = formats.GetFormatFor(description, format); - formats.Unlock(); if (result != B_OK) { *format = speex_encoded_media_format(); // ignore error, allow user to use ReadChunk interface diff --git a/src/add-ons/media/plugins/ogg/OggTheoraFormats.h b/src/add-ons/media/plugins/ogg/OggTheoraFormats.h new file mode 100644 index 0000000000..b6ad23238b --- /dev/null +++ b/src/add-ons/media/plugins/ogg/OggTheoraFormats.h @@ -0,0 +1,42 @@ +#ifndef _OGG_THEORA_FORMATS_H +#define _OGG_THEORA_FORMATS_H + +#include +#include +#include + +/* + * theora descriptions/formats + */ + + +static media_format_description +theora_description() +{ + media_format_description description; + description.family = B_MISC_FORMAT_FAMILY; + description.u.misc.file_format = 'OggS'; + description.u.misc.codec = 'theo'; + return description; +} + + +static void +init_theora_media_raw_video_format(media_raw_video_format * output) +{ +} + + +static media_format +theora_encoded_media_format() +{ + media_format format; + format.type = B_MEDIA_ENCODED_AUDIO; + format.user_data_type = B_CODEC_TYPE_INFO; + strncpy((char*)format.user_data, "theo", 4); + init_theora_media_raw_video_format(&format.u.encoded_video.output); + return format; +} + + +#endif _OGG_THEORA_FORMATS_H diff --git a/src/add-ons/media/plugins/ogg/OggTheoraStream.cpp b/src/add-ons/media/plugins/ogg/OggTheoraStream.cpp index 9a1bbae931..83157c8fd2 100644 --- a/src/add-ons/media/plugins/ogg/OggTheoraStream.cpp +++ b/src/add-ons/media/plugins/ogg/OggTheoraStream.cpp @@ -1,3 +1,4 @@ +#include "OggTheoraFormats.h" #include "OggTheoraStream.h" #include #include @@ -134,7 +135,7 @@ OggTheoraStream::IsValidHeader(const ogg_packet & packet) OggTheoraStream::OggTheoraStream(long serialno) : OggStream(serialno) { - + TRACE("OggTheoraStream::OggTheoraStream\n"); } OggTheoraStream::~OggTheoraStream() @@ -181,28 +182,18 @@ OggTheoraStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration, } // get the format for the description - media_format_description description; - description.family = B_MISC_FORMAT_FAMILY; - description.u.misc.file_format = 'OggS'; - description.u.misc.codec = 'theo'; + media_format_description description = theora_description(); BMediaFormats formats; result = formats.InitCheck(); - if (result != B_OK) { - return result; + if (result == B_OK) { + result = formats.GetFormatFor(description, format); } - if (!formats.Lock()) { - return B_ERROR; - } - result = formats.GetFormatFor(description, format); - formats.Unlock(); if (result != B_OK) { - return result; + *format = theora_encoded_media_format(); + // ignore error, allow user to use ReadChunk interface } // fill out format from header packet - format->type = B_MEDIA_ENCODED_VIDEO; - format->user_data_type = B_CODEC_TYPE_INFO; - strncpy((char*)format->user_data, "theo", 4); format->u.encoded_video.frame_size = info.frame_width * info.frame_height ; format->u.encoded_video.output.display.line_width = info.frame_width; format->u.encoded_video.output.display.line_count = info.frame_height; diff --git a/src/add-ons/media/plugins/ogg/OggTobiasStream.cpp b/src/add-ons/media/plugins/ogg/OggTobiasStream.cpp index 6231117b10..d0b1314ebf 100644 --- a/src/add-ons/media/plugins/ogg/OggTobiasStream.cpp +++ b/src/add-ons/media/plugins/ogg/OggTobiasStream.cpp @@ -110,14 +110,9 @@ OggTobiasStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration, | header->subtype[2] << 8 | header->subtype[3]; BMediaFormats formats; result = formats.InitCheck(); - if (result != B_OK) { - return result; + if (result == B_OK) { + result = formats.GetFormatFor(description, format); } - if (!formats.Lock()) { - return B_ERROR; - } - result = formats.GetFormatFor(description, format); - formats.Unlock(); if (result != B_OK) { *format = tobias_encoded_media_format(); // ignore error, allow user to use ReadChunk interface diff --git a/src/add-ons/media/plugins/ogg/OggVorbisStream.cpp b/src/add-ons/media/plugins/ogg/OggVorbisStream.cpp index 406b52c974..e1db9e50af 100644 --- a/src/add-ons/media/plugins/ogg/OggVorbisStream.cpp +++ b/src/add-ons/media/plugins/ogg/OggVorbisStream.cpp @@ -136,14 +136,9 @@ OggVorbisStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration, media_format_description description = vorbis_description(); BMediaFormats formats; result = formats.InitCheck(); - if (result != B_OK) { - return result; + if (result == B_OK) { + result = formats.GetFormatFor(description, format); } - if (!formats.Lock()) { - return B_ERROR; - } - result = formats.GetFormatFor(description, format); - formats.Unlock(); if (result != B_OK) { *format = vorbis_encoded_media_format(); // ignore error, allow user to use ReadChunk interface