mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-10-29 05:40:23 -04:00 
			
		
		
		
	add user volume API
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@255 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									a6471e2602
								
							
						
					
					
						commit
						da45617efc
					
				
					 6 changed files with 45 additions and 2 deletions
				
			
		
							
								
								
									
										3
									
								
								doc/todo
									
										
									
									
									
								
							
							
						
						
									
										3
									
								
								doc/todo
									
										
									
									
									
								
							|  | @ -1,6 +1,7 @@ | ||||||
| *** $Id$ *** | *** $Id$ *** | ||||||
| 
 | 
 | ||||||
| *** 0.6 **** | *** 0.6 **** | ||||||
|  | - latency interpolation | ||||||
| - per-channel volume | - per-channel volume | ||||||
| - unix socket directories include user name | - unix socket directories include user name | ||||||
| - add sample directory | - add sample directory | ||||||
|  | @ -22,7 +23,7 @@ | ||||||
| 
 | 
 | ||||||
| backends for: | backends for: | ||||||
| - portaudio  (semi-done) | - portaudio  (semi-done) | ||||||
|  | - gstreamer (semi-done) | ||||||
| - alsa-lib | - alsa-lib | ||||||
| - sdl | - sdl | ||||||
| - gstreamer (semi-done) |  | ||||||
| - OSS (esddsp style) | - OSS (esddsp style) | ||||||
|  |  | ||||||
|  | @ -33,7 +33,7 @@ AM_LDADD=$(PTHREAD_LIBS) -lm | ||||||
| AM_LIBADD=$(PTHREAD_LIBS) -lm | AM_LIBADD=$(PTHREAD_LIBS) -lm | ||||||
| 
 | 
 | ||||||
| EXTRA_DIST = default.pa.in daemon.conf.in client.conf.in depmod.py esdcompat.sh.in | EXTRA_DIST = default.pa.in daemon.conf.in client.conf.in depmod.py esdcompat.sh.in | ||||||
| bin_PROGRAMS = polypaudio pacat pactl paplay | bin_PROGRAMS = polypaudio pacat pactl paplay voltest | ||||||
| bin_SCRIPTS = esdcompat.sh | bin_SCRIPTS = esdcompat.sh | ||||||
| noinst_PROGRAMS = \ | noinst_PROGRAMS = \ | ||||||
| 		mainloop-test \ | 		mainloop-test \ | ||||||
|  | @ -408,6 +408,10 @@ mainloop_test_SOURCES = mainloop-test.c | ||||||
| mainloop_test_CFLAGS = $(AM_CFLAGS) | mainloop_test_CFLAGS = $(AM_CFLAGS) | ||||||
| mainloop_test_LDADD = $(AM_LDADD) libpolyp-mainloop-@PA_MAJORMINOR@.la libpolyp-@PA_MAJORMINOR@.la | mainloop_test_LDADD = $(AM_LDADD) libpolyp-mainloop-@PA_MAJORMINOR@.la libpolyp-@PA_MAJORMINOR@.la | ||||||
| 
 | 
 | ||||||
|  | voltest_SOURCES = voltest.c sample.c | ||||||
|  | voltest_CFLAGS = $(AM_CFLAGS) | ||||||
|  | voltest_LDADD = $(AM_LDADD) | ||||||
|  | 
 | ||||||
| cpulimit_test_SOURCES = cpulimit-test.c cpulimit.c util.c log.c | cpulimit_test_SOURCES = cpulimit-test.c cpulimit.c util.c log.c | ||||||
| cpulimit_test_CFLAGS = $(AM_CFLAGS) | cpulimit_test_CFLAGS = $(AM_CFLAGS) | ||||||
| cpulimit_test_LDADD = $(AM_LDADD) libpolyp-mainloop-@PA_MAJORMINOR@.la | cpulimit_test_LDADD = $(AM_LDADD) libpolyp-mainloop-@PA_MAJORMINOR@.la | ||||||
|  |  | ||||||
|  | @ -27,6 +27,8 @@ | ||||||
| /** \file
 | /** \file
 | ||||||
|  * Define header version */ |  * Define header version */ | ||||||
| 
 | 
 | ||||||
|  | PA_C_DECL_BEGIN | ||||||
|  | 
 | ||||||
