mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
gst/wavenc/gstwavenc.c: Switch to GST_WRITE_UINT32_LE macros (bug #144624)
Original commit message from CVS: * gst/wavenc/gstwavenc.c: (gst_wavenc_setup), (gst_wavenc_stop_file): Switch to GST_WRITE_UINT32_LE macros (bug #144624) * sys/oss/gstosselement.c: (gst_osselement_probe_caps), (gst_osselement_rate_probe_check): Add another workaround for buggy drivers (bug #145336)
This commit is contained in:
parent
ef5f5ffb3a
commit
13dd7366cd
3 changed files with 37 additions and 21 deletions
|
@ -1,3 +1,12 @@
|
|||
2004-07-02 David Schleef <ds@schleef.org>
|
||||
|
||||
* gst/wavenc/gstwavenc.c: (gst_wavenc_setup),
|
||||
(gst_wavenc_stop_file): Switch to GST_WRITE_UINT32_LE macros
|
||||
(bug #144624)
|
||||
* sys/oss/gstosselement.c: (gst_osselement_probe_caps),
|
||||
(gst_osselement_rate_probe_check): Add another workaround for
|
||||
buggy drivers (bug #145336)
|
||||
|
||||
2004-07-02 David Schleef <ds@schleef.org>
|
||||
|
||||
* gst/tcp/gstmultifdsink.c: (gst_multifdsink_handle_client_write):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
|
||||
/* -*- mOde: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2 -*- */
|
||||
/* GStreamer
|
||||
* Copyright (C) <2002> Iain Holmes <iain@prettypeople.org>
|
||||
*
|
||||
|
@ -34,14 +34,6 @@ static void gst_wavenc_chain (GstPad * pad, GstData * _data);
|
|||
|
||||
#define WAVE_FORMAT_PCM 0x0001
|
||||
|
||||
#define WRITE_U32(buf, x) *(buf) = (unsigned char) (x&0xff);\
|
||||
*((buf)+1) = (unsigned char)((x>>8)&0xff);\
|
||||
*((buf)+2) = (unsigned char)((x>>16)&0xff);\
|
||||
*((buf)+3) = (unsigned char)((x>>24)&0xff);
|
||||
|
||||
#define WRITE_U16(buf, x) *(buf) = (unsigned char) (x&0xff);\
|
||||
*((buf)+1) = (unsigned char)((x>>8)&0xff);
|
||||
|
||||
struct riff_struct
|
||||
{
|
||||
guint8 id[4]; /* RIFF */
|
||||
|
@ -220,19 +212,20 @@ gst_wavenc_setup (GstWavEnc * wavenc)
|
|||
wave.data.len = size - 44;
|
||||
|
||||
strncpy (wavenc->header, wave.riff.id, 4);
|
||||
WRITE_U32 (wavenc->header + 4, wave.riff.len);
|
||||
GST_WRITE_UINT32_LE (wavenc->header + 4, wave.riff.len);
|
||||
strncpy (wavenc->header + 8, wave.riff.wav_id, 4);
|
||||
strncpy (wavenc->header + 12, wave.format.id, 4);
|
||||
WRITE_U32 (wavenc->header + 16, wave.format.len);
|
||||
WRITE_U16 (wavenc->header + 20, wave.common.wFormatTag);
|
||||
WRITE_U16 (wavenc->header + 22, wave.common.wChannels);
|
||||
WRITE_U32 (wavenc->header + 24, wave.common.dwSamplesPerSec);
|
||||
WRITE_U32 (wavenc->header + 28, wave.common.dwAvgBytesPerSec);
|
||||
WRITE_U16 (wavenc->header + 32, wave.common.wBlockAlign);
|
||||
WRITE_U16 (wavenc->header + 34, wave.common.wBitsPerSample);
|
||||
GST_WRITE_UINT32_LE (wavenc->header + 16, wave.format.len);
|
||||
GST_WRITE_UINT16_LE (wavenc->header + 20, wave.common.wFormatTag);
|
||||
GST_WRITE_UINT16_LE (wavenc->header + 22, wave.common.wChannels);
|
||||
GST_WRITE_UINT32_LE (wavenc->header + 24, wave.common.dwSamplesPerSec);
|
||||
GST_WRITE_UINT32_LE (wavenc->header + 28, wave.common.dwAvgBytesPerSec);
|
||||
GST_WRITE_UINT16_LE (wavenc->header + 32, wave.common.wBlockAlign);
|
||||
GST_WRITE_UINT16_LE (wavenc->header + 34, wave.common.wBitsPerSample);
|
||||
strncpy (wavenc->header + 36, wave.data.id, 4);
|
||||
WRITE_U32 (wavenc->header + 40, wave.data.len);
|
||||
GST_WRITE_UINT32_LE (wavenc->header + 40, wave.data.len);
|
||||
|
||||
wavenc->length = 0;
|
||||
wavenc->setup = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -267,11 +260,17 @@ gst_wavenc_stop_file (GstWavEnc * wavenc)
|
|||
GstBuffer *outbuf;
|
||||
|
||||
event = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, 0);
|
||||
gst_pad_send_event (GST_PAD_PEER (wavenc->srcpad), event);
|
||||
gst_pad_push (wavenc->srcpad, GST_DATA (event));
|
||||
|
||||
outbuf = gst_buffer_new_and_alloc (WAV_HEADER_LEN);
|
||||
WRITE_U32 (wavenc->header + 4, wavenc->length);
|
||||
GST_WRITE_UINT32_LE (wavenc->header + 4,
|
||||
wavenc->length + (WAV_HEADER_LEN - 8));
|
||||
GST_WRITE_UINT32_LE (wavenc->header + 40, wavenc->length);
|
||||
memcpy (GST_BUFFER_DATA (outbuf), wavenc->header, WAV_HEADER_LEN);
|
||||
GST_BUFFER_OFFSET (outbuf) = 0;
|
||||
GST_BUFFER_OFFSET_END (outbuf) = WAV_HEADER_LEN;
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = 0;
|
||||
GST_BUFFER_DURATION (outbuf) = 0;
|
||||
|
||||
gst_pad_push (wavenc->srcpad, GST_DATA (outbuf));
|
||||
}
|
||||
|
|
|
@ -1126,7 +1126,7 @@ gst_osselement_probe_caps (GstOssElement * oss)
|
|||
|
||||
if (gst_caps_is_empty (caps)) {
|
||||
GST_ELEMENT_ERROR (oss, RESOURCE, SETTINGS,
|
||||
(_("Your oss device could not be probed correctly")), (NULL));
|
||||
(_("Your OSS device could not be probed correctly")), (NULL));
|
||||
return;
|
||||
}
|
||||
GST_DEBUG ("probed caps: %" GST_PTR_FORMAT, caps);
|
||||
|
@ -1217,6 +1217,14 @@ gst_osselement_rate_probe_check (GstOssProbe * probe)
|
|||
}
|
||||
}
|
||||
n_checks++;
|
||||
if (probe->min == -1 || probe->max == -1) {
|
||||
/* This is a workaround for drivers that return -EINVAL (or another
|
||||
* error) for rates outside of [8000,48000]. If this fails, the
|
||||
* driver is seriously buggy, and probably doesn't work with other
|
||||
* media libraries/apps. */
|
||||
probe->min = gst_osselement_rate_check_rate (probe, 8000);
|
||||
probe->max = gst_osselement_rate_check_rate (probe, 48000);
|
||||
}
|
||||
if (probe->min == -1 || probe->max == -1) {
|
||||
GST_DEBUG ("unexpected check_rate error");
|
||||
return FALSE;
|
||||
|
|
Loading…
Reference in a new issue