Commit 1de1cce2 authored by Philip Gladstone's avatar Philip Gladstone

* Make it work with sound cards (like mine) that can only capture in stereo.

* Add a kludge to allow the left channel to be inverted -- my tv card/sound card
  ends up with the left channel = minus right channel. Converting to mono by
  adding the channels doesn't work well.

Originally committed as revision 458 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent f80c1ac0
......@@ -38,6 +38,7 @@ typedef struct {
int channels;
int frame_size; /* in bytes ! */
int codec_id;
int flip_left : 1;
UINT8 buffer[AUDIO_BLOCK_SIZE];
int buffer_ptr;
} AudioData;
......@@ -46,6 +47,7 @@ static int audio_open(AudioData *s, int is_output)
{
int audio_fd;
int tmp, err;
char *flip = getenv("AUDIO_FLIP_LEFT");
/* open linux audio device */
if (is_output)
......@@ -57,6 +59,10 @@ static int audio_open(AudioData *s, int is_output)
return -EIO;
}
if (flip && *flip == '1') {
s->flip_left = 1;
}
/* non blocking mode */
fcntl(audio_fd, F_SETFL, O_NONBLOCK);
......@@ -114,6 +120,8 @@ static int audio_open(AudioData *s, int is_output)
perror("SNDCTL_DSP_STEREO");
goto fail;
}
if (tmp)
s->channels = 2;
tmp = s->sample_rate;
err = ioctl(audio_fd, SNDCTL_DSP_SPEED, &tmp);
......@@ -259,6 +267,15 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
}
}
pkt->size = ret;
if (s->flip_left && s->channels == 2) {
int i;
short *p = (short *) pkt->data;
for (i = 0; i < ret; i += 4) {
*p = ~*p;
p += 2;
}
}
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment