mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-01 22:58:47 -04:00
add support for querying sample ist with esound protocol
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@101 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
8705af792b
commit
e10b918009
5 changed files with 71 additions and 14 deletions
1
doc/todo
1
doc/todo
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
- enable searchdir
|
- enable searchdir
|
||||||
|
|
||||||
- scache memory leak
|
|
||||||
- scache remove()
|
- scache remove()
|
||||||
- scache in native protocol
|
- scache in native protocol
|
||||||
- scache/debug.h copyright
|
- scache/debug.h copyright
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@
|
||||||
|
|
||||||
|
|
||||||
# Load audio drivers
|
# Load audio drivers
|
||||||
load module-alsa-sink
|
#load module-alsa-sink
|
||||||
load module-alsa-source device=plughw:1,0
|
#load module-alsa-source device=plughw:1,0
|
||||||
#load module-oss device="/dev/dsp"
|
load module-oss device="/dev/dsp"
|
||||||
#load module-oss-mmap device="/dev/dsp"
|
#load module-oss-mmap device="/dev/dsp"
|
||||||
|
|
||||||
# Load several protocols
|
# Load several protocols
|
||||||
|
|
@ -30,12 +30,15 @@ load module-simple-protocol-tcp
|
||||||
load module-native-protocol-unix
|
load module-native-protocol-unix
|
||||||
load module-cli-protocol-unix
|
load module-cli-protocol-unix
|
||||||
|
|
||||||
|
# Load X11 bell module
|
||||||
|
load module-x11-bell
|
||||||
|
|
||||||
# Load the CLI module
|
# Load the CLI module
|
||||||
load module-cli
|
load module-cli
|
||||||
|
|
||||||
.nofail
|
.nofail
|
||||||
|
|
||||||
# Make some devices default
|
# Make some devices default
|
||||||
sink_default alsa_output
|
sink_default oss_output
|
||||||
source_default alsa_input
|
source_default oss_input
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
|
|
||||||
#define MAX_CACHE_SAMPLE_SIZE (1024000)
|
#define MAX_CACHE_SAMPLE_SIZE (1024000)
|
||||||
|
|
||||||
#define SCACHE_PREFIX "esound~"
|
#define SCACHE_PREFIX "esound."
|
||||||
|
|
||||||
/* This is heavily based on esound's code */
|
/* This is heavily based on esound's code */
|
||||||
|
|
||||||
|
|
@ -299,8 +299,10 @@ static int esd_proto_stream_play(struct connection *c, esd_proto_t request, cons
|
||||||
if (!pa_sample_spec_valid(&ss))
|
if (!pa_sample_spec_valid(&ss))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(sink = get_output_sink(c->protocol)))
|
if (!(sink = get_output_sink(c->protocol))) {
|
||||||
|
fprintf(stderr, __FILE__": No output sink\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
strncpy(name, data + sizeof(int)*2, sizeof(name));
|
strncpy(name, data + sizeof(int)*2, sizeof(name));
|
||||||
name[sizeof(name)-1] = 0;
|
name[sizeof(name)-1] = 0;
|
||||||
|
|
@ -438,6 +440,7 @@ static int esd_proto_all_info(struct connection *c, esd_proto_t request, const v
|
||||||
size_t t, k, s;
|
size_t t, k, s;
|
||||||
struct connection *conn;
|
struct connection *conn;
|
||||||
size_t index = PA_IDXSET_INVALID;
|
size_t index = PA_IDXSET_INVALID;
|
||||||
|
unsigned nsamples;
|
||||||
assert(c && data && length == sizeof(int));
|
assert(c && data && length == sizeof(int));
|
||||||
|
|
||||||
if (esd_proto_server_info(c, request, data, length) < 0)
|
if (esd_proto_server_info(c, request, data, length) < 0)
|
||||||
|
|
@ -445,7 +448,8 @@ static int esd_proto_all_info(struct connection *c, esd_proto_t request, const v
|
||||||
|
|
||||||
k = sizeof(int)*5+ESD_NAME_MAX;
|
k = sizeof(int)*5+ESD_NAME_MAX;
|
||||||
s = sizeof(int)*6+ESD_NAME_MAX;
|
s = sizeof(int)*6+ESD_NAME_MAX;
|
||||||
response = connection_write(c, (t = s+k*(c->protocol->n_player+1)));
|
nsamples = c->protocol->core->scache_idxset ? pa_idxset_ncontents(c->protocol->core->scache_idxset) : 0;
|
||||||
|
response = connection_write(c, (t = s*(nsamples+1) + k*(c->protocol->n_player+1)));
|
||||||
assert(k);
|
assert(k);
|
||||||
|
|
||||||
for (conn = pa_idxset_first(c->protocol->connections, &index); conn; conn = pa_idxset_next(c->protocol->connections, &index)) {
|
for (conn = pa_idxset_first(c->protocol->connections, &index); conn; conn = pa_idxset_next(c->protocol->connections, &index)) {
|
||||||
|
|
@ -463,7 +467,7 @@ static int esd_proto_all_info(struct connection *c, esd_proto_t request, const v
|
||||||
}
|
}
|
||||||
|
|
||||||
/* id */
|
/* id */
|
||||||
*((int*) response) = maybe_swap_endian_32(c->swap_byte_order, (int) conn->index);
|
*((int*) response) = maybe_swap_endian_32(c->swap_byte_order, (int) (conn->index+1));
|
||||||
response += sizeof(int);
|
response += sizeof(int);
|
||||||
|
|
||||||
/* name */
|
/* name */
|
||||||
|
|
@ -490,8 +494,56 @@ static int esd_proto_all_info(struct connection *c, esd_proto_t request, const v
|
||||||
t-= k;
|
t-= k;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(t == s+k);
|
assert(t == s*(nsamples+1)+k);
|
||||||
memset(response, 0, t);
|
memset(response, 0, k);
|
||||||
|
response += k;
|
||||||
|
t -= k;
|
||||||
|
|
||||||
|
if (nsamples) {
|
||||||
|
struct pa_scache_entry *ce;
|
||||||
|
|
||||||
|
index = PA_IDXSET_INVALID;
|
||||||
|
for (ce = pa_idxset_first(c->protocol->core->scache_idxset, &index); ce; ce = pa_idxset_next(c->protocol->core->scache_idxset, &index)) {
|
||||||
|
assert(t >= s*2);
|
||||||
|
|
||||||
|
/* id */
|
||||||
|
*((int*) response) = maybe_swap_endian_32(c->swap_byte_order, (int) (ce->index+1));
|
||||||
|
response += sizeof(int);
|
||||||
|
|
||||||
|
/* name */
|
||||||
|
if (strncmp(ce->name, SCACHE_PREFIX, sizeof(SCACHE_PREFIX)-1) == 0)
|
||||||
|
strncpy(response, ce->name+sizeof(SCACHE_PREFIX)-1, ESD_NAME_MAX);
|
||||||
|
else
|
||||||
|
snprintf(response, ESD_NAME_MAX, "native.%s", ce->name);
|
||||||
|
response += ESD_NAME_MAX;
|
||||||
|
|
||||||
|
/* rate */
|
||||||
|
*((int*) response) = maybe_swap_endian_32(c->swap_byte_order, ce->sample_spec.rate);
|
||||||
|
response += sizeof(int);
|
||||||
|
|
||||||
|
/* left */
|
||||||
|
*((int*) response) = maybe_swap_endian_32(c->swap_byte_order, (ce->volume*0xFF)/0x100);
|
||||||
|
response += sizeof(int);
|
||||||
|
|
||||||
|
/*right*/
|
||||||
|
*((int*) response) = maybe_swap_endian_32(c->swap_byte_order, (ce->volume*0xFF)/0x100);
|
||||||
|
response += sizeof(int);
|
||||||
|
|
||||||
|
/*format*/
|
||||||
|
*((int*) response) = maybe_swap_endian_32(c->swap_byte_order, format_native2esd(&ce->sample_spec));
|
||||||
|
response += sizeof(int);
|
||||||
|
|
||||||
|
/*length*/
|
||||||
|
*((int*) response) = maybe_swap_endian_32(c->swap_byte_order, (int) ce->memchunk.length);
|
||||||
|
response += sizeof(int);
|
||||||
|
|
||||||
|
t -= s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(t == s);
|
||||||
|
memset(response, 0, s);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -501,7 +553,7 @@ static int esd_proto_stream_pan(struct connection *c, esd_proto_t request, const
|
||||||
struct connection *conn;
|
struct connection *conn;
|
||||||
assert(c && data && length == sizeof(int)*3);
|
assert(c && data && length == sizeof(int)*3);
|
||||||
|
|
||||||
index = (uint32_t) maybe_swap_endian_32(c->swap_byte_order, *(int*)data);
|
index = (uint32_t) maybe_swap_endian_32(c->swap_byte_order, *(int*)data)-1;
|
||||||
volume = (uint32_t) maybe_swap_endian_32(c->swap_byte_order, *((int*)data + 1));
|
volume = (uint32_t) maybe_swap_endian_32(c->swap_byte_order, *((int*)data + 1));
|
||||||
volume = (volume*0x100)/0xFF;
|
volume = (volume*0x100)/0xFF;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ void pa_scache_add_item(struct pa_core *c, const char *name, struct pa_sample_sp
|
||||||
assert(e->name);
|
assert(e->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e->volume = 0x100;
|
||||||
|
|
||||||
if (ss)
|
if (ss)
|
||||||
e->sample_spec = *ss;
|
e->sample_spec = *ss;
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
struct pa_scache_entry {
|
struct pa_scache_entry {
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
char *name;
|
char *name;
|
||||||
|
uint32_t volume;
|
||||||
struct pa_sample_spec sample_spec;
|
struct pa_sample_spec sample_spec;
|
||||||
struct pa_memchunk memchunk;
|
struct pa_memchunk memchunk;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue