diff --git a/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp b/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp index a22fda5628..bccf754a2a 100644 --- a/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp +++ b/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp @@ -210,6 +210,11 @@ MultiAudioNode::MultiAudioNode(BMediaAddOn* addon, const char* name, // measured in Hertz fOutputPreferredFormat.u.raw_audio.byte_order = B_MEDIA_HOST_ENDIAN; + if (fOutputPreferredFormat.u.raw_audio.format == 0) { + fInitStatus = B_BAD_VALUE; + return; + } + // we'll use the consumer's preferred buffer size, if any fOutputPreferredFormat.u.raw_audio.buffer_size = fDevice->BufferList().return_playback_buffer_size @@ -230,6 +235,11 @@ MultiAudioNode::MultiAudioNode(BMediaAddOn* addon, const char* name, // measured in Hertz fInputPreferredFormat.u.raw_audio.byte_order = B_MEDIA_HOST_ENDIAN; + if (fInputPreferredFormat.u.raw_audio.format == 0) { + fInitStatus = B_BAD_VALUE; + return; + } + // we'll use the consumer's preferred buffer size, if any fInputPreferredFormat.u.raw_audio.buffer_size = fDevice->BufferList().return_record_buffer_size @@ -722,6 +732,12 @@ MultiAudioNode::Connected(const media_source& producer, return B_MEDIA_BAD_DESTINATION; } + if (with_format.u.raw_audio.frame_rate <= 0 + || with_format.u.raw_audio.channel_count <= 0 + || ((with_format.u.raw_audio.format + & media_raw_audio_format::B_AUDIO_SIZE_MASK) == 0)) + return B_BAD_VALUE; + _UpdateInternalLatency(with_format); // record the agreed upon values @@ -2322,6 +2338,9 @@ MultiAudioNode::_SetNodeInputFrameRate(float frameRate) if (error != B_OK) return error; + if (frameRate <= 0) + return B_BAD_VALUE; + // it went fine -- update all formats fOutputPreferredFormat.u.raw_audio.frame_rate = frameRate; fOutputPreferredFormat.u.raw_audio.buffer_size @@ -2374,6 +2393,12 @@ MultiAudioNode::_SetNodeOutputFrameRate(float frameRate) if (error != B_OK) return error; + if (frameRate <= 0 + || fInputPreferredFormat.u.raw_audio.channel_count <= 0 + || ((fInputPreferredFormat.u.raw_audio.format + & media_raw_audio_format::B_AUDIO_SIZE_MASK) == 0)) + return B_BAD_VALUE; + // it went fine -- update all formats fInputPreferredFormat.u.raw_audio.frame_rate = frameRate; fInputPreferredFormat.u.raw_audio.buffer_size