Browse Source

Do not use perror() in audio, video, and DV grabbers

Originally committed as revision 11058 to svn://svn.ffmpeg.org/ffmpeg/trunk
tags/v0.5
Luca Abeni 18 years ago
parent
commit
9f74582cea
3 changed files with 16 additions and 16 deletions
  1. +4
    -4
      libavformat/audio.c
  2. +8
    -8
      libavformat/dv1394.c
  3. +4
    -4
      libavformat/v4l.c

+ 4
- 4
libavformat/audio.c View File

@@ -58,7 +58,7 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
else else
audio_fd = open(audio_device, O_RDONLY); audio_fd = open(audio_device, O_RDONLY);
if (audio_fd < 0) { if (audio_fd < 0) {
perror(audio_device);
av_log(NULL, AV_LOG_ERROR, "%s: %s\n", audio_device, strerror(errno));
return AVERROR(EIO); return AVERROR(EIO);
} }


@@ -114,14 +114,14 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
} }
err=ioctl(audio_fd, SNDCTL_DSP_SETFMT, &tmp); err=ioctl(audio_fd, SNDCTL_DSP_SETFMT, &tmp);
if (err < 0) { if (err < 0) {
perror("SNDCTL_DSP_SETFMT");
av_log(NULL, AV_LOG_ERROR, "SNDCTL_DSP_SETFMT: %s\n", strerror(errno));
goto fail; goto fail;
} }


tmp = (s->channels == 2); tmp = (s->channels == 2);
err = ioctl(audio_fd, SNDCTL_DSP_STEREO, &tmp); err = ioctl(audio_fd, SNDCTL_DSP_STEREO, &tmp);
if (err < 0) { if (err < 0) {
perror("SNDCTL_DSP_STEREO");
av_log(NULL, AV_LOG_ERROR, "SNDCTL_DSP_STEREO: %s\n", strerror(errno));
goto fail; goto fail;
} }
if (tmp) if (tmp)
@@ -130,7 +130,7 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
tmp = s->sample_rate; tmp = s->sample_rate;
err = ioctl(audio_fd, SNDCTL_DSP_SPEED, &tmp); err = ioctl(audio_fd, SNDCTL_DSP_SPEED, &tmp);
if (err < 0) { if (err < 0) {
perror("SNDCTL_DSP_SPEED");
av_log(NULL, AV_LOG_ERROR, "SNDCTL_DSP_SPEED: %s\n", strerror(errno));
goto fail; goto fail;
} }
s->sample_rate = tmp; /* store real sample rate */ s->sample_rate = tmp; /* store real sample rate */


+ 8
- 8
libavformat/dv1394.c View File

