Codebase list squeezelite / e30e37b
Portaudio options - add ability to force playnice mode on osx, fix parsing of device id 0 Adrian Smith 10 years ago
3 changed file(s) with 21 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
3333 " -a <b>:<p>:<f>:<m>\tSpecify ALSA params to open output device, b = buffer time in ms or size in bytes, p = period count or size in bytes, f sample format (16|24|24_3|32), m = use mmap (0|1)\n"
3434 #endif
3535 #if PORTAUDIO
36 " -a <latency>\t\tSpecify output target latency in ms\n"
36 #if MAC
37 " -a <l>:<r>\t\tSpecify Portaudio params to open output device, l = target latency in ms, r = allow OSX to resample (0|1)\n"
38 #else
39 " -a <l>\t\tSpecify Portaudio params to open output device, l = target latency in ms\n"
40 #endif
3741 #endif
3842 " -b <stream>:<output>\tSpecify internal Stream and Output buffer sizes in Kbytes\n"
3943 " -c <codec1>,<codec2>\tRestrict codecs to those specified, otherwise load all available codecs; known codecs: flac,pcm,mp3,ogg,aac (mad,mpg for specific mp3 codec)\n"
108112 #endif
109113 #if PORTAUDIO
110114 unsigned pa_latency = 0;
115 int pa_osx_playnice = -1;
111116 #endif
112117
113118 log_level log_output = lWARN;
154159 if (m) alsa_mmap = atoi(m);
155160 #endif
156161 #if PORTAUDIO
157 pa_latency = (unsigned)atoi(optarg);
162 char *l = next_param(optarg, ':');
163 char *p = next_param(NULL, ':');
164 if (l) pa_latency = (unsigned)atoi(l);
165 if (p) pa_osx_playnice = atoi(p);
158166 #endif
159167 }
160168 break;
288296 max_rate, rt_priority);
289297 #endif
290298 #if PORTAUDIO
291 output_init(log_output, output_device, output_buf_size, pa_latency, max_rate);
299 output_init(log_output, output_device, output_buf_size, pa_latency, pa_osx_playnice, max_rate);
292300 #endif
293301
294302 decode_init(log_decode, codecs);
393393 if (!strncmp(device, "default", 7)) {
394394 return Pa_GetDefaultOutputDevice();
395395 }
396 if (len >= 1 && len <= 2 && device[0] > '0' && device[0] <= '9') {
396 if (len >= 1 && len <= 2 && device[0] >= '0' && device[0] <= '9') {
397397 return atoi(device);
398398 }
399399
511511 outputParameters.hostApiSpecificStreamInfo = NULL;
512512
513513 #if OSX
514 // enable pro mode which aims to avoid resampling if possible for non built in devices
515 // see http://code.google.com/p/squeezelite/issues/detail?id=11 for reason for not doing with built in device
514 // enable pro mode which aims to avoid resampling if possible
515 // see http://code.google.com/p/squeezelite/issues/detail?id=11 & http://code.google.com/p/squeezelite/issues/detail?id=37
516 // command line controls osx_playnice which is -1 if not specified, 0 or 1
516517 PaMacCoreStreamInfo macInfo;
517518 unsigned long streamInfoFlags;
518 if (!strcmp(Pa_GetDeviceInfo(outputParameters.device)->name, "Built-in Output")) {
519 if (output.osx_playnice == 1 ||
520 (output.osx_playnice == -1 && !strcmp(Pa_GetDeviceInfo(outputParameters.device)->name, "Built-in Output"))) {
519521 LOG_INFO("opening device in PlayNice mode");
520522 streamInfoFlags = paMacCorePlayNice;
521523 } else {
13281330 const char *alsa_sample_fmt, bool mmap, unsigned max_rate, unsigned rt_priority) {
13291331 #endif
13301332 #if PORTAUDIO
1331 void output_init(log_level level, const char *device, unsigned output_buf_size, unsigned latency, unsigned max_rate) {
1333 void output_init(log_level level, const char *device, unsigned output_buf_size, unsigned latency, int osx_playnice, unsigned max_rate) {
13321334 PaError err;
13331335 #endif
13341336 loglevel = level;
13751377
13761378 #if PORTAUDIO
13771379 output.latency = latency;
1380 output.osx_playnice = osx_playnice;
13781381 pa.stream = NULL;
13791382
13801383 LOG_INFO("requested latency: %u", output.latency);
433433 #if PORTAUDIO
434434 bool pa_reopen;
435435 unsigned latency;
436 int osx_playnice;
436437 #endif
437438 unsigned frames_played;
438439 unsigned current_sample_rate;
464465 void output_init(log_level level, const char *device, unsigned output_buf_size, unsigned alsa_buffer, unsigned alsa_period, const char *alsa_sample_fmt, bool mmap, unsigned max_rate, unsigned rt_priority);
465466 #endif
466467 #if PORTAUDIO
467 void output_init(log_level level, const char *device, unsigned output_buf_size, unsigned latency, unsigned max_rate);
468 void output_init(log_level level, const char *device, unsigned output_buf_size, unsigned latency, int osx_playnice, unsigned max_rate);
468469 #endif
469470 void output_flush(void);
470471 void output_close(void);