xref: /aosp_15_r20/system/media/audio_utils/include/audio_utils/TraceConstants.h (revision b9df5ad1c9ac98a7fefaac271a55f7ae3db05414)
1 /*
2  * Copyright 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 /*
20  * To promote uniform usage of audio key values within the ATRACE environment
21  * we keep a master list of all keys used and the meaning of the associated values.
22  *
23  * These macro definitions allow compile-time check of misspellings.
24  *
25  * By convention we use camel case, but automated conversion to snake case
26  * depending on the output medium is possible.
27  *
28  * Values here are all specified in alphabetical order.
29  */
30 
31 /*
32  * Do not modify any AUDIO_TRACE_THREAD_ or AUDIO_TRACE_TRACK_
33  * events without consulting the git blame owner.
34  *
35  * These form a taxonomy of events suitable for prefix filtering.
36  *
37  * audio.track will include all track events.
38  * audio.track.interval will include only the track interval events.
39  */
40 
41 // This is used for the linux thread name, which is limited to 16 chars in linux.
42 #define AUDIO_TRACE_THREAD_NAME_PREFIX "atd."             // Data worker thread
43 
44 #define AUDIO_TRACE_PREFIX_AUDIO         "audio."         // Top level prefix
45 #define AUDIO_TRACE_PREFIX_FASTCAPTURE   "fastCapture."
46 #define AUDIO_TRACE_PREFIX_FASTMIXER     "fastMixer."
47 #define AUDIO_TRACE_PREFIX_THREAD        "thread."        // Data worker thread
48 #define AUDIO_TRACE_PREFIX_TRACK         "track."         // Audio(Track|Record)
49 
50 #define AUDIO_TRACE_PREFIX_AUDIO_THREAD         AUDIO_TRACE_PREFIX_AUDIO AUDIO_TRACE_PREFIX_THREAD
51 #define AUDIO_TRACE_PREFIX_AUDIO_TRACK          AUDIO_TRACE_PREFIX_AUDIO AUDIO_TRACE_PREFIX_TRACK
52 
53 #define AUDIO_TRACE_PREFIX_AUDIO_TRACK_ACTION   AUDIO_TRACE_PREFIX_AUDIO_TRACK "action."
54 #define AUDIO_TRACE_PREFIX_AUDIO_TRACK_FRDY     AUDIO_TRACE_PREFIX_AUDIO_TRACK "fRdy."
55 #define AUDIO_TRACE_PREFIX_AUDIO_TRACK_INTERVAL AUDIO_TRACE_PREFIX_AUDIO_TRACK "interval."
56 #define AUDIO_TRACE_PREFIX_AUDIO_TRACK_NRDY     AUDIO_TRACE_PREFIX_AUDIO_TRACK "nRdy."
57 
58 /*
59  * Events occur during the trace timeline.
60  */
61 #define AUDIO_TRACE_EVENT_BEGIN_INTERVAL     "beginInterval"
62 #define AUDIO_TRACE_EVENT_END_INTERVAL       "endInterval"
63 #define AUDIO_TRACE_EVENT_FLUSH              "flush"
64 #define AUDIO_TRACE_EVENT_PAUSE              "pause"
65 #define AUDIO_TRACE_EVENT_REFRESH_INTERVAL   "refreshInterval"
66 #define AUDIO_TRACE_EVENT_START              "start"
67 #define AUDIO_TRACE_EVENT_STOP               "stop"
68 #define AUDIO_TRACE_EVENT_UNDERRUN           "underrun"
69 
70 /*
71  * Key, Value pairs are used to designate what happens during an event.
72  */
73 #define AUDIO_TRACE_OBJECT_KEY_CHANNEL_MASK "channelMask" // int32_t
74 #define AUDIO_TRACE_OBJECT_KEY_CONTENT_TYPE "contentType" // string (audio_content_type_t)
75 #define AUDIO_TRACE_OBJECT_KEY_DEVICES      "devices"     // string (audio_devices_t,
76                                                           //   separated by '+')
77 #define AUDIO_TRACE_OBJECT_KEY_EVENT        "event"       // string (AUDIO_TRACE_EVENT_*)
78 #define AUDIO_TRACE_OBJECT_KEY_FLAGS        "flags"       // string (audio_output_flags_t,
79                                                           //   audio_input_flags_t,
80                                                           //   separated by '+')
81 #define AUDIO_TRACE_OBJECT_KEY_FRAMECOUNT   "frameCount"  // int64_t
82 #define AUDIO_TRACE_OBJECT_KEY_FORMAT       "format"      // string
83 #define AUDIO_TRACE_OBJECT_KEY_ID           "id"          // int32_t (for threads io_handle_t)
84 #define AUDIO_TRACE_OBJECT_KEY_PID          "pid"         // int32_t
85 #define AUDIO_TRACE_OBJECT_KEY_SAMPLE_RATE  "sampleRate"  // int32_t
86 #define AUDIO_TRACE_OBJECT_KEY_TYPE         "type"        // string (for threads
87                                                           //   IAfThreadBase::type_t)
88 #define AUDIO_TRACE_OBJECT_KEY_UID          "uid"         // int32_t
89 #define AUDIO_TRACE_OBJECT_KEY_USAGE        "usage"       // string (audio_usage_t)
90