| /** Return the version of the header files. Keep in mind that this is
 | /** Return the version of the header files. Keep in mind that this is
 | ||||||
| a macro and not a function, so it is impossible to get the pointer of | a macro and not a function, so it is impossible to get the pointer of | ||||||
| it. */ | it. */ | ||||||
|  | @ -40,4 +42,6 @@ const char* pa_get_library_version(void); | ||||||
|  * PA_API_VERSION undefined.  */ |  * PA_API_VERSION undefined.  */ | ||||||
| #define PA_API_VERSION @PA_API_VERSION@ | #define PA_API_VERSION @PA_API_VERSION@ | ||||||
| 
 | 
 | ||||||
|  | PA_C_DECL_END | ||||||
|  | 
 | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -125,6 +125,22 @@ double pa_volume_to_dB(pa_volume_t v) { | ||||||
|     return 20*log10((double) v/PA_VOLUME_NORM); |     return 20*log10((double) v/PA_VOLUME_NORM); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #define USER_DECIBEL_RANGE 30 | ||||||
|  | 
 | ||||||
|  | double pa_volume_to_user(pa_volume_t v) { | ||||||
|  |     double dB = pa_volume_to_dB(v); | ||||||
|  | 
 | ||||||
|  |     return dB < -USER_DECIBEL_RANGE ? 0 : dB/USER_DECIBEL_RANGE+1; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | pa_volume_t pa_volume_from_user(double v) { | ||||||
|  | 
 | ||||||
|  |     if (v <= 0) | ||||||
|  |         return PA_VOLUME_MUTED; | ||||||
|  |      | ||||||
|  |     return pa_volume_from_dB((v-1)*USER_DECIBEL_RANGE); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void pa_bytes_snprint(char *s, size_t l, unsigned v) { | void pa_bytes_snprint(char *s, size_t l, unsigned v) { | ||||||
|     if (v >= ((unsigned) 1024)*1024*1024) |     if (v >= ((unsigned) 1024)*1024*1024) | ||||||
|         snprintf(s, l, "%0.1f GB", ((double) v)/1024/1024/1024); |         snprintf(s, l, "%0.1f GB", ((double) v)/1024/1024/1024); | ||||||
|  |  | ||||||
|  | @ -110,6 +110,12 @@ pa_volume_t pa_volume_from_dB(double f); | ||||||
| /** Convert volume from linear level to decibel.  \since 0.4 */ | /** Convert volume from linear level to decibel.  \since 0.4 */ | ||||||
| double pa_volume_to_dB(pa_volume_t v); | double pa_volume_to_dB(pa_volume_t v); | ||||||
| 
 | 
 | ||||||
|  | /** Convert volume to scaled value understandable by the user (between 0 and 1). \since 0.6 */ | ||||||
|  | double pa_volume_to_user(pa_volume_t v); | ||||||
|  | 
 | ||||||
|  | /** Convert user volume to polypaudio volume. \since 0.6 */ | ||||||
|  | pa_volume_t pa_volume_from_user(double v); | ||||||
|  | 
 | ||||||
| #ifdef INFINITY | #ifdef INFINITY | ||||||
| #define PA_DECIBEL_MININFTY (-INFINITY) | #define PA_DECIBEL_MININFTY (-INFINITY) | ||||||
| #else | #else | ||||||
|  |  | ||||||
							
								
								
									
										12
									
								
								polyp/voltest.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								polyp/voltest.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,12 @@ | ||||||
|  | #include <stdio.h> | ||||||
|  | 
 | ||||||
|  | #include <polyp/sample.h> | ||||||
|  | 
 | ||||||
|  | int main() { | ||||||
|  |     int p; | ||||||
|  |     for (p = 0; p <= 200; p++) { | ||||||
|  |         pa_volume_t v = pa_volume_from_user((double) p/100); | ||||||
|  |         double dB = pa_volume_to_dB(v); | ||||||
|  |         printf("%3i%% = %u = %0.2f dB = %u = %3i%%\n", p, v, dB, pa_volume_from_dB(dB), (int) (pa_volume_to_user(v)*100)); | ||||||
|  |     } | ||||||
|  | } | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lennart Poettering
						Lennart Poettering