[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[312] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-11-09 14:05:05
|
Revision: 312 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=312&view=rev Author: nickols_k Date: 2012-11-09 14:04:48 +0000 (Fri, 09 Nov 2012) Log Message: ----------- use more universal MPXP_Rc Modified Paths: -------------- mplayerxp/libao2/ao_alsa9.c mplayerxp/libao2/ao_arts.c mplayerxp/libao2/ao_esd.c mplayerxp/libao2/ao_jack.c mplayerxp/libao2/ao_nas.c mplayerxp/libao2/ao_null.c mplayerxp/libao2/ao_openal.c mplayerxp/libao2/ao_oss.c mplayerxp/libao2/ao_sdl.c mplayerxp/libao2/ao_wav.c mplayerxp/libao2/audio_out.c mplayerxp/libao2/audio_out.h mplayerxp/libvo/screenshot.c mplayerxp/libvo/screenshot.h mplayerxp/libvo/video_out.c mplayerxp/libvo/video_out.h mplayerxp/libvo/video_out_internal.h mplayerxp/libvo/vo_dga.c mplayerxp/libvo/vo_fbdev.c mplayerxp/libvo/vo_null.c mplayerxp/libvo/vo_opengl.c mplayerxp/libvo/vo_sdl.c mplayerxp/libvo/vo_vesa.c mplayerxp/libvo/vo_x11.c mplayerxp/libvo/vo_xv.c mplayerxp/libvo/vo_xvidix.c mplayerxp/libvo/vosub_vidix.c mplayerxp/libvo/vosub_vidix.h mplayerxp/libvo/x11_common.c mplayerxp/libvo/x11_common.h mplayerxp/mplayerxp.c mplayerxp/postproc/vf_vo.c Modified: mplayerxp/libao2/ao_alsa9.c =================================================================== --- mplayerxp/libao2/ao_alsa9.c 2012-11-09 12:29:58 UTC (rev 311) +++ mplayerxp/libao2/ao_alsa9.c 2012-11-09 14:04:48 UTC (rev 312) @@ -310,7 +310,7 @@ open & setup audio device return: 1=success 0=fail */ -static int __FASTCALL__ init(ao_data_t* ao,unsigned flags) +static MPXP_Rc __FASTCALL__ init(ao_data_t* ao,unsigned flags) { int err; int cards = -1; @@ -341,7 +341,7 @@ if(strcmp(p+1,"-1")==0) { *p='\0'; show_caps(atoi(alsa_port)); - return 0; + return MPXP_False; } } if(alsa_port) snprintf(alsa_device,sizeof(alsa_device),"%s:%s",alsa_dev,alsa_port); @@ -352,7 +352,7 @@ if ((err = snd_card_next(&cards)) < 0 || cards < 0) { MSG_ERR("alsa-init: no soundcards found: %s\n", snd_strerror(err)); - return 0; + return MPXP_False; } if (alsa_device[0] == '\0') { @@ -360,17 +360,17 @@ if ((err = snd_pcm_info_malloc(&alsa_info)) < 0) { MSG_ERR("alsa-init: memory allocation error: %s\n", snd_strerror(err)); - return 0; + return MPXP_False; } if ((tmp_device = snd_pcm_info_get_device(alsa_info)) < 0) { MSG_ERR("alsa-init: cant get device\n"); - return 0; + return MPXP_False; } if ((tmp_subdevice = snd_pcm_info_get_subdevice(alsa_info)) < 0) { MSG_ERR("alsa-init: cant get subdevice\n"); - return 0; + return MPXP_False; } MSG_V("alsa-init: got device=%i, subdevice=%i\n", tmp_device, tmp_subdevice); @@ -401,7 +401,7 @@ if ((err = snd_pcm_open(&priv->handler, alsa_device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); alsa_device[0]='\0'; - return 0; + return MPXP_False; } else { block_mode = 0; str_block_mode = "block-mode"; @@ -409,7 +409,7 @@ } else { MSG_ERR("alsa-init: playback open error: %s\n", snd_strerror(err)); alsa_device[0]='\0'; - return 0; + return MPXP_False; } } alsa_device[0]='\0'; @@ -426,7 +426,7 @@ { MSG_ERR("alsa-init: unable to get initial parameters: %s\n", snd_strerror(err)); - return 0; + return MPXP_False; } MSG_DBG2("snd_pcm_hw_params_any()\n"); if (priv_conf.mmap) { @@ -443,13 +443,13 @@ } if (err < 0) { MSG_ERR("alsa-init: unable to set access type: %s\n", snd_strerror(err)); - return 0; + return MPXP_False; } } // end switch priv->handler (spdif) - return 1; + return MPXP_Ok; } // end init -static int __FASTCALL__ configure(ao_data_t* ao,unsigned rate_hz,unsigned channels,unsigned format) +static MPXP_Rc __FASTCALL__ configure(ao_data_t* ao,unsigned rate_hz,unsigned channels,unsigned format) { priv_t*priv=ao->priv; int err,i; @@ -492,7 +492,7 @@ case -1: MSG_ERR("alsa-conf: invalid format (%s) requested - output disabled\n", ao_format_name(format)); - return 0; + return MPXP_False; default: break; } @@ -508,7 +508,7 @@ if (!(snd_pcm_hw_params_test_format(priv->handler, priv->hwparams, i))) MSG_HINT("%s ",snd_pcm_format_name(i)); MSG_HINT("\n"); - return 0; + return MPXP_False; } MSG_DBG2("snd_pcm_hw_params_set_format(%i)\n",priv->format); @@ -516,7 +516,7 @@ MSG_ERR("alsa-conf: unable to set samplerate %u: %s\n", ao->samplerate, snd_strerror(err)); - return 0; + return MPXP_False; } MSG_DBG2("snd_pcm_hw_params_set_rate_near(%i)\n",ao->samplerate); @@ -525,7 +525,7 @@ MSG_ERR("alsa-conf: unable to set %u channels: %s\n", ao->channels, snd_strerror(err)); - return 0; + return MPXP_False; } MSG_DBG2("snd_pcm_hw_params_set_channels(%i)\n",ao->channels); #ifdef BUFFERTIME @@ -536,7 +536,7 @@ if ((err = snd_pcm_hw_params_set_buffer_time_near(priv->handler, priv->hwparams, &alsa_buffer_time, &dir)) < 0) { MSG_ERR("alsa-init: unable to set buffer time near: %s\n", snd_strerror(err)); - return 0; + return MPXP_False; } MSG_DBG2("snd_pcm_hw_set_buffer_time_near(%i)\n",alsa_buffer_time); @@ -545,7 +545,7 @@ /* original: alsa_buffer_time/ao->bps */ MSG_ERR("alsa-init: unable to set period time: %s\n", snd_strerror(err)); - return 0; + return MPXP_False; } MSG_DBG2("snd_pcm_hw_set_period_time_near(%i)\n",period_time); MSG_V("alsa-init: buffer_time: %d, period_time :%d\n",alsa_buffer_time, period_time); @@ -557,14 +557,14 @@ snd_pcm_uframes_t size; if ((err = snd_pcm_hw_params_set_period_time_near(priv->handler, priv->hwparams, &period_time, &dir)) < 0) { MSG_ERR("alsa-init: unable to set period_time: %s\n", snd_strerror(err)); - return 0; + return MPXP_False; } MSG_DBG2("snd_pcm_hw_set_period_time(%i)\n",period_time); //get chunksize if ((err = snd_pcm_hw_params_get_period_size(priv->hwparams, &size, &dir)) < 0) { MSG_ERR("alsa-init: unable to get period_size: %s\n", snd_strerror(err)); - return 0; + return MPXP_False; } MSG_DBG2("snd_pcm_hw_get_period_size(%i)\n",size); chunk_size=size; @@ -573,7 +573,7 @@ // gets buffersize for control if ((err = snd_pcm_hw_params_get_buffer_size(priv->hwparams,&dummy)) < 0) { MSG_ERR("alsa-conf: unable to get buffersize: %s\n", snd_strerror(err)); - return 0; + return MPXP_False; } else { ao->buffersize = dummy * priv->bytes_per_sample; MSG_V("alsa-conf: got buffersize=%i\n", ao->buffersize); @@ -590,39 +590,39 @@ if ((err = snd_pcm_hw_params(priv->handler, priv->hwparams)) < 0) { MSG_ERR("alsa-conf: unable to set hw-parameters: %s\n", snd_strerror(err)); - return 0; + return MPXP_False; } MSG_DBG2("snd_pcm_hw_params()\n"); // setting sw-params (only avail-min) if noblocking mode was choosed if (priv_conf.noblock) { if ((err = snd_pcm_sw_params_current(priv->handler, priv->swparams)) < 0) { MSG_ERR("alsa-conf: unable to get parameters: %s\n",snd_strerror(err)); - return 0; + return MPXP_False; } //set min available frames to consider pcm ready (4) //increased for nonblock-mode should be set dynamically later if ((err = snd_pcm_sw_params_set_avail_min(priv->handler, priv->swparams, 4)) < 0) { MSG_ERR("alsa-conf: unable to set avail_min %s\n",snd_strerror(err)); - return 0; + return MPXP_False; } if ((err = snd_pcm_sw_params(priv->handler, priv->swparams)) < 0) { - MSG_ERR("alsa-conf: unable to install sw-params\n"); - return 0; + MSG_ERR("alsa-conf: unable to install sw-params\n"); + return MPXP_False; } }//end swparams if ((err = snd_pcm_prepare(priv->handler)) < 0) { MSG_ERR("alsa-conf: pcm prepare error: %s\n", snd_strerror(err)); - return 0; + return MPXP_False; } // end setting hw-params MSG_V("alsa-conf: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n", ao->samplerate, ao->channels, priv->bytes_per_sample, ao->buffersize, snd_pcm_format_description(priv->format)); - return 1; + return MPXP_Ok; } // end configure /* close audio device */ Modified: mplayerxp/libao2/ao_arts.c =================================================================== --- mplayerxp/libao2/ao_arts.c 2012-11-09 12:29:58 UTC (rev 311) +++ mplayerxp/libao2/ao_arts.c 2012-11-09 14:04:48 UTC (rev 312) @@ -50,37 +50,37 @@ UNUSED(ao); UNUSED(cmd); UNUSED(arg); - return MPXP_Unknown; + return MPXP_Unknown; } -static int init(ao_data_t* ao,unsigned flags) +static MPXP_Rc init(ao_data_t* ao,unsigned flags) { - int err; - UNUSED(ao); - UNUSED(flags); + int err; + UNUSED(ao); + UNUSED(flags); - if( (err=arts_init()) ) { - MSG_ERR("[aRts] init failed: %s\n", arts_error_text(err)); - /*TODO: system("artsd -l0");*/ - return 0; - } - MSG_INFO("[aRts] connected to server\n"); - return 1; + if( (err=arts_init()) ) { + MSG_ERR("[aRts] init failed: %s\n", arts_error_text(err)); + /*TODO: system("artsd -l0");*/ + return MPXP_False; + } + MSG_INFO("[aRts] connected to server\n"); + return MPXP_Ok; } -static int __FASTCALL__ configure(ao_data_t* ao,unsigned rate,unsigned channels,unsigned format) +static MPXP_Rc __FASTCALL__ configure(ao_data_t* ao,unsigned rate,unsigned channels,unsigned format) { arts_stream_t stream; - unsigned frag_spec,samplesize; - /* - * arts supports 8bit unsigned and 16bit signed sample formats - * (16bit apparently in little endian format, even in the case - * when artsd runs on a big endian cpu). - * - * Unsupported formats are translated to one of these two formats - * using mplayer's audio filters. - */ - switch (format) { + unsigned frag_spec,samplesize; + /* + * arts supports 8bit unsigned and 16bit signed sample formats + * (16bit apparently in little endian format, even in the case + * when artsd runs on a big endian cpu). + * + * Unsupported formats are translated to one of these two formats + * using mplayer's audio filters. + */ + switch (format) { case AFMT_U8: case AFMT_S8: format = AFMT_U8; @@ -106,34 +106,34 @@ samplesize=2; format = AFMT_S16_LE; /* artsd always expects little endian?*/ break; - } + } - ao->format = format; - ao->channels = channels; - ao->samplerate = rate; - ao->bps = rate*channels*samplesize; + ao->format = format; + ao->channels = channels; + ao->samplerate = rate; + ao->bps = rate*channels*samplesize; - stream=arts_play_stream(rate, samplesize*8, channels, "MPlayerXP"); - ao->priv=stream; + stream=arts_play_stream(rate, samplesize*8, channels, "MPlayerXP"); + ao->priv=stream; - if(stream == NULL) { - MSG_ERR("[aRts] Can't open stream\n"); - arts_free(); - return 0; - } + if(stream == NULL) { + MSG_ERR("[aRts] Can't open stream\n"); + arts_free(); + return MPXP_False; + } - /* Set the stream to blocking: it will not block anyway, but it seems */ - /* to be working better */ - arts_stream_set(stream, ARTS_P_BLOCKING, 1); - frag_spec = ARTS_PACKET_SIZE_LOG2 | ARTS_PACKETS << 16; - arts_stream_set(stream, ARTS_P_PACKET_SETTINGS, frag_spec); - ao->buffersize = arts_stream_get(stream, ARTS_P_BUFFER_SIZE); - MSG_INFO("[aRts] Stream opened\n"); + /* Set the stream to blocking: it will not block anyway, but it seems */ + /* to be working better */ + arts_stream_set(stream, ARTS_P_BLOCKING, 1); + frag_spec = ARTS_PACKET_SIZE_LOG2 | ARTS_PACKETS << 16; + arts_stream_set(stream, ARTS_P_PACKET_SETTINGS, frag_spec); + ao->buffersize = arts_stream_get(stream, ARTS_P_BUFFER_SIZE); + MSG_INFO("[aRts] Stream opened\n"); - MSG_V("[aRts] buffersize=%u\n",ao->buffersize); - MSG_V("[aRts] buffersize=%u\n", arts_stream_get(stream, ARTS_P_PACKET_SIZE)); + MSG_V("[aRts] buffersize=%u\n",ao->buffersize); + MSG_V("[aRts] buffersize=%u\n", arts_stream_get(stream, ARTS_P_PACKET_SIZE)); - return 1; + return MPXP_Ok; } static void uninit(ao_data_t* ao) Modified: mplayerxp/libao2/ao_esd.c =================================================================== --- mplayerxp/libao2/ao_esd.c 2012-11-09 12:29:58 UTC (rev 311) +++ mplayerxp/libao2/ao_esd.c 2012-11-09 14:04:48 UTC (rev 312) @@ -161,7 +161,7 @@ * open & setup audio device * return: 1=success 0=fail */ -static int init(ao_data_t* ao,unsigned flags) +static MPXP_Rc init(ao_data_t* ao,unsigned flags) { ao->priv=mp_mallocz(sizeof(priv_t)); priv_t*priv=ao->priv; @@ -172,13 +172,13 @@ priv->fd = esd_open_sound(server); if (priv->fd < 0) { MSG_ERR("ESD: Can't open sound: %s\n", strerror(errno)); - return 0; + return MPXP_False; } } - return 1; + return MPXP_Ok; } -static int configure(ao_data_t* ao,unsigned rate_hz,unsigned channels,unsigned format) +static MPXP_Rc configure(ao_data_t* ao,unsigned rate_hz,unsigned channels,unsigned format) { priv_t*priv=ao->priv; char *server = ao->subdevice; /* NULL for localhost */ @@ -264,7 +264,7 @@ server, ESD_CLIENT_NAME); if (priv->play_fd < 0) { MSG_ERR("ESD: Can't open play stream: %s\n", strerror(errno)); - return 0; + return MPXP_False; } /* enable non-blocking i/o on the socket connection to the esd server */ @@ -290,7 +290,7 @@ priv->samples_written = 0; priv->bytes_per_sample = bytes_per_sample; - return 1; + return MPXP_Ok; } Modified: mplayerxp/libao2/ao_jack.c =================================================================== --- mplayerxp/libao2/ao_jack.c 2012-11-09 12:29:58 UTC (rev 311) +++ mplayerxp/libao2/ao_jack.c 2012-11-09 14:04:48 UTC (rev 312) @@ -212,18 +212,18 @@ ); } #endif -static int init(ao_data_t* ao,unsigned flags) { +static MPXP_Rc init(ao_data_t* ao,unsigned flags) { ao->priv=mp_mallocz(sizeof(priv_t)); UNUSED(flags); - return 1; + return MPXP_Ok; } -static int configure(ao_data_t* ao,unsigned rate,unsigned channels,unsigned format) { +static MPXP_Rc configure(ao_data_t* ao,unsigned rate,unsigned channels,unsigned format) { priv_t*priv=ao->priv; - const char **matching_ports = NULL; - char *port_name = NULL; - char *client_name = NULL; - int autostart = 0; + const char **matching_ports = NULL; + char *port_name = NULL; + char *client_name = NULL; + int autostart = 0; /* const opt_t subopts[] = { {"port", OPT_ARG_MSTRZ, &port_name, NULL}, @@ -233,93 +233,92 @@ {NULL} }; */ - jack_options_t open_options = JackUseExactName; - int port_flags = JackPortIsInput; - unsigned i; - priv->estimate = 1; - UNUSED(format); + jack_options_t open_options = JackUseExactName; + int port_flags = JackPortIsInput; + unsigned i; + priv->estimate = 1; + UNUSED(format); /* if (subopt_parse(ao->subdevice, subopts) != 0) { print_help(); return 0; } */ - if (channels > MAX_CHANS) { - MSG_FATAL("[JACK] Invalid number of channels: %i\n", channels); - goto err_out; - } - if (!client_name) { - client_name = mp_malloc(40); - sprintf(client_name, "MPlayerXP [%d]", getpid()); - } - if (!autostart) - open_options |= JackNoStartServer; - priv->client = jack_client_open(client_name, open_options, NULL); - if (!priv->client) { - MSG_FATAL("[JACK] cannot open server\n"); - goto err_out; - } - priv->buffer = cb_fifo_alloc(BUFFSIZE); - jack_set_process_callback(priv->client, outputaudio, ao); + if (channels > MAX_CHANS) { + MSG_FATAL("[JACK] Invalid number of channels: %i\n", channels); + goto err_out; + } + if (!client_name) { + client_name = mp_malloc(40); + sprintf(client_name, "MPlayerXP [%d]", getpid()); + } + if (!autostart) + open_options |= JackNoStartServer; + priv->client = jack_client_open(client_name, open_options, NULL); + if (!priv->client) { + MSG_FATAL("[JACK] cannot open server\n"); + goto err_out; + } + priv->buffer = cb_fifo_alloc(BUFFSIZE); + jack_set_process_callback(priv->client, outputaudio, ao); - // list matching priv->ports - if (!port_name) - port_flags |= JackPortIsPhysical; - matching_ports = jack_get_ports(priv->client, ao->subdevice, NULL, port_flags); - if (!matching_ports || !matching_ports[0]) { - MSG_FATAL("[JACK] no physical priv->ports available\n"); - goto err_out; - } - i = 1; - while (matching_ports[i]) i++; - if (channels > i) channels = i; - priv->num_ports = channels; + // list matching priv->ports + if (!port_name) + port_flags |= JackPortIsPhysical; + matching_ports = jack_get_ports(priv->client, ao->subdevice, NULL, port_flags); + if (!matching_ports || !matching_ports[0]) { + MSG_FATAL("[JACK] no physical priv->ports available\n"); + goto err_out; + } + i = 1; + while (matching_ports[i]) i++; + if (channels > i) channels = i; + priv->num_ports = channels; - // create out output priv->ports - for (i = 0; i < priv->num_ports; i++) { - char pname[30]; - snprintf(pname, 30, "out_%d", i); - priv->ports[i] = jack_port_register(priv->client, pname, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); - if (!priv->ports[i]) { - MSG_FATAL("[JACK] not enough priv->ports available\n"); - goto err_out; + // create out output priv->ports + for (i = 0; i < priv->num_ports; i++) { + char pname[30]; + snprintf(pname, 30, "out_%d", i); + priv->ports[i] = jack_port_register(priv->client, pname, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); + if (!priv->ports[i]) { + MSG_FATAL("[JACK] not enough priv->ports available\n"); + goto err_out; + } } - } - if (jack_activate(priv->client)) { - MSG_FATAL("[JACK] activate failed\n"); - goto err_out; - } - for (i = 0; i < priv->num_ports; i++) { - if (jack_connect(priv->client, jack_port_name(priv->ports[i]), matching_ports[i])) { - MSG_FATAL( "[JACK] connecting failed\n"); - goto err_out; + if (jack_activate(priv->client)) { + MSG_FATAL("[JACK] activate failed\n"); + goto err_out; } - } - rate = jack_get_sample_rate(priv->client); - priv->latency = (float)(jack_port_get_total_latency(priv->client, priv->ports[0]) + - jack_get_buffer_size(priv->client)) / (float)rate; - priv->callback_interval = 0; + for (i = 0; i < priv->num_ports; i++) { + if (jack_connect(priv->client, jack_port_name(priv->ports[i]), matching_ports[i])) { + MSG_FATAL( "[JACK] connecting failed\n"); + goto err_out; + } + } + rate = jack_get_sample_rate(priv->client); + priv->latency = (float)(jack_port_get_total_latency(priv->client, priv->ports[0]) + + jack_get_buffer_size(priv->client)) / (float)rate; + priv->callback_interval = 0; - ao->channels = channels; - ao->samplerate = rate; - ao->format = AFMT_FLOAT32; - ao->bps = channels * rate * sizeof(float); - ao->buffersize = CHUNK_SIZE * NUM_CHUNKS; - ao->outburst = CHUNK_SIZE; - mp_free(matching_ports); - mp_free(port_name); - mp_free(client_name); - return 1; + ao->channels = channels; + ao->samplerate = rate; + ao->format = AFMT_FLOAT32; + ao->bps = channels * rate * sizeof(float); + ao->buffersize = CHUNK_SIZE * NUM_CHUNKS; + ao->outburst = CHUNK_SIZE; + mp_free(matching_ports); + mp_free(port_name); + mp_free(client_name); + return MPXP_Ok; err_out: - mp_free(matching_ports); - mp_free(port_name); - mp_free(client_name); - if (priv->client) - jack_client_close(priv->client); - cb_fifo_free(priv->buffer); - priv->buffer = NULL; - return 0; + mp_free(matching_ports); + mp_free(port_name); + mp_free(client_name); + if (priv->client) jack_client_close(priv->client); + cb_fifo_free(priv->buffer); + priv->buffer = NULL; + return MPXP_False; } // close audio device Modified: mplayerxp/libao2/ao_nas.c =================================================================== --- mplayerxp/libao2/ao_nas.c 2012-11-09 12:29:58 UTC (rev 311) +++ mplayerxp/libao2/ao_nas.c 2012-11-09 14:04:48 UTC (rev 312) @@ -66,199 +66,198 @@ #define NAS_FRAG_SIZE 4096 static const char * const nas_event_types[] = { - "Undefined", - "Undefined", - "ElementNotify", - "GrabNotify", - "MonitorNotify", - "BucketNotify", - "DeviceNotify" + "Undefined", + "Undefined", + "ElementNotify", + "GrabNotify", + "MonitorNotify", + "BucketNotify", + "DeviceNotify" }; static const char * const nas_elementnotify_kinds[] = { - "LowWater", - "HighWater", - "State", - "Unknown" + "LowWater", + "HighWater", + "State", + "Unknown" }; static const char * const nas_states[] = { - "Stop", - "Start", - "Pause", - "Any" + "Stop", + "Start", + "Pause", + "Any" }; static const char * const nas_reasons[] = { - "User", - "Underrun", - "Overrun", - "EOF", - "Watermark", - "Hardware", - "Any" + "User", + "Underrun", + "Overrun", + "EOF", + "Watermark", + "Hardware", + "Any" }; #ifdef MP_DEBUG static const char* nas_reason(unsigned int reason) { - if (reason > 6) reason = 6; - return nas_reasons[reason]; + if (reason > 6) reason = 6; + return nas_reasons[reason]; } static const char* nas_elementnotify_kind(unsigned int kind) { - if (kind > 2) kind = 3; - return nas_elementnotify_kinds[kind]; + if (kind > 2) kind = 3; + return nas_elementnotify_kinds[kind]; } static const char* nas_event_type(unsigned int type) { - if (type > 6) type = 0; - return nas_event_types[type]; + if (type > 6) type = 0; + return nas_event_types[type]; } static const char* nas_state(unsigned int state) { - if (state>3) state = 3; - return nas_states[state]; + if (state>3) state = 3; + return nas_states[state]; } #endif -static const ao_info_t info = -{ - "NAS audio output", - "nas", - "Tobias Diedrich <ran...@td...>", - "" +static const ao_info_t info = { + "NAS audio output", + "nas", + "Tobias Diedrich <ran...@td...>", + "" }; typedef struct priv_s { - AuServer *aud; - AuFlowID flow; - AuDeviceID dev; - AuFixedPoint gain; + AuServer *aud; + AuFlowID flow; + AuDeviceID dev; + AuFixedPoint gain; - unsigned int state; - int expect_underrun; + unsigned int state; + int expect_underrun; - char *client_buffer; - char *server_buffer; - unsigned int client_buffer_size; - unsigned int client_buffer_used; - unsigned int server_buffer_size; - unsigned int server_buffer_used; - pthread_mutex_t buffer_mutex; + char *client_buffer; + char *server_buffer; + unsigned int client_buffer_size; + unsigned int client_buffer_used; + unsigned int server_buffer_size; + unsigned int server_buffer_used; + pthread_mutex_t buffer_mutex; - pthread_t event_thread; - int stop_thread; + pthread_t event_thread; + int stop_thread; }priv_t; LIBAO_EXTERN(nas) static void nas_print_error(AuServer *aud, const char *prefix, AuStatus as) { - char s[100]; - AuGetErrorText(aud, as, s, 100); - MSG_ERR("ao_nas: %s: returned status %d (%s)\n", prefix, as, s); + char s[100]; + AuGetErrorText(aud, as, s, 100); + MSG_ERR("ao_nas: %s: returned status %d (%s)\n", prefix, as, s); } static int nas_readBuffer(priv_t *priv, unsigned int num) { - AuStatus as; + AuStatus as; - pthread_mutex_lock(&priv->buffer_mutex); - MSG_DBG2("ao_nas: nas_readBuffer(): num=%d client=%d/%d server=%d/%d\n", + pthread_mutex_lock(&priv->buffer_mutex); + MSG_DBG2("ao_nas: nas_readBuffer(): num=%d client=%d/%d server=%d/%d\n", num, priv->client_buffer_used, priv->client_buffer_size, priv->server_buffer_used, priv->server_buffer_size); - if (priv->client_buffer_used == 0) { - MSG_DBG2("ao_nas: buffer is empty, nothing read.\n"); - pthread_mutex_unlock(&priv->buffer_mutex); - return 0; - } - if (num > priv->client_buffer_used) - num = priv->client_buffer_used; + if (priv->client_buffer_used == 0) { + MSG_DBG2("ao_nas: buffer is empty, nothing read.\n"); + pthread_mutex_unlock(&priv->buffer_mutex); + return 0; + } + if (num > priv->client_buffer_used) + num = priv->client_buffer_used; - /* - * It is not appropriate to call AuWriteElement() here because the - * buffer is locked and delays writing to the network will cause - * other threads to block waiting for buffer_mutex. Instead the - * data is copied to "server_buffer" and written to the network - * outside of the locked section of code. - * - * (Note: Rather than these two buffers, a single circular buffer - * could eliminate the memcpy/memmove steps.) - */ - /* make sure we don't overflow the buffer */ - if (num > priv->server_buffer_size) - num = priv->server_buffer_size; - memcpy(priv->server_buffer, priv->client_buffer, num); + /* + * It is not appropriate to call AuWriteElement() here because the + * buffer is locked and delays writing to the network will cause + * other threads to block waiting for buffer_mutex. Instead the + * data is copied to "server_buffer" and written to the network + * outside of the locked section of code. + * + * (Note: Rather than these two buffers, a single circular buffer + * could eliminate the memcpy/memmove steps.) + */ + /* make sure we don't overflow the buffer */ + if (num > priv->server_buffer_size) + num = priv->server_buffer_size; + memcpy(priv->server_buffer, priv->client_buffer, num); - priv->client_buffer_used -= num; - priv->server_buffer_used += num; - memmove(priv->client_buffer, priv->client_buffer + num, priv->client_buffer_used); - pthread_mutex_unlock(&priv->buffer_mutex); + priv->client_buffer_used -= num; + priv->server_buffer_used += num; + memmove(priv->client_buffer, priv->client_buffer + num, priv->client_buffer_used); + pthread_mutex_unlock(&priv->buffer_mutex); - /* - * Now write the new buffer to the network. - */ - AuWriteElement(priv->aud, priv->flow, 0, num, priv->server_buffer, AuFalse, &as); - if (as != AuSuccess) - nas_print_error(priv->aud, "nas_readBuffer(): AuWriteElement", as); + /* + * Now write the new buffer to the network. + */ + AuWriteElement(priv->aud, priv->flow, 0, num, priv->server_buffer, AuFalse, &as); + if (as != AuSuccess) + nas_print_error(priv->aud, "nas_readBuffer(): AuWriteElement", as); - return num; + return num; } static int nas_writeBuffer(priv_t *priv, any_t*data, unsigned int len) { - pthread_mutex_lock(&priv->buffer_mutex); - MSG_DBG2("ao_nas: nas_writeBuffer(): len=%d client=%d/%d server=%d/%d\n", - len, priv->client_buffer_used, priv->client_buffer_size, - priv->server_buffer_used, priv->server_buffer_size); + pthread_mutex_lock(&priv->buffer_mutex); + MSG_DBG2("ao_nas: nas_writeBuffer(): len=%d client=%d/%d server=%d/%d\n", + len, priv->client_buffer_used, priv->client_buffer_size, + priv->server_buffer_used, priv->server_buffer_size); - /* make sure we don't overflow the buffer */ - if (len > priv->client_buffer_size - priv->client_buffer_used) - len = priv->client_buffer_size - priv->client_buffer_used; - memcpy(priv->client_buffer + priv->client_buffer_used, data, len); - priv->client_buffer_used += len; + /* make sure we don't overflow the buffer */ + if (len > priv->client_buffer_size - priv->client_buffer_used) + len = priv->client_buffer_size - priv->client_buffer_used; + memcpy(priv->client_buffer + priv->client_buffer_used, data, len); + priv->client_buffer_used += len; - pthread_mutex_unlock(&priv->buffer_mutex); + pthread_mutex_unlock(&priv->buffer_mutex); - return len; + return len; } static int nas_empty_event_queue(priv_t *priv) { - AuEvent ev; - int result = 0; + AuEvent ev; + int result = 0; - while (AuScanForTypedEvent(priv->aud, AuEventsQueuedAfterFlush, + while (AuScanForTypedEvent(priv->aud, AuEventsQueuedAfterFlush, AuTrue, AuEventTypeElementNotify, &ev)) { - AuDispatchEvent(priv->aud, &ev); - result = 1; - } - return result; + AuDispatchEvent(priv->aud, &ev); + result = 1; + } + return result; } static any_t*nas_event_thread_start(any_t*data) { - priv_t *priv = data; + priv_t *priv = data; - do { - MSG_DBG2( - "ao_nas: event thread heartbeat (state=%s)\n", - nas_state(priv->state)); - nas_empty_event_queue(priv); - usleep(1000); - } while (!priv->stop_thread); + do { + MSG_DBG2( + "ao_nas: event thread heartbeat (state=%s)\n", + nas_state(priv->state)); + nas_empty_event_queue(priv); + usleep(1000); + } while (!priv->stop_thread); - return NULL; + return NULL; } static AuBool nas_error_handler(AuServer* aud, AuErrorEvent* ev) { - char s[100]; - AuGetErrorText(aud, ev->error_code, s, 100); - MSG_ERR( "ao_nas: error [%s]\n" + char s[100]; + AuGetErrorText(aud, ev->error_code, s, 100); + MSG_ERR( "ao_nas: error [%s]\n" "error_code: %d\n" "request_code: %d\n" "minor_code: %d\n", @@ -267,7 +266,7 @@ ev->request_code, ev->minor_code); - return AuTrue; + return AuTrue; } static AuBool nas_event_handler(AuServer *aud, AuEvent *ev, AuEventHandlerRec *hnd) @@ -414,125 +413,125 @@ } -static int init(ao_data_t* ao,unsigned flags) +static MPXP_Rc init(ao_data_t* ao,unsigned flags) { ao->priv=mp_mallocz(sizeof(priv_t)); priv_t* priv=ao->priv; UNUSED(flags); - return 1; + return MPXP_Ok; } // open & setup audio device // return: 1=success 0=fail -static int configure(ao_data_t* ao,unsigned rate,unsigned channels,unsigned format) +static MPXP_Rc configure(ao_data_t* ao,unsigned rate,unsigned channels,unsigned format) { priv_t* priv=ao->priv; - AuElement elms[3]; - AuStatus as; - char str[256]; - unsigned char auformat = nas_aformat_to_auformat(&format); - unsigned bytes_per_sample = channels * AuSizeofFormat(auformat); - unsigned buffer_size; - char *server; + AuElement elms[3]; + AuStatus as; + char str[256]; + unsigned char auformat = nas_aformat_to_auformat(&format); + unsigned bytes_per_sample = channels * AuSizeofFormat(auformat); + unsigned buffer_size; + char *server; - ao->format = format; - ao->samplerate = rate; - ao->channels = channels; - ao->outburst = NAS_FRAG_SIZE; - ao->bps = rate * bytes_per_sample; - buffer_size = ao->bps; /* buffer 1 second */ + ao->format = format; + ao->samplerate = rate; + ao->channels = channels; + ao->outburst = NAS_FRAG_SIZE; + ao->bps = rate * bytes_per_sample; + buffer_size = ao->bps; /* buffer 1 second */ - MSG_V("ao2: %d Hz %d chans %s\n",rate,channels, + MSG_V("ao2: %d Hz %d chans %s\n",rate,channels, mpaf_fmt2str(format,str,256)); - /* - * round up to multiple of NAS_FRAG_SIZE - * divide by 3 first because of 2:1 split - */ - buffer_size = (buffer_size/3 + NAS_FRAG_SIZE-1) & ~(NAS_FRAG_SIZE-1); - ao->buffersize = buffer_size*3; + /* + * round up to multiple of NAS_FRAG_SIZE + * divide by 3 first because of 2:1 split + */ + buffer_size = (buffer_size/3 + NAS_FRAG_SIZE-1) & ~(NAS_FRAG_SIZE-1); + ao->buffersize = buffer_size*3; - priv->client_buffer_size = buffer_size*2; - priv->client_buffer = mp_malloc(priv->client_buffer_size); - priv->server_buffer_size = buffer_size; - priv->server_buffer = mp_malloc(priv->server_buffer_size); + priv->client_buffer_size = buffer_size*2; + priv->client_buffer = mp_malloc(priv->client_buffer_size); + priv->server_buffer_size = buffer_size; + priv->server_buffer = mp_malloc(priv->server_buffer_size); - if (!bytes_per_sample) { - MSG_ERR("ao_nas: init(): Zero bytes per sample -> nosound\n"); - return 0; - } + if (!bytes_per_sample) { + MSG_ERR("ao_nas: init(): Zero bytes per sample -> nosound\n"); + return MPXP_False; + } - if (!(server = getenv("AUDIOSERVER")) && + if (!(server = getenv("AUDIOSERVER")) && !(server = getenv("DISPLAY"))) { - MSG_ERR("ao_nas: init(): AUDIOSERVER environment variable not set -> nosound\n"); - return 0; - } + MSG_ERR("ao_nas: init(): AUDIOSERVER environment variable not set -> nosound\n"); + return MPXP_False; + } - MSG_V("ao_nas: init(): Using audioserver %s\n", server); + MSG_V("ao_nas: init(): Using audioserver %s\n", server); - priv->aud = AuOpenServer(server, 0, NULL, 0, NULL, NULL); - if (!priv->aud) { - MSG_ERR("ao_nas: init(): Can't open nas audio server -> nosound\n"); - return 0; - } + priv->aud = AuOpenServer(server, 0, NULL, 0, NULL, NULL); + if (!priv->aud) { + MSG_ERR("ao_nas: init(): Can't open nas audio server -> nosound\n"); + return MPXP_False; + } - while (channels>0) { - priv->dev = nas_find_device(priv->aud, channels); - if (priv->dev != AuNone && - ((priv->flow = AuCreateFlow(priv->aud, NULL)) != 0)) - break; - channels--; - } + while (channels>0) { + priv->dev = nas_find_device(priv->aud, channels); + if (priv->dev != AuNone && + ((priv->flow = AuCreateFlow(priv->aud, NULL)) != 0)) + break; + channels--; + } - if (priv->flow == 0) { - MSG_ERR("ao_nas: init(): Can't find a suitable output device -> nosound\n"); - AuCloseServer(priv->aud); - priv->aud = 0; - return 0; - } + if (priv->flow == 0) { + MSG_ERR("ao_nas: init(): Can't find a suitable output device -> nosound\n"); + AuCloseServer(priv->aud); + priv->aud = 0; + return MPXP_False; + } - AuMakeElementImportClient(elms, rate, auformat, channels, AuTrue, + AuMakeElementImportClient(elms, rate, auformat, channels, AuTrue, buffer_size / bytes_per_sample, (buffer_size - NAS_FRAG_SIZE) / bytes_per_sample, 0, NULL); - priv->gain = AuFixedPointFromFraction(1, 1); - AuMakeElementMultiplyConstant(elms+1, 0, priv->gain); - AuMakeElementExportDevice(elms+2, 1, priv->dev, rate, + priv->gain = AuFixedPointFromFraction(1, 1); + AuMakeElementMultiplyConstant(elms+1, 0, priv->gain); + AuMakeElementExportDevice(elms+2, 1, priv->dev, rate, AuUnlimitedSamples, 0, NULL); - AuSetElements(priv->aud, priv->flow, AuTrue, sizeof(elms)/sizeof(*elms), elms, &as); - if (as != AuSuccess) { - nas_print_error(priv->aud, "init(): AuSetElements", as); - AuCloseServer(priv->aud); - priv->aud = 0; - return 0; - } - AuRegisterEventHandler(priv->aud, AuEventHandlerIDMask | + AuSetElements(priv->aud, priv->flow, AuTrue, sizeof(elms)/sizeof(*elms), elms, &as); + if (as != AuSuccess) { + nas_print_error(priv->aud, "init(): AuSetElements", as); + AuCloseServer(priv->aud); + priv->aud = 0; + return MPXP_False; + } + AuRegisterEventHandler(priv->aud, AuEventHandlerIDMask | AuEventHandlerTypeMask, AuEventTypeElementNotify, priv->flow, nas_event_handler, (AuPointer) priv); - AuSetErrorHandler(priv->aud, nas_error_handler); - priv->state=AuStateStop; - priv->expect_underrun=0; + AuSetErrorHandler(priv->aud, nas_error_handler); + priv->state=AuStateStop; + priv->expect_underrun=0; - pthread_mutex_init(&priv->buffer_mutex, NULL); - pthread_create(&priv->event_thread, NULL, &nas_event_thread_start, priv); + pthread_mutex_init(&priv->buffer_mutex, NULL); + pthread_create(&priv->event_thread, NULL, &nas_event_thread_start, priv); - return 1; + return MPXP_Ok; } // close audio device static void uninit(ao_data_t* ao){ priv_t* priv=ao->priv; - MSG_DBG3("ao_nas: uninit()\n"); + MSG_DBG3("ao_nas: uninit()\n"); - priv->expect_underrun = 1; - while (priv->state != AuStateStop) usleep(1000); - priv->stop_thread = 1; - pthread_join(priv->event_thread, NULL); - AuCloseServer(priv->aud); - priv->aud = 0; - mp_free(priv->client_buffer); - mp_free(priv->server_buffer); + priv->expect_underrun = 1; + while (priv->state != AuStateStop) usleep(1000); + priv->stop_thread = 1; + pthread_join(priv->event_thread, NULL); + AuCloseServer(priv->aud); + priv->aud = 0; + mp_free(priv->client_buffer); + mp_free(priv->server_buffer); mp_free(priv); } Modified: mplayerxp/libao2/ao_null.c =================================================================== --- mplayerxp/libao2/ao_null.c 2012-11-09 12:29:58 UTC (rev 311) +++ mplayerxp/libao2/ao_null.c 2012-11-09 14:04:48 UTC (rev 312) @@ -106,7 +106,7 @@ // open & setup audio device // return: 1=success 0=fail -static int __FASTCALL__ init(ao_data_t* ao,unsigned flags){ +static MPXP_Rc __FASTCALL__ init(ao_data_t* ao,unsigned flags){ ao->priv=mp_mallocz(sizeof(priv_t)); priv_t*priv = (priv_t*)ao->priv; char *null_dev=NULL,*mode=NULL; @@ -118,10 +118,10 @@ //if(priv->fd) priv->fast_mode=1; if(strcmp(mode,"wav")==0) priv->wav_mode=1; } //end parsing ao->subdevice - return 1; + return MPXP_Ok; } -static int __FASTCALL__ configure(ao_data_t* ao,unsigned rate,unsigned channels,unsigned format){ +static MPXP_Rc __FASTCALL__ configure(ao_data_t* ao,unsigned rate,unsigned channels,unsigned format){ priv_t*priv = (priv_t*)ao->priv; unsigned bits; ao->buffersize= 0xFFFFF; @@ -173,7 +173,7 @@ fwrite(&wavhdr,sizeof(wavhdr),1,priv->fd); wavhdr.file_length=wavhdr.data_length=0; } - return 1; + return MPXP_Ok; } // close audio device Modified: mplayerxp/libao2/ao_openal.c =================================================================== --- mplayerxp/libao2/ao_openal.c 2012-11-09 12:29:58 UTC (rev 311) +++ mplayerxp/libao2/ao_openal.c 2012-11-09 14:04:48 UTC (rev 312) @@ -91,34 +91,34 @@ ); } #endif -static int init(ao_data_t* ao,unsigned flags) +static MPXP_Rc init(ao_data_t* ao,unsigned flags) { ao->priv=mp_mallocz(sizeof(priv_t)); priv_t*priv=ao->priv; - UNUSED(flags); - priv->alc_dev = alcOpenDevice(NULL); - if (!priv->alc_dev) { - MSG_ERR("[OpenAL] could not open device\n"); - return 0; - } - return 1; + UNUSED(flags); + priv->alc_dev = alcOpenDevice(NULL); + if (!priv->alc_dev) { + MSG_ERR("[OpenAL] could not open device\n"); + return MPXP_False; + } + return MPXP_Ok; } -static int configure(ao_data_t* ao,unsigned rate, unsigned channels, unsigned format) +static MPXP_Rc configure(ao_data_t* ao,unsigned rate, unsigned channels, unsigned format) { priv_t*priv=ao->priv; - ALCcontext *ctx = NULL; - float position[3] = {0, 0, 0}; - float direction[6] = {0, 0, 1, 0, -1, 0}; - float sppos[MAX_CHANS][3] = { - {-1, 0, 0.5}, {1, 0, 0.5}, - {-1, 0, -1}, {1, 0, -1}, - {0, 0, 1}, {0, 0, 0.1}, - {-1, 0, 0}, {1, 0, 0}, - }; - ALCint freq = 0; - ALCint attribs[] = {ALC_FREQUENCY, rate, 0, 0}; - unsigned i; + ALCcontext *ctx = NULL; + float position[3] = {0, 0, 0}; + float direction[6] = {0, 0, 1, 0, -1, 0}; + float sppos[MAX_CHANS][3] = { + {-1, 0, 0.5}, {1, 0, 0.5}, + {-1, 0, -1}, {1, 0, -1}, + {0, 0, 1}, {0, 0, 0.1}, + {-1, 0, 0}, {1, 0, 0}, + }; + ALCint freq = 0; + ALCint attribs[] = {ALC_FREQUENCY, rate, 0, 0}; + unsigned i; /* const opt_t subopts[] = { {NULL} @@ -128,39 +128,38 @@ return 0; } */ - UNUSED(format); - if (channels > MAX_CHANS) { - MSG_ERR("[OpenAL] Invalid number of channels: %i\n", channels); - goto err_out; - } - ctx = alcCreateContext(priv->alc_dev, attribs); - alcMakeContextCurrent(ctx); - alListenerfv(AL_POSITION, position); - alListenerfv(AL_ORIENTATION, direction); - alGenSources(channels, priv->sources); - for (i = 0; i < channels; i++) { - priv->cur_buf[i] = 0; - priv->unqueue_buf[i] = 0; - alGenBuffers(NUM_BUF, priv->buffers[i]); - alSourcefv(priv->sources[i], AL_POSITION, sppos[i]); - alSource3f(priv->sources[i], AL_VELOCITY, 0, 0, 0); - } - if (channels == 1) - alSource3f(priv->sources[0], AL_POSITION, 0, 0, 1); - ao->channels = channels; - alcGetIntegerv(priv->alc_dev, ALC_FREQUENCY, 1, &freq); - if (alcGetError(priv->alc_dev) == ALC_NO_ERROR && freq) - rate = freq; - ao->samplerate = rate; - ao->format = AFMT_S16_NE; - ao->bps = channels * rate * 2; - ao->buffersize = CHUNK_SIZE * NUM_BUF; - ao->outburst = channels * CHUNK_SIZE; - priv->tmpbuf = mp_malloc(CHUNK_SIZE); - return 1; - + UNUSED(format); + if (channels > MAX_CHANS) { + MSG_ERR("[OpenAL] Invalid number of channels: %i\n", channels); + goto err_out; + } + ctx = alcCreateContext(priv->alc_dev, attribs); + alcMakeContextCurrent(ctx); + alListenerfv(AL_POSITION, position); + alListenerfv(AL_ORIENTATION, direction); + alGenSources(channels, priv->sources); + for (i = 0; i < channels; i++) { + priv->cur_buf[i] = 0; + priv->unqueue_buf[i] = 0; + alGenBuffers(NUM_BUF, priv->buffers[i]); + alSourcefv(priv->sources[i], AL_POSITION, sppos[i]); + alSource3f(priv->sources[i], AL_VELOCITY, 0, 0, 0); + } + if (channels == 1) + alSource3f(priv->sources[0], AL_POSITION, 0, 0, 1); + ao->channels = channels; + alcGetIntegerv(priv->alc_dev, ALC_FREQUENCY, 1, &freq); + if (alcGetError(priv->alc_dev) == ALC_NO_ERROR && freq) + rate = freq; + ao->samplerate = rate; + ao->format = AFMT_S16_NE; + ao->bps = channels * rate * 2; + ao->buffersize = CHUNK_SIZE * NUM_BUF; + ao->outburst = channels * CHUNK_SIZE; + priv->tmpbuf = mp_malloc(CHUNK_SIZE); + return MPXP_Ok; err_out: - return 0; + return MPXP_False; } // close audio device Modified: mplayerxp/libao2/ao_oss.c =================================================================== --- mplayerxp/libao2/ao_oss.c 2012-11-09 12:29:58 UTC (rev 311) +++ mplayerxp/libao2/ao_oss.c 2012-11-09 14:04:48 UTC (rev 312) @@ -196,157 +196,149 @@ } // open & setup audio device // return: 1=success 0=fail -static int __FASTCALL__ init(ao_data_t* ao,unsigned flags){ - char *mixer_channels [SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES; - UNUSED(flags); - ao->priv=mp_mallocz(sizeof(priv_t)); - priv_t*priv=ao->priv; - priv->dsp=PATH_DEV_DSP; - priv->mixer_channel=SOUND_MIXER_PCM; - priv->fd=-1; - priv->delay_method=2; - if (ao->subdevice) - { - char *p; - p=strrchr(ao->subdevice,':'); - priv->dsp = ao->subdevice; - if(p) { *p=0; p++; if(strcmp(p,"-1")==0) { show_caps(ao); return 0; } } - } +static MPXP_Rc __FASTCALL__ init(ao_data_t* ao,unsigned flags){ + char *mixer_channels [SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES; + UNUSED(flags); + ao->priv=mp_mallocz(sizeof(priv_t)); + priv_t*priv=ao->priv; + priv->dsp=PATH_DEV_DSP; + priv->mixer_channel=SOUND_MIXER_PCM; + priv->fd=-1; + priv->delay_method=2; + if (ao->subdevice) { + char *p; + p=strrchr(ao->subdevice,':'); + priv->dsp = ao->subdevice; + if(p) { *p=0; p++; if(strcmp(p,"-1")==0) { show_caps(ao); return MPXP_False; } } + } - MSG_V("audio_setup: using '%s' priv->dsp device\n", priv->dsp); - MSG_V("audio_setup: using '%s'(%s) mixer device\n", oss_mixer_device,mixer_channels[priv->mixer_channel]); + MSG_V("audio_setup: using '%s' priv->dsp device\n", priv->dsp); + MSG_V("audio_setup: using '%s'(%s) mixer device\n", oss_mixer_device,mixer_channels[priv->mixer_channel]); #ifdef __linux__ - priv->fd=open(priv->dsp, O_WRONLY | O_NONBLOCK); + priv->fd=open(priv->dsp, O_WRONLY | O_NONBLOCK); #else - priv->fd=open(priv->dsp, O_WRONLY); + priv->fd=open(priv->dsp, O_WRONLY); #endif - if(priv->fd<0){ - MSG_ERR("Can't open audio device %s: %s\n", priv->dsp, strerror(errno)); - return 0; - } + if(priv->fd<0){ + MSG_ERR("Can't open audio device %s: %s\n", priv->dsp, strerror(errno)); + return MPXP_False; + } #ifdef __linux__ /* Remove the non-blocking flag */ - if(fcntl(priv->fd, F_SETFL, 0) < 0) { - MSG_ERR("Can't make filedescriptor non-blocking: %s\n", strerror(errno)); - return 0; - } + if(fcntl(priv->fd, F_SETFL, 0) < 0) { + MSG_ERR("Can't make filedescriptor non-blocking: %s\n", strerror(errno)); + return MPXP_False; + } #endif #if defined(FD_CLOEXEC) && defined(F_SETFD) - fcntl(priv->fd, F_SETFD, FD_CLOEXEC); + fcntl(priv->fd, F_SETFD, FD_CLOEXEC); #endif - return 1; + return MPXP_Ok; } -static int __FASTCALL__ configure(ao_data_t* ao,unsigned rate,unsigned channels,unsigned format) +static MPXP_Rc __FASTCALL__ configure(ao_data_t* ao,unsigned rate,unsigned channels,unsigned format) { priv_t*priv=ao->priv; MSG_V("ao2: %d Hz %d chans %s\n",rate,channels, ao_format_name(format)); - if(format == AFMT_AC3) { - ao->samplerate=rate; - ioctl (priv->fd, SNDCTL_DSP_SPEED, &ao->samplerate); - } + if(format == AFMT_AC3) { + ao->samplerate=rate; + ioctl (priv->fd, SNDCTL_DSP_SPEED, &ao->samplerate); + } ac3_retry: - ao->format=format; - if( ioctl(priv->fd, SNDCTL_DSP_SETFMT, &ao->format)<0 || - ao->format != format) - { - if(format == AFMT_AC3){ - MSG_WARN("OSS-CONF: Can't set audio device %s to AC3 output, trying S16...\n", priv->dsp); + ao->format=format; + if( ioctl(priv->fd, SNDCTL_DSP_SETFMT, &ao->format)<0 || ao->format != format) { + if(format == AFMT_AC3){ + MSG_WARN("OSS-CONF: Can't set audio device %s to AC3 output, trying S16...\n", priv->dsp); #ifdef WORDS_BIGENDIAN - format=AFMT_S16_BE; + format=AFMT_S16_BE; #else - format=AFMT_S16_LE; + format=AFMT_S16_LE; #endif - goto ac3_retry; - } - else - { - MSG_ERR("OSS-CONF: Can't configure for: %s\n",ao_format_name(format)); - show_fmts(ao); - ao->format=format; - return 0; - } - } - ao->channels = channels; - if(format != AFMT_AC3) { - // We only use SNDCTL_DSP_CHANNELS for >2 channels, in case some drivers don't have it - if (ao->channels > 2) { - if ( ioctl(priv->fd, SNDCTL_DSP_CHANNELS, &ao->channels) == -1 || - ao->channels != channels ) { - MSG_ERR("OSS-CONF: Failed to set audio device to %d channels\n", channels); - return 0; - } + goto ac3_retry; + } else { + MSG_ERR("OSS-CONF: Can't configure for: %s\n",ao_format_name(format)); + show_fmts(ao); + ao->format=format; + return MPXP_False; + } } - else { - int c = ao->channels-1; - if (ioctl (priv->fd, SNDCTL_DSP_STEREO, &c) == -1) { - MSG_ERR("OSS-CONF: Failed to set audio device to %d channels\n", ao->channels); - return 0; - } - ao->channels=c+1; + ao->channels = channels; + if(format != AFMT_AC3) { + // We only use SNDCTL_DSP_CHANNELS for >2 channels, in case some drivers don't have it + if (ao->channels > 2) { + if ( ioctl(priv->fd, SNDCTL_DSP_CHANNELS, &ao->channels) == -1 || ao->channels != channels ) { + MSG_ERR("OSS-CONF: Failed to set audio device to %d channels\n", channels); + return MPXP_False; + } + } else { + int c = ao->channels-1; + if (ioctl (priv->fd, SNDCTL_DSP_STEREO, &c) == -1) { + MSG_ERR("OSS-CONF: Failed to set audio device to %d channels\n", ao->channels); + return MPXP_False; + } + ao->channels=c+1; + } + MSG_V("OSS-CONF: using %d channels (requested: %d)\n", ao->channels, channels); + // set rate + ao->samplerate=rate; + ioctl (priv->fd, SNDCTL_DSP_SPEED, &ao->samplerate); + MSG_V("OSS-CONF: using %d Hz samplerate (requested: %d)\n",ao->samplerate,rate); } - MSG_V("OSS-CONF: using %d channels (requested: %d)\n", ao->channels, channels); - // set rate - ao->samplerate=rate; - ioctl (priv->fd, SNDCTL_DSP_SPEED, &ao->samplerate); - MSG_V("OSS-CONF: using %d Hz samplerate (requested: %d)\n",ao->samplerate,rate); - } - if(ioctl(priv->fd, SNDCTL_DSP_GETOSPACE, &priv->zz)==-1){ - int r=0; - MSG_WARN("OSS-CONF: driver doesn't support SNDCTL_DSP_GETOSPACE :-(\n"); - if(ioctl(priv->fd, SNDCTL_DSP_GETBLKSIZE, &r)==-1){ - MSG_V("OSS-CONF: %d bytes/frag (mp_config.h)\n",ao->outburst); - } else { - ao->outburst=r; - MSG_V("OSS-CONF: %d bytes/frag (GETBLKSIZE)\n",ao->outburst); - } - } else { - MSG_V("OSS-CONF: frags: %3d/%d (%d bytes/frag) mp_free: %6d\n", - priv->zz.fragments, priv->zz.fragstotal, priv->zz.fragsize, priv->zz.bytes); - if(ao->buffersize==0) ao->buffersize=priv->zz.bytes; - ao->outburst=priv->zz.fragsize; - } - - if(ao->buffersize==0){ - // Measuring buffer size: - any_t* data; - ao->buffersize=0; -#ifdef HAVE_AUDIO_SELECT - data=mp_mallocz(ao->outburst); - while(ao->buffersize<0x40000){ - fd_set rfds; - struct timeval tv; - FD_ZERO(&rfds); FD_SET(priv->fd,&rfds); - tv.tv_sec=0; tv.tv_usec = 0; - if(!select(priv->fd+1, NULL, &rfds, NULL, &tv)) break; - write(priv->fd,data,ao->outburst); - ao->buffersize+=ao->outburst; + if(ioctl(priv->fd, SNDCTL_DSP_GETOSPACE, &priv->zz)==-1){ + int r=0; + MSG_WARN("OSS-CONF: driver doesn't support SNDCTL_DSP_GETOSPACE :-(\n"); + if(ioctl(priv->fd, SNDCTL_DSP_GETBLKSIZE, &r)==-1){ + MSG_V("OSS-CONF: %d bytes/frag (mp_config.h)\n",ao->outburst); + } else { + ao->outburst=r; + MSG_V("OSS-CONF: %d bytes/frag (GETBLKSIZE)\n",ao->outburst); + } + } else { + MSG_V("OSS-CONF: frags: %3d/%d (%d bytes/frag) mp_free: %6d\n", + priv->zz.fragments, priv->zz.fragstotal, priv->zz.fragsize, priv->zz.bytes); + if(ao->buffersize==0) ao->buffersize=priv->zz.bytes; + ao->outburst=priv->zz.fragsize; } - mp_free(data); + if(ao->buffersize==0){ - MSG_ERR("\n *** OSS-CONF: Your audio driver DOES NOT support select() ***\n" - "Recompile mplayerxp with #undef HAVE_AUDIO_SELECT in mp_config.h !\n\n"); - return 0; - } + // Measuring buffer size: + any_t* data; + ao->buffersize=0; +#ifdef HAVE_AUDIO_SELECT + data=mp_mallocz(ao->outburst); + while(ao->buffersize<0x40000) { + fd_set rfds; + struct timeval tv; + FD_ZERO(&rfds); FD_SET(priv->fd,&rfds); + tv.tv_sec=0; tv.tv_usec = 0; + if(!select(priv->fd+1, NULL, &rfds, NULL, &tv)) break; + write(priv->fd,data,ao->outburst); + ao->buffersize+=ao->outburst; + } + mp_free(data); + if(ao->buffersize==0){ + MSG_ERR("\n *** OSS-CONF: Your audio driver DOES NOT support select() ***\n" + "Recompile mplayerxp with #undef HAVE_AUDIO_SELECT in mp_config.h !\n\n"); + return MPXP_False; + } #endif - } + } - ao->bps=ao->channels; - if(ao->format != AFMT_U8 && ao->format != AFMT_S8) - ao->bps*=2; + ao->bps=ao->channels; + if(ao->format != AFMT_U8 && ao->format != AFMT_S8) ao->bps*=2; - ao->outburst-=ao->outburst % ao->bps; // round down - ao->bps*=ao->samplerate; + ao->outburst-=ao->outburst % ao->bps; // round down + ao->bps*=ao->samplerate; - return 1; + return MPXP_Ok; } // close audio device Modified: mplayerxp/libao2/ao_sdl.c =================================================================== --- mplayerxp/libao2/ao_sdl.c 2012-11-09 12:29:58 UTC (rev 311) +++ mplayerxp/libao2/ao_sdl.c 2012-11-09 14:04:48 UTC (rev 312) @@ -142,131 +142,131 @@ // open & setup audio device // return: 1=success 0=fail -static int __FASTCALL__ init(ao_data_t* ao,unsigned flags) +static MPXP_Rc __FASTCALL__ init(ao_data_t* ao,unsigned flags) { - unsigned i; - UNUSED(flags); - ao->priv=mp_mallocz(sizeof(priv_t)); - priv_t*priv=ao->priv; - priv->volume=127; - /* Allocate ring-priv->buffer memory */ - for(i=0;i<NUM_BUFS;i++) priv->buffer[i]=(unsigned char *) mp_malloc(BUFFSIZE); + unsigned i; + UNUSED(flags); + ao->priv=mp_mallocz(sizeof(priv_t)); + priv_t*priv=ao->priv; + priv->volume=127; + /* Allocate ring-priv->buffer memory */ + for(i=0;i<NUM_BUFS;i++) priv->buffer[i]=(unsigned char *) mp_malloc(BUFFSIZE); - if(ao->subdevice) { - setenv("SDL_AUDIODRIVER", ao->subdevice, 1); - } - return 1; + if(ao->subdevice) { + setenv("SDL_AUDIODRIVER", ao->subdevice, 1); + } + return MPXP_Ok; } -static int __FASTCALL__ configure(ao_data_t* ao,unsigned rate,unsigned channels,unsigned format) +static MPXP_Rc __FASTCALL__ configure(ao_data_t* ao,unsigned rate,unsigned channels,unsigned format) { - /* SDL Audio Specifications */ - SDL_AudioSpec aspec, obtained; - char drv_name[80]; + /* SDL Audio Specifications */ + SDL_AudioSpec aspec, obtained; + char drv_name[80]; - ao->channels=channels; - ao->samplerate=rate; - ao->format=format; + ao->channels=channels; + ao->samplerate=rate; + ao->format=format; - ao->bps=channels*rate; - if(format != AFMT_U8 && format != AFMT_S8) - ao->bps*=2; - - /* The desired audio format (see SDL_AudioSpec) */ - switch(format) { - case AFMT_U8: - aspec.format = AUDIO_U8; + ao->bps=channels*rate; + if(format != AFMT_U8 && format != AFMT_S8) + ao->bps*=2; + + /* The desired audio format (see SDL_AudioSpec) */ + switch(format) { + case AFMT_U8: + aspec.format = AUDIO_U8; break; - case AFMT_S16_LE: - aspec.format = AUDIO_S16LSB; + case AFMT_S16_LE: + aspec.format = AUDIO_S16LSB; break; - case AFMT_S16_BE: - aspec.format = AUDIO_S16MSB; + case AFMT_S16_BE: + aspec.format = AUDIO_S16MSB; break; - case AFMT_S8: - aspec.format = AUDIO_S8; + case AFMT_S8: + aspec.format = AUDIO_S8; break; - case AFMT_U16_LE: - aspec.format = AUDIO_U16LSB; + case AFMT_U16_LE: + aspec.format = AUDIO_U16LSB; break; - case AFMT_U16_BE: - aspec.format = AUDIO_U16MSB; + case AFMT_U16_BE: + aspec.format = AUDIO_U16MSB; break; - default: - MSG_ERR("SDL: Unsupported audio format: 0x%x.\n", format); - return 0; - } + default: + MSG_ERR("SDL: Unsupported audio format: 0x%x.\n", format); + return MPXP_False; + } - /* The desired audio frequency in samples-per-second. */ - aspec.freq = rate; + /* The desired audio frequency in samples-per-second. */ + aspec.freq = rate; - /* Number of channels (mono/stereo) */ - aspec.channels = channels; + /* Number of channels (mono/stereo) */ + aspec.channels = channels; - /* The desired size of the audio priv->buffer in samples. This number should be a power of two, and may be adjusted by the audio driver to a value more suitable for the hardware. Good values seem to range between 512 and 8192 inclusive, depending on the application and CPU speed. Smaller values yield faster response time, but can lead to underflow if the application is doing heavy processing and cannot fill the audio priv->buffer in time. A stereo sample consists of both right and left channels in LR ordering. Note that the number of samples is directly related to time by the following formula: ms = (samples*1000)/freq */ - aspec.samples = SAMPLESIZE; + /* The desired size of the audio priv->buffer in samples. This number should be a power of two, and may be adjusted by the audio driver to a value more suitable for the hardware. Good values seem to range between 512 and 8192 inclusive, depending on the application and CPU speed. Smaller values yield faster response time, but can lead to underflow if the application is doing heavy processing and cannot fill the audio priv->buffer in time. A stereo sample consists of both right and left channels in LR ordering. Note that the number of samples is directly related to time by the following formula: ms = (samples*1000)/freq */ + aspec.samples = SAMPLESIZE; - /* This should be set to a function that will be called when the audio device is ready for more data. It is passed a pointer to the audio priv->buffer, and the length in bytes of the audio priv->buffer. This function usually runs in a separate thread, and so you should protect data structures that it accesses by calling SDL_LockAudio and SDL_UnlockAudio in your code. The callback prototype is: -void callback(any_t*userdata, Uint8 *stream, int len); userdata is the pointer stored in userdata field of the SDL_AudioSpec. stream is a pointer to the audio priv->buffer you want to fill with information and len is the length of the audio priv->buffer in bytes. */ - aspec.callback = outputaudio; + /* This should be set to a function that will be called when the audio device is ready for more data. It is passed a pointer to the audio priv->buffer, and the length in bytes of the audio priv->buffer. This function usually runs in a separate thread, and so you should protect data structures that it accesses by calling SDL_LockAudio and SDL_UnlockAudio in your code. The callback prototype is: + void callback(any_t*userdata, Uint8 *stream, int len); userdata is the pointer stored in userdata field of the SDL_AudioSpec. stream is a pointer to the audio priv->buffer you want to fill with information and len is the length of the audio priv->buffer in bytes. */ + aspec.callback = outputaudio; - /* This pointer is passed as the first parameter to the callback function. */ - aspec.userdata = ao; + /* This pointer is passed as the first parameter to the callback function. */ + aspec.userdata = ao; - /* initialize the SDL Audio system */ - if (SDL_Init (SDL_INIT_AUDIO/*|SDL_INIT_NOPARACHUTE*/)) { - MSG_ERR("SDL: Initializing of SDL Audio failed: %s.\n", SDL_GetError()); - return 0; - } + /* initialize the SDL Audio system */ + if (SDL_Init (SDL_INIT_AUDIO/*|SDL_INIT_NOPARACHUTE*/)) { + MSG_ERR("SDL: Initializing of SDL Audio failed: %s.\n", SDL_GetError()); + return MPXP_False; + } - /* Open the audio device and start playing sound! */ - if(SDL_OpenAudio(&aspec, &obtained) < 0) { - MSG_ERR("SDL: Unable to open audio: %s\n", SDL_GetError()); - return(0); - } - - /* did we got what we wanted ? */ - ao->channels=obtained.channels; - ao->samplerate=obtained.freq; + /* Open the audio device and start playing sound! */ + if(SDL_OpenAudio(&aspec, &obtained) < 0) { + MSG_ERR("SDL: Unable to open audio: %s\n", SDL_GetError()); + return MPXP_False; + } - switch(obtained.format) { - case AUDIO_U8 : - ao->format = AFMT_U8; + /* did we got what we wanted ? */ + ao->channels=obtained.channels; + ao->samplerate=obtained.freq; + + switch(obtained.format) { + case AUDIO_U8 : + ao->format = AFMT_U8; break; - case AUDIO_S16LSB : - ao->format = AFMT_S16_LE; + case AUDIO_S16LSB : + ao->format = AFMT_S16_LE; break; - case AUDIO_S16MSB : - ao->format = AFMT_S16_BE; + case AUDIO_S16MSB : + ao->format = AFMT_S16_BE; break; - case AUDIO_S8 : - ao->format = AFMT_S8; + case AUDIO_S8 : + ao->format = AFMT_S8; break; - case AUDIO_U16LSB : - ao->format = AFMT_U16_LE; + case AUDIO_U16LSB : + ao->format = AFMT_U16_LE; break; - case AUDIO_U16MSB : - ao->format = AFMT_U16_BE; + case AUDIO_U16MSB : + ao->format = AFMT_U16_BE; break; - default: - MSG_WARN("SDL: Unsupported SDL audio format: 0x%x.\n", obtained.format); - return 0; - } + default: + MSG_WARN("SDL: Unsupported SDL audio format: 0x%x.\n", obtained.format); + return MPXP_False; + } - MSG_V("SDL: buf size = %d\n",aspec.size); - ao->buffersize=obtained.size; + MSG_V("SDL: buf size = %d\n",aspec.size); + ao->buffersize=obtained.size; - SDL_AudioDriverName(drv_name, sizeof(drv_name)); - MSG_OK("SDL: using %s audio driver (%iHz %s \"%s\")\n" + SDL_AudioDriverName(drv_name, sizeof(drv_name)); + MSG_OK("SDL: using %s audio driver (%iHz %s \"%s\")\n" ,drv_name ,rate ,channels>4?"Surround":channels>2?"Quadro":channels>1?"Stereo":"Mono" ,ao_format_name(format)); - /* unsilence audio, if callback is ready */ - SDL_PauseAudio(0); + /* unsilence audio, if callback is ready */ + SDL_PauseAudio(0); - return 1; + return MPXP_Ok; } // close audio device Modified: mplayerxp/libao2/ao_wav.c =================================================================== --- mplayerxp/libao2/ao_wav.c 2012-11-09 12:29:58 UTC (rev 311) +++ mplayerxp/libao2/ao_wav.c 2012-11-09 14:04:48 UTC (rev 312) @@ -96,16 +96,16 @@ // open & setup audio device // return: 1=success 0=fail -static int init(ao_data_t* ao,unsigned flags) { +static MPXP_Rc init(ao_data_t* ao,unsigned flags) { // set defaults UNUSED(flags); ao->priv=mp_mallocz(sizeof(priv_t)); priv_t* priv=ao->priv; priv->pcm_waveheader=1; - return 1; + return MPXP_Ok; } -static int configure(ao_data_t* ao,unsigned rate,unsigned channels,unsigned format){ +static MPXP_Rc configure(ao_data_t* ao,unsigned rate,unsigned channels,unsigned format){ priv_t* priv=ao->priv; unsigned bits; char str[256]; @@ -169,10 +169,10 @@ if(priv->pcm_waveheader){ /* Reserve space for wave header */ fwrite(&priv->wavhdr,sizeof(priv->wavhdr),1,priv->fp); } - return 1; + return MPXP_Ok; } MSG_ERR("ao_wav: can't open output file: %s\n", priv->out_filename); - return 0; + return MPXP_False; } // close audio device Mo... [truncated message content] |