Loading services/audiopolicy/common/managerdefinitions/src/AudioPatch.cpp +19 −38 Original line number Diff line number Diff line Loading @@ -34,51 +34,32 @@ AudioPatch::AudioPatch(const struct audio_patch *patch, uid_t uid) : { } status_t AudioPatch::dump(int fd, int spaces, int index) const static String8 dumpPatchEndpoints( int spaces, const char *prefix, int count, const audio_port_config *cfgs) { const size_t SIZE = 256; char buffer[SIZE]; String8 result; snprintf(buffer, SIZE, "%*sAudio patch %d:\n", spaces, "", index+1); result.append(buffer); snprintf(buffer, SIZE, "%*s- handle: %2d\n", spaces, "", mHandle); result.append(buffer); snprintf(buffer, SIZE, "%*s- audio flinger handle: %2d\n", spaces, "", mAfPatchHandle); result.append(buffer); snprintf(buffer, SIZE, "%*s- owner uid: %2d\n", spaces, "", mUid); result.append(buffer); snprintf(buffer, SIZE, "%*s- %d sources:\n", spaces, "", mPatch.num_sources); result.append(buffer); for (size_t i = 0; i < mPatch.num_sources; i++) { if (mPatch.sources[i].type == AUDIO_PORT_TYPE_DEVICE) { for (int i = 0; i < count; ++i) { const audio_port_config &cfg = cfgs[i]; result.appendFormat("%*s [%s %d] ", spaces, "", prefix, i + 1); if (cfg.type == AUDIO_PORT_TYPE_DEVICE) { std::string device; deviceToString(mPatch.sources[i].ext.device.type, device); snprintf(buffer, SIZE, "%*s- Device ID %d %s\n", spaces + 2, "", mPatch.sources[i].id, device.c_str()); deviceToString(cfg.ext.device.type, device); result.appendFormat("Device ID %d %s", cfg.id, device.c_str()); } else { snprintf(buffer, SIZE, "%*s- Mix ID %d I/O handle %d\n", spaces + 2, "", mPatch.sources[i].id, mPatch.sources[i].ext.mix.handle); } result.append(buffer); result.appendFormat("Mix ID %d I/O handle %d", cfg.id, cfg.ext.mix.handle); } snprintf(buffer, SIZE, "%*s- %d sinks:\n", spaces, "", mPatch.num_sinks); result.append(buffer); for (size_t i = 0; i < mPatch.num_sinks; i++) { if (mPatch.sinks[i].type == AUDIO_PORT_TYPE_DEVICE) { std::string device; deviceToString(mPatch.sinks[i].ext.device.type, device); snprintf(buffer, SIZE, "%*s- Device ID %d %s\n", spaces + 2, "", mPatch.sinks[i].id, device.c_str()); } else { snprintf(buffer, SIZE, "%*s- Mix ID %d I/O handle %d\n", spaces + 2, "", mPatch.sinks[i].id, mPatch.sinks[i].ext.mix.handle); result.append("\n"); } result.append(buffer); return result; } status_t AudioPatch::dump(int fd, int spaces, int index) const { String8 result; result.appendFormat("%*sPatch %d: owner uid %4d, handle %2d, af handle %2d\n", spaces, "", index + 1, mUid, mHandle, mAfPatchHandle); result.append(dumpPatchEndpoints(spaces, "src ", mPatch.num_sources, mPatch.sources)); result.append(dumpPatchEndpoints(spaces, "sink", mPatch.num_sinks, mPatch.sinks)); write(fd, result.string(), result.size()); return NO_ERROR; } Loading Loading
services/audiopolicy/common/managerdefinitions/src/AudioPatch.cpp +19 −38 Original line number Diff line number Diff line Loading @@ -34,51 +34,32 @@ AudioPatch::AudioPatch(const struct audio_patch *patch, uid_t uid) : { } status_t AudioPatch::dump(int fd, int spaces, int index) const static String8 dumpPatchEndpoints( int spaces, const char *prefix, int count, const audio_port_config *cfgs) { const size_t SIZE = 256; char buffer[SIZE]; String8 result; snprintf(buffer, SIZE, "%*sAudio patch %d:\n", spaces, "", index+1); result.append(buffer); snprintf(buffer, SIZE, "%*s- handle: %2d\n", spaces, "", mHandle); result.append(buffer); snprintf(buffer, SIZE, "%*s- audio flinger handle: %2d\n", spaces, "", mAfPatchHandle); result.append(buffer); snprintf(buffer, SIZE, "%*s- owner uid: %2d\n", spaces, "", mUid); result.append(buffer); snprintf(buffer, SIZE, "%*s- %d sources:\n", spaces, "", mPatch.num_sources); result.append(buffer); for (size_t i = 0; i < mPatch.num_sources; i++) { if (mPatch.sources[i].type == AUDIO_PORT_TYPE_DEVICE) { for (int i = 0; i < count; ++i) { const audio_port_config &cfg = cfgs[i]; result.appendFormat("%*s [%s %d] ", spaces, "", prefix, i + 1); if (cfg.type == AUDIO_PORT_TYPE_DEVICE) { std::string device; deviceToString(mPatch.sources[i].ext.device.type, device); snprintf(buffer, SIZE, "%*s- Device ID %d %s\n", spaces + 2, "", mPatch.sources[i].id, device.c_str()); deviceToString(cfg.ext.device.type, device); result.appendFormat("Device ID %d %s", cfg.id, device.c_str()); } else { snprintf(buffer, SIZE, "%*s- Mix ID %d I/O handle %d\n", spaces + 2, "", mPatch.sources[i].id, mPatch.sources[i].ext.mix.handle); } result.append(buffer); result.appendFormat("Mix ID %d I/O handle %d", cfg.id, cfg.ext.mix.handle); } snprintf(buffer, SIZE, "%*s- %d sinks:\n", spaces, "", mPatch.num_sinks); result.append(buffer); for (size_t i = 0; i < mPatch.num_sinks; i++) { if (mPatch.sinks[i].type == AUDIO_PORT_TYPE_DEVICE) { std::string device; deviceToString(mPatch.sinks[i].ext.device.type, device); snprintf(buffer, SIZE, "%*s- Device ID %d %s\n", spaces + 2, "", mPatch.sinks[i].id, device.c_str()); } else { snprintf(buffer, SIZE, "%*s- Mix ID %d I/O handle %d\n", spaces + 2, "", mPatch.sinks[i].id, mPatch.sinks[i].ext.mix.handle); result.append("\n"); } result.append(buffer); return result; } status_t AudioPatch::dump(int fd, int spaces, int index) const { String8 result; result.appendFormat("%*sPatch %d: owner uid %4d, handle %2d, af handle %2d\n", spaces, "", index + 1, mUid, mHandle, mAfPatchHandle); result.append(dumpPatchEndpoints(spaces, "src ", mPatch.num_sources, mPatch.sources)); result.append(dumpPatchEndpoints(spaces, "sink", mPatch.num_sinks, mPatch.sinks)); write(fd, result.string(), result.size()); return NO_ERROR; } Loading