grab device is in AVFormatParameter (at least better than global variable)

Originally committed as revision 1499 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Fabrice Bellard
2003-01-23 10:33:16 +00:00
parent 79a7c2683e
commit 7f172339fd
6 changed files with 17 additions and 16 deletions

View File

@@ -28,8 +28,6 @@
#include <sys/mman.h>
#include <sys/time.h>
const char *audio_device = "/dev/dsp";
#define AUDIO_BLOCK_SIZE 4096
typedef struct {
@@ -43,13 +41,16 @@ typedef struct {
int buffer_ptr;
} AudioData;
static int audio_open(AudioData *s, int is_output)
static int audio_open(AudioData *s, int is_output, const char *audio_device)
{
int audio_fd;
int tmp, err;
char *flip = getenv("AUDIO_FLIP_LEFT");
/* open linux audio device */
if (!audio_device)
audio_device = "/dev/dsp";
if (is_output)
audio_fd = open(audio_device, O_WRONLY);
else
@@ -155,7 +156,7 @@ static int audio_write_header(AVFormatContext *s1)
st = s1->streams[0];
s->sample_rate = st->codec.sample_rate;
s->channels = st->codec.channels;
ret = audio_open(s, 1);
ret = audio_open(s, 1, NULL);
if (ret < 0) {
return -EIO;
} else {
@@ -217,7 +218,7 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)
s->sample_rate = ap->sample_rate;
s->channels = ap->channels;
ret = audio_open(s, 0);
ret = audio_open(s, 0, ap->device);
if (ret < 0) {
av_free(st);
return -EIO;