* 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
This commit is contained in:
Philip Gladstone 2002-05-09 01:15:21 +00:00
parent f80c1ac01b
commit 1de1cce27d
1 changed files with 17 additions and 0 deletions

View File

@ -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;
}