return strdup(buffer);
}
-
-void profile_dump(const alsa_device_profile* profile, int fd)
-{
- if (profile == NULL) {
- dprintf(fd, " %s\n", "No USB Profile");
- return; /* bail early */
- }
-
- if (!profile->is_valid) {
- dprintf(fd, " Profile is INVALID");
- }
-
- /* card/device/direction */
- dprintf(fd, " card:%d, device:%d - %s\n",
- profile->card, profile->device, profile->direction == PCM_OUT ? "OUT" : "IN");
-
- /* formats */
- dprintf(fd, " Formats: ");
- for (int fmtIndex = 0;
- profile->formats[fmtIndex] != PCM_FORMAT_INVALID && fmtIndex < MAX_PROFILE_FORMATS;
- fmtIndex++) {
- dprintf(fd, "%d ", profile->formats[fmtIndex]);
- }
- dprintf(fd, "\n");
-
- /* sample rates */
- dprintf(fd, " Rates: ");
- for (int rateIndex = 0;
- profile->sample_rates[rateIndex] != 0 && rateIndex < MAX_PROFILE_SAMPLE_RATES;
- rateIndex++) {
- dprintf(fd, "%u ", profile->sample_rates[rateIndex]);
- }
- dprintf(fd, "\n");
-
- // channel counts
- dprintf(fd, " Channel Counts: ");
- for (int cntIndex = 0;
- profile->channel_counts[cntIndex] != 0 && cntIndex < MAX_PROFILE_CHANNEL_COUNTS;
- cntIndex++) {
- dprintf(fd, "%u ", profile->channel_counts[cntIndex]);
- }
- dprintf(fd, "\n");
-
- dprintf(fd, " min/max period size [%u : %u]\n",
- profile->min_period_size,profile-> max_period_size);
- dprintf(fd, " min/max channel count [%u : %u]\n",
- profile->min_channel_count, profile->max_channel_count);
-
- // struct pcm_config default_config;
- dprintf(fd, " Default Config:\n");
- dprintf(fd, " channels: %d\n", profile->default_config.channels);
- dprintf(fd, " rate: %d\n", profile->default_config.rate);
- dprintf(fd, " period_size: %d\n", profile->default_config.period_size);
- dprintf(fd, " period_count: %d\n", profile->default_config.period_count);
- dprintf(fd, " format: %d\n", profile->default_config.format);
-}
{
return pcm_read(proxy->pcm, data, count);
}
-
-/*
- * Debugging
- */
-void proxy_dump(const alsa_device_proxy* proxy, int fd)
-{
- if (proxy != NULL) {
- dprintf(fd, " channels: %d\n", proxy->alsa_config.channels);
- dprintf(fd, " rate: %d\n", proxy->alsa_config.rate);
- dprintf(fd, " period_size: %d\n", proxy->alsa_config.period_size);
- dprintf(fd, " period_count: %d\n", proxy->alsa_config.period_count);
- dprintf(fd, " format: %d\n", proxy->alsa_config.format);
- }
-}
uint64_t transferred; /* the total frames transferred, not cleared on standby */
} alsa_device_proxy;
-
-/* State */
void proxy_prepare(alsa_device_proxy * proxy, alsa_device_profile * profile,
struct pcm_config * config);
-int proxy_open(alsa_device_proxy * proxy);
-void proxy_close(alsa_device_proxy * proxy);
-int proxy_get_presentation_position(const alsa_device_proxy * proxy,
- uint64_t *frames, struct timespec *timestamp);
-/* Attributes */
unsigned proxy_get_sample_rate(const alsa_device_proxy * proxy);
enum pcm_format proxy_get_format(const alsa_device_proxy * proxy);
unsigned proxy_get_channel_count(const alsa_device_proxy * proxy);
+
unsigned int proxy_get_period_size(const alsa_device_proxy * proxy);
+
unsigned proxy_get_latency(const alsa_device_proxy * proxy);
-/* I/O */
+int proxy_get_presentation_position(const alsa_device_proxy * proxy,
+ uint64_t *frames, struct timespec *timestamp);
+
+int proxy_open(alsa_device_proxy * proxy);
+void proxy_close(alsa_device_proxy * proxy);
+
int proxy_write(alsa_device_proxy * proxy, const void *data, unsigned int count);
int proxy_read(const alsa_device_proxy * proxy, void *data, unsigned int count);
-/* Debugging */
-void proxy_dump(const alsa_device_proxy * proxy, int fd);
-
#endif /* ANDROID_SYSTEM_MEDIA_ALSA_UTILS_ALSA_DEVICE_PROXY_H */