diff options
author | joyping <joyping@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-08-15 18:02:24 +0000 |
---|---|---|
committer | joyping <joyping@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-08-15 18:02:24 +0000 |
commit | 9646f76179ad4536d0c631353f02f2d86929bc4d (patch) | |
tree | 674f770cfe6574c59eb3dc4b8125d5a7190b3bce /libao2/ao_alsa9.c | |
parent | 604f4432f3249b500d1a5747731f368c27f85175 (diff) | |
download | mpv-9646f76179ad4536d0c631353f02f2d86929bc4d.tar.bz2 mpv-9646f76179ad4536d0c631353f02f2d86929bc4d.tar.xz |
no channels moving, autosubdievice, nonsupported fix by Vladimir I. Umnov <uvi@ezmail.ru>, removed braindeaded startup message
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10624 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libao2/ao_alsa9.c')
-rw-r--r-- | libao2/ao_alsa9.c | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/libao2/ao_alsa9.c b/libao2/ao_alsa9.c index b635b7d00a..f5284bfa06 100644 --- a/libao2/ao_alsa9.c +++ b/libao2/ao_alsa9.c @@ -208,8 +208,7 @@ static int init(int rate_hz, int channels, int format, int flags) snd_pcm_info_t *alsa_info; char *str_block_mode; int device_set = 0; - - printf("alsa-init: testing and bugreports are welcome.\n"); + printf("alsa-init: requested format: %d Hz, %d channels, %s\n", rate_hz, channels, audio_out_format_name(format)); @@ -286,7 +285,6 @@ static int init(int rate_hz, int channels, int format, int flags) default: break; } - bytes_per_sample = ao_data.bps / ao_data.samplerate; if (ao_subdevice) { //start parsing ao_subdevice, ugly and not thread safe! @@ -337,7 +335,25 @@ static int init(int rate_hz, int channels, int format, int flags) } } } - } //end parsing ao_subdevice + } else { //end parsing ao_subdevice + /* in any case for multichannel playback we should select + * appropriate device + */ + char devstr[128]; + + switch (channels) { + case 4: + strcpy(devstr, "surround40"); + alsa_device = devstr; + break; + case 6: + strcpy(devstr, "surround51"); + alsa_device = devstr; + break; + default: + } + } + /* switch for spdif * sets opening sequence for SPDIF @@ -377,7 +393,7 @@ static int init(int rate_hz, int channels, int format, int flags) default: fprintf(stderr, "%d channels are not supported\n", channels); - return(0); + exit (0); } alsa_device = devstr; @@ -544,6 +560,21 @@ static int init(int rate_hz, int channels, int format, int flags) printf("alsa-init: unable to set access type: %s\n", snd_strerror(err)); return (0); } + + /* workaround for nonsupported formats + sets default format to S16_LE if the given formats aren't supported */ + if ((err = snd_pcm_hw_params_test_format(alsa_handler, alsa_hwparams, + alsa_format)) < 0) + { + printf("alsa-init: format %s are not supported by hardware, trying default\n", + audio_out_format_name(format)); + alsa_format = SND_PCM_FORMAT_S16_LE; + ao_data.format = AFMT_S16_LE; + ao_data.bps = channels * rate_hz * 2; + } + + bytes_per_sample = ao_data.bps / ao_data.samplerate; //it should be here + if ((err = snd_pcm_hw_params_set_format(alsa_handler, alsa_hwparams, alsa_format)) < 0) @@ -916,7 +947,7 @@ static int play_normal(void* data, int len) printf("alsa-play: write error %s", snd_strerror(res)); return 0; } - return res < 0 ? (int)res : len; + return res < 0 ? (int)res : len - len % bytes_per_sample; } /* mmap-mode mainly based on descriptions by Joshua Haberman <joshua@haberman.com> |