@@ -74,7 +74,7 @@ static int dv1394_start(struct dv1394_data *dv)
{ {
/* Tell DV1394 driver to enable receiver */ /* Tell DV1394 driver to enable receiver */
if (ioctl(dv->fd, DV1394_START_RECEIVE, 0) < 0) { if (ioctl(dv->fd, DV1394_START_RECEIVE, 0) < 0) {
perror("Failed to start receiver");
av_log(NULL, AV_LOG_ERROR, "Failed to start receiver: %s\n", strerror(errno));
return -1; return -1;
} }
return 0; return 0;
@@ -101,19 +101,19 @@ static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap
/* Open and initialize DV1394 device */ /* Open and initialize DV1394 device */
dv->fd = open(context->filename, O_RDONLY); dv->fd = open(context->filename, O_RDONLY);
if (dv->fd < 0) { if (dv->fd < 0) {
perror("Failed to open DV interface");
av_log(context, AV_LOG_ERROR, "Failed to open DV interface: %s\n", strerror(errno));
goto failed; goto failed;
} }


if (dv1394_reset(dv) < 0) { if (dv1394_reset(dv) < 0) {
perror("Failed to initialize DV interface");
av_log(context, AV_LOG_ERROR, "Failed to initialize DV interface: %s\n", strerror(errno));
goto failed; goto failed;
} }


dv->ring = mmap(NULL, DV1394_PAL_FRAME_SIZE * DV1394_RING_FRAMES, dv->ring = mmap(NULL, DV1394_PAL_FRAME_SIZE * DV1394_RING_FRAMES,
PROT_READ, MAP_PRIVATE, dv->fd, 0); PROT_READ, MAP_PRIVATE, dv->fd, 0);
if (dv->ring == MAP_FAILED) { if (dv->ring == MAP_FAILED) {
perror("Failed to mmap DV ring buffer");
av_log(context, AV_LOG_ERROR, "Failed to mmap DV ring buffer: %s\n", strerror(errno));
goto failed; goto failed;
} }


@@ -162,12 +162,12 @@ restart_poll:
if (poll(&p, 1, -1) < 0) { if (poll(&p, 1, -1) < 0) {
if (errno == EAGAIN || errno == EINTR) if (errno == EAGAIN || errno == EINTR)
goto restart_poll; goto restart_poll;
perror("Poll failed");
av_log(context, AV_LOG_ERROR, "Poll failed: %s\n", strerror(errno));
return AVERROR(EIO); return AVERROR(EIO);
} }


if (ioctl(dv->fd, DV1394_GET_STATUS, &s) < 0) { if (ioctl(dv->fd, DV1394_GET_STATUS, &s) < 0) {
perror("Failed to get status");
av_log(context, AV_LOG_ERROR, "Failed to get status: %s\n", strerror(errno));
return AVERROR(EIO); return AVERROR(EIO);
} }
#ifdef DV1394_DEBUG #ifdef DV1394_DEBUG
@@ -213,11 +213,11 @@ static int dv1394_close(AVFormatContext * context)


/* Shutdown DV1394 receiver */ /* Shutdown DV1394 receiver */
if (ioctl(dv->fd, DV1394_SHUTDOWN, 0) < 0) if (ioctl(dv->fd, DV1394_SHUTDOWN, 0) < 0)
perror("Failed to shutdown DV1394");
av_log(context, AV_LOG_ERROR, "Failed to shutdown DV1394: %s\n", strerror(errno));


/* Unmap ring buffer */ /* Unmap ring buffer */
if (munmap(dv->ring, DV1394_NTSC_FRAME_SIZE * DV1394_RING_FRAMES) < 0) if (munmap(dv->ring, DV1394_NTSC_FRAME_SIZE * DV1394_RING_FRAMES) < 0)
perror("Failed to munmap DV1394 ring buffer");
av_log(context, AV_LOG_ERROR, "Failed to munmap DV1394 ring buffer: %s\n", strerror(errno));


close(dv->fd); close(dv->fd);
av_free(dv->dv_demux); av_free(dv->dv_demux);


+ 4
- 4
libavformat/v4l.c View File

@@ -119,12 +119,12 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)


video_fd = open(s1->filename, O_RDWR); video_fd = open(s1->filename, O_RDWR);
if (video_fd < 0) { if (video_fd < 0) {
perror(s1->filename);
av_log(s1, AV_LOG_ERROR, "%s: %s\n", s1->filename, strerror(errno));
goto fail; goto fail;
} }


if (ioctl(video_fd,VIDIOCGCAP, &s->video_cap) < 0) { if (ioctl(video_fd,VIDIOCGCAP, &s->video_cap) < 0) {
perror("VIDIOCGCAP");
av_log(s1, AV_LOG_ERROR, "VIDIOCGCAP: %s\n", strerror(errno));
goto fail; goto fail;
} }


@@ -221,7 +221,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
if ((unsigned char*)-1 == s->video_buf) { if ((unsigned char*)-1 == s->video_buf) {
s->video_buf = mmap(0,s->gb_buffers.size,PROT_READ|PROT_WRITE,MAP_PRIVATE,video_fd,0); s->video_buf = mmap(0,s->gb_buffers.size,PROT_READ|PROT_WRITE,MAP_PRIVATE,video_fd,0);
if ((unsigned char*)-1 == s->video_buf) { if ((unsigned char*)-1 == s->video_buf) {
perror("mmap");
av_log(s1, AV_LOG_ERROR, "mmap: %s\n", strerror(errno));
goto fail; goto fail;
} }
} }
@@ -298,7 +298,7 @@ static int v4l_mm_read_picture(VideoData *s, uint8_t *buf)
if (errno == EAGAIN) if (errno == EAGAIN)
av_log(NULL, AV_LOG_ERROR, "Cannot Sync\n"); av_log(NULL, AV_LOG_ERROR, "Cannot Sync\n");
else else
perror("VIDIOCMCAPTURE");
av_log(NULL, AV_LOG_ERROR, "VIDIOCMCAPTURE: %s\n", strerror(errno));
return AVERROR(EIO); return AVERROR(EIO);
} }




Loading…
Cancel
Save