diff --git a/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp b/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp index 1d012dd985..d7d70cb656 100644 --- a/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp +++ b/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.cpp @@ -35,8 +35,17 @@ RawDecoder::NegotiateOutputFormat(media_format *ioDecodedFormat) // BeBook says: The codec will find and return in ioFormat its best matching format // => This means, we never return an error, and always change the format values // that we don't support to something more applicable + + char s[1024]; + + string_for_format(*ioDecodedFormat, s, sizeof(s)); + printf("RawDecoder::NegotiateOutputFormat enter: %s\n", s); *ioDecodedFormat = fInputFormat; + + string_for_format(*ioDecodedFormat, s, sizeof(s)); + printf("RawDecoder::NegotiateOutputFormat leave: %s\n", s); + return B_OK; } diff --git a/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp b/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp index 8650da1a1d..2e68d4d49b 100644 --- a/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp +++ b/src/add-ons/media/plugins/wav_reader/WavReaderPlugin.cpp @@ -10,9 +10,11 @@ #if TRACE_THIS #define TRACE printf #else - #define TRACE ((void)0) + #define TRACE(a...) #endif +#define BUFFER_SIZE 16384 + #define FOURCC(fcc) (*reinterpret_cast(fcc)) struct wavdata @@ -123,8 +125,8 @@ WavReader::AllocateCookie(int32 streamNumber, void **cookie) data->position = 0; data->datasize = fDataSize; data->framesize = (B_LENDIAN_TO_HOST_INT16(fRawHeader.common.bits_per_sample) / 8) * B_LENDIAN_TO_HOST_INT16(fRawHeader.common.channels); - data->fps = B_LENDIAN_TO_HOST_INT32(fRawHeader.common.samples_per_sec) / B_LENDIAN_TO_HOST_INT16(fRawHeader.common.channels); - data->buffersize = (65536 / data->framesize) * data->framesize; + data->fps = B_LENDIAN_TO_HOST_INT32(fRawHeader.common.samples_per_sec); // WAVE samples_per_sec really means frames per sec + data->buffersize = (BUFFER_SIZE / data->framesize) * data->framesize; data->buffer = malloc(data->buffersize); data->framecount = fDataSize / data->framesize; data->duration = (data->framecount * 1000000LL) / data->fps; @@ -143,7 +145,6 @@ WavReader::AllocateCookie(int32 streamNumber, void **cookie) _get_format_for_description(&data->format, description); - //data->format.type = B_MEDIA_RAW_AUDIO; data->format.u.raw_audio.frame_rate = data->fps; data->format.u.raw_audio.channel_count = B_LENDIAN_TO_HOST_INT16(fRawHeader.common.channels); data->format.u.raw_audio.format = media_raw_audio_format::B_AUDIO_SHORT; // XXX fixme @@ -199,6 +200,7 @@ WavReader::Seek(void *cookie, TRACE("WavReader::Seek newtime %Ld\n", *time); } else if (seekTo & B_MEDIA_SEEK_TO_TIME) { pos = (*time * data->fps) / 1000000LL; + pos = (pos / data->framesize) * data->framesize; // round down to frame start TRACE("WavReader::Seek to time %Ld, pos %Ld\n", *time, pos); *time = (pos * 1000000LL) / data->fps; *frame = pos / data->framesize; diff --git a/src/kits/media/MediaFormats.cpp b/src/kits/media/MediaFormats.cpp index c3fa3d2032..f8fbaf8fad 100644 --- a/src/kits/media/MediaFormats.cpp +++ b/src/kits/media/MediaFormats.cpp @@ -308,7 +308,10 @@ _get_format_for_description(media_format *out_format, const media_format_descrip // if (B_OK != QueryServer(SERVER_GET_FORMAT_FOR_DESCRIPTION, &request, sizeof(request), &reply, sizeof(reply))) // return B_ERROR; - reply.format.type = B_MEDIA_ENCODED_AUDIO; + if (in_desc.family == B_BEOS_FORMAT_FAMILY && in_desc.u.beos.format == B_BEOS_FORMAT_RAW_AUDIO) + reply.format.type = B_MEDIA_RAW_AUDIO; + else + reply.format.type = B_MEDIA_ENCODED_AUDIO; reply.format.u.encoded_audio.encoding = (enum media_encoded_audio_format::audio_encoding) 1; *out_format = reply.